Skip to content

Commit

Permalink
[*] update normally
Browse files Browse the repository at this point in the history
  • Loading branch information
heng30 committed Aug 29, 2024
1 parent 3a1f83c commit 6ddf143
Show file tree
Hide file tree
Showing 31 changed files with 495 additions and 113 deletions.
2 changes: 2 additions & 0 deletions src/logic/tr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ pub fn tr(text: &str) -> String {
("Jump to", "跳转到"),
("Example", "例子"),
("Detail", "说明"),
("Log in", "登陆"),
("Sign in", "注册"),
]);

if let Some(txt) = items.get(text) {
Expand Down
2 changes: 1 addition & 1 deletion ui/base/account-balance.slint
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export component AccountBalance inherits Rectangle {
in-out property account-name <=> account.text;
in-out property balance <=> balance-label.text;

callback account-clicked <=> account.clicked;
callback name-clicked <=> account.clicked;
callback copy <=> copy-btn.clicked;

VerticalLayout {
Expand Down
5 changes: 4 additions & 1 deletion ui/base/address-book.slint
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export component AddressBookDetail inherits SettingDetail {
private property <AddressBookEntry> entry: AddressBookSetting.current-entry;
in property <image> qr-code: Icons.no-data;
in-out property address <=> address-input.text;
in-out property name <=> name-input.text;

// (uuid, name) -> void
callback update-name(string, string);
Expand Down Expand Up @@ -132,10 +133,11 @@ export component AddressBookDetail inherits SettingDetail {
text: Logic.tr("Address name");
}

LineInput {
name-input := LineInput {
enabled: AddressBookSetting.enabled-input;
width: root.width - Theme.padding * 4;
text: entry.name;
is-show-icon: true;
icon: self.enabled ? Icons.checked-box : Icons.edit;
clicked => {
self.enabled = !self.enabled;
Expand Down Expand Up @@ -166,6 +168,7 @@ export component AddressBookDetail inherits SettingDetail {
text: entry.address;

icon: self.enabled ? Icons.checked-box : Icons.edit;
is-show-icon: true;
clicked => {
self.enabled = !self.enabled;

Expand Down
8 changes: 4 additions & 4 deletions ui/base/btn.slint
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export component CancelBtn inherits IconBtn {
use-auto-size: true;
icon: Icons.cancel;
icon-size: Theme.icon-size;
border-radius: self.height / 2;
border-radius: Theme.border-radius;
bg-color: Theme.info-color.brighter(50%);
bg-pressed-color: self.bg-color.darker(30%);
colorize: self.bg-pressed-color.darker(100%);
Expand All @@ -17,10 +17,10 @@ export component CancelBtn inherits IconBtn {
export component ConfirmBtn inherits IconBtn {
use-auto-size: true;
icon: Icons.success;
border-radius: self.height / 2;
bg-color: Theme.success-color.darker(20%);
border-radius: Theme.border-radius;
bg-color: Theme.third-brand-color.darker(20%);
bg-pressed-color: self.bg-color.darker(30%);
colorize: Theme.base-color;
colorize: Theme.light-text-color;
text: Logic.tr("Confirm");
}

Expand Down
2 changes: 1 addition & 1 deletion ui/base/circle-progress.slint
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export component CircleProgress inherits Rectangle {

in-out property <string> finished-text: Logic.tr("Finished");
in-out property <string> unfinished-text: root.calc-percent(root.ring-angle) + "%";
in-out property <color> finished-text-color: Colors.white;
in-out property <color> finished-text-color: Theme.light-text-color;
in-out property <color> unfinished-text-color: Theme.invert-base-color;
in-out property font-size <=> txt.font-size;

Expand Down
15 changes: 4 additions & 11 deletions ui/base/dialog.slint
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Store } from "../store.slint";
import { Logic } from "../logic.slint";
import { IconBtn } from "./icon-btn.slint";
import { CenterLayout } from "./center-layout.slint";
import { TextBtn } from "./btn.slint";
import { ConfirmBtn, CancelBtn } from "./btn.slint";

export component Dialog inherits Rectangle {
in-out property <string> title;
Expand All @@ -14,9 +14,6 @@ export component Dialog inherits Rectangle {
in-out property <bool> is-hide-cancel-btn: false;
in-out property <bool> is-prevent-event-forward: false;

in-out property <color> cancel-text-color: Theme.info-color;
in-out property <color> confirm-text-color: Theme.third-brand-color;

callback close <=> cancel-clicked;
callback canceled <=> cancel-clicked;
callback confirmed <=> ok-clicked;
Expand All @@ -39,7 +36,7 @@ export component Dialog inherits Rectangle {
height: txt.preferred-height * 1.33;
background: root.title-bg;
txt := Text {
color: Colors.white;
color: Theme.light-text-color;
font-size: Theme.title3-font-size;
text: root.title;
}
Expand Down Expand Up @@ -70,22 +67,18 @@ export component Dialog inherits Rectangle {
spacing: Theme.spacing * 8;
padding: Theme.padding * 4;

if !is-hide-cancel-btn: TextBtn {
if !is-hide-cancel-btn: CancelBtn {
icon: Icons.cancel;
text: Logic.tr("Cancel");
text-color: root.cancel-text-color;
colorize: self.text-color;

clicked => {
root.cancel-clicked();
}
}

if !is-hide-confirm-btn: TextBtn {
if !is-hide-confirm-btn: ConfirmBtn {
icon: Icons.success;
text: Logic.tr("Confirm");
text-color: root.confirm-text-color;
colorize: self.text-color;

clicked => {
root.ok-clicked();
Expand Down
2 changes: 2 additions & 0 deletions ui/base/line-input.slint
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export component LineInput inherits Rectangle {
in-out property text <=> text-input.text;
in-out property font-size <=> text-input.font-size;
in property input-type <=> text-input.input-type;
in property read-only <=> text-input.read-only;
in property <bool> enabled <=> text-input.enabled;
in property <string> placeholder-text;

Expand Down Expand Up @@ -87,6 +88,7 @@ export component LineInput inherits Rectangle {
text-input := TextInput {
single-line: true;
vertical-alignment: TextVerticalAlignment.center;
color: Theme.primary-text-color;

accepted => {
self.clear-focus();
Expand Down
46 changes: 25 additions & 21 deletions ui/base/login.slint → ui/base/log-in.slint
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@ import { IconBtn } from "./icon-btn.slint";
import { Label } from "./label.slint";
import { Head } from "./head.slint";
import { LineInput } from "./line-input.slint";
import { CancelBtn, ConfirmBtn } from "./btn.slint";
import { TextBtnWithoutIcon } from "./btn.slint";
import { SettingDetailInner, SettingDetailInnerVbox, SettingDetailLabel } from "./setting-detail.slint";

export component Login inherits Rectangle {
export component LogIn inherits Rectangle {
in property <bool> is-show-header: true;

private property <string> error-message;

callback back();
callback cancel();

// (username, password) -> string
callback confirm(string, string) -> string;
callback confirmed(string, string) -> string;

public function reset() {
error-message = "";
Expand All @@ -40,6 +39,17 @@ export component Login inherits Rectangle {
SettingDetailInner {
vbox-alignment: LayoutAlignment.center;

SettingDetailInnerVbox {
HorizontalLayout {
alignment: LayoutAlignment.center;
Label {
text: Logic.tr("Log in");
font-size: Theme.title1-font-size;
font-weight: Theme.bold-font-weight;
}
}
}

SettingDetailInnerVbox {
username-txt := SettingDetailLabel {
text: Logic.tr("Please enter username");
Expand All @@ -52,6 +62,7 @@ export component Login inherits Rectangle {
icon: Icons.paste;
width: root.width - Theme.padding * 4;
placeholder-text: Logic.tr("Username");
is-show-icon: true;

edited => {
root.error-message = "";
Expand All @@ -77,6 +88,7 @@ export component Login inherits Rectangle {
width: root.width - Theme.padding * 4;
placeholder-text: Logic.tr("At least 8 chars");
input-type: is-show-password ? InputType.text : InputType.password;
is-show-icon: true;

edited => {
root.error-message = "";
Expand All @@ -99,24 +111,16 @@ export component Login inherits Rectangle {
}
}

HorizontalLayout {
spacing: Theme.spacing * 10;
padding: Theme.padding * 5;
confirm-btn := TextBtnWithoutIcon {
width: password-lineedit.width;
height: self.text-height + Theme.padding * 2;
text: Logic.tr("Log in");
font-size: Theme.title3-font-size;
bg-color: Theme.third-brand-color;
text-color: Theme.light-text-color;

CancelBtn {
text: Logic.tr("Cancel");
clicked => {
root.reset();
root.cancel();
}
}

confirm-btn := ConfirmBtn {
text: Logic.tr("Confirm");

clicked => {
root.error-message = root.confirm(username-lineedit.text, password-lineedit.text);
}
clicked => {
root.error-message = root.confirmed(username-lineedit.text, password-lineedit.text);
}
}
}
Expand Down
23 changes: 12 additions & 11 deletions ui/base/mnemonic.slint
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { LineEdit } from "std-widgets.slint";
import { Theme, Icons } from "../theme.slint";
import { Store } from "../store.slint";
import { Logic } from "../logic.slint";
Expand All @@ -7,6 +6,7 @@ import { IconBtn } from "icon-btn.slint";
import { CancelBtn, ConfirmBtn, TextBtn } from "btn.slint";
import { Label } from "label.slint";
import { Head } from "head.slint";
import { LineInput } from "line-input.slint";

export component Mnemonic inherits Rectangle {
in-out property <[string]> mnemonics;
Expand All @@ -18,7 +18,7 @@ export component Mnemonic inherits Rectangle {
in property <string> header-title;

private property <int> cell-pre-row: 2;
private property <length> label-width: 20px;
private property <length> label-width: Theme.default-font-size * 2;
private property <int> max-blocks: mnemonics.length == 24 ? 2 : (mnemonics.length == 12 ? 1 : 0);

out property <bool> is-mnemonic-counts-12: max-blocks != 2;
Expand All @@ -28,8 +28,8 @@ export component Mnemonic inherits Rectangle {
callback copy([string]);
callback paste();
callback refresh(int);
callback cancel();
callback confirm();
callback canceled();
callback confirmed();
callback switch-mnemonic-counts(int);

public function reset-mnemonics(counts: int) {
Expand Down Expand Up @@ -140,7 +140,7 @@ export component Mnemonic inherits Rectangle {
private property <int> cell-start-index: index * cell-pre-row + block-start-index;

HorizontalLayout {
spacing: Theme.spacing;
spacing: Theme.spacing * 2;
horizontal-stretch: 1;

Label {
Expand All @@ -149,7 +149,7 @@ export component Mnemonic inherits Rectangle {
horizontal-alignment: TextHorizontalAlignment.right;
}

LineEdit {
LineInput {
horizontal-stretch: 1;
read-only: is-read-only;
text: mnemonics[cell-start-index];
Expand All @@ -162,15 +162,15 @@ export component Mnemonic inherits Rectangle {

HorizontalLayout {
horizontal-stretch: 1;
spacing: Theme.spacing;
spacing: Theme.spacing * 2;

Label {
width: label-width;
text: cell-start-index + 2;
horizontal-alignment: TextHorizontalAlignment.right;
}

LineEdit {
LineInput {
horizontal-stretch: 1;
read-only: is-read-only;
text: mnemonics[cell-start-index + 1];
Expand All @@ -197,20 +197,21 @@ export component Mnemonic inherits Rectangle {
}

if is-show-btns: HorizontalLayout {
alignment: LayoutAlignment.end;
padding: Theme.padding * 5;
spacing: Theme.spacing * 10;
spacing: Theme.spacing * 8;

CancelBtn {
text: Logic.tr("Cancel");
clicked => {
root.cancel();
root.canceled();
}
}

ConfirmBtn {
text: Logic.tr("Confirm");
clicked => {
root.confirm();
root.confirmed();
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions ui/base/no-data.slint
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ export component NoDataImg inherits Rectangle {

CenterLayout {
txt := Text {
opacity: 0.5;
color: Theme.regular-text-color;
color: Theme.primary-text-color;
font-size: Theme.default-font-size + 4px;
}
}
Expand Down
3 changes: 1 addition & 2 deletions ui/base/no-message.slint
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ export component NoMessageImg inherits Rectangle {

CenterLayout {
txt := Text {
opacity: 0.5;
color: Theme.regular-text-color;
color: Theme.primary-text-color;
font-size: Theme.default-font-size + 4px;
}
}
Expand Down
6 changes: 3 additions & 3 deletions ui/base/pagination.slint
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export component Pagination inherits Rectangle {

text: start-page + index + 1;
font-size: root.font-size;
text-color: root.real-current-page == index ? Colors.white : root.text-color;
text-color: root.real-current-page == index ? Theme.light-text-color : root.text-color;

clicked => {
root.real-current-page = index;
Expand Down Expand Up @@ -121,7 +121,7 @@ export component Pagination inherits Rectangle {

text: start-page + index + 1;
font-size: root.font-size;
text-color: root.real-current-page == start-page + index ? Colors.white : root.text-color;
text-color: root.real-current-page == start-page + index ? Theme.light-text-color : root.text-color;

clicked => {
root.real-current-page = start-page + index;
Expand Down Expand Up @@ -155,7 +155,7 @@ export component Pagination inherits Rectangle {
text: inner-real-current-page + 1;
font-size: root.font-size;
background: root.real-current-page == inner-real-current-page ? Theme.third-brand-color : Colors.transparent;
text-color: root.real-current-page == inner-real-current-page ? Colors.white : root.text-color;
text-color: root.real-current-page == inner-real-current-page ? Theme.light-text-color : root.text-color;

clicked => {
root.real-current-page = inner-real-current-page;
Expand Down
Loading

0 comments on commit 6ddf143

Please sign in to comment.