diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb index 9d18d78d..76dcd7c8 100644 --- a/lib/l10n/app_de.arb +++ b/lib/l10n/app_de.arb @@ -192,6 +192,7 @@ "pingInputIP": "Bitte gib eine Ziel-IP/Domain ein.", "pingNoServer": "Kein Server zum Anpingen.\nBitte füge einen Server hinzu.", "pkg": "Pkg", + "pkgUpgradeTip": "Bitte sichern Sie Ihr System vor dem Update.", "platformNotSupportUpdate": "Die aktuelle Plattform unterstützt keine In-App-Updates.\nBitte kompiliere vom Quellcode und installiere sie.", "plugInType": "Einfügetyp", "plzEnterHost": "Bitte Host eingeben.", diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 91137733..a02cc559 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -192,6 +192,7 @@ "pingInputIP": "Please input a target IP / domain.", "pingNoServer": "No server to ping.\nPlease add a server in server tab.", "pkg": "Pkg", + "pkgUpgradeTip": "Please backup your system before updating.", "platformNotSupportUpdate": "Current platform does not support in app update.\nPlease build from source and install it.", "plugInType": "Insertion Type", "plzEnterHost": "Please enter host.", diff --git a/lib/l10n/app_es.arb b/lib/l10n/app_es.arb index a07c6e73..1e58fca0 100644 --- a/lib/l10n/app_es.arb +++ b/lib/l10n/app_es.arb @@ -192,6 +192,7 @@ "pingInputIP": "Por favor, introduce la IP de destino o el dominio", "pingNoServer": "No hay servidores disponibles para hacer Ping\nPor favor, añade un servidor en la pestaña de servidores y vuelve a intentarlo", "pkg": "Gestión de paquetes", + "pkgUpgradeTip": "Realice una copia de seguridad de su sistema antes de actualizar.", "platformNotSupportUpdate": "La plataforma actual no soporta actualizaciones, por favor instala manualmente la última versión del código fuente", "plugInType": "Tipo de inserción", "plzEnterHost": "Por favor, introduce el host", diff --git a/lib/l10n/app_fr.arb b/lib/l10n/app_fr.arb index 122c0790..284983a4 100644 --- a/lib/l10n/app_fr.arb +++ b/lib/l10n/app_fr.arb @@ -192,6 +192,7 @@ "pingInputIP": "Veuillez saisir une adresse IP / un domaine cible.", "pingNoServer": "Aucun serveur pour ping.\nVeuillez ajouter un serveur dans l'onglet serveur.", "pkg": "Pkg", + "pkgUpgradeTip": "Veuillez sauvegarder votre système avant de mettre à jour.", "platformNotSupportUpdate": "La plateforme actuelle ne prend pas en charge la mise à jour dans l'application. \nVeuillez le compiler à partir de la source et l'installer.", "plugInType": "Type d'insertion", "plzEnterHost": "Veuillez saisir l'hôte.", diff --git a/lib/l10n/app_id.arb b/lib/l10n/app_id.arb index 9e76c684..02de00ac 100644 --- a/lib/l10n/app_id.arb +++ b/lib/l10n/app_id.arb @@ -192,6 +192,7 @@ "pingInputIP": "Harap masukkan IP / domain target.", "pingNoServer": "Tidak ada server untuk melakukan ping.\nHarap tambahkan server di tab Server.", "pkg": "Pkg", + "pkgUpgradeTip": "Harap cadangkan sistem Anda sebelum memperbarui.", "platformNotSupportUpdate": "Platform saat ini tidak mendukung pembaruan aplikasi.\nSilakan bangun dari sumber dan instal.", "plugInType": "Jenis Penyisipan", "plzEnterHost": "Harap masukkan host.", diff --git a/lib/l10n/app_ja.arb b/lib/l10n/app_ja.arb index ccb6f9f0..cb77278d 100644 --- a/lib/l10n/app_ja.arb +++ b/lib/l10n/app_ja.arb @@ -192,6 +192,7 @@ "pingInputIP": "対象のIPまたはドメインを入力してください", "pingNoServer": "Pingに使用するサーバーがありません\nサーバータブでサーバーを追加してから再試行してください", "pkg": "パッケージ管理", + "pkgUpgradeTip": "アップデートする前にシステムのバックアップを取ってください。", "platformNotSupportUpdate": "現在のプラットフォームは更新をサポートしていません。最新のソースコードをコンパイルして手動でインストールしてください", "plugInType": "挿入タイプ", "plzEnterHost": "ホストを入力してください", diff --git a/lib/l10n/app_pt.arb b/lib/l10n/app_pt.arb index 4953884e..49cd246f 100644 --- a/lib/l10n/app_pt.arb +++ b/lib/l10n/app_pt.arb @@ -192,6 +192,7 @@ "pingInputIP": "Por favor, insira o IP ou domínio alvo", "pingNoServer": "Nenhum servidor disponível para Ping\nPor favor, adicione um servidor na aba de servidores e tente novamente", "pkg": "Gerenciamento de pacotes", + "pkgUpgradeTip": "Por favor, faça backup do seu sistema antes de atualizar.", "platformNotSupportUpdate": "Atualização não suportada na plataforma atual, por favor, instale manualmente a versão mais recente do código-fonte", "plugInType": "Tipo de Inserção", "plzEnterHost": "Por favor, insira o host", diff --git a/lib/l10n/app_ru.arb b/lib/l10n/app_ru.arb index 4be54b17..b66f64c6 100644 --- a/lib/l10n/app_ru.arb +++ b/lib/l10n/app_ru.arb @@ -192,6 +192,7 @@ "pingInputIP": "Пожалуйста, введите целевой IP или доменное имя", "pingNoServer": "Нет доступных серверов для Ping\nПожалуйста, добавьте серверы на вкладке серверов и попробуйте снова", "pkg": "менеджер пакетов", + "pkgUpgradeTip": "Пожалуйста, сделайте резервную копию системы перед обновлением.", "platformNotSupportUpdate": "Текущая платформа не поддерживает обновления, пожалуйста, вручную установите последнюю версию из исходного кода", "plugInType": "Тип вставки", "plzEnterHost": "Пожалуйста, введите хост", diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index 5a7ac70a..f0167d15 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -192,6 +192,7 @@ "pingInputIP": "请输入目标IP或域名", "pingNoServer": "没有服务器可用于Ping\n请在服务器tab添加服务器后再试", "pkg": "包管理", + "pkgUpgradeTip": "请在更新前备份系统。", "platformNotSupportUpdate": "当前平台不支持更新,请编译最新源码后手动安装", "plugInType": "插入类型", "plzEnterHost": "请输入主机", diff --git a/lib/l10n/app_zh_tw.arb b/lib/l10n/app_zh_tw.arb index 5ff002e1..dfcd2262 100644 --- a/lib/l10n/app_zh_tw.arb +++ b/lib/l10n/app_zh_tw.arb @@ -192,6 +192,7 @@ "pingInputIP": "請輸入目標IP或域名", "pingNoServer": "沒有服務器可用於Ping\n請在服務器tab新增服務器後再試", "pkg": "包管理", + "pkgUpgradeTip": "請在更新前備份系統。", "platformNotSupportUpdate": "當前平台不支持更新,請編譯最新源碼後手動安裝", "plugInType": "插入類型", "plzEnterHost": "請輸入主機", diff --git a/lib/view/widget/count_down_btn.dart b/lib/view/widget/count_down_btn.dart new file mode 100644 index 00000000..033190d0 --- /dev/null +++ b/lib/view/widget/count_down_btn.dart @@ -0,0 +1,69 @@ +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:toolbox/core/extension/context/locale.dart'; + +final class CountDownBtn extends StatefulWidget { + final int seconds; + final String text; + final Color? afterColor; + final VoidCallback onTap; + + const CountDownBtn({ + super.key, + required this.onTap, + this.seconds = 3, + this.text = 'Go', + this.afterColor, + }); + + @override + State createState() => _CountDownBtnState(); +} + +final class _CountDownBtnState extends State { + late int _seconds = widget.seconds; + Timer? _timer; + + @override + void initState() { + super.initState(); + _startCountDown(); + } + + @override + void dispose() { + _timer?.cancel(); + super.dispose(); + } + + bool get isCounting => _seconds > 0; + + void _startCountDown() { + if (isCounting) return; + _timer = Timer.periodic(const Duration(seconds: 1), (timer) { + if (!isCounting) { + _timer?.cancel(); + } + setState(() { + _seconds--; + }); + }); + } + + @override + Widget build(BuildContext context) { + return TextButton( + onPressed: () { + if (isCounting) return; + widget.onTap(); + }, + child: Text( + isCounting ? '$_seconds${l10n.second}' : widget.text, + style: TextStyle( + color: _seconds > 0 ? Colors.grey : widget.afterColor, + ), + ), + ); + } +} diff --git a/lib/view/widget/server_func_btns.dart b/lib/view/widget/server_func_btns.dart index 59f8cc43..bab8d298 100644 --- a/lib/view/widget/server_func_btns.dart +++ b/lib/view/widget/server_func_btns.dart @@ -18,6 +18,7 @@ import 'package:toolbox/data/res/path.dart'; import 'package:toolbox/data/res/provider.dart'; import 'package:toolbox/data/res/store.dart'; import 'package:toolbox/data/res/ui.dart'; +import 'package:toolbox/view/widget/count_down_btn.dart'; import '../../core/route.dart'; import '../../core/utils/server.dart'; @@ -279,12 +280,13 @@ Future _onPkg(BuildContext context, ServerPrivateInfo spi) async { final gotoUpgrade = await context.showRoundDialog( title: Text(l10n.attention), child: SingleChildScrollView( - child: Text('${l10n.foundNUpdate(upgradeable.length)}\n\n$upgradeCmd'), + child: Text('${l10n.pkgUpgradeTip}\n${l10n.foundNUpdate(upgradeable.length)}\n\n$upgradeCmd'), ), actions: [ - TextButton( - onPressed: () => context.pop(true), - child: Text(l10n.update), + CountDownBtn( + onTap: () => context.pop(true), + text: l10n.update, + afterColor: Colors.red, ), ], );