From 079efb02b93f548c88ed9f4105ffbd11888865ba Mon Sep 17 00:00:00 2001 From: Christien Rioux Date: Thu, 1 Aug 2024 16:03:50 -0500 Subject: [PATCH] minor ui cleanups --- lib/chat_list/views/chat_list_widget.dart | 12 ++-- .../chat_single_contact_item_widget.dart | 2 +- lib/contacts/views/contacts_browser.dart | 4 +- .../home/drawer_menu/menu_item_widget.dart | 56 +++++++++---------- lib/layout/home/home_screen.dart | 2 +- lib/theme/views/responsive.dart | 4 ++ lib/theme/views/styled_scaffold.dart | 2 +- 7 files changed, 43 insertions(+), 39 deletions(-) diff --git a/lib/chat_list/views/chat_list_widget.dart b/lib/chat_list/views/chat_list_widget.dart index 67bcc5d..8fc57cf 100644 --- a/lib/chat_list/views/chat_list_widget.dart +++ b/lib/chat_list/views/chat_list_widget.dart @@ -15,13 +15,13 @@ import '../chat_list.dart'; class ChatListWidget extends StatelessWidget { const ChatListWidget({super.key}); - Widget _itemBuilderDirect(proto.DirectChat direct, - IMap contactMap, bool busy) { + Widget _itemBuilderDirect( + proto.DirectChat direct, IMap contactMap) { final contact = contactMap[direct.localConversationRecordKey]; if (contact == null) { return const Text('...'); } - return ChatSingleContactItemWidget(contact: contact, disabled: busy) + return ChatSingleContactItemWidget(contact: contact) .paddingLTRB(0, 4, 0, 0); } @@ -70,8 +70,10 @@ class ChatListWidget extends StatelessWidget { itemBuilder: (c) { switch (c.whichKind()) { case proto.Chat_Kind.direct: - return _itemBuilderDirect(c.direct, contactMap, - contactListV.busy || chatListV.busy); + return _itemBuilderDirect( + c.direct, + contactMap, + ); case proto.Chat_Kind.group: return const Text( 'group chats not yet supported!'); diff --git a/lib/chat_list/views/chat_single_contact_item_widget.dart b/lib/chat_list/views/chat_single_contact_item_widget.dart index b186290..1bd5f64 100644 --- a/lib/chat_list/views/chat_single_contact_item_widget.dart +++ b/lib/chat_list/views/chat_single_contact_item_widget.dart @@ -11,7 +11,7 @@ import '../chat_list.dart'; class ChatSingleContactItemWidget extends StatelessWidget { const ChatSingleContactItemWidget({ required proto.Contact contact, - required bool disabled, + bool disabled = false, super.key, }) : _contact = contact, _disabled = disabled; diff --git a/lib/contacts/views/contacts_browser.dart b/lib/contacts/views/contacts_browser.dart index db2a602..2eea880 100644 --- a/lib/contacts/views/contacts_browser.dart +++ b/lib/contacts/views/contacts_browser.dart @@ -242,7 +242,7 @@ class _ContactsBrowserState extends State contact: contact, selected: widget.selectedContactRecordKey == contact.localConversationRecordKey.toVeilid(), - disabled: ciBusy, + disabled: false, onTap: _onTapContact, onDoubleTap: _onStartChat, onDelete: _onDeleteContact) @@ -250,7 +250,7 @@ class _ContactsBrowserState extends State case ContactsBrowserElementKind.invitation: final invitation = element.invitation!; return ContactInvitationItemWidget( - contactInvitationRecord: invitation, disabled: cilBusy) + contactInvitationRecord: invitation, disabled: false) .paddingLTRB(0, 4, 0, 0); } }, diff --git a/lib/layout/home/drawer_menu/menu_item_widget.dart b/lib/layout/home/drawer_menu/menu_item_widget.dart index 12c5008..e538b15 100644 --- a/lib/layout/home/drawer_menu/menu_item_widget.dart +++ b/lib/layout/home/drawer_menu/menu_item_widget.dart @@ -27,36 +27,34 @@ class MenuItemWidget extends StatelessWidget { @override Widget build(BuildContext context) => TextButton( - onPressed: callback, - style: TextButton.styleFrom(foregroundColor: foregroundColor).copyWith( - backgroundColor: WidgetStateProperty.resolveWith((states) { - if (states.contains(WidgetState.hovered)) { - return backgroundHoverColor; - } - if (states.contains(WidgetState.focused)) { - return backgroundFocusColor; - } - return backgroundColor; - }), - side: WidgetStateBorderSide.resolveWith((states) { - if (states.contains(WidgetState.hovered)) { + onPressed: callback, + style: TextButton.styleFrom(foregroundColor: foregroundColor).copyWith( + backgroundColor: WidgetStateProperty.resolveWith((states) { + if (states.contains(WidgetState.hovered)) { + return backgroundHoverColor; + } + if (states.contains(WidgetState.focused)) { + return backgroundFocusColor; + } + return backgroundColor; + }), + side: WidgetStateBorderSide.resolveWith((states) { + if (states.contains(WidgetState.hovered)) { + return borderColor != null + ? BorderSide(width: 2, color: borderHoverColor!) + : null; + } + if (states.contains(WidgetState.focused)) { + return borderColor != null + ? BorderSide(width: 2, color: borderFocusColor!) + : null; + } return borderColor != null - ? BorderSide(width: 2, color: borderHoverColor!) + ? BorderSide(width: 2, color: borderColor!) : null; - } - if (states.contains(WidgetState.focused)) { - return borderColor != null - ? BorderSide(width: 2, color: borderFocusColor!) - : null; - } - return borderColor != null - ? BorderSide(width: 2, color: borderColor!) - : null; - }), - shape: WidgetStateProperty.all(RoundedRectangleBorder( - borderRadius: BorderRadius.circular(borderRadius ?? 0)))), - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 8), + }), + shape: WidgetStateProperty.all(RoundedRectangleBorder( + borderRadius: BorderRadius.circular(borderRadius ?? 0)))), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -83,7 +81,7 @@ class MenuItemWidget extends StatelessWidget { onPressed: footerCallback), ], ), - )); + ); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { diff --git a/lib/layout/home/home_screen.dart b/lib/layout/home/home_screen.dart index 5fd463a..893ca97 100644 --- a/lib/layout/home/home_screen.dart +++ b/lib/layout/home/home_screen.dart @@ -230,7 +230,7 @@ class HomeScreenState extends State menuScreenTapClose: canClose, mainScreenTapClose: canClose, disableDragGesture: !canClose, - mainScreenScale: .15, + mainScreenScale: .25, slideWidth: min(360, MediaQuery.of(context).size.width * 0.9), ))); } diff --git a/lib/theme/views/responsive.dart b/lib/theme/views/responsive.dart index a80faf6..91af81d 100644 --- a/lib/theme/views/responsive.dart +++ b/lib/theme/views/responsive.dart @@ -14,6 +14,10 @@ const kMobileWidthCutoff = 500.0; bool isMobileWidth(BuildContext context) => MediaQuery.of(context).size.width < kMobileWidthCutoff; +bool isMobileSize(BuildContext context) => + MediaQuery.of(context).size.width < kMobileWidthCutoff || + MediaQuery.of(context).size.height < kMobileWidthCutoff; + bool responsiveVisibility({ required BuildContext context, bool phone = true, diff --git a/lib/theme/views/styled_scaffold.dart b/lib/theme/views/styled_scaffold.dart index 61e32aa..9560ecc 100644 --- a/lib/theme/views/styled_scaffold.dart +++ b/lib/theme/views/styled_scaffold.dart @@ -12,7 +12,7 @@ class StyledScaffold extends StatelessWidget { final scale = theme.extension()!; final scaleConfig = theme.extension()!; - final enableBorder = !isMobileWidth(context); + final enableBorder = !isMobileSize(context); final scaffold = clipBorder( clipEnabled: enableBorder,