Skip to content

Commit

Permalink
feat(message): add success type
Browse files Browse the repository at this point in the history
  • Loading branch information
cEvolve05 committed Aug 31, 2024
1 parent e2ec28d commit 34219a9
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 58 deletions.
6 changes: 3 additions & 3 deletions ui/assets/image/icon/arrow-left.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions ui/assets/image/icon/check-circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions ui/assets/image/image_token.slint
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct EventoIconCollection {
tree-list: image,
account-box: image,
pentagon: image,
check-circle: image,
}

struct EventoDisplayCollection {
Expand Down Expand Up @@ -88,6 +89,7 @@ export global EventoImageToken {
tree-list: @image-url("./icon/tree-list.svg"),
account-box: @image-url("./icon/account-box-outline.svg"),
pentagon: @image-url("./icon/pentagon.svg"),
check-circle: @image-url("./icon/check-circle.svg"),
};
// display used as images bigger than icon
// most display image won't change according to darkmode switch
Expand Down
71 changes: 25 additions & 46 deletions ui/components/toast.slint
Original file line number Diff line number Diff line change
Expand Up @@ -36,76 +36,55 @@ export component Toast {
}

_content := HorizontalLayout {
padding: 16px;
spacing: 12px;
padding-left: 16px;
padding-right: 16px;
spacing: 8px;
alignment: start;
if have-icon: _icon := Empty {
width: 24px;
height: 100%;
Image {
height: 24px;
width: 24px;
source: icon;
colorize: on-surface;
}
}
_text := Text {
vertical-alignment: center;
horizontal-alignment: left;
text: message-data.content;
color: on-surface;
font-size: font.size;
font-weight: font.weight;
Empty {
height: 100%;
_text := Text {
text: message-data.content;
color: on-surface;
font-size: font.size;
font-weight: font.weight;
}
}

states [
have-icon when have-icon: {
padding-left: 12px;
}
]
}
}

// TODO: support more type
states [
error when message-data.type == MessageType.Error: {
error when message-data.type == MessageType.error: {
have-icon: true;
icon: Token.image.icon.error;
surface: Token.color.error;
on-surface: Token.color.on-error;
}
warning when message-data.type == MessageType.Warning: {
warning when message-data.type == MessageType.warning: {
have-icon: true;
icon: Token.image.icon.error;
}
info when message-data.type == MessageType.Info: {
success when message-data.type == MessageType.success: {
have-icon: true;
icon: Token.image.icon.check-circle;
}
info when message-data.type == MessageType.info: {
have-icon: false;
}
]
}

component Test {
// HorizontalLayout {
// y: - self.height;
// Button {
// content: "Info";
// clicked => {
// MessageManagerBridge.type = MessageType.Info;
// }
// }

// Button {
// content: "Warning";
// clicked => {
// MessageManagerBridge.type = MessageType.Warning;
// }
// }

// Button {
// content: "Error";
// clicked => {
// MessageManagerBridge.type = MessageType.Error;
// }
// }
// }

Toast {
// width: 20px;
init => {
debug(self.width)
}
}
}
7 changes: 4 additions & 3 deletions ui/logic/message_manager.slint
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export enum MessageType{
Info,
Warning,
Error
info,
success,
warning,
error
}

export struct MessageData {
Expand Down
2 changes: 1 addition & 1 deletion ui/views/overlay/login.slint
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export global LoginOverlayBridge {
in-out property <string> version:"v0.0.0-00000000";
callback link-login();
public function guest-login() {
MessageManager.show-message("访客登录尚未完成", MessageType.Info);
MessageManager.show-message("访客登录尚未完成", MessageType.info);
// ViewManager.prior-view();
}
}
Expand Down
2 changes: 1 addition & 1 deletion ui/views/overlay/menu.slint
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export component MenuOverlay inherits Overlay {
label: "纪念卡";
clicked => {
// NOTE: Unsupport
MessageManager.show-message("功能还在开发中,咕咕咕 😣", MessageType.Info);
MessageManager.show-message("功能还在开发中,咕咕咕 😣", MessageType.info);
}
}
if AccountManager.is-login:Divider { }
Expand Down
5 changes: 1 addition & 4 deletions ui/views/page/setting.slint
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export global SettingPageBridge {
in-out property <bool> notice-begin: false;
in-out property <bool> notice-end: false;
in-out property <bool> minimal-to-tray: false;

public function change-theme() {
if (theme-index == 1) {
Token.set-display-mode(ColorScheme.light);
Expand All @@ -19,7 +18,6 @@ export global SettingPageBridge {
Token.set-display-mode(ColorScheme.unknown);
}
}

callback language-changed();
callback theme-changed();
callback notice-begin-changed();
Expand Down Expand Up @@ -65,7 +63,6 @@ export component SettingPage inherits Page {
alignment: LayoutAlignment.start;
padding: 50px;
spacing: 15px;

Text {
text: "设置";
font-size: Token.font.display.medium.size;
Expand Down Expand Up @@ -129,7 +126,7 @@ export component SettingPage inherits Page {
checked <=> SettingPageBridge.minimal-to-tray;
toggled => {
SettingPageBridge.minimal-to-tray-changed();
MessageManager.show-message("下次启动应用时生效", MessageType.Info);
MessageManager.show-message("下次启动应用时生效", MessageType.info);
}
}
}
Expand Down

0 comments on commit 34219a9

Please sign in to comment.