From 9c3d181deb49d5bb92412293837b2e81372532b2 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 6 Oct 2024 01:25:10 +0800 Subject: [PATCH] :iphone: Optimize the call experience on landscape device --- lib/providers/call.dart | 2 +- lib/screens/channel/channel_chat.dart | 5 +- lib/shells/sidebar_shell.dart | 62 ------------------- lib/theme.dart | 5 +- .../channel/channel_call_indicator.dart | 4 +- lib/widgets/sidebar/empty_placeholder.dart | 5 +- 6 files changed, 14 insertions(+), 69 deletions(-) delete mode 100644 lib/shells/sidebar_shell.dart diff --git a/lib/providers/call.dart b/lib/providers/call.dart index 5f24c13..ff99de9 100644 --- a/lib/providers/call.dart +++ b/lib/providers/call.dart @@ -392,7 +392,7 @@ class ChatCallProvider extends GetxController { } Future gotoScreen(BuildContext context) { - return Navigator.of(context, rootNavigator: true).push( + return Navigator.of(context).push( MaterialPageRoute(builder: (context) => const CallScreen()), ); } diff --git a/lib/screens/channel/channel_chat.dart b/lib/screens/channel/channel_chat.dart index af986ca..def7460 100644 --- a/lib/screens/channel/channel_chat.dart +++ b/lib/screens/channel/channel_chat.dart @@ -275,7 +275,7 @@ class _ChannelChatScreenState extends State channel: _channel!, ongoingCall: _ongoingCall!, onJoin: () { - if (!AppTheme.isLargeScreen(context)) { + if (!AppTheme.isUltraLargeScreen(context)) { final ChatCallProvider call = Get.find(); call.gotoScreen(context); } @@ -329,7 +329,8 @@ class _ChannelChatScreenState extends State ), Obx(() { final ChatCallProvider call = Get.find(); - if (call.isMounted.value && AppTheme.isLargeScreen(context)) { + if (call.isMounted.value && + AppTheme.isUltraLargeScreen(context)) { return const Expanded( child: Row(children: [ VerticalDivider(width: 0.3, thickness: 0.3), diff --git a/lib/shells/sidebar_shell.dart b/lib/shells/sidebar_shell.dart deleted file mode 100644 index af6a7ca..0000000 --- a/lib/shells/sidebar_shell.dart +++ /dev/null @@ -1,62 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; -import 'package:go_router/go_router.dart'; -import 'package:solian/theme.dart'; -import 'package:solian/widgets/app_bar_leading.dart'; -import 'package:solian/widgets/app_bar_title.dart'; -import 'package:solian/widgets/sidebar/sidebar_placeholder.dart'; - -class SidebarShell extends StatelessWidget { - final bool showAppBar; - final GoRouterState state; - final Widget child; - - final bool sidebarFirst; - final Widget? sidebar; - - const SidebarShell({ - super.key, - required this.child, - required this.state, - this.showAppBar = true, - this.sidebarFirst = false, - this.sidebar, - }); - - List buildContent(BuildContext context) { - return [ - Flexible( - flex: 2, - child: child, - ), - if (AppTheme.isExtraLargeScreen(context)) - const VerticalDivider(thickness: 0.3, width: 1), - if (AppTheme.isExtraLargeScreen(context)) - Flexible( - flex: 1, - child: sidebar ?? const SidebarPlaceholder(), - ), - ]; - } - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: showAppBar - ? AppBar( - leading: AppBarLeadingButton.adaptive(context), - title: AppBarTitle(state.topRoute?.name?.tr ?? 'page'.tr), - centerTitle: false, - toolbarHeight: AppTheme.toolbarHeight(context), - ) - : null, - body: AppTheme.isLargeScreen(context) - ? Row( - children: sidebarFirst - ? buildContent(context).reversed.toList() - : buildContent(context), - ) - : child, - ); - } -} diff --git a/lib/theme.dart b/lib/theme.dart index 91c1c14..daa95a4 100644 --- a/lib/theme.dart +++ b/lib/theme.dart @@ -6,7 +6,10 @@ abstract class AppTheme { MediaQuery.of(context).size.width > 640; static bool isExtraLargeScreen(BuildContext context) => - MediaQuery.of(context).size.width > 720; + MediaQuery.of(context).size.width > 920; + + static bool isUltraLargeScreen(BuildContext context) => + MediaQuery.of(context).size.width > 1200; static bool isSpecializedMacOS(BuildContext context) => PlatformInfo.isMacOS && !AppTheme.isLargeScreen(context); diff --git a/lib/widgets/channel/channel_call_indicator.dart b/lib/widgets/channel/channel_call_indicator.dart index 5cca3f6..4eee693 100644 --- a/lib/widgets/channel/channel_call_indicator.dart +++ b/lib/widgets/channel/channel_call_indicator.dart @@ -98,12 +98,12 @@ class ChannelCallIndicator extends StatelessWidget { child: Text('callJoin'.tr), ); } else if (call.channel.value?.id == channel.id && - !AppTheme.isLargeScreen(context)) { + !AppTheme.isUltraLargeScreen(context)) { return TextButton( onPressed: () => onJoin(), child: Text('callResume'.tr), ); - } else if (!AppTheme.isLargeScreen(context)) { + } else if (!AppTheme.isUltraLargeScreen(context)) { return TextButton( onPressed: null, child: Text('callJoin'.tr), diff --git a/lib/widgets/sidebar/empty_placeholder.dart b/lib/widgets/sidebar/empty_placeholder.dart index d012cb9..39fd98b 100644 --- a/lib/widgets/sidebar/empty_placeholder.dart +++ b/lib/widgets/sidebar/empty_placeholder.dart @@ -8,7 +8,10 @@ class EmptyPagePlaceholder extends StatelessWidget { return Material( color: Theme.of(context).colorScheme.surface, child: Center( - child: Image.asset('assets/logo.png', width: 80, height: 80), + child: ClipRRect( + borderRadius: const BorderRadius.all(Radius.circular(12)), + child: Image.asset('assets/logo.png', width: 80, height: 80), + ), ), ); }