From fe506c5ff2277cb6249a0b7893d640a74c88e512 Mon Sep 17 00:00:00 2001 From: csf Date: Thu, 29 Sep 2022 21:53:50 +0800 Subject: [PATCH] mobile cm client info CircleAvatar color --- flutter/lib/desktop/pages/server_page.dart | 79 ---------------------- flutter/lib/mobile/pages/server_page.dart | 67 ++++++++++-------- flutter/lib/models/server_model.dart | 2 +- 3 files changed, 38 insertions(+), 110 deletions(-) diff --git a/flutter/lib/desktop/pages/server_page.dart b/flutter/lib/desktop/pages/server_page.dart index f93591355..5d6805d97 100644 --- a/flutter/lib/desktop/pages/server_page.dart +++ b/flutter/lib/desktop/pages/server_page.dart @@ -529,85 +529,6 @@ class _CmControlPanel extends StatelessWidget { } } -class PaddingCard extends StatelessWidget { - PaddingCard({required this.child, this.title, this.titleIcon}); - - final String? title; - final IconData? titleIcon; - final Widget child; - - @override - Widget build(BuildContext context) { - final children = [child]; - if (title != null) { - children.insert( - 0, - Padding( - padding: EdgeInsets.symmetric(vertical: 5.0), - child: Row( - children: [ - titleIcon != null - ? Padding( - padding: EdgeInsets.only(right: 10), - child: Icon(titleIcon, - color: MyTheme.accent80, size: 30)) - : SizedBox.shrink(), - Text( - title!, - style: TextStyle( - fontFamily: 'WorkSans', - fontWeight: FontWeight.bold, - fontSize: 20, - color: MyTheme.accent80, - ), - ) - ], - ))); - } - return Container( - width: double.maxFinite, - child: Card( - margin: EdgeInsets.fromLTRB(15.0, 15.0, 15.0, 0), - child: Padding( - padding: EdgeInsets.symmetric(vertical: 15.0, horizontal: 30.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: children, - ), - ), - )); - } -} - -Widget clientInfo(Client client) { - return Padding( - padding: EdgeInsets.symmetric(vertical: 8), - child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - children: [ - Expanded( - flex: -1, - child: Padding( - padding: EdgeInsets.only(right: 12), - child: CircleAvatar( - child: Text(client.name[0]), - backgroundColor: MyTheme.border))), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text(client.name, - style: TextStyle(color: MyTheme.idColor, fontSize: 18)), - SizedBox(width: 8), - Text(client.peerId, - style: TextStyle(color: MyTheme.idColor, fontSize: 10)) - ])) - ], - ), - ])); -} - void checkClickTime(int id, Function() callback) async { var clickCallbackTime = DateTime.now().millisecondsSinceEpoch; await bind.cmCheckClickTime(connId: id); diff --git a/flutter/lib/mobile/pages/server_page.dart b/flutter/lib/mobile/pages/server_page.dart index cc80e3e0c..0b2a51d40 100644 --- a/flutter/lib/mobile/pages/server_page.dart +++ b/flutter/lib/mobile/pages/server_page.dart @@ -381,7 +381,7 @@ class ConnectionManager extends StatelessWidget { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Expanded(child: clientInfo(client)), + Expanded(child: ClientInfo(client)), Expanded( flex: -1, child: client.isFileTransfer || !client.authorized @@ -493,35 +493,42 @@ class PaddingCard extends StatelessWidget { } } -Widget clientInfo(Client client) { - return Padding( - padding: const EdgeInsets.symmetric(vertical: 8), - child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - children: [ - Expanded( - flex: -1, - child: Padding( - padding: const EdgeInsets.only(right: 12), - child: CircleAvatar( - backgroundColor: MyTheme.border, - child: Text(client.name[0])))), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text(client.name, - style: const TextStyle( - color: MyTheme.idColor, fontSize: 18)), - const SizedBox(width: 8), - Text(client.peerId, - style: - const TextStyle(color: MyTheme.idColor, fontSize: 10)) - ])) - ], - ), - ])); +class ClientInfo extends StatelessWidget { + final Client client; + ClientInfo(this.client); + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 8), + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Row( + children: [ + Expanded( + flex: -1, + child: Padding( + padding: const EdgeInsets.only(right: 12), + child: CircleAvatar( + backgroundColor: + str2color(client.name).withOpacity(0.7), + child: Text(client.name[0])))), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text(client.name, + style: const TextStyle( + color: MyTheme.idColor, fontSize: 18)), + const SizedBox(width: 8), + Text(client.peerId, + style: const TextStyle( + color: MyTheme.idColor, fontSize: 10)) + ])) + ], + ), + ])); + } } void androidChannelInit() { diff --git a/flutter/lib/models/server_model.dart b/flutter/lib/models/server_model.dart index 625a3e681..7a94da5ad 100644 --- a/flutter/lib/models/server_model.dart +++ b/flutter/lib/models/server_model.dart @@ -433,7 +433,7 @@ class ServerModel with ChangeNotifier { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(translate("Do you accept?")), - clientInfo(client), + ClientInfo(client), Text( translate("android_new_connection_tip"), style: Theme.of(globalKey.currentContext!).textTheme.bodyMedium,