From 5df90d4fa17880388c071fbf350d559b4e641a55 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Mon, 2 Aug 2021 22:21:23 +0800 Subject: [PATCH] fix on help tools and tranlating 'Failed' --- flutter_hbb/lib/common.dart | 1 - flutter_hbb/lib/model.dart | 5 ++++- flutter_hbb/lib/remote_page.dart | 38 +++++++++++++++----------------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/flutter_hbb/lib/common.dart b/flutter_hbb/lib/common.dart index a40356de2..26d9826d6 100644 --- a/flutter_hbb/lib/common.dart +++ b/flutter_hbb/lib/common.dart @@ -21,7 +21,6 @@ class MyTheme { } final ButtonStyle flatButtonStyle = TextButton.styleFrom( - primary: MyTheme.accent, minimumSize: Size(88, 36), padding: EdgeInsets.symmetric(horizontal: 16.0), shape: const RoundedRectangleBorder( diff --git a/flutter_hbb/lib/model.dart b/flutter_hbb/lib/model.dart index d22e110e8..0dbd3182c 100644 --- a/flutter_hbb/lib/model.dart +++ b/flutter_hbb/lib/model.dart @@ -741,7 +741,10 @@ final langs = >{ 'en': {} }; -String translate(name) { +String translate(String name) { + if (name.startsWith('Failed') && name.contains(':')) { + return name.split(': ').map((x) => translate(x)).join(': '); + } final tmp = isCn ? langs['cn'] : langs['en']; final v = tmp[name]; if (v == null) { diff --git a/flutter_hbb/lib/remote_page.dart b/flutter_hbb/lib/remote_page.dart index d5299d71c..66613ad76 100644 --- a/flutter_hbb/lib/remote_page.dart +++ b/flutter_hbb/lib/remote_page.dart @@ -352,26 +352,24 @@ class _RemotePageState extends State { } var wrap = (String text, void Function() onPressed, [bool active, IconData icon]) { - return ButtonTheme( - padding: EdgeInsets.symmetric( - vertical: icon != null ? 3 : 6, - horizontal: 6), //adds padding inside the button - materialTapTargetSize: MaterialTapTargetSize - .shrinkWrap, //limits the touch area to the button area - minWidth: 0, //wraps child's width - height: 0, - child: TextButton( - style: TextButton.styleFrom( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(5.0), - ), - primary: active == true ? MyTheme.accent80 : null, - ), - child: icon != null - ? Icon(icon, size: 17, color: Colors.white) - : Text(translate(text), - style: TextStyle(color: Colors.white, fontSize: 11)), - onPressed: onPressed)); + return TextButton( + style: TextButton.styleFrom( + minimumSize: Size(0, 0), + padding: EdgeInsets.symmetric( + vertical: icon != null ? 3 : 6, + horizontal: 6), //adds padding inside the button + tapTargetSize: MaterialTapTargetSize + .shrinkWrap, //limits the touch area to the button area + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5.0), + ), + backgroundColor: active == true ? MyTheme.accent80 : null, + ), + child: icon != null + ? Icon(icon, size: 17, color: Colors.white) + : Text(translate(text), + style: TextStyle(color: Colors.white, fontSize: 11)), + onPressed: onPressed); }; final mouse = [ wrap('Drag', () {