diff --git a/src/logic/about.rs b/src/logic/about.rs index 02343af..440bcff 100644 --- a/src/logic/about.rs +++ b/src/logic/about.rs @@ -4,7 +4,7 @@ use slint::ComponentHandle; pub fn init(ui: &AppWindow) { ui.global::().set_title(slint::format!( - "sollaw {}", + "slint-template {}", if VERSION.is_empty() { "v0.0.1" } else { diff --git a/src/logic/clipboard.rs b/src/logic/clipboard.rs index 3167756..42f89dc 100644 --- a/src/logic/clipboard.rs +++ b/src/logic/clipboard.rs @@ -55,8 +55,8 @@ pub fn init(ui: &AppWindow) { ui.global::().on_copy_to_clipboard(move |msg| { let ui = ui_handle.unwrap(); match copy_to_clipboard(&msg) { - Err(e) => toast_warn!(ui, format!("{}. {}: {e:?}", tr("复制失败"), tr("原因"))), - _ => toast_success!(ui, tr("复制成功")), + Err(e) => toast_warn!(ui, format!("{}. {}: {e:?}", tr("Copy failed"), tr("Reason"))), + _ => toast_success!(ui, tr("Copy success")), } }); @@ -65,7 +65,7 @@ pub fn init(ui: &AppWindow) { let ui = ui_handle.unwrap(); match copy_from_clipboard() { Err(e) => { - toast_warn!(ui, format!("{}. {}: {e:?}", tr("粘贴失败"), tr("原因"))); + toast_warn!(ui, format!("{}. {}: {e:?}", tr("Paste failed"), tr("Reason"))); slint::SharedString::default() } Ok(msg) => msg.into(), diff --git a/src/logic/confirm_dialog.rs b/src/logic/confirm_dialog.rs index 46a4530..61d98f9 100644 --- a/src/logic/confirm_dialog.rs +++ b/src/logic/confirm_dialog.rs @@ -1,16 +1,16 @@ -use crate::slint_generatedAppWindow::{AppWindow, Logic}; +use crate::slint_generatedAppWindow::{AppWindow, Util, Logic}; use slint::ComponentHandle; pub fn init(ui: &AppWindow) { let ui_handle = ui.as_weak(); - ui.global::() + ui.global::() .on_handle_confirm_dialog(move |handle_type, _user_data| { - let _ui = ui_handle.unwrap(); + let ui = ui_handle.unwrap(); match handle_type.as_str() { - // "remove-all-cache" => { - // ui.global::().invoke_remove_all_cache(); - // } + "remove-all-cache" => { + ui.global::().invoke_remove_all_cache(); + } _ => (), } }); diff --git a/src/logic/setting.rs b/src/logic/setting.rs index 6ca372e..dc6746c 100644 --- a/src/logic/setting.rs +++ b/src/logic/setting.rs @@ -15,7 +15,7 @@ pub fn init(ui: &AppWindow) { .set_is_show_landing_page(config::is_first_run()); ui.global::() - .on_tr(move |_is_cn, text| tr(text.as_str()).into()); + .on_inner_tr(move |_is_cn, text| tr(text.as_str()).into()); let ui_handle = ui.as_weak(); ui.global::().on_get_setting_ui(move || { diff --git a/src/logic/toast.rs b/src/logic/toast.rs index 1f14117..a5ce183 100644 --- a/src/logic/toast.rs +++ b/src/logic/toast.rs @@ -1,11 +1,14 @@ -use crate::slint_generatedAppWindow::{AppWindow, ToastSetting, Util}; +use crate::slint_generatedAppWindow::{AppWindow, ToastSetting, ToastStatus, Util}; use slint::{ComponentHandle, Timer, TimerMode, Weak}; #[macro_export] macro_rules! toast_warn { ($ui:expr, $msg:expr) => { $ui.global::() - .invoke_show_toast(slint::format!("{}", $msg), "warning".into()) + .invoke_show_toast( + slint::format!("{}", $msg), + crate::slint_generatedAppWindow::ToastStatus::Warning, + ) }; } @@ -13,7 +16,10 @@ macro_rules! toast_warn { macro_rules! toast_success { ($ui:expr, $msg:expr) => { $ui.global::() - .invoke_show_toast(slint::format!("{}", $msg), "success".into()) + .invoke_show_toast( + slint::format!("{}", $msg), + crate::slint_generatedAppWindow::ToastStatus::Success, + ) }; } @@ -22,7 +28,10 @@ macro_rules! toast_success { macro_rules! toast_info { ($ui:expr, $msg:expr) => { $ui.global::() - .invoke_show_toast(slint::format!("{}", $msg), "info".into()) + .invoke_show_toast( + slint::format!("{}", $msg), + crate::slint_generatedAppWindow::ToastStatus::Info, + ) }; } @@ -31,7 +40,7 @@ pub fn async_toast_warn(ui: Weak, msg: String) { let _ = slint::invoke_from_event_loop(move || { ui.unwrap() .global::() - .invoke_show_toast(slint::format!("{}", msg), "warning".into()); + .invoke_show_toast(slint::format!("{}", msg), ToastStatus::Warning); }); } @@ -40,7 +49,7 @@ pub fn async_toast_success(ui: Weak, msg: String) { let _ = slint::invoke_from_event_loop(move || { ui.unwrap() .global::() - .invoke_show_toast(slint::format!("{}", msg), "success".into()); + .invoke_show_toast(slint::format!("{}", msg), ToastStatus::Success); }); } @@ -49,14 +58,14 @@ pub fn async_toast_info(ui: Weak, msg: String) { let _ = slint::invoke_from_event_loop(move || { ui.unwrap() .global::() - .invoke_show_toast(slint::format!("{}", msg), "info".into()); + .invoke_show_toast(slint::format!("{}", msg), ToastStatus::Info); }); } pub fn init(ui: &AppWindow) { let timer = Timer::default(); let ui_handle = ui.as_weak(); - ui.global::().on_show_toast(move |msg, msg_type| { + ui.global::().on_show_toast(move |msg, status| { let ui = ui_handle.unwrap(); if timer.running() { @@ -69,13 +78,14 @@ pub fn init(ui: &AppWindow) { 2 }; - ui.global::().invoke_set(msg, msg_type); + ui.global::().invoke_set(msg, status); timer.start( TimerMode::SingleShot, std::time::Duration::from_secs(interval), move || { - ui.global::().invoke_set("".into(), "".into()); + ui.global::() + .invoke_set("".into(), ToastStatus::None); }, ); }); diff --git a/src/logic/tr.rs b/src/logic/tr.rs index a50d171..19a5236 100644 --- a/src/logic/tr.rs +++ b/src/logic/tr.rs @@ -2,302 +2,294 @@ use crate::config; use std::collections::HashMap; pub fn tr(text: &str) -> String { - if config::ui().language == "cn" { + if config::ui().language == "en" { return text.to_string(); } - let mut items: HashMap<&str, &str> = HashMap::new(); - items.insert("出错", "Error"); - items.insert("原因", "Reason"); - items.insert("取消", "Cancel"); - items.insert("确认", "Confirm"); - items.insert("确定", "Confirm"); - items.insert("编辑", "Edit"); - items.insert("删除", "Delete"); - items.insert("清空", "Clear"); - items.insert("发送", "Send"); - - items.insert("删除成功", "Delete success"); - items.insert("删除失败", "Delete failed"); - items.insert("添加成功", "Add success"); - items.insert("添加失败", "Add failed"); - items.insert("复制失败", "Copy failed"); - items.insert("复制成功", "Copy success"); - items.insert("清空失败", "Delete failed"); - items.insert("清空成功", "Delete success"); - items.insert("保存失败", "Save failed"); - items.insert("保存成功", "Save success"); - items.insert("重置成功", "Reset success"); - items.insert("刷新成功", "Refresh success"); - items.insert("刷新失败", "Refresh failed"); - items.insert("发送失败", "Send failed"); - items.insert("下载成功", "Download success"); - items.insert("下载失败", "Download failed"); - items.insert("加载失败", "Load failed"); - items.insert("非法输入", "Invalid input"); - items.insert("打开链接失败", "Open link failed"); - - items.insert("新建成功", "New success"); - items.insert("新建失败", "New failed"); - items.insert("编辑成功", "Edit success"); - items.insert("编辑失败", "Edit failed"); - - items.insert("微信支付", "Wechat pay"); - items.insert("小狐狸(加密)支付", "MetaMask crypto pay"); - - items.insert("收藏成功", "Favorite success"); - items.insert("收藏失败", "Favorite failed"); - items.insert("取消收藏成功", "Cancel favorite success"); - items.insert("取消收藏失败", "Cancel favorite failed"); - - items.insert("正在刷新...", "Refreshing..."); - items.insert("正在同步...", "Syncing..."); - items.insert("同步成功", "Refresh success"); - items.insert("同步完成", "Refresh finished"); - items.insert("查找完成", "Search finish"); - items.insert("返回为空", "Empty data"); - - items.insert("是否删除?", "Delete or not?"); - items.insert("是否删除全部?", "Delete all entrys or not?"); - items.insert("是否删除全部缓存?", "Delete all cache or not?"); - items.insert("清除缓存失败", "Remove cache failed"); - items.insert("清除缓存成功", "Remove cache success"); - items.insert("超过1000字数限制", "Over the limit of 2048 word counts"); - - items.insert("界 面", "UI"); - items.insert("偏好设置", "Preference"); - items.insert("账户管理", "Account"); - items.insert("阅 读", "Reading"); - items.insert("同 步", "Sync"); - items.insert("代 理", "Proxy"); - items.insert("缓 存", "Cache"); - items.insert("关 于", "About"); - items.insert("帮 助", "Help"); - items.insert("反 馈", "Feedback"); - items.insert("捐 赠", "Donate"); - - items.insert("新建", "New"); - items.insert("没有订阅", "No RSS"); - items.insert("RSS名称和图标", "RSS name and icon"); - items.insert("请输入RSS名称", "Please input RSS name"); - items.insert("RSS源地址", "RSS URL"); - items.insert("请输入RSS源地址", "Please input RSS URL"); - items.insert("RSS源格式", "RSS format"); - items.insert("已启用Http代理", "Enabled Http proxy"); - items.insert("未启用Http代理", "Disable Http proxy"); - items.insert("已启用Socks5代理", "Enabled Socks5 proxy"); - items.insert("未启用Socks5代理", "Disable Socks5 proxy"); - items.insert("已收藏", "Star"); - items.insert("未收藏", "Not star"); - items.insert("图标库", "Icons"); - items.insert("请选择条目", "Please select entry"); - items.insert("请添加RSS源", "Please add RSS URL"); - items.insert("选择浏览器", "Select browser"); - items.insert("已启用阅后即焚", "Enabled delete after reading"); - items.insert("未启用阅后即焚", "Disable delete after reading"); - - items.insert("字体大小", "Font size"); - items.insert("字体样式", "Font family"); - items.insert("选择语言", "Choose language"); - items.insert("同步时间间隔(分钟)", "Sync time interval(minute)"); - items.insert("请输入时间间隔", "Please input time interval"); - items.insert("同步超时(秒)", "Sync timeout(second)"); - items.insert("请输入同步超时", "Please input sync timeout"); - items.insert("已启用自动同步", "Enabled auto sync"); - items.insert("未启用自动同步", "Disable auto sync"); - items.insert( - "程序启动时,马上进行一次同步", - "Starting sync once, when application starting", - ); - items.insert( - "程序启动时,不马上进行一次同步", - "Don't start sync, when application starting", - ); - items.insert("代理地址", "Proxy address"); - items.insert("代理端口", "Proxy port"); - - items.insert("警告", "Warning"); - items.insert("订阅", "RSS"); - items.insert("收藏夹", "Collection"); - items.insert("发现", "Find"); - items.insert("添加", "Add"); - items.insert("设置", "Setting"); - - items.insert("成功移除黑名单", "Remove from blacklist success"); - items.insert("没有数据", "No Data"); - items.insert("没有消息", "No Message"); - items.insert("输入关键字", "Input keyword"); - - items.insert("备份与恢复", "Backup and recover"); - items.insert("API 令牌", "API token"); - items.insert("请输入API令牌", "Please input API token"); - items.insert("备份与恢复选项", "Backup and recover options"); - items.insert("RSS列表", "RSS list"); - items.insert("用户设置", "User setting"); - items.insert("备份", "Backup"); - items.insert("恢复", "Recover"); - items.insert("备份成功", "Backup success"); - items.insert("备份失败", "Backup failed"); - items.insert("恢复成功", "Recover success"); - items.insert("恢复失败", "Recover failed"); - items.insert("是否备份?", "Backup or not?"); - items.insert("是否恢复?", "Recover or not?"); - - items.insert("获取最新版本", "Latest version"); - items.insert("版本信息", "Current version"); - items.insert("当前版本", "Latest version"); - items.insert("更新信息", "Update detail"); - items.insert("下载最新版本", "Download"); - items.insert("选择主题", "Choose Theme"); - items.insert("白天", "Light"); - items.insert("黑暗", "Dark"); - items.insert("跳过", "Skip"); - items.insert("下一步", "Next"); - items.insert("完成", "Finish"); - items.insert("返回", "Back"); - items.insert("请选择语言", "Please select language"); - items.insert("没有记录", "No record"); - items.insert("没有地址", "No address"); - items.insert("请输入用户名", "Please enter username"); - items.insert("用户名", "Username"); - items.insert("请输入密码", "Please enter password"); - items.insert("请再次输入密码", "Please enter password again"); - items.insert("至少8个字符", "At least 8 chars"); - items.insert("创建账户", "Create account"); - items.insert("恢复账户", "Recover account"); - items.insert("生成组记词失败", "New mnemonic failed"); - items.insert("登录", "Login"); - items.insert( - "组记词数量不对,仅支持12和24个组记词", - "Mnemonic counts is no correct. Only support 12 or 24 word counts mnemonic", - ); - items.insert("非法组记词", "Invalid mnemonic"); - items.insert("用户名不能为空", "Username can not be empty"); - items.insert("密码不相同", "Two passwords is different"); - items.insert("密码不能小于8位", "Password can not less than 8 chars"); - items.insert("更新账户成功", "Update account success"); - items.insert( - "更新账户失败. 账户不存在", - "Update account failed. The account don't exist", - ); - items.insert("不允许删除当前用户", "Not allow delete current account"); - items.insert("不允许删除主账号", "Not allow delete the main account"); - items.insert("删除账户成功", "Delete account success"); - items.insert("移除账户成功", "Remove account success"); - items.insert("切换账户成功", "Switch account success"); - items.insert( - "切换账户失败. 账户不存在", - "Switch account failed. The account don't exist", - ); - items.insert( - "创建用户失败. 非法密码", - "Create account failed. Invalid password", - ); - items.insert("创建用户成功", "Create account success"); - items.insert("创建用户失败", "Create account failed"); - items.insert("账户管理", "Account Management"); - items.insert("是否删除账户?", "Delete account or not?"); - items.insert("内部错误", "Internal error"); - items.insert("密码错误", "Password is wrong"); - items.insert("组记词", "Mnemonic"); - items.insert("地址簿", "Address Book"); - items.insert("移除地址", "Delete address"); - items.insert("是否删除地址?", "Delete address or not?"); - items.insert("地址名称", "Address name"); - items.insert("账户地址", "Account address"); - items.insert("地 址", "Address"); - items.insert("删除地址成功", "Delete address success"); - items.insert("更新地址成功", "Update address success"); - items.insert("更新地址失败", "Update address failed"); - items.insert("切换账户", "Switch account"); - items.insert("是否删除所有账户?", "Delete all account or not?"); - items.insert("删除所有账户成功", "Delete all accounts success"); - items.insert("打开成功", "Open link success"); - items.insert("打开失败", "Open link failed"); - items.insert("安全与隐私", "Security & Privacy "); - items.insert("重置账户", "Reset account"); - items.insert("是否重置账户?", "Reset account or not?"); - items.insert("请输入旧密码", "Please input old password"); - items.insert("请输入新密码", "Please input new password"); - items.insert("请再次输入新密码", "Please input new password again"); - items.insert("测试模式", "Test model"); - items.insert("主网络", "Main Network"); - items.insert("测试网络", "Test Network"); - items.insert("开发网络", "Dev Network"); - items.insert("未知网络", "Unknown Network"); - items.insert("注意: 当前处于", "Warning: Current Network is "); - items.insert("主页", "Home"); - items.insert("接收", "Recipient"); - items.insert("接收代币", "Recipient"); - items.insert("历史", "History"); - items.insert("历史记录", "History"); - items.insert("开发者模式", "Developer Mode"); - items.insert("账户名称", "Account name"); - items.insert("显示组记词", "Show mnemonics"); - items.insert("移除账户", "Remove account"); - items.insert("更改密码", "Change password"); - items.insert("位组记词", "mnemonics"); - items.insert("刷新完成", "Refresh finished"); - items.insert("管理代币", "Manage token"); - items.insert("发送代币", "Send token"); - items.insert("获取Token失败", "Fetch account tokens failed"); - items.insert("更新账户余额成功", "Refresh account balance success"); - items.insert("请求空投", "Request airdrop"); - items.insert("请求空投成功", "Request airdrop success"); - items.insert("请求空投失败", "Request airdrop failed"); - items.insert("请耐心等待...", "It may takes a long time. Please wait..."); - items.insert("估计交易费用失败", "Evaluating transaction fee failed"); - items.insert("正在估计交易费用...", "Evaluating gas fee..."); - items.insert("交易记录", "Transaction signature"); - items.insert("区块网络", "Blockchain network"); - items.insert("发送数量", "Send amount"); - items.insert("交易记录", "Transaction history"); - items.insert("关闭", "Close"); - items.insert("交易失败", "Transaction failed"); - items.insert("等待交易确认...", "Waiting transaction confirmed..."); - items.insert("交易信息", "Transaction detail"); - items.insert("发送地址", "Send address"); - items.insert("接收地址", "Recipient address"); - items.insert("交易费用", "Transaction fee"); - items.insert("交易已经确认", "Transaction has been confirmed"); - items.insert("交易成功", "Transaction success"); - items.insert("非法地址", "Invalid address"); - items.insert("账户", "Account"); - items.insert("创建账户费用", "Create token account fee"); - items.insert("创建组记词", "Create mnemonic"); - items.insert("恢复账户", "Recover account"); - items.insert("二维码", "QrCode"); - items.insert("高级设置", "Advance setting"); - items.insert("备注", "Memo"); - items.insert("优先费用", "Prioritization fee"); - items.insert("基础费用", "Base fee"); - items.insert("最大优先费用", "Max prioritization fee"); - items.insert("最大优先费用为", "Max prioritization fee is"); - items.insert("慢", "Slow"); - items.insert("正常", "Normal"); - items.insert("快", "Fast"); - items.insert("非法优先费用", "Invalid prioritization fee"); - items.insert("请设置更大的优先费用", "Please setting max prioritization fee"); - items.insert("登出账户", "Logout account"); - items.insert("密码错误", "Wrong password"); - items.insert("内部错误. 密码不存在", "Internal error. Password not exist"); - items.insert( - "更新账户余额失败. 账户不存在", - "Refresh account balance failed. The account is not found", - ); - - items.insert( - "创建账户和使用组记词恢复账户", - "Create account and recover account from mnemonics", - ); - items.insert( - "查看、发送和接收Sol代币和Solana的通证", - "Show, send and receive Sol and tokens of Solana", - ); - items.insert( - "欢迎使用,享受你的加密之旅", - "Welcome! Enjoying you journey of crypto", - ); + let items: HashMap<&str, &str> = HashMap::from([ + ("Error", "出错"), + ("Reason", "原因"), + ("Cancel", "取消"), + ("Confirm", "确认"), + ("Confirm", "确定"), + ("Edit", "编辑"), + ("Delete", "删除"), + ("Clear", "清空"), + ("Send", "发送"), + ("Delete success", "删除成功"), + ("Delete failed", "删除失败"), + ("Add success", "添加成功"), + ("Add failed", "添加失败"), + ("Copy failed", "复制失败"), + ("Copy success", "复制成功"), + ("Paste failed", "粘贴失败"), + ("Delete failed", "清空失败"), + ("Delete success", "清空成功"), + ("Save failed", "保存失败"), + ("Save success", "保存成功"), + ("Reset success", "重置成功"), + ("Refresh success", "刷新成功"), + ("Refresh failed", "刷新失败"), + ("Send failed", "发送失败"), + ("Download success", "下载成功"), + ("Download failed", "下载失败"), + ("Load failed", "加载失败"), + ("Invalid input", "非法输入"), + ("Open link failed", "打开链接失败"), + ("Input can not be empty", "输入不能为空"), + ("New success", "新建成功"), + ("New failed", "新建失败"), + ("Edit success", "编辑成功"), + ("Edit failed", "编辑失败"), + ("Wechat pay", "微信支付"), + ("MetaMask crypto pay", "小狐狸(加密)支付"), + ("Favorite success", "收藏成功"), + ("Favorite failed", "收藏失败"), + ("Cancel favorite success", "取消收藏成功"), + ("Cancel favorite failed", "取消收藏失败"), + ("Refreshing...", "正在刷新..."), + ("Syncing...", "正在同步..."), + ("Refresh success", "同步成功"), + ("Refresh finished", "同步完成"), + ("Search finish", "查找完成"), + ("Empty data", "返回为空"), + ("Delete or not?", "是否删除?"), + ("Delete all entrys or not?", "是否删除全部?"), + ("Delete all cache or not?", "是否删除全部缓存?"), + ("Remove cache failed", "清除缓存失败"), + ("Remove cache success", "清除缓存成功"), + ("Over the limit of 2048 word counts", "超过1000字数限制"), + ("UI", "界 面"), + ("Preference", "偏好设置"), + ("Account", "账户管理"), + ("Reading", "阅 读"), + ("Sync", "同 步"), + ("Proxy", "代 理"), + ("Cache", "缓 存"), + ("About", "关 于"), + ("Help", "帮 助"), + ("Feedback", "反 馈"), + ("Donate", "捐 赠"), + ("New", "新建"), + ("No RSS", "没有订阅"), + ("RSS name and icon", "RSS名称和图标"), + ("Please input RSS name", "请输入RSS名称"), + ("RSS URL", "RSS源地址"), + ("Please input RSS URL", "请输入RSS源地址"), + ("RSS format", "RSS源格式"), + ("Enabled Http proxy", "已启用Http代理"), + ("Disable Http proxy", "未启用Http代理"), + ("Enabled Socks5 proxy", "已启用Socks5代理"), + ("Disable Socks5 proxy", "未启用Socks5代理"), + ("Star", "已收藏"), + ("Not star", "未收藏"), + ("Icons", "图标库"), + ("Please select entry", "请选择条目"), + ("Please add RSS URL", "请添加RSS源"), + ("Select browser", "选择浏览器"), + ("Enabled delete after reading", "已启用阅后即焚"), + ("Disable delete after reading", "未启用阅后即焚"), + ("Font size", "字体大小"), + ("Font family", "字体样式"), + ("Choose language", "选择语言"), + ("Sync time interval(minute)", "同步时间间隔(分钟)"), + ("Please input time interval", "请输入时间间隔"), + ("Sync timeout(second)", "同步超时(秒)"), + ("Please input sync timeout", "请输入同步超时"), + ("Enabled auto sync", "已启用自动同步"), + ("Disable auto sync", "未启用自动同步"), + ( + "Starting sync once, when application starting", + "程序启动时,马上进行一次同步", + ), + ( + "Donot start sync, when application starting", + "程序启动时,不马上进行一次同步", + ), + ("Proxy address", "代理地址"), + ("Proxy port", "代理端口"), + ("Warning", "警告"), + ("RSS", "订阅"), + ("Collection", "收藏夹"), + ("Find", "发现"), + ("Add", "添加"), + ("Setting", "设置"), + ("Remove from blacklist success", "成功移除黑名单"), + ("No Data", "没有数据"), + ("No Message", "没有消息"), + ("Input keyword", "输入关键字"), + ("Backup and recover", "备份与恢复"), + ("API token", "API 令牌"), + ("Please input API token", "请输入API令牌"), + ("Backup and recover options", "备份与恢复选项"), + ("RSS list", "RSS列表"), + ("User setting", "用户设置"), + ("Backup", "备份"), + ("Recover", "恢复"), + ("Backup success", "备份成功"), + ("Backup failed", "备份失败"), + ("Recover success", "恢复成功"), + ("Recover failed", "恢复失败"), + ("Backup or not?", "是否备份?"), + ("Recover or not?", "是否恢复?"), + ("Latest version", "获取最新版本"), + ("Current version", "版本信息"), + ("Latest version", "当前版本"), + ("Update detail", "更新信息"), + ("Download", "下载最新版本"), + ("Choose Theme", "选择主题"), + ("Light", "白天"), + ("Dark", "黑暗"), + ("Skip", "跳过"), + ("Next", "下一步"), + ("Finish", "完成"), + ("Back", "返回"), + ("Please select language", "请选择语言"), + ("No record", "没有记录"), + ("No address", "没有地址"), + ("Please enter username", "请输入用户名"), + ("Username", "用户名"), + ("Please enter password", "请输入密码"), + ("Please enter password again", "请再次输入密码"), + ("At least 8 chars", "至少8个字符"), + ("Create account", "创建账户"), + ("Recover account", "恢复账户"), + ("New mnemonic failed", "生成组记词失败"), + ("Login", "登录"), + ( + "Mnemonic counts is no correct. Only support 12 or 24 word counts mnemonic", + "组记词数量不对,仅支持12和24个组记词", + ), + ("Invalid mnemonic", "非法组记词"), + ("Username can not be empty", "用户名不能为空"), + ("Two passwords is different", "密码不相同"), + ("Password can not less than 8 chars", "密码不能小于8位"), + ("Update account success", "更新账户成功"), + ( + "Update account failed. The account do not exist", + "更新账户失败. 账户不存在", + ), + ("Not allow delete current account", "不允许删除当前用户"), + ("Not allow delete the main account", "不允许删除主账号"), + ("Delete account success", "删除账户成功"), + ("Remove account success", "移除账户成功"), + ("Switch account success", "切换账户成功"), + ( + "Switch account failed. The account do not exist", + "切换账户失败. 账户不存在", + ), + ( + "Create account failed. Invalid password", + "创建用户失败. 非法密码", + ), + ("Create account success", "创建用户成功"), + ("Create account failed", "创建用户失败"), + ("Account Management", "账户管理"), + ("Delete account or not?", "是否删除账户?"), + ("Internal error", "内部错误"), + ("Password is wrong", "密码错误"), + ("Mnemonic", "组记词"), + ("Address Book", "地址簿"), + ("Delete address", "移除地址"), + ("Delete address or not?", "是否删除地址?"), + ("Address name", "地址名称"), + ("Account address", "账户地址"), + ("Address", "地 址"), + ("Delete address success", "删除地址成功"), + ("Update address success", "更新地址成功"), + ("Update address failed", "更新地址失败"), + ("Switch account", "切换账户"), + ("Delete all account or not?", "是否删除所有账户?"), + ("Delete all accounts success", "删除所有账户成功"), + ("Open link success", "打开成功"), + ("Open link failed", "打开失败"), + ("Security & Privacy ", "安全与隐私"), + ("Reset account", "重置账户"), + ("Reset account or not?", "是否重置账户?"), + ("Please input old password", "请输入旧密码"), + ("Please input new password", "请输入新密码"), + ("Please input new password again", "请再次输入新密码"), + ("Test model", "测试模式"), + ("Main Network", "主网络"), + ("Test Network", "测试网络"), + ("Dev Network", "开发网络"), + ("Unknown Network", "未知网络"), + ("Warning: Current Network is ", "注意: 当前处于"), + ("Home", "主页"), + ("Recipient", "接收"), + ("Recipient", "接收代币"), + ("History", "历史"), + ("History", "历史记录"), + ("Developer Mode", "开发者模式"), + ("Account name", "账户名称"), + ("Show mnemonics", "显示组记词"), + ("Remove account", "移除账户"), + ("Change password", "更改密码"), + ("mnemonics", "位组记词"), + ("Refresh finished", "刷新完成"), + ("Manage token", "管理代币"), + ("Send token", "发送代币"), + ("Fetch account tokens failed", "获取Token失败"), + ("Refresh account balance success", "更新账户余额成功"), + ("Request airdrop", "请求空投"), + ("Request airdrop success", "请求空投成功"), + ("Request airdrop failed", "请求空投失败"), + ("It may takes a long time. Please wait...", "请耐心等待..."), + ("Evaluating transaction fee failed", "估计交易费用失败"), + ("Evaluating gas fee...", "正在估计交易费用..."), + ("Transaction signature", "交易记录"), + ("Blockchain network", "区块网络"), + ("Send amount", "发送数量"), + ("Transaction history", "交易记录"), + ("Close", "关闭"), + ("Transaction failed", "交易失败"), + ("Waiting transaction confirmed...", "等待交易确认..."), + ("Transaction detail", "交易信息"), + ("Send address", "发送地址"), + ("Recipient address", "接收地址"), + ("Transaction fee", "交易费用"), + ("Transaction has been confirmed", "交易已经确认"), + ("Transaction success", "交易成功"), + ("Invalid address", "非法地址"), + ("Account", "账户"), + ("Create token account fee", "创建账户费用"), + ("Create mnemonic", "创建组记词"), + ("Recover account", "恢复账户"), + ("QrCode", "二维码"), + ("Advance setting", "高级设置"), + ("Memo", "备注"), + ("Prioritization fee", "优先费用"), + ("Base fee", "基础费用"), + ("Max prioritization fee", "最大优先费用"), + ("Max prioritization fee is", "最大优先费用为"), + ("Slow", "慢"), + ("Normal", "正常"), + ("Fast", "快"), + ("Invalid prioritization fee", "非法优先费用"), + ( + "Please setting max prioritization fee", + "请设置更大的优先费用", + ), + ("Logout account", "登出账户"), + ("Wrong password", "密码错误"), + ("Internal error. Password not exist", "内部错误. 密码不存在"), + ( + "Refresh account balance failed. The account is not found", + "更新账户余额失败. 账户不存在", + ), + ( + "Create account and recover account from mnemonics", + "创建账户和使用组记词恢复账户", + ), + ( + "Show, send and receive Sol and tokens of Solana", + "查看、发送和接收Sol代币和Solana的通证", + ), + ( + "Welcome! Enjoying you journey of crypto", + "欢迎使用,享受你的加密之旅", + ), + ]); if let Some(txt) = items.get(text) { return txt.to_string(); diff --git a/src/logic/util.rs b/src/logic/util.rs index 77e4301..a6cbc03 100644 --- a/src/logic/util.rs +++ b/src/logic/util.rs @@ -34,7 +34,7 @@ pub fn init(ui: &AppWindow) { }; if let Err(e) = webbrowser::open_browser(browser, url.as_str()) { - toast_warn!(ui, format!("{}{}: {:?}", tr("打开链接失败"), tr("原因"), e)); + toast_warn!(ui, format!("{}{}: {:?}", tr("Open link failed"), tr("Reason"), e)); } }); diff --git a/src/version.rs b/src/version.rs index ad45a2b..9bf90ee 100644 --- a/src/version.rs +++ b/src/version.rs @@ -1 +1 @@ -pub static VERSION: &str = "v0.1.3"; \ No newline at end of file +pub static VERSION: &str = "v0.0.1"; diff --git a/ui/appwindow.slint b/ui/appwindow.slint index cb2c0f3..d772fd8 100644 --- a/ui/appwindow.slint +++ b/ui/appwindow.slint @@ -3,7 +3,7 @@ import { Logic } from "./logic.slint"; import { Store, SettingDetailIndex } from "./store.slint"; import { Util } from "./util.slint"; import { Panel } from "./panel/panel.slint"; -import { LoadingStatus, Toast, IconsDialogSetting, IconsDialog, ConfirmDialogDialog, ConfirmDialogSetting, Blanket, LandingPage, AboutSetting, ToastSetting } from "./base/widgets.slint"; +import { LoadingStatus, Toast, IconsDialogSetting, IconsDialog, ConfirmDialogDialog, ConfirmDialogSetting, Blanket, LandingPage, AboutSetting, ToastSetting, ToastStatus } from "./base/widgets.slint"; export component AppWindow inherits Window { default-font-size: Theme.default-font-size; @@ -39,10 +39,8 @@ export component AppWindow inherits Window { x: root.width / 2 - self.width / 2; y: 50px; inner-max-width: root.width * 80%; - text: ToastSetting.text; - type: ToastSetting.text-type; clicked => { - Logic.copy-to-clipboard(self.text); + Logic.copy-to-clipboard(ToastSetting.text); } } @@ -67,4 +65,4 @@ export component AppWindow inherits Window { } } -export { Util, Logic, Store, Theme, Icons, IconsDialogSetting, LoadingStatus, SettingDetailIndex, AboutSetting, ToastSetting } +export { Util, Logic, Store, Theme, Icons, IconsDialogSetting, LoadingStatus, SettingDetailIndex, AboutSetting, ToastSetting, ToastStatus } diff --git a/ui/base/about.slint b/ui/base/about.slint index ef3c2cd..967e6b0 100644 --- a/ui/base/about.slint +++ b/ui/base/about.slint @@ -12,13 +12,13 @@ import { Brand } from "brand.slint"; export global AboutSetting { - in-out property title: "sollaw v0.0.1"; + in-out property title: "slint-template v0.0.1"; in-out property sponsor: "0xf1199999751b1a3A74590adBf95401D19AB30014"; in-out property text: "Based on Slint-UI. Copyright 2022-2030. All rights reserved. The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE."; } export component About inherits SettingDetail { - title: Logic.tr(Store.is-cn, "关 于"); + title: Logic.tr("About"); VerticalLayout { alignment: start; diff --git a/ui/base/address-book.slint b/ui/base/address-book.slint index 7697c8b..3c2baee 100644 --- a/ui/base/address-book.slint +++ b/ui/base/address-book.slint @@ -49,11 +49,11 @@ export component AddressBook inherits Rectangle { if AddressBookSetting.entries.length == 0: NoDataImg { width: 80%; - text: Logic.tr(Store.is-cn, "没有数据"); + text: Logic.tr("No Data"); } sd := SettingDetail { - title: Logic.tr(Store.is-cn, "地址簿"); + title: Logic.tr("Address book"); SettingDetailInner { vbox-spacing: Theme.spacing * 2; @@ -106,7 +106,7 @@ export component AddressBookDetail inherits SettingDetail { // (uuid, address) -> void callback update-address(string, string); - title: Logic.tr(Store.is-cn, "地 址"); + title: Logic.tr("Address"); SettingDetailInner { HorizontalLayout { @@ -129,7 +129,7 @@ export component AddressBookDetail inherits SettingDetail { SettingDetailInnerVbox { SettingDetailLabel { - text: Logic.tr(Store.is-cn, "地址名称"); + text: Logic.tr("Address name"); } LineInput { @@ -157,7 +157,7 @@ export component AddressBookDetail inherits SettingDetail { SettingDetailInnerVbox { SettingDetailLabel { - text: Logic.tr(Store.is-cn, "账户地址"); + text: Logic.tr("Account address"); } address-input := LineInput { @@ -192,10 +192,10 @@ export component AddressBookDetail inherits SettingDetail { text-color: Theme.danger-color; border-radius: Theme.border-radius; font-size: Theme.title3-font-size; - text: Logic.tr(Store.is-cn, "移除地址"); + text: Logic.tr("Delete address"); clicked => { - ConfirmDialogSetting.set(true, "warning", Logic.tr(Store.is-cn, "警告"), Logic.tr(Store.is-cn, "是否删除地址?"), "remove-address-book-entry", entry.uuid); + ConfirmDialogSetting.set(true, "warning", Logic.tr("Warning"), Logic.tr("Delete address or not?"), "remove-address-book-entry", entry.uuid); } } } diff --git a/ui/base/confirm-dialog.slint b/ui/base/confirm-dialog.slint index d2ec39d..721a0e6 100644 --- a/ui/base/confirm-dialog.slint +++ b/ui/base/confirm-dialog.slint @@ -58,7 +58,7 @@ export component ConfirmDialogDialog inherits Rectangle { spacing: Theme.spacing * 4; TextBtn { - text: Logic.tr(Store.is-cn, "取消"); + text: Logic.tr("Cancel"); icon: Icons.cancel; clicked => { @@ -68,10 +68,10 @@ export component ConfirmDialogDialog inherits Rectangle { TextBtn { icon: Icons.success; - text: Logic.tr(Store.is-cn, "确认"); + text: Logic.tr("Confirm"); clicked => { - Logic.handle-confirm-dialog(ConfirmDialogSetting.handle-type, ConfirmDialogSetting.user-data); + Util.handle-confirm-dialog(ConfirmDialogSetting.handle-type, ConfirmDialogSetting.user-data); ConfirmDialogSetting.show = false; } } diff --git a/ui/base/def.slint b/ui/base/def.slint index 6aa9a30..d66d9e9 100644 --- a/ui/base/def.slint +++ b/ui/base/def.slint @@ -9,3 +9,12 @@ export enum PrioritizationFeeStatus { Normal, Fast, } + +export enum ToastStatus { + Success, + Info, + Warning, + Danger, + None, +} + diff --git a/ui/base/dialog.slint b/ui/base/dialog.slint index 6e52899..8a6010a 100644 --- a/ui/base/dialog.slint +++ b/ui/base/dialog.slint @@ -62,14 +62,14 @@ export component Dialog inherits Rectangle { padding: Theme.padding * 2; cancel-btn := CancelBtn { - text: Logic.tr(Store.is-cn, "取消"); + text: Logic.tr("Cancel"); clicked => { root.cancel-clicked(); } } ConfirmBtn { - text: Logic.tr(Store.is-cn, "确认"); + text: Logic.tr("Confirm"); clicked => { root.ok-clicked(); } diff --git a/ui/base/help.slint b/ui/base/help.slint index aca3390..1c10946 100644 --- a/ui/base/help.slint +++ b/ui/base/help.slint @@ -5,7 +5,7 @@ import { SettingDetail, SettingDetailInner } from "setting-detail.slint"; import { Label } from "label.slint"; export component Help inherits SettingDetail { - title: Logic.tr(Store.is-cn, "帮 助"); + title: Logic.tr("Help"); in-out property <[string]> entries; SettingDetailInner { diff --git a/ui/base/icons-dialog.slint b/ui/base/icons-dialog.slint index 3049a22..83d66ce 100644 --- a/ui/base/icons-dialog.slint +++ b/ui/base/icons-dialog.slint @@ -78,7 +78,7 @@ export global IconsDialogSetting { } export component IconsDialog inherits Dialog { - title: Logic.tr(Store.is-cn, "图标库"); + title: Logic.tr("Icons"); width: (icon-size + icon-spacing) * column-count - icon-spacing + Theme.padding * 2; is-hide-btns: true; diff --git a/ui/base/landing-page.slint b/ui/base/landing-page.slint index 13c1d3f..4ff84e5 100644 --- a/ui/base/landing-page.slint +++ b/ui/base/landing-page.slint @@ -31,7 +31,7 @@ component LangPage inherits Rectangle { } Label { - text: Logic.tr(Store.is-cn, "请选择语言"); + text: Logic.tr("Please select language"); font-size: Theme.title3-font-size; color: Theme.secondary-brand-color; } @@ -105,7 +105,7 @@ export component LandingPage inherits Rectangle { HorizontalLayout { alignment: LayoutAlignment.end; skip-btn := TextBtn { - text: Logic.tr(Store.is-cn, "跳过"); + text: Logic.tr("Skip"); colorize: Theme.have-read-text-color; font-size: Theme.default-font-size - 2px; } @@ -127,7 +127,7 @@ export component LandingPage inherits Rectangle { alignment: current-index == -1 ? LayoutAlignment.end : LayoutAlignment.space-between; if current-index > -1: TextBtn { - text: Logic.tr(Store.is-cn, "返回"); + text: Logic.tr("Next"); colorize: Theme.have-read-text-color; font-size: Theme.default-font-size - 2px; clicked => { @@ -137,8 +137,7 @@ export component LandingPage inherits Rectangle { TextBtn { font-size: Theme.default-font-size - 2px; - text: Logic.tr(Store.is-cn, - details.length == current-index + 1 ? "完成" : "下一步"); + text: Logic.tr(details.length == current-index + 1 ? "Finish" : "Next"); clicked => { current-index += 1; diff --git a/ui/base/language-dialog.slint b/ui/base/language-dialog.slint index c0bf541..ca87699 100644 --- a/ui/base/language-dialog.slint +++ b/ui/base/language-dialog.slint @@ -6,7 +6,7 @@ import { ConfirmBtn } from "./btn.slint"; import { RadioBtn } from "./radio-btn.slint"; export component LanguageDialog inherits Dialog { - title: Logic.tr(Store.is-cn, "请选择语言"); + title: Logic.tr("Please select language"); is-hide-btns: true; in-out property language: "cn"; @@ -36,7 +36,7 @@ export component LanguageDialog inherits Dialog { alignment: end; ConfirmBtn { - text: Logic.tr(Store.is-cn, "确认"); + text: Logic.tr("Confirm"); clicked => { Store.setting-ui.language = root.language; Logic.set-setting-ui(Store.setting-ui); diff --git a/ui/base/login.slint b/ui/base/login.slint index 88144f5..e10519e 100644 --- a/ui/base/login.slint +++ b/ui/base/login.slint @@ -30,7 +30,7 @@ export component Login inherits Rectangle { vbox := VerticalLayout { if is-show-header: Head { - title: Logic.tr(Store.is-cn, "返回"); + title: Logic.tr("Back"); hbox-alignment: LayoutAlignment.start; clicked => { root.back(); @@ -42,7 +42,7 @@ export component Login inherits Rectangle { SettingDetailInnerVbox { username-txt := SettingDetailLabel { - text: Logic.tr(Store.is-cn, "请输入用户名"); + text: Logic.tr("Please enter username"); } HorizontalLayout { @@ -51,7 +51,7 @@ export component Login inherits Rectangle { username-lineedit := LineInput { icon: Icons.paste; width: root.width - Theme.padding * 4; - placeholder-text: Logic.tr(Store.is-cn, "用户名"); + placeholder-text: Logic.tr("Username"); edited => { root.error-message = ""; @@ -69,13 +69,13 @@ export component Login inherits Rectangle { private property is-show-password; password-txt := SettingDetailLabel { - text: Logic.tr(Store.is-cn, "请输入密码"); + text: Logic.tr("Please enter password"); } password-lineedit := LineInput { icon: parent.is-show-password ? Icons.eye : Icons.close-eye; width: root.width - Theme.padding * 4; - placeholder-text: Logic.tr(Store.is-cn, "至少8个字符"); + placeholder-text: Logic.tr("At least 8 chars"); input-type: is-show-password ? InputType.text : InputType.password; edited => { @@ -104,7 +104,7 @@ export component Login inherits Rectangle { padding: Theme.padding * 5; CancelBtn { - text: Logic.tr(Store.is-cn, "取消"); + text: Logic.tr("Cancel"); clicked => { root.reset(); root.cancel(); @@ -112,7 +112,7 @@ export component Login inherits Rectangle { } confirm-btn := ConfirmBtn { - text: Logic.tr(Store.is-cn, "确认"); + text: Logic.tr("Confirm"); clicked => { root.error-message = root.confirm(username-lineedit.text, password-lineedit.text); diff --git a/ui/base/mnemonic.slint b/ui/base/mnemonic.slint index 13b43a2..f2cadd2 100644 --- a/ui/base/mnemonic.slint +++ b/ui/base/mnemonic.slint @@ -22,7 +22,7 @@ export component Mnemonic inherits Rectangle { private property max-blocks: mnemonics.length == 24 ? 2 : (mnemonics.length == 12 ? 1 : 0); out property is-mnemonic-counts-12: max-blocks != 2; - private property switch-mnemonic-counts-btn-text: (is-mnemonic-counts-12 ? "24" : "12") + Logic.tr(Store.is-cn, "位组记词"); + private property switch-mnemonic-counts-btn-text: (is-mnemonic-counts-12 ? "24" : "12") + Logic.tr("mnemonics"); callback back(); callback copy([string]); @@ -88,7 +88,7 @@ export component Mnemonic inherits Rectangle { VerticalLayout { if is-show-header: Head { - title: Logic.tr(Store.is-cn, root.header-title); + title: Logic.tr(root.header-title); hbox-alignment: LayoutAlignment.start; clicked => { root.back(); @@ -201,14 +201,14 @@ export component Mnemonic inherits Rectangle { spacing: Theme.spacing * 10; CancelBtn { - text: Logic.tr(Store.is-cn, "取消"); + text: Logic.tr("Cancel"); clicked => { root.cancel(); } } ConfirmBtn { - text: Logic.tr(Store.is-cn, "确认"); + text: Logic.tr("Confirm"); clicked => { root.confirm(); } diff --git a/ui/base/password.slint b/ui/base/password.slint index 1995858..da276a9 100644 --- a/ui/base/password.slint +++ b/ui/base/password.slint @@ -42,7 +42,7 @@ export component Password inherits Rectangle { vbox := VerticalLayout { if is-show-header: Head { - title: Logic.tr(Store.is-cn, "返回"); + title: Logic.tr("Back"); hbox-alignment: LayoutAlignment.start; clicked => { root.back(); @@ -56,13 +56,13 @@ export component Password inherits Rectangle { private property is-show-password; password-txt := SettingDetailLabel { - text: Logic.tr(Store.is-cn, "请输入密码"); + text: Logic.tr("Please enter password"); } password-lineedit := LineInput { icon: parent.is-show-password ? Icons.eye : Icons.close-eye; width: root.width - Theme.padding * 4; - placeholder-text: Logic.tr(Store.is-cn, "至少8个字符"); + placeholder-text: Logic.tr("At least 8 chars"); input-type: is-show-password ? InputType.text : InputType.password; edited => { @@ -91,7 +91,7 @@ export component Password inherits Rectangle { padding: Theme.padding * 5; CancelBtn { - text: Logic.tr(Store.is-cn, "取消"); + text: Logic.tr("Cancel"); clicked => { root.reset(); root.cancel(); @@ -99,7 +99,7 @@ export component Password inherits Rectangle { } confirm-btn := ConfirmBtn { - text: Logic.tr(Store.is-cn, "确认"); + text: Logic.tr("Confirm"); clicked => { root.error-message = root.confirm(PasswordSetting.handle-type, password-lineedit.text, PasswordSetting.user-data); diff --git a/ui/base/reset-password.slint b/ui/base/reset-password.slint index 19bb4c1..9f165db 100644 --- a/ui/base/reset-password.slint +++ b/ui/base/reset-password.slint @@ -29,7 +29,7 @@ export component ResetPassword inherits Rectangle { vbox := VerticalLayout { if is-show-header: Head { - title: Logic.tr(Store.is-cn, "返回"); + title: Logic.tr("Back"); hbox-alignment: LayoutAlignment.start; clicked => { root.back(); @@ -41,7 +41,7 @@ export component ResetPassword inherits Rectangle { SettingDetailInnerVbox { password-old-txt := SettingDetailLabel { - text: Logic.tr(Store.is-cn, "请输入旧密码"); + text: Logic.tr("Please input old password"); } HorizontalLayout { @@ -51,7 +51,7 @@ export component ResetPassword inherits Rectangle { password-old-lineedit := LineInput { width: root.width - Theme.padding * 4; - placeholder-text: Logic.tr(Store.is-cn, "至少8个字符"); + placeholder-text: Logic.tr("At least 8 chars"); icon: parent.is-show-password ? Icons.eye : Icons.close-eye; input-type: parent.is-show-password ? InputType.text : InputType.password; @@ -68,7 +68,7 @@ export component ResetPassword inherits Rectangle { SettingDetailInnerVbox { password-first-txt := SettingDetailLabel { - text: Logic.tr(Store.is-cn, "请输入新密码"); + text: Logic.tr("Please input new password"); } HorizontalLayout { @@ -78,7 +78,7 @@ export component ResetPassword inherits Rectangle { password-first-lineedit := LineInput { width: root.width - Theme.padding * 4; - placeholder-text: Logic.tr(Store.is-cn, "至少8个字符"); + placeholder-text: Logic.tr("At least 8 chars"); icon: parent.is-show-password ? Icons.eye : Icons.close-eye; input-type: parent.is-show-password ? InputType.text : InputType.password; @@ -95,7 +95,7 @@ export component ResetPassword inherits Rectangle { SettingDetailInnerVbox { password-second-txt := SettingDetailLabel { - text: Logic.tr(Store.is-cn, "请再次输入新密码"); + text: Logic.tr("Please enter password again"); } HorizontalLayout { @@ -105,7 +105,7 @@ export component ResetPassword inherits Rectangle { password-second-lineedit := LineInput { width: root.width - Theme.padding * 4; - placeholder-text: Logic.tr(Store.is-cn, "至少8个字符"); + placeholder-text: Logic.tr("At least 8 chars"); icon: parent.is-show-password ? Icons.eye : Icons.close-eye; input-type: is-show-password ? InputType.text : InputType.password; @@ -132,7 +132,7 @@ export component ResetPassword inherits Rectangle { padding: Theme.padding * 5; CancelBtn { - text: Logic.tr(Store.is-cn, "取消"); + text: Logic.tr("Cancel"); clicked => { root.reset(); root.cancel(); @@ -140,7 +140,7 @@ export component ResetPassword inherits Rectangle { } ConfirmBtn { - text: Logic.tr(Store.is-cn, "确认"); + text: Logic.tr("confirm"); clicked => { root.error-message = root.confirm(password-old-lineedit.text, password-first-lineedit.text, password-second-lineedit.text); diff --git a/ui/base/sign-in.slint b/ui/base/sign-in.slint index 01a56d4..a0be932 100644 --- a/ui/base/sign-in.slint +++ b/ui/base/sign-in.slint @@ -30,7 +30,7 @@ export component SignIn inherits Rectangle { vbox := VerticalLayout { if is-show-header: Head { - title: Logic.tr(Store.is-cn, "返回"); + title: Logic.tr("Back"); hbox-alignment: LayoutAlignment.start; clicked => { root.back(); @@ -42,7 +42,7 @@ export component SignIn inherits Rectangle { SettingDetailInnerVbox { username-txt := SettingDetailLabel { - text: Logic.tr(Store.is-cn, "请输入用户名"); + text: Logic.tr("Please enter username"); } HorizontalLayout { @@ -51,7 +51,7 @@ export component SignIn inherits Rectangle { username-lineedit := LineInput { icon: Icons.paste; width: root.width - Theme.padding * 4; - placeholder-text: Logic.tr(Store.is-cn, "用户名"); + placeholder-text: Logic.tr("Username"); edited => { root.error-message = ""; @@ -67,7 +67,7 @@ export component SignIn inherits Rectangle { SettingDetailInnerVbox { password-first-txt := SettingDetailLabel { - text: Logic.tr(Store.is-cn, "请输入密码"); + text: Logic.tr("Please input password"); } HorizontalLayout { @@ -77,7 +77,7 @@ export component SignIn inherits Rectangle { password-first-lineedit := LineInput { width: root.width - Theme.padding * 4; - placeholder-text: Logic.tr(Store.is-cn, "至少8个字符"); + placeholder-text: Logic.tr("At least 8 chars"); icon: parent.is-show-password ? Icons.eye : Icons.close-eye; input-type: parent.is-show-password ? InputType.text : InputType.password; @@ -94,7 +94,7 @@ export component SignIn inherits Rectangle { SettingDetailInnerVbox { password-second-txt := SettingDetailLabel { - text: Logic.tr(Store.is-cn, "请再次输入密码"); + text: Logic.tr("Please enter password again"); } HorizontalLayout { @@ -104,7 +104,7 @@ export component SignIn inherits Rectangle { password-second-lineedit := LineInput { width: root.width - Theme.padding * 4; - placeholder-text: Logic.tr(Store.is-cn, "至少8个字符"); + placeholder-text: Logic.tr("At least 8 chars"); icon: parent.is-show-password ? Icons.eye : Icons.close-eye; input-type: is-show-password ? InputType.text : InputType.password; @@ -131,7 +131,7 @@ export component SignIn inherits Rectangle { padding: Theme.padding * 5; CancelBtn { - text: Logic.tr(Store.is-cn, "取消"); + text: Logic.tr("Cancel"); clicked => { root.reset(); root.cancel(); @@ -139,7 +139,7 @@ export component SignIn inherits Rectangle { } ConfirmBtn { - text: Logic.tr(Store.is-cn, "登录"); + text: Logic.tr("Login"); clicked => { root.error-message = root.confirm(username-lineedit.text, password-first-lineedit.text, password-second-lineedit.text); diff --git a/ui/base/toast.slint b/ui/base/toast.slint index f29378c..3629e97 100644 --- a/ui/base/toast.slint +++ b/ui/base/toast.slint @@ -1,30 +1,29 @@ import { Theme } from "../theme.slint"; import { Util } from "../util.slint"; -import { Label } from "./label.slint"; -import { CenterLayout } from "./center-layout.slint"; +import { Label } from "label.slint"; +import { CenterLayout } from "center-layout.slint"; +import { ToastStatus } from "def.slint"; export global ToastSetting { in-out property text; - in-out property text-type; + in-out property status; - public function set(text: string, text-type: string) { + public function set(text: string, status: ToastStatus) { self.text = text; - self.text-type = text-type; + self.status = status; } } export component Toast inherits Rectangle { - in-out property type: "success"; in-out property inner-max-width: 300px; - in-out property text <=> txt.text; callback clicked <=> touch.clicked; - width: hbox.preferred-width + Theme.padding * 2; + width: hbox.preferred-width + Theme.padding; height: hbox.preferred-height; border-radius: Theme.border-radius; border-color: Theme.base-border-color; - background: Util.text-color(root.type); + background: Util.text-color(ToastSetting.status); hbox := HorizontalLayout { alignment: LayoutAlignment.center; @@ -35,7 +34,7 @@ export component Toast inherits Rectangle { img := Image { width: txt.font-size * 1.2; height: self.width; - source: Util.icon-source(root.type); + source: Util.icon-source(ToastSetting.status); colorize: Colors.white; } } @@ -45,6 +44,7 @@ export component Toast inherits Rectangle { font-size: Theme.title4-font-size; color: img.colorize; wrap: word-wrap; + text: ToastSetting.text; } } diff --git a/ui/base/token-list.slint b/ui/base/token-list.slint index f5b7348..b12cb2b 100644 --- a/ui/base/token-list.slint +++ b/ui/base/token-list.slint @@ -49,14 +49,14 @@ export component TokenListWithSwitch inherits SettingDetail { } if is-loading: Loading { - loading-text: Logic.tr(Store.is-cn, "正在刷新..."); + loading-text: Logic.tr("Refreshing..."); colorize: Theme.secondary-brand-color; icon-size: Theme.icon-size * 2; } if !is-loading && entries.length == 0: Rectangle { NoDataImg { - text: Logic.tr(Store.is-cn, "没有数据"); + text: Logic.tr("No Data"); } } } diff --git a/ui/base/token-sender.slint b/ui/base/token-sender.slint index b776fb6..48682e7 100644 --- a/ui/base/token-sender.slint +++ b/ui/base/token-sender.slint @@ -43,7 +43,7 @@ export component TokenSender inherits SettingDetail { root.prioritization-fee = ""; } - title: Logic.tr(Store.is-cn, "发送代币"); + title: Logic.tr("Send token"); SettingDetailInner { HorizontalLayout { @@ -67,7 +67,7 @@ export component TokenSender inherits SettingDetail { SettingDetailInnerVbox { SettingDetailLabel { - text: Logic.tr(Store.is-cn, "区块网络"); + text: Logic.tr("Blockchain network"); } network-input := LineInput { @@ -80,7 +80,7 @@ export component TokenSender inherits SettingDetail { SettingDetailInnerVbox { SettingDetailLabel { - text: Logic.tr(Store.is-cn, "发送代币"); + text: Logic.tr("Send token"); } send-token-input := LineInput { @@ -104,7 +104,7 @@ export component TokenSender inherits SettingDetail { SettingDetailInnerVbox { SettingDetailLabel { - text: Logic.tr(Store.is-cn, "发送地址"); + text: Logic.tr("Send address"); } send-address-input := LineInput { @@ -117,7 +117,7 @@ export component TokenSender inherits SettingDetail { SettingDetailInnerVbox { SettingDetailLabel { - text: Logic.tr(Store.is-cn, "接收地址"); + text: Logic.tr("Recipient address"); } recipient-address-input := LineInput { @@ -138,7 +138,7 @@ export component TokenSender inherits SettingDetail { SettingDetailInnerVbox { SettingDetailLabel { - text: Logic.tr(Store.is-cn, "发送数量"); + text: Logic.tr("Send amount"); } amount-input := LineInput { @@ -171,7 +171,7 @@ export component TokenSender inherits SettingDetail { } TextBtn { - text: Logic.tr(Store.is-cn, "高级设置"); + text: Logic.tr("Advance setting"); icon: Icons.advance-setting; clicked => { @@ -181,7 +181,7 @@ export component TokenSender inherits SettingDetail { if is-show-advance-setting: SettingDetailInnerVbox { SettingDetailLabel { - text: Logic.tr(Store.is-cn, "备注"); + text: Logic.tr("Memo"); } memo-input := LineInput { @@ -201,7 +201,7 @@ export component TokenSender inherits SettingDetail { if is-show-advance-setting: SettingDetailInnerVbox { SettingDetailLabel { - text: Logic.tr(Store.is-cn, "优先费用"); + text: Logic.tr("Prioritization fee"); } prioritization-fee-input := LineInput { @@ -226,7 +226,7 @@ export component TokenSender inherits SettingDetail { spacing: Theme.spacing * 2; TextBtn { - text: Logic.tr(Store.is-cn, "慢"); + text: Logic.tr("Slow"); bg-color: Theme.info-color; use-auto-size: true; icon: Icons.turtle; @@ -238,7 +238,7 @@ export component TokenSender inherits SettingDetail { } TextBtn { - text: Logic.tr(Store.is-cn,"正常"); + text: Logic.tr("Normal"); use-auto-size: true; icon: Icons.rabbit; @@ -249,7 +249,7 @@ export component TokenSender inherits SettingDetail { } TextBtn { - text: Logic.tr(Store.is-cn,"快"); + text: Logic.tr("Fast"); use-auto-size: true; icon: Icons.horse; @@ -273,12 +273,12 @@ export component TokenSender inherits SettingDetail { spacing: Theme.spacing * 10; cancel-btn := CancelBtn { - text: Logic.tr(Store.is-cn, "取消"); + text: Logic.tr("Cancel"); } confirm-btn := ConfirmBtn { icon: Icons.send; - text: Logic.tr(Store.is-cn, "确认"); + text: Logic.tr("Confirm"); } } } diff --git a/ui/base/transaction-fee.slint b/ui/base/transaction-fee.slint index b02b0e6..35f874f 100644 --- a/ui/base/transaction-fee.slint +++ b/ui/base/transaction-fee.slint @@ -27,19 +27,19 @@ export component TransactionFee inherits SettingDetail { callback cancel(); callback confirm(); - title: Logic.tr(Store.is-cn, "交易信息"); + title: Logic.tr("Transaction detail"); SettingDetailInner { if loading-status == LoadingStatus.Loading: Loading { height: 150px; - loading-text: Logic.tr(Store.is-cn, "正在估计交易费用..."); + loading-text: Logic.tr("Evaluating gas fee..."); colorize: Theme.secondary-brand-color; icon-size: Theme.icon-size * 2; } SettingDetailInnerVbox { SettingDetailLabel { - text: Logic.tr(Store.is-cn, "区块网络"); + text: Logic.tr("Blockchain network"); } network-input := LineInput { @@ -52,7 +52,7 @@ export component TransactionFee inherits SettingDetail { SettingDetailInnerVbox { SettingDetailLabel { - text: Logic.tr(Store.is-cn, "发送代币"); + text: Logic.tr("Send token"); } send-token-input := LineInput { @@ -65,7 +65,7 @@ export component TransactionFee inherits SettingDetail { SettingDetailInnerVbox { SettingDetailLabel { - text: Logic.tr(Store.is-cn, "发送地址"); + text: Logic.tr("Send address"); } send-address-input := LineInput { @@ -78,7 +78,7 @@ export component TransactionFee inherits SettingDetail { SettingDetailInnerVbox { SettingDetailLabel { - text: Logic.tr(Store.is-cn, "接收地址"); + text: Logic.tr("Recipient address"); } recipient-address-input := LineInput { @@ -91,7 +91,7 @@ export component TransactionFee inherits SettingDetail { SettingDetailInnerVbox { SettingDetailLabel { - text: Logic.tr(Store.is-cn, "发送数量"); + text: Logic.tr("Send amount"); } amount-input := LineInput { @@ -110,7 +110,7 @@ export component TransactionFee inherits SettingDetail { if loading-status == LoadingStatus.Success: SettingDetailInnerVbox { SettingDetailLabel { - text: Logic.tr(Store.is-cn, "基础费用"); + text: Logic.tr("Base fee"); } LineInput { @@ -128,7 +128,7 @@ export component TransactionFee inherits SettingDetail { if root.prioritization-fee != "": SettingDetailInnerVbox { SettingDetailLabel { - text: Logic.tr(Store.is-cn, "优先费用"); + text: Logic.tr("Prioritization fee"); } LineInput { @@ -141,7 +141,7 @@ export component TransactionFee inherits SettingDetail { if loading-status == LoadingStatus.Success && root.create-token-account-fee != "": SettingDetailInnerVbox { SettingDetailLabel { - text: Logic.tr(Store.is-cn, "创建账户费用"); + text: Logic.tr("Create token account fee"); } LineInput { @@ -159,7 +159,7 @@ export component TransactionFee inherits SettingDetail { if root.memo != "": SettingDetailInnerVbox { SettingDetailLabel { - text: Logic.tr(Store.is-cn, "备注"); + text: Logic.tr("Memo"); } LineInput { @@ -176,7 +176,7 @@ export component TransactionFee inherits SettingDetail { if loading-status == LoadingStatus.Loading: CancelBtn { border-radius: Theme.border-radius; - text: Logic.tr(Store.is-cn, "取消"); + text: Logic.tr("Cancel"); clicked => { root.cancel(); } @@ -185,7 +185,7 @@ export component TransactionFee inherits SettingDetail { if loading-status == LoadingStatus.Fail: CancelBtn { border-radius: Theme.border-radius; bg-color: Theme.warning-color; - text: Logic.tr(Store.is-cn, "估计交易费用失败"); + text: Logic.tr("Evaluating transaction fee failed"); icon: Icons.warning; clicked => { root.back(); @@ -194,7 +194,7 @@ export component TransactionFee inherits SettingDetail { if loading-status == LoadingStatus.Success: ConfirmBtn { border-radius: Theme.border-radius; - text: Logic.tr(Store.is-cn, "确认"); + text: Logic.tr("Confirm"); clicked => { root.confirm(); } diff --git a/ui/base/wait-transaction-confirmed.slint b/ui/base/wait-transaction-confirmed.slint index c8106de..43f8ea3 100644 --- a/ui/base/wait-transaction-confirmed.slint +++ b/ui/base/wait-transaction-confirmed.slint @@ -18,19 +18,19 @@ export component WaitTransactionConfirmed inherits SettingDetail { callback open-signature <=> signature-input.clicked; - title: Logic.tr(Store.is-cn, "交易记录"); + title: Logic.tr("Transaction signature"); SettingDetailInner { if loading-status == LoadingStatus.Loading: Loading { height: 150px; - loading-text: Logic.tr(Store.is-cn, "等待交易确认..."); + loading-text: Logic.tr("Waiting transaction confirmed..."); colorize: Theme.secondary-brand-color; icon-size: Theme.icon-size * 2; } SettingDetailInnerVbox { SettingDetailLabel { - text: Logic.tr(Store.is-cn, "区块网络"); + text: Logic.tr("Blockchain network"); } network-input := LineInput { @@ -43,7 +43,7 @@ export component WaitTransactionConfirmed inherits SettingDetail { SettingDetailInnerVbox { SettingDetailLabel { - text: Logic.tr(Store.is-cn, "发送代币"); + text: Logic.tr("Send token"); } send-token-input := LineInput { @@ -56,7 +56,7 @@ export component WaitTransactionConfirmed inherits SettingDetail { SettingDetailInnerVbox { SettingDetailLabel { - text: Logic.tr(Store.is-cn, "发送数量"); + text: Logic.tr("Send amount"); } amount-input := LineInput { @@ -75,7 +75,7 @@ export component WaitTransactionConfirmed inherits SettingDetail { SettingDetailInnerVbox { SettingDetailLabel { - text: Logic.tr(Store.is-cn, "交易记录"); + text: Logic.tr("Transaction history"); } signature-input := LineInput { @@ -91,7 +91,7 @@ export component WaitTransactionConfirmed inherits SettingDetail { if loading-status == LoadingStatus.Loading: CancelBtn { border-radius: Theme.border-radius; - text: Logic.tr(Store.is-cn, "关闭"); + text: Logic.tr("Close"); clicked => { root.back(); } @@ -100,7 +100,7 @@ export component WaitTransactionConfirmed inherits SettingDetail { if loading-status == LoadingStatus.Fail: CancelBtn { border-radius: Theme.border-radius; bg-color: Theme.warning-color; - text: Logic.tr(Store.is-cn, "交易失败"); + text: Logic.tr("Transaction failed"); icon: Icons.warning; clicked => { root.back(); @@ -109,7 +109,7 @@ export component WaitTransactionConfirmed inherits SettingDetail { if loading-status == LoadingStatus.Success: ConfirmBtn { border-radius: Theme.border-radius; - text: Logic.tr(Store.is-cn, "交易成功"); + text: Logic.tr("Transaction success"); clicked => { root.back(); } diff --git a/ui/base/widgets.slint b/ui/base/widgets.slint index 49ea347..fb1390d 100644 --- a/ui/base/widgets.slint +++ b/ui/base/widgets.slint @@ -1,4 +1,4 @@ -import { LoadingStatus, PrioritizationFeeStatus } from "def.slint"; +import { LoadingStatus, PrioritizationFeeStatus, ToastStatus } from "def.slint"; import { Toast, ToastSetting } from "toast.slint"; import { TabBtn } from "tab-btn.slint"; import { IconBtn, RotationType } from "icon-btn.slint"; @@ -52,6 +52,7 @@ import { WaitTransactionConfirmed } from "wait-transaction-confirmed.slint"; export { LoadingStatus, PrioritizationFeeStatus, + ToastStatus, Toast, ToastSetting, TabBtn, diff --git a/ui/logic.slint b/ui/logic.slint index 0abceac..7741e7b 100644 --- a/ui/logic.slint +++ b/ui/logic.slint @@ -1,39 +1,25 @@ -import { Store, SettingUI } from "store.slint"; -import { Icons } from "theme.slint"; -import { TransactionTileEntry, TransactionTileStatus } from "base/transaction-tile.slint"; -import { TokenTileEntry } from "base/token-tile.slint"; -import { PrioritizationFeeStatus } from "base/def.slint"; +import { Store, SettingUI, TabIndex} from "store.slint"; export global Logic { - pure callback new-mnemonics(int) -> [string]; - pure callback paste-mnemonics() -> [string]; - pure callback join-mnemonics([string]) -> string; - pure callback is-valid-mnemonic([string]) -> bool; - pure callback split-mnemonic(string) -> [string]; - - - callback show-toast(string, string); - - pure callback qr-code(string) -> image; - qr-code => { - return Icons.no-data; - } - - // (password) -> void - callback login(string); - callback update-cache-size(); callback remove-all-cache(); callback copy-to-clipboard(string); callback copy-from-clipboard() -> string; - callback handle-confirm-dialog(string, string); callback get-setting-ui() -> SettingUI; callback set-setting-ui(SettingUI); - pure callback tr(bool, string) -> string; - tr(is-cn, text) => { + pure callback inner-tr(bool, string) -> string; + inner-tr(is-cn, text) => { return text; } + + pure public function tr(text: string) -> string { + inner-tr(Store.is-cn, text) + } + + public function switch-tab(tab-index: TabIndex) { + Store.current-tab-index = tab-index; + } } diff --git a/ui/panel/bodyer/home.slint b/ui/panel/bodyer/home.slint index 1f5f4f3..d1ec955 100644 --- a/ui/panel/bodyer/home.slint +++ b/ui/panel/bodyer/home.slint @@ -1,19 +1,25 @@ import { Theme, Icons } from "../../theme.slint"; import { Store } from "../../store.slint"; import { Logic } from "../../logic.slint"; -import { Head } from "../../base/widgets.slint"; +import { Head, Label } from "../../base/widgets.slint"; component TopHead inherits Head { - icon: Icons.home-light; - title: Logic.tr(Store.is-cn, "主页"); + icon: Icons.home-fill; + title: Logic.tr("Home"); hbox-alignment: LayoutAlignment.start; } -component Body inherits Rectangle { } +component Body inherits Rectangle { + Label { + text: "HOME"; + font-size: Theme.title1-font-size; + } +} export component Home inherits Rectangle { VerticalLayout { TopHead { } + Body { } } } diff --git a/ui/panel/bodyer/setting.slint b/ui/panel/bodyer/setting.slint index be32c1d..3411dcd 100644 --- a/ui/panel/bodyer/setting.slint +++ b/ui/panel/bodyer/setting.slint @@ -3,10 +3,10 @@ import { Theme, Icons } from "../../theme.slint"; import { Logic } from "../../logic.slint"; import { Util } from "../../util.slint"; import { Store, SettingUI, SettingDetailIndex } from "../../store.slint"; -import { LineInput, CenterLayout, ConfirmDialogSetting, Divider, Link, Brand, IconBtn, Label, Head, SettingEntry, SettingDetail, SettingDetailInner, TabBtn, SettingDetailInnerVbox, SettingDetailLabel, TxtEdit, CancelBtn, ConfirmBtn, NoDataImg, Tag, RadioBtn, TokenRecipient, SlideCard, ListTile, IconsDialogSetting, ElevatedBtn, Help, SettingDetailSwitch, About } from "../../base/widgets.slint"; +import { LineInput, CenterLayout, ConfirmDialogSetting, Divider, Link, Brand, IconBtn, Label, Head, SettingEntry, SettingDetail, SettingDetailInner, TabBtn, SettingDetailInnerVbox, SettingDetailLabel, TxtEdit, CancelBtn, ConfirmBtn, NoDataImg, Tag, RadioBtn, TokenRecipient, SlideCard, ListTile, IconsDialogSetting, ElevatedBtn, Help, SettingDetailSwitch, About, ToastStatus } from "../../base/widgets.slint"; component UI inherits SettingDetail { - title: Logic.tr(Store.is-cn, "偏好设置"); + title: Logic.tr("Preference"); public function get() -> SettingUI { font-size-lineedit.clear-focus(); @@ -27,20 +27,20 @@ component UI inherits SettingDetail { SettingDetailInner { SettingDetailInnerVbox { font-size-txt := SettingDetailLabel { - text: Logic.tr(Store.is-cn, "字体大小"); + text: Logic.tr("Font size"); } font-size-lineedit := LineEdit { input-type: number; height: font-size-txt.preferred-height * 1.6; - placeholder-text: Logic.tr(Store.is-cn, "10 ~ 50"); + placeholder-text: Logic.tr("10 ~ 50"); text: Store.setting-ui.font-size; } } SettingDetailInnerVbox { fonts-label := SettingDetailLabel { - text: Logic.tr(Store.is-cn, "字体样式"); + text: Logic.tr("Font family"); } fonts-combox := ComboBox { @@ -52,7 +52,7 @@ component UI inherits SettingDetail { SettingDetailInnerVbox { SettingDetailLabel { - text: Logic.tr(Store.is-cn, "选择语言"); + text: Logic.tr("Choose language"); } HorizontalLayout { @@ -79,14 +79,14 @@ component UI inherits SettingDetail { SettingDetailInnerVbox { SettingDetailLabel { - text: Logic.tr(Store.is-cn, "选择主题"); + text: Logic.tr("Choose Theme"); } HorizontalLayout { HorizontalLayout { width: 50%; RadioBtn { - text: Logic.tr(Store.is-cn, "白天"); + text: Logic.tr("Light"); checked: !Theme.is-dark; check => { Theme.toggle(); @@ -95,7 +95,7 @@ component UI inherits SettingDetail { } RadioBtn { - text: Logic.tr(Store.is-cn, "黑暗"); + text: Logic.tr("Dark"); checked: Theme.is-dark; check => { Theme.toggle(); @@ -107,7 +107,7 @@ component UI inherits SettingDetail { } component Donate inherits SettingDetail { - title: Logic.tr(Store.is-cn, "捐 赠"); + title: Logic.tr("Donate"); private property is-wechat: true; @@ -119,7 +119,7 @@ component Donate inherits SettingDetail { width: 50%; height: Theme.footer-height; icon: Icons.wechat-light; - text: Logic.tr(Store.is-cn, "微信支付"); + text: Logic.tr("Wechat pay"); checked: root.is-wechat; clicked => { root.is-wechat = true; @@ -129,7 +129,7 @@ component Donate inherits SettingDetail { TabBtn { height: Theme.footer-height; icon: Icons.metamask-light; - text: Logic.tr(Store.is-cn, "小狐狸(加密)支付"); + text: Logic.tr("MetaMask crypto pay"); checked: !root.is-wechat; clicked => { root.is-wechat = false; @@ -164,7 +164,7 @@ component Body inherits VerticalLayout { head := Head { hbox-alignment: LayoutAlignment.start; icon: Icons.setting-fill; - title: Logic.tr(Store.is-cn, "设置"); + title: Logic.tr("Setting"); } Flickable { @@ -174,7 +174,7 @@ component Body inherits VerticalLayout { spacing: Theme.spacing * 2; SettingEntry { - text: Logic.tr(Store.is-cn, "偏好设置"); + text: Logic.tr("Preference"); icon: Icons.ui; clicked => { @@ -183,7 +183,7 @@ component Body inherits VerticalLayout { } SettingEntry { - text: Logic.tr(Store.is-cn, "关 于"); + text: Logic.tr("About"); icon: Icons.about-light; clicked => { root.current-setting-detail-index = SettingDetailIndex.About; @@ -191,7 +191,7 @@ component Body inherits VerticalLayout { } SettingEntry { - text: Logic.tr(Store.is-cn, "帮 助"); + text: Logic.tr("Help"); icon: Icons.help-light; clicked => { root.current-setting-detail-index = SettingDetailIndex.Help; @@ -199,7 +199,7 @@ component Body inherits VerticalLayout { } SettingEntry { - text: Logic.tr(Store.is-cn, "捐 赠"); + text: Logic.tr("Donate"); icon: Icons.donate; clicked => { root.current-setting-detail-index = SettingDetailIndex.Donate; @@ -207,10 +207,10 @@ component Body inherits VerticalLayout { } SettingEntry { - text: Logic.tr(Store.is-cn, "Github"); + text: Logic.tr("Github"); icon: Icons.github; clicked => { - Util.open-url("Default","https://github.com/Heng30/solana-wallet-sollaw"); + Util.open-url("Default","https://github.com/Heng30/slint-template"); } } } @@ -226,7 +226,7 @@ export component Setting inherits Rectangle { if Store.current-setting-detail-index == SettingDetailIndex.UI: UI { back => { if (self.get().font-size == "") { - Util.show-toast(Logic.tr(Store.is-cn, "非法输入,输入不能为空"), "warning"); + Util.show-toast(Logic.tr("Input cann't be empty"), ToastStatus.Warning); return; } Store.current-setting-detail-index = SettingDetailIndex.Home; diff --git a/ui/panel/footer.slint b/ui/panel/footer.slint index fee204f..cbff463 100644 --- a/ui/panel/footer.slint +++ b/ui/panel/footer.slint @@ -21,11 +21,11 @@ export component Footer inherits Rectangle { width: root.btn-width; height: root.btn-height; icon: Icons.home-light; - text: Logic.tr(Store.is-cn, "主页"); + text: Logic.tr("Home"); checked: Store.current-tab-index == TabIndex.Home; clicked => { - Store.switch-tab(TabIndex.Home); + Logic.switch-tab(TabIndex.Home); } } @@ -33,11 +33,11 @@ export component Footer inherits Rectangle { width: root.btn-width; height: root.btn-height; icon: Icons.setting-light; - text: Logic.tr(Store.is-cn, "设置"); + text: Logic.tr("Setting"); checked: Store.current-tab-index == TabIndex.Setting; clicked => { - Store.switch-tab(TabIndex.Setting); + Logic.switch-tab(TabIndex.Setting); } } } diff --git a/ui/store.slint b/ui/store.slint index e6ed68b..8909af1 100644 --- a/ui/store.slint +++ b/ui/store.slint @@ -12,8 +12,6 @@ export enum SettingDetailIndex { Donate, } - - export struct SettingUI { font-size: string, font-family: string, @@ -21,19 +19,18 @@ export struct SettingUI { is-dark: bool, } - export global Store { in-out property is-first-run; + in-out property is-show-landing-page; + in-out property current-tab-index: TabIndex.Home; in-out property current-setting-detail-index: SettingDetailIndex.Home; - in-out property is-show-landing-page; - in-out property is-cn: setting-ui.language == "cn"; in-out property setting-ui: { font-size: "16", font-family: "Source Han Sans CN", - language: "cn", + language: "en", is-dark: false, }; @@ -45,7 +42,4 @@ export global Store { "Data directory: ~/.local/share/", ]; - public function switch-tab(tab-index: TabIndex) { - current-tab-index = tab-index; - } } diff --git a/ui/util.slint b/ui/util.slint index 37aa971..e132663 100644 --- a/ui/util.slint +++ b/ui/util.slint @@ -1,9 +1,12 @@ import { Theme, Icons } from "theme.slint"; +import { ToastStatus } from "./base/def.slint"; export global Util { - callback show-toast(string, string); + // (message, status) + callback show-toast(string, ToastStatus); - pure callback qr-code(string) -> image; + // (message-type, user-data) + callback handle-confirm-dialog(string, string); callback string-fixed2(string) -> string; callback float-fixed2(float) -> string; @@ -16,6 +19,11 @@ export global Util { // (low-bound, up-bound) => void pure callback rand-int(int, int) -> int; + pure callback qr-code(string) -> image; + qr-code => { + return Icons.no-data; + } + pure callback local-now(string) -> string; local-now => { return "12:34:45"; @@ -31,23 +39,23 @@ export global Util { return input; } - public pure function text-color(type: string) -> color { - if (type == "success") { + public pure function text-color(status: ToastStatus) -> color { + if (status == ToastStatus.Success) { return Theme.success-color; - } else if (type == "warning") { + } else if (status == ToastStatus.Warning) { return Theme.warning-color.darker(10%); - } else if (type == "danger") { + } else if (status == ToastStatus.Danger) { return Theme.danger-color; } return Theme.info-color; } - public pure function icon-source(type: string) -> image { - if (type == "success") { + public pure function icon-source(status: ToastStatus) -> image { + if (status == ToastStatus.Success) { return @image-url("./images/success.svg"); - } else if (type == "warning") { + } else if (status == ToastStatus.Warning) { return @image-url("./images/warning.svg"); - } else if (type == "danger") { + } else if (status == ToastStatus.Danger) { return @image-url("./images/danger.svg"); } return @image-url("./images/info.svg");