From f226ede64be1af028b6145dec6ac8e77107e30a5 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Sat, 14 Aug 2021 14:14:01 +0800 Subject: [PATCH] unify peer color --- flutter_hbb/lib/common.dart | 3 ++- flutter_hbb/lib/home_page.dart | 15 +++++++++------ flutter_hbb/lib/model.dart | 1 + 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/flutter_hbb/lib/common.dart b/flutter_hbb/lib/common.dart index 26d9826d6..15588f13c 100644 --- a/flutter_hbb/lib/common.dart +++ b/flutter_hbb/lib/common.dart @@ -174,5 +174,6 @@ Color str2color(String str, [alpha = 0xFF]) { for (var i = 0; i < str.length; i += 1) { hash = str.codeUnitAt(i) + ((hash << 5) - hash); } - return Color((hash & 0xFFFFFF) | (alpha << 24)); + hash = hash % 16777216; + return Color((hash & 0xFF7FFF) | (alpha << 24)); } diff --git a/flutter_hbb/lib/home_page.dart b/flutter_hbb/lib/home_page.dart index dd9c1f24d..fb38dd5bd 100644 --- a/flutter_hbb/lib/home_page.dart +++ b/flutter_hbb/lib/home_page.dart @@ -7,6 +7,7 @@ import 'dart:async'; import 'common.dart'; import 'model.dart'; import 'remote_page.dart'; +import 'dart:io'; class HomePage extends StatefulWidget { HomePage({Key key, this.title}) : super(key: key); @@ -24,10 +25,12 @@ class _HomePageState extends State { @override void initState() { super.initState(); - Timer(Duration(seconds: 5), () { - _updateUrl = FFI.getByName('software_update_url'); - if (_updateUrl.isNotEmpty) setState(() {}); - }); + if (Platform.isAndroid) { + Timer(Duration(seconds: 5), () { + _updateUrl = FFI.getByName('software_update_url'); + if (_updateUrl.isNotEmpty) setState(() {}); + }); + } } @override @@ -87,7 +90,7 @@ class _HomePageState extends State { width: double.infinity, color: Colors.pinkAccent, padding: EdgeInsets.symmetric(vertical: 12), - child: Text('Download new version', + child: Text(translate('Download new version'), style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold)))), @@ -248,7 +251,7 @@ class _HomePageState extends State { leading: Container( padding: const EdgeInsets.all(6), child: getPlatformImage('${p.platform}'), - color: str2color('${p.id}${p.platform}', 0x77)), + color: str2color('${p.id}${p.platform}', 0x7f)), ))))); }); return Wrap(children: cards); diff --git a/flutter_hbb/lib/model.dart b/flutter_hbb/lib/model.dart index 13caa06c1..78772ee35 100644 --- a/flutter_hbb/lib/model.dart +++ b/flutter_hbb/lib/model.dart @@ -746,6 +746,7 @@ final langs = >{ 'Remote ID': '远程ID', 'Paste': '粘贴', 'Are you sure to close the connection?': '是否确认关闭连接?', + 'Download new version': '下载新版本', }, 'en': {} };