Browse Source

Pull request #3722: BI-129824 fix: 控件优化

Merge in VISUAL/fineui from ~IMP/fineui_fui:master to master

* commit '84e4135f881013c84ffb67324c1237112b4054f0':
  BI-129824 fix: 控件优化
  BI-129824 fix: 控件优化
research/test
imp-张健 11 months ago
parent
commit
318bfa262b
  1. 4
      packages/fineui/src/base/foundation/message.js
  2. 28
      packages/fineui/src/case/button/switch.js
  3. 5
      packages/fineui/typescript/case/button/switch.ts

4
packages/fineui/src/base/foundation/message.js

@ -199,7 +199,9 @@ function _show(hasCancel, title, message, callback, config = {}) {
items: [ items: [
{ {
type: VerticalLayout.xtype, type: VerticalLayout.xtype,
cls: "bi-card bi-border-radius",
width: 450, width: 450,
hgap: 32,
attributes: { attributes: {
tabIndex: 1, tabIndex: 1,
}, },
@ -224,8 +226,6 @@ function _show(hasCancel, title, message, callback, config = {}) {
} catch (e) { } catch (e) {
} }
}, },
cls: "bi-card",
hgap: 32,
items: [ items: [
{ {
el: { el: {

28
packages/fineui/src/case/button/switch.js

@ -1,15 +1,13 @@
import { AbsoluteLayout, shortcut, i18nText } from "@/core"; import { AbsoluteLayout, shortcut, i18nText } from "@/core";
import { TextButton, Label, BasicButton } from "@/base"; import { TextButton, Label, BasicButton } from "@/base";
const CIRCLE_SIZE = 12;
@shortcut() @shortcut()
export class Switch extends BasicButton { export class Switch extends BasicButton {
static xtype = "bi.switch"; static xtype = "bi.switch";
static EVENT_CHANGE = "EVENT_CHANGE"; static EVENT_CHANGE = "EVENT_CHANGE";
constants = {
CIRCLE_SIZE: 12,
};
props = { props = {
extraCls: "bi-switch", extraCls: "bi-switch",
attributes: { attributes: {
@ -17,13 +15,13 @@ export class Switch extends BasicButton {
}, },
height: 20, height: 20,
width: 44, width: 44,
showTip: false, showTip: true,
textGap: 8,
}; };
render() { render() {
const o = this.options, const { selected, width, height, textGap, showTip } = this.options;
c = this.constants; const tgap = (height - CIRCLE_SIZE) / 2;
const tgap = (o.height - c.CIRCLE_SIZE) / 2;
return { return {
type: AbsoluteLayout.xtype, type: AbsoluteLayout.xtype,
@ -39,15 +37,15 @@ export class Switch extends BasicButton {
width: 12, width: 12,
height: 12, height: 12,
top: tgap, top: tgap,
left: o.selected ? 28 : 4, left: selected ? width - height + tgap : tgap,
}, },
{ {
type: Label.xtype, type: Label.xtype,
text: i18nText("BI-Basic_Simple_Open"), text: i18nText("BI-Basic_Simple_Open"),
cls: "content-tip", cls: "content-tip",
left: 8, left: textGap,
top: tgap - 2, top: tgap - 2,
invisible: !(o.showTip && o.selected), invisible: !(showTip && selected),
ref: _ref => { ref: _ref => {
this.openTip = _ref; this.openTip = _ref;
}, },
@ -56,9 +54,9 @@ export class Switch extends BasicButton {
type: Label.xtype, type: Label.xtype,
text: i18nText("BI-Basic_Simple_Close"), text: i18nText("BI-Basic_Simple_Close"),
cls: "content-tip", cls: "content-tip",
right: 8, right: textGap,
top: tgap - 2, top: tgap - 2,
invisible: !(o.showTip && !o.selected), invisible: !(showTip && !selected),
ref: _ref => { ref: _ref => {
this.closeTip = _ref; this.closeTip = _ref;
}, },
@ -78,7 +76,9 @@ export class Switch extends BasicButton {
setSelected(v) { setSelected(v) {
super.setSelected(...arguments); super.setSelected(...arguments);
this.layout.attr("items")[0].left = v ? 28 : 4; const { width, height } = this.options;
const tgap = (height - CIRCLE_SIZE) / 2;
this.layout.attr("items")[0].left = v ? width - height + tgap : tgap;
this.layout.resize(); this.layout.resize();
this.options.showTip && this.openTip.setVisible(v); this.options.showTip && this.openTip.setVisible(v);
this.options.showTip && this.closeTip.setVisible(!v); this.options.showTip && this.closeTip.setVisible(!v);

5
packages/fineui/typescript/case/button/switch.ts

@ -1,6 +1,11 @@
import { BasicButton } from "../../base/single/button/button.basic"; import { BasicButton } from "../../base/single/button/button.basic";
export declare class Switch extends BasicButton { export declare class Switch extends BasicButton {
props: {
textGap: number;
} & BasicButton['props']
static xtype: string; static xtype: string;
static EVENT_CHANGE: string; static EVENT_CHANGE: string;
} }

Loading…
Cancel
Save