From 37c40a2cb5ecb09727e9e9e0abecc17eab75584b Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Thu, 20 May 2021 13:33:06 +0200 Subject: [PATCH] feat: Cute animation for hiding the + button in inputbar --- lib/views/chat.dart | 5 +- lib/views/ui/chat_ui.dart | 110 +++++++++++++++++++------------------- 2 files changed, 56 insertions(+), 59 deletions(-) diff --git a/lib/views/chat.dart b/lib/views/chat.dart index 758bc1f7..5431d22f 100644 --- a/lib/views/chat.dart +++ b/lib/views/chat.dart @@ -652,10 +652,7 @@ class ChatController extends State { room.sendTypingNotification(true, timeout: Duration(seconds: 30).inMilliseconds); } - // Workaround for a current desktop bug - if (!PlatformInfos.isBetaDesktop) { - setState(() => inputText = text); - } + setState(() => inputText = text); } void cancelReplyEventAction() => setState(() { diff --git a/lib/views/ui/chat_ui.dart b/lib/views/ui/chat_ui.dart index a65cd999..b09a5b7e 100644 --- a/lib/views/ui/chat_ui.dart +++ b/lib/views/ui/chat_ui.dart @@ -571,80 +571,80 @@ class ChatUI extends StatelessWidget { : Container(), ] : [ - if (controller.inputText.isEmpty) - Container( - height: 56, - alignment: Alignment.center, - child: PopupMenuButton( - icon: Icon(Icons.add_outlined), - onSelected: controller - .onAddPopupMenuButtonSelected, - itemBuilder: (BuildContext context) => - >[ + AnimatedContainer( + duration: Duration(milliseconds: 200), + height: 56, + width: + controller.inputText.isEmpty ? 56 : 0, + alignment: Alignment.center, + clipBehavior: Clip.hardEdge, + decoration: BoxDecoration(), + child: PopupMenuButton( + icon: Icon(Icons.add_outlined), + onSelected: controller + .onAddPopupMenuButtonSelected, + itemBuilder: (BuildContext context) => + >[ + PopupMenuItem( + value: 'file', + child: ListTile( + leading: CircleAvatar( + backgroundColor: Colors.green, + foregroundColor: Colors.white, + child: Icon( + Icons.attachment_outlined), + ), + title: + Text(L10n.of(context).sendFile), + contentPadding: EdgeInsets.all(0), + ), + ), + PopupMenuItem( + value: 'image', + child: ListTile( + leading: CircleAvatar( + backgroundColor: Colors.blue, + foregroundColor: Colors.white, + child: Icon(Icons.image_outlined), + ), + title: Text( + L10n.of(context).sendImage), + contentPadding: EdgeInsets.all(0), + ), + ), + if (PlatformInfos.isMobile) PopupMenuItem( - value: 'file', + value: 'camera', child: ListTile( leading: CircleAvatar( - backgroundColor: Colors.green, + backgroundColor: Colors.purple, foregroundColor: Colors.white, child: Icon( - Icons.attachment_outlined), + Icons.camera_alt_outlined), ), title: Text( - L10n.of(context).sendFile), + L10n.of(context).openCamera), contentPadding: EdgeInsets.all(0), ), ), + if (PlatformInfos.isMobile) PopupMenuItem( - value: 'image', + value: 'voice', child: ListTile( leading: CircleAvatar( - backgroundColor: Colors.blue, + backgroundColor: Colors.red, foregroundColor: Colors.white, - child: - Icon(Icons.image_outlined), + child: Icon( + Icons.mic_none_outlined), ), - title: Text( - L10n.of(context).sendImage), + title: Text(L10n.of(context) + .voiceMessage), contentPadding: EdgeInsets.all(0), ), ), - if (PlatformInfos.isMobile) - PopupMenuItem( - value: 'camera', - child: ListTile( - leading: CircleAvatar( - backgroundColor: - Colors.purple, - foregroundColor: Colors.white, - child: Icon(Icons - .camera_alt_outlined), - ), - title: Text(L10n.of(context) - .openCamera), - contentPadding: - EdgeInsets.all(0), - ), - ), - if (PlatformInfos.isMobile) - PopupMenuItem( - value: 'voice', - child: ListTile( - leading: CircleAvatar( - backgroundColor: Colors.red, - foregroundColor: Colors.white, - child: Icon( - Icons.mic_none_outlined), - ), - title: Text(L10n.of(context) - .voiceMessage), - contentPadding: - EdgeInsets.all(0), - ), - ), - ], - ), + ], ), + ), Container( height: 56, alignment: Alignment.center,