From 71ef402db81f93cebad5fb72300186ec98485ad4 Mon Sep 17 00:00:00 2001 From: sherlock <43041967+sherlockvn@users.noreply.github.com> Date: Thu, 6 Jun 2024 19:17:41 +0700 Subject: [PATCH] TW-1698: Add minWidth for group details (#1809) --- .../chat_adaptive_scaffold_builder.dart | 14 +++++++------- lib/utils/responsive/responsive_utils.dart | 11 ++++++++++- .../adaptive_layout/app_adaptive_scaffold.dart | 5 +++-- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/lib/pages/chat_adaptive_scaffold/chat_adaptive_scaffold_builder.dart b/lib/pages/chat_adaptive_scaffold/chat_adaptive_scaffold_builder.dart index 324db4a8e4..bfc570fc92 100644 --- a/lib/pages/chat_adaptive_scaffold/chat_adaptive_scaffold_builder.dart +++ b/lib/pages/chat_adaptive_scaffold/chat_adaptive_scaffold_builder.dart @@ -1,4 +1,3 @@ -import 'package:fluffychat/pages/chat/events/message/message_style.dart'; import 'package:fluffychat/pages/chat_adaptive_scaffold/chat_adaptive_scaffold_style.dart'; import 'package:fluffychat/presentation/enum/chat/right_column_type_enum.dart'; import 'package:fluffychat/utils/platform_infos.dart'; @@ -38,6 +37,8 @@ class ChatAdaptiveScaffoldBuilderController extends State { final rightColumnTypeNotifier = ValueNotifier(null); + final responsiveUtils = ResponsiveUtils(); + void hideRightColumn() { if (PlatformInfos.isMobile) { Navigator.of(context).pop(); @@ -70,8 +71,7 @@ class ChatAdaptiveScaffoldBuilderController @override Widget build(BuildContext context) { - const breakpoint = ResponsiveUtils.minTabletWidth + - MessageStyle.messageBubbleDesktopMaxWidth; + final breakpoint = responsiveUtils.getMinDesktopWidth(context); return ValueListenableBuilder( valueListenable: rightColumnTypeNotifier, builder: (context, rightColumnType, body) { @@ -80,7 +80,7 @@ class ChatAdaptiveScaffoldBuilderController child: AdaptiveLayout( body: SlotLayout( config: { - const WidthPlatformBreakpoint( + WidthPlatformBreakpoint( end: breakpoint, ): SlotLayout.from( key: AppAdaptiveScaffold.breakpointMobileKey, @@ -96,7 +96,7 @@ class ChatAdaptiveScaffoldBuilderController ], ), ), - const WidthPlatformBreakpoint( + WidthPlatformBreakpoint( begin: breakpoint, ): SlotLayout.from( key: AppAdaptiveScaffold.breakpointWebAndDesktopKey, @@ -117,13 +117,13 @@ class ChatAdaptiveScaffoldBuilderController secondaryBody: rightColumnType != null ? SlotLayout( config: { - const WidthPlatformBreakpoint( + WidthPlatformBreakpoint( end: breakpoint, ): SlotLayout.from( key: AppAdaptiveScaffold.breakpointMobileKey, builder: null, ), - const WidthPlatformBreakpoint( + WidthPlatformBreakpoint( begin: breakpoint, ): SlotLayout.from( key: AppAdaptiveScaffold.breakpointWebAndDesktopKey, diff --git a/lib/utils/responsive/responsive_utils.dart b/lib/utils/responsive/responsive_utils.dart index 136f6a16cb..74f63f2e4b 100644 --- a/lib/utils/responsive/responsive_utils.dart +++ b/lib/utils/responsive/responsive_utils.dart @@ -20,7 +20,16 @@ class ResponsiveUtils { static const double heightBottomNavigation = 72; static const double heightBottomNavigationBar = 56; - static const double bodyWithRightColumnRatio = 0.7; + static const double bodyWithRightColumnRatio = 0.64; + static const double groupDetailsMinWidth = 370; + + double getChatBodyRatio(BuildContext context) => + bodyRadioWidth / context.width; + + double getMinDesktopWidth(BuildContext context) => + ResponsiveUtils.groupDetailsMinWidth / + (1 - ResponsiveUtils.bodyWithRightColumnRatio) / + (1 - ResponsiveUtils().getChatBodyRatio(context)); bool isScreenWithShortestSide(BuildContext context) => context.mediaQueryShortestSide < minTabletWidth; diff --git a/lib/widgets/layouts/adaptive_layout/app_adaptive_scaffold.dart b/lib/widgets/layouts/adaptive_layout/app_adaptive_scaffold.dart index b165dbb9d3..b3de7e43aa 100644 --- a/lib/widgets/layouts/adaptive_layout/app_adaptive_scaffold.dart +++ b/lib/widgets/layouts/adaptive_layout/app_adaptive_scaffold.dart @@ -1,4 +1,3 @@ -import 'package:fluffychat/utils/extension/build_context_extension.dart'; import 'package:fluffychat/utils/responsive/responsive_utils.dart'; import 'package:fluffychat/widgets/layouts/adaptive_layout/adaptive_scaffold_appbar.dart'; import 'package:fluffychat/widgets/layouts/adaptive_layout/adaptive_scaffold_route_style.dart'; @@ -26,6 +25,8 @@ class AppAdaptiveScaffold extends StatelessWidget { this.displayAppBar = true, }) : super(key: key ?? scaffoldWithNestedNavigationKey); + static final _responsiveUtils = ResponsiveUtils(); + @override Widget build(BuildContext context) { return Portal( @@ -60,7 +61,7 @@ class AppAdaptiveScaffold extends StatelessWidget { ), }, ), - bodyRatio: ResponsiveUtils.bodyRadioWidth / context.width, + bodyRatio: _responsiveUtils.getChatBodyRatio(context), secondaryBody: SlotLayout( config: { const WidthPlatformBreakpoint(