diff --git a/lib/chat/views/no_conversation_widget.dart b/lib/chat/views/no_conversation_widget.dart index e05cbf0..ccbc888 100644 --- a/lib/chat/views/no_conversation_widget.dart +++ b/lib/chat/views/no_conversation_widget.dart @@ -20,7 +20,6 @@ class NoConversationWidget extends StatelessWidget { ), child: Column( mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Icon( Icons.diversity_3, diff --git a/lib/layout/home/home_account_ready/home_account_ready_main.dart b/lib/layout/home/home_account_ready/home_account_ready_main.dart index 4b79771..440f4dc 100644 --- a/lib/layout/home/home_account_ready/home_account_ready_main.dart +++ b/lib/layout/home/home_account_ready/home_account_ready_main.dart @@ -76,14 +76,11 @@ class _HomeAccountReadyMainState extends State { ])); }); - Widget buildPhone(BuildContext context) => - Material(color: Colors.transparent, child: buildUserPanel()); - - Widget buildTabletLeftPane(BuildContext context) => Builder( + Widget buildLeftPane(BuildContext context) => Builder( builder: (context) => Material(color: Colors.transparent, child: buildUserPanel())); - Widget buildTabletRightPane(BuildContext context) { + Widget buildRightPane(BuildContext context) { final activeChatLocalConversationKey = context.watch().state; if (activeChatLocalConversationKey == null) { @@ -94,42 +91,73 @@ class _HomeAccountReadyMainState extends State { key: ValueKey(activeChatLocalConversationKey)); } - // ignore: prefer_expression_function_bodies - Widget buildTablet(BuildContext context) { + @override + Widget build(BuildContext context) { + final isLarge = responsiveVisibility( + context: context, + phone: false, + ); + final w = MediaQuery.of(context).size.width; final theme = Theme.of(context); final scale = theme.extension()!; final scaleConfig = theme.extension()!; - final children = [ - ConstrainedBox( - constraints: const BoxConstraints(minWidth: 300, maxWidth: 300), + final activeChat = context.watch().state; + final hasActiveChat = activeChat != null; + // if (hasActiveChat) { + // _chatAnimationController.forward(); + // } else { + // _chatAnimationController.reset(); + // } + + late final bool offstageLeft; + late final bool offstageRight; + late final double leftWidth; + late final double rightWidth; + if (isLarge) { + leftWidth = 300; + rightWidth = w - 300 - 2; + offstageLeft = false; + offstageRight = false; + } else { + leftWidth = w; + rightWidth = w; + if (hasActiveChat) { + offstageLeft = true; + offstageRight = false; + } else { + offstageLeft = false; + offstageRight = true; + } + } + + return Row(crossAxisAlignment: CrossAxisAlignment.stretch, children: [ + Offstage( + offstage: offstageLeft, child: ConstrainedBox( - constraints: BoxConstraints(maxWidth: w / 2), - child: buildTabletLeftPane(context))), - SizedBox( - width: 2, - height: double.infinity, - child: ColoredBox( - color: scaleConfig.preferBorders - ? scale.primaryScale.subtleBorder - : scale.primaryScale.subtleBackground)), - Expanded(child: buildTabletRightPane(context)), - ]; - - return Row( - children: children, - ); + constraints: + BoxConstraints(minWidth: leftWidth, maxWidth: leftWidth), + child: buildLeftPane(context))), + Offstage( + offstage: offstageLeft || offstageRight, + child: SizedBox( + width: 2, + height: double.infinity, + child: ColoredBox( + color: scaleConfig.preferBorders + ? scale.primaryScale.subtleBorder + : scale.primaryScale.subtleBackground))), + Offstage( + offstage: offstageRight, + child: ConstrainedBox( + constraints: + BoxConstraints(minWidth: rightWidth, maxWidth: rightWidth), + child: buildRightPane(context), + )), + ]); } - @override - Widget build(BuildContext context) => responsiveVisibility( - context: context, - phone: false, - ) - ? buildTablet(context) - : buildPhone(context); - //////////////////////////////////////////////////////////////////////////// final _mainPagerKey = GlobalKey(debugLabel: '_mainPagerKey'); } diff --git a/lib/layout/home/home_screen.dart b/lib/layout/home/home_screen.dart index 018c3be..9083790 100644 --- a/lib/layout/home/home_screen.dart +++ b/lib/layout/home/home_screen.dart @@ -1,14 +1,12 @@ import 'dart:math'; import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_zoom_drawer/flutter_zoom_drawer.dart'; import 'package:provider/provider.dart'; import 'package:transitioned_indexed_stack/transitioned_indexed_stack.dart'; import 'package:veilid_support/veilid_support.dart'; import '../../account_manager/account_manager.dart'; -import '../../chat/chat.dart'; import '../../theme/theme.dart'; import '../../tools/tools.dart'; import 'drawer_menu/drawer_menu.dart'; @@ -32,19 +30,6 @@ class HomeScreenState extends State with SingleTickerProviderStateMixin { @override void initState() { - // Chat animation setup (open in phone mode) - _chatAnimationController = AnimationController( - vsync: this, - duration: const Duration(milliseconds: 250), - ); - _chatAnimation = Tween( - begin: const Offset(1, 0), - end: Offset.zero, - ).animate(CurvedAnimation( - parent: _chatAnimationController, - curve: Curves.easeInOut, - )); - WidgetsBinding.instance.addPostFrameCallback((_) async { final localAccounts = context.read().state; final activeLocalAccount = context.read().state; @@ -62,44 +47,6 @@ class HomeScreenState extends State super.initState(); } - @override - void dispose() { - _chatAnimationController.dispose(); - super.dispose(); - } - - Widget _buildAccountReadyDeviceSpecific(BuildContext context) { - if (responsiveVisibility( - context: context, - tablet: false, - tabletLandscape: false, - desktop: false)) { - final activeChatCubit = context.watch(); - - return BlocConsumer( - bloc: activeChatCubit, - listener: (context, activeChat) { - final hasActiveChat = activeChat != null; - if (hasActiveChat) { - _chatAnimationController.forward(); - } else { - _chatAnimationController.reset(); - } - }, - builder: (context, activeChat) => Stack( - children: [ - const HomeAccountReadyMain(), - Offstage( - offstage: activeChat == null, - child: SlideTransition( - position: _chatAnimation, - child: const HomeAccountReadyChat())), - ], - )); - } - return const HomeAccountReadyMain(); - } - Widget _buildAccountPage( BuildContext context, TypedKey superIdentityRecordKey, @@ -117,7 +64,7 @@ class HomeScreenState extends State // Re-export all ready blocs to the account display subtree return perAccountCollectionState.provide( - child: Builder(builder: _buildAccountReadyDeviceSpecific)); + child: const HomeAccountReadyMain()); } } @@ -217,6 +164,4 @@ class HomeScreenState extends State //////////////////////////////////////////////////////////////////////////// final _zoomDrawerController = ZoomDrawerController(); - late final Animation _chatAnimation; - late final AnimationController _chatAnimationController; }