Skip to content

Commit

Permalink
TW-1698: Add minWidth for group details (#1809)
Browse files Browse the repository at this point in the history
  • Loading branch information
sherlockvn authored Jun 6, 2024
1 parent 32901cc commit 71ef402
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -38,6 +37,8 @@ class ChatAdaptiveScaffoldBuilderController
extends State<ChatAdaptiveScaffoldBuilder> {
final rightColumnTypeNotifier = ValueNotifier<RightColumnType?>(null);

final responsiveUtils = ResponsiveUtils();

void hideRightColumn() {
if (PlatformInfos.isMobile) {
Navigator.of(context).pop();
Expand Down Expand Up @@ -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) {
Expand All @@ -80,7 +80,7 @@ class ChatAdaptiveScaffoldBuilderController
child: AdaptiveLayout(
body: SlotLayout(
config: {
const WidthPlatformBreakpoint(
WidthPlatformBreakpoint(
end: breakpoint,
): SlotLayout.from(
key: AppAdaptiveScaffold.breakpointMobileKey,
Expand All @@ -96,7 +96,7 @@ class ChatAdaptiveScaffoldBuilderController
],
),
),
const WidthPlatformBreakpoint(
WidthPlatformBreakpoint(
begin: breakpoint,
): SlotLayout.from(
key: AppAdaptiveScaffold.breakpointWebAndDesktopKey,
Expand All @@ -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,
Expand Down
11 changes: 10 additions & 1 deletion lib/utils/responsive/responsive_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -60,7 +61,7 @@ class AppAdaptiveScaffold extends StatelessWidget {
),
},
),
bodyRatio: ResponsiveUtils.bodyRadioWidth / context.width,
bodyRatio: _responsiveUtils.getChatBodyRatio(context),
secondaryBody: SlotLayout(
config: <Breakpoint, SlotLayoutConfig>{
const WidthPlatformBreakpoint(
Expand Down

0 comments on commit 71ef402

Please sign in to comment.