unify peer color

This commit is contained in:
rustdesk 2021-08-14 14:14:01 +08:00
parent c17f48c128
commit f226ede64b
3 changed files with 12 additions and 7 deletions

View File

@ -174,5 +174,6 @@ Color str2color(String str, [alpha = 0xFF]) {
for (var i = 0; i < str.length; i += 1) { for (var i = 0; i < str.length; i += 1) {
hash = str.codeUnitAt(i) + ((hash << 5) - hash); hash = str.codeUnitAt(i) + ((hash << 5) - hash);
} }
return Color((hash & 0xFFFFFF) | (alpha << 24)); hash = hash % 16777216;
return Color((hash & 0xFF7FFF) | (alpha << 24));
} }

View File

@ -7,6 +7,7 @@ import 'dart:async';
import 'common.dart'; import 'common.dart';
import 'model.dart'; import 'model.dart';
import 'remote_page.dart'; import 'remote_page.dart';
import 'dart:io';
class HomePage extends StatefulWidget { class HomePage extends StatefulWidget {
HomePage({Key key, this.title}) : super(key: key); HomePage({Key key, this.title}) : super(key: key);
@ -24,10 +25,12 @@ class _HomePageState extends State<HomePage> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
Timer(Duration(seconds: 5), () { if (Platform.isAndroid) {
_updateUrl = FFI.getByName('software_update_url'); Timer(Duration(seconds: 5), () {
if (_updateUrl.isNotEmpty) setState(() {}); _updateUrl = FFI.getByName('software_update_url');
}); if (_updateUrl.isNotEmpty) setState(() {});
});
}
} }
@override @override
@ -87,7 +90,7 @@ class _HomePageState extends State<HomePage> {
width: double.infinity, width: double.infinity,
color: Colors.pinkAccent, color: Colors.pinkAccent,
padding: EdgeInsets.symmetric(vertical: 12), padding: EdgeInsets.symmetric(vertical: 12),
child: Text('Download new version', child: Text(translate('Download new version'),
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.white,
fontWeight: FontWeight.bold)))), fontWeight: FontWeight.bold)))),
@ -248,7 +251,7 @@ class _HomePageState extends State<HomePage> {
leading: Container( leading: Container(
padding: const EdgeInsets.all(6), padding: const EdgeInsets.all(6),
child: getPlatformImage('${p.platform}'), child: getPlatformImage('${p.platform}'),
color: str2color('${p.id}${p.platform}', 0x77)), color: str2color('${p.id}${p.platform}', 0x7f)),
))))); )))));
}); });
return Wrap(children: cards); return Wrap(children: cards);

View File

@ -746,6 +746,7 @@ final langs = <String, Map<String, String>>{
'Remote ID': '远程ID', 'Remote ID': '远程ID',
'Paste': '粘贴', 'Paste': '粘贴',
'Are you sure to close the connection?': '是否确认关闭连接?', 'Are you sure to close the connection?': '是否确认关闭连接?',
'Download new version': '下载新版本',
}, },
'en': <String, String>{} 'en': <String, String>{}
}; };