Skip to content

Commit

Permalink
[*] update normally
Browse files Browse the repository at this point in the history
  • Loading branch information
heng30 committed Aug 30, 2024
1 parent 6ddf143 commit 6701aac
Show file tree
Hide file tree
Showing 19 changed files with 568 additions and 66 deletions.
8 changes: 5 additions & 3 deletions src/logic/tr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ pub fn tr(text: &str) -> String {
("Security & Privacy ", "安全与隐私"),
("Reset account", "重置账户"),
("Reset account or not?", "是否重置账户?"),
("Please input old password", "请输入旧密码"),
("Please input new password", "请输入新密码"),
("Please input new password again", "请再次输入新密码"),
("Please enter old password", "请输入旧密码"),
("Please enter new password", "请输入新密码"),
("Please enter new password again", "请再次输入新密码"),
("Test model", "测试模式"),
("Main Network", "主网络"),
("Test Network", "测试网络"),
Expand Down Expand Up @@ -297,6 +297,8 @@ pub fn tr(text: &str) -> String {
("Detail", "说明"),
("Log in", "登陆"),
("Sign in", "注册"),
("Password", "密码"),
("Reset password", "重置密码"),
]);

if let Some(txt) = items.get(text) {
Expand Down
8 changes: 8 additions & 0 deletions ui/base/slide-card.slint
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export component SlideCard inherits Rectangle {
in property <bool> hide-icons-after-clicked: true;
in property <length> gap: 0px;

in-out property <length> inner-hpadding: 0px;
in-out property <length> inner-vpadding: 0px;

private property <length> max-move-pixels-up-bound: self.width * 0.04;
private property <length> max-move-pixels-low-bound: self.width * 0.02;
private property <bool> is-show-icons: false;
Expand Down Expand Up @@ -85,6 +88,11 @@ export component SlideCard inherits Rectangle {
}

vbox := VerticalLayout {
padding-top: root.inner-vpadding;
padding-bottom: root.inner-vpadding;
padding-left: root.inner-hpadding;
padding-right: root.inner-hpadding;

@children
}

Expand Down
2 changes: 1 addition & 1 deletion ui/base/switch-btn.slint
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export component SwitchBtn inherits Rectangle {
in-out property enabled <=> ta.enabled;
in-out property <bool> checked;

in-out property <color> unchecked-background: Theme.is-dark ? Theme.secondary-background.darker(50%) : Theme.secondary-background.darker(10%);
in-out property <color> unchecked-background: Theme.is-dark ? Theme.secondary-background.brighter(50%) : Theme.secondary-background.darker(10%);
in-out property <length> indicator-size: Theme.icon-size;
in-out property <length> hpadding: Theme.padding;
in-out property <length> vpadding: Theme.padding;
Expand Down
66 changes: 30 additions & 36 deletions ui/base/token-sender.slint
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Logic } from "../logic.slint";
import { Store } from "../store.slint";
import { Label } from "label.slint";
import { Avatar } from "avatar.slint";
import { TabBtns } from "tab-btns.slint";
import { LineInput } from "line-input.slint";
import { CancelBtn, ConfirmBtn, TextBtn } from "btn.slint";
import { SettingDetail, SettingDetailInner, SettingDetailInnerVbox, SettingDetailLabel } from "setting-detail.slint";
Expand Down Expand Up @@ -61,7 +62,7 @@ export component TokenSender inherits SettingDetail {
name-label := Label {
text: "Account1";
font-size: Theme.title2-font-size;
color: Theme.brand-color;
color: Theme.regular-text-color;
}
}

Expand All @@ -75,6 +76,7 @@ export component TokenSender inherits SettingDetail {
text: "test";
icon: Icons.browser-access;
enabled: false;
is-show-icon: true;
}
}

Expand All @@ -88,6 +90,7 @@ export component TokenSender inherits SettingDetail {
text: "ETH";
icon: is-token-edit ? Icons.checked-box : Icons.edit;
enabled: is-token-edit;
is-show-icon: true;

clicked => {
is-token-edit = !is-token-edit;
Expand All @@ -112,6 +115,7 @@ export component TokenSender inherits SettingDetail {
text: "0xf1199999751b1a3A74590adBf95401D19AB30014";
icon: Icons.copy;
enabled: false;
is-show-icon: true;
}
}

Expand All @@ -124,6 +128,7 @@ export component TokenSender inherits SettingDetail {
width: root.width - Theme.spacing * 4;
text: "GEScvfEF1Xt2oyrnJij5V5DYSmPjuUt45DfUs3VFrsED";
icon: Icons.address-book;
is-show-icon: true;

edited => {
root.recipient-address-edited(self.text);
Expand All @@ -146,6 +151,7 @@ export component TokenSender inherits SettingDetail {
text: "0";
icon: Icons.max;
input-type: InputType.decimal;
is-show-icon: true;

clicked => {
self.text = root.total-balance;
Expand Down Expand Up @@ -188,6 +194,7 @@ export component TokenSender inherits SettingDetail {
width: root.width - Theme.spacing * 4;
icon: Icons.cancel;
text: root.memo;
is-show-icon: true;

clicked => {
self.text = "";
Expand All @@ -210,6 +217,7 @@ export component TokenSender inherits SettingDetail {
input-type: InputType.number;
placeholder-text: "micro lamports";
text: root.prioritization-fee;
is-show-icon: true;

clicked => {
self.text = "";
Expand All @@ -223,39 +231,26 @@ export component TokenSender inherits SettingDetail {

HorizontalLayout {
alignment: LayoutAlignment.start;
spacing: Theme.spacing * 2;

TextBtn {
text: Logic.tr("Slow");
bg-color: Theme.info-color;
use-auto-size: true;
icon: Icons.turtle;

clicked => {
prioritization-fee-input.text = root.get-prioritization-fee(PrioritizationFeeStatus.Slow);
root.prioritization-fee = prioritization-fee-input.text;
}
}

TextBtn {
text: Logic.tr("Normal");
use-auto-size: true;
icon: Icons.rabbit;

clicked => {
prioritization-fee-input.text = root.get-prioritization-fee(PrioritizationFeeStatus.Normal);
root.prioritization-fee = prioritization-fee-input.text;
}
}

TextBtn {
text: Logic.tr("Fast");
use-auto-size: true;
icon: Icons.horse;

clicked => {
prioritization-fee-input.text = root.get-prioritization-fee(PrioritizationFeeStatus.Fast);
root.prioritization-fee = prioritization-fee-input.text;
spacing: Theme.spacing * 4;

TabBtns {
items: [
{ icon: Icons.turtle, text: "Slow" },
{ icon: Icons.rabbit, text: "Normal" },
{ icon: Icons.horse, text: "Fast" }
];

clicked(index) => {
if (index == 0) {
prioritization-fee-input.text = root.get-prioritization-fee(PrioritizationFeeStatus.Slow);
root.prioritization-fee = prioritization-fee-input.text;
} else if (index == 1) {
prioritization-fee-input.text = root.get-prioritization-fee(PrioritizationFeeStatus.Normal);
root.prioritization-fee = prioritization-fee-input.text;
} else {
prioritization-fee-input.text = root.get-prioritization-fee(PrioritizationFeeStatus.Fast);
root.prioritization-fee = prioritization-fee-input.text;
}
}
}
}
Expand All @@ -267,10 +262,9 @@ export component TokenSender inherits SettingDetail {
}

HorizontalLayout {
alignment: LayoutAlignment.center;
padding-top: Theme.padding * 5;
padding-bottom: Theme.padding * 5;
spacing: Theme.spacing * 10;
spacing: Theme.spacing * 8;

cancel-btn := CancelBtn {
text: Logic.tr("Cancel");
Expand Down
7 changes: 5 additions & 2 deletions ui/base/token-tile.slint
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Switch } from "std-widgets.slint";
import { Theme, Icons } from "../theme.slint";
import { ListTile } from "list-tile.slint";
import { Label } from "label.slint";
import { IconBtn } from "icon-btn.slint";
import { Util } from "../util.slint";
import { SwitchBtn } from "switch-btn.slint";

export struct TokenTileEntry {
uuid: string,
Expand Down Expand Up @@ -114,5 +114,8 @@ export component TokenTileWithSwitch inherits Tile {

callback toggled <=> sw.toggled;

sw := Switch { }
VerticalLayout {
alignment: LayoutAlignment.center;
sw := SwitchBtn { }
}
}
15 changes: 12 additions & 3 deletions ui/base/transaction-tile.slint
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ export component TransactionTile inherits Rectangle {
in property <color> icon-colorize: status-icon-colorize(entry.status);
in property <length> icon-size: Theme.icon-size;

in-out property <color> hash-color: Theme.primary-text-color;
in-out property <length> hash-font-size: Theme.title3-font-size;

in-out property <color> balance-color: Theme.regular-text-color;
in-out property <length> balance-font-size: Theme.default-font-size;

in-out property <TransactionTileEntry> entry;

pure public function status-icon(status: TransactionTileStatus) -> image {
Expand Down Expand Up @@ -67,11 +73,13 @@ export component TransactionTile inherits Rectangle {
horizontal-stretch: 1;

Label {
font-size: Theme.title4-font-size;
width: self.preferred-width;
font-size: root.hash-font-size;
color: root.hash-color;
text: entry.hash;
wrap: TextWrap.no-wrap;
overflow: TextOverflow.elide;
font-weight: 0.5;
font-weight: Theme.bold-font-weight;

hash-ta := TouchArea {
mouse-cursor: MouseCursor.pointer;
Expand All @@ -86,7 +94,8 @@ export component TransactionTile inherits Rectangle {
text: entry.balance;
wrap: TextWrap.no-wrap;
overflow: TextOverflow.elide;
color: Theme.have-read-text-color;
color: root.balance-color;
font-size: root.balance-font-size;
}

Label {
Expand Down
4 changes: 1 addition & 3 deletions ui/base/wait-transaction-confirmed.slint
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export component WaitTransactionConfirmed inherits SettingDetail {
width: root.width - Theme.spacing * 4;
text: "test";
enabled: false;
is-show-icon: false;
}
}

Expand All @@ -50,7 +49,6 @@ export component WaitTransactionConfirmed inherits SettingDetail {
width: root.width - Theme.spacing * 4;
text: "ETH";
enabled: false;
is-show-icon: false;
}
}

Expand All @@ -63,7 +61,6 @@ export component WaitTransactionConfirmed inherits SettingDetail {
width: root.width - Theme.spacing * 4;
text: "0";
input-type: InputType.decimal;
is-show-icon: false;
enabled: false;
}

Expand All @@ -82,6 +79,7 @@ export component WaitTransactionConfirmed inherits SettingDetail {
width: root.width - Theme.spacing * 4;
enabled: false;
icon: Icons.browser-access;
is-show-icon: true;
}
}

Expand Down
6 changes: 5 additions & 1 deletion ui/panel/desktop/examples/blanket.slint
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Util, Theme } from "../../def.slint";
import { Blanket, ExampleComponent } from "../../../base/widgets.slint";
import { Label, Blanket, ExampleComponent } from "../../../base/widgets.slint";

export component BlanketExample inherits Flickable {
viewport-height: vbox.preferred-height;
Expand All @@ -23,6 +23,10 @@ export component BlanketExample inherits Flickable {
height: 400px;
background: red;

Label {
text: "Click Me";
}

bl := Blanket { }

TouchArea {
Expand Down
2 changes: 1 addition & 1 deletion ui/panel/desktop/examples/reset-password.slint
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Util, Theme, Icons } from "../../def.slint";
import { Label, ResetPassword, ExampleComponent } from "../../../base/widgets.slint";
import { ResetPassword, ExampleComponent } from "../../../base/widgets.slint";

export component ResetPasswordExample inherits Flickable {
viewport-height: vbox.preferred-height;
Expand Down
61 changes: 61 additions & 0 deletions ui/panel/desktop/examples/setting.slint
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { Util, Theme, Icons, Logic } from "../../def.slint";
import { SettingEntry, SettingEntryV2, SettingDetail, SettingDetailLabel, SettingDetailInnerVbox, SettingDetailInner, LineInput, ExampleComponent } from "../../../base/widgets.slint";

export component SettingExample inherits Flickable {
viewport-height: vbox.preferred-height;
viewport-width: vbox.preferred-width;

vbox := VerticalLayout {
spacing: Theme.spacing * 20;
padding-top: Theme.padding * 5;
padding-bottom: Theme.padding * 5;
alignment: LayoutAlignment.center;

HorizontalLayout {
width: root.width;
alignment: LayoutAlignment.center;

ExampleComponent {
width: Math.max(1000px, root.width * 0.8);

SettingDetail {
title: Logic.tr("Preference");

SettingDetailInner {
SettingDetailInnerVbox {
win-size-txt := SettingDetailLabel {
text: Logic.tr("Window width");
}

LineInput {
horizontal-stretch: 1;
input-type: number;
placeholder-text: Logic.tr("width");

edited => {
}
}
}

SettingDetailInnerVbox {
SettingDetailLabel {
text: Logic.tr("Window height");
}

LineInput {
horizontal-stretch: 1;
input-type: number;
placeholder-text: Logic.tr("height");

edited => {
}
}
}
}
}

code: "SettingDetail {\n title: Logic.tr(\"Preference\");\n\n SettingDetailInner {\n SettingDetailInnerVbox {\n win-size-txt := SettingDetailLabel {\n text: Logic.tr(\"Window width\");\n }\n\n LineInput {\n horizontal-stretch: 1;\n input-type: number;\n placeholder-text: Logic.tr(\"width\");\n\n edited => { }\n }\n }\n\n SettingDetailInnerVbox {\n SettingDetailLabel {\n text: Logic.tr(\"Window height\");\n }\n\n LineInput {\n horizontal-stretch: 1;\n input-type: number;\n placeholder-text: Logic.tr(\"height\");\n\n edited => { }\n }\n }\n }\n}";
}
}
}
}
Loading

0 comments on commit 6701aac

Please sign in to comment.