diff --git a/lib/main.dart b/lib/main.dart index 7beac74..b8ed3d4 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,3 @@ -import 'dart:developer'; - import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; import 'package:flutter_acrylic/flutter_acrylic.dart'; @@ -21,8 +19,6 @@ import 'package:solian/router.dart'; import 'package:solian/theme.dart'; import 'package:solian/translations.dart'; -late final double titlebarHeight; - void main() async { await SentryFlutter.init( (options) { @@ -45,10 +41,12 @@ void main() async { ); if (PlatformInfo.isMacOS) { + await Window.hideTitle(); + await Window.hideCloseButton(); + await Window.hideMiniaturizeButton(); + await Window.hideZoomButton(); await Window.makeTitlebarTransparent(); await Window.enableFullSizeContentView(); - - titlebarHeight = await Window.getTitlebarHeight(); } } @@ -100,22 +98,10 @@ class SolianApp extends StatelessWidget { }); }, builder: (context, child) { - final content = ScaffoldMessenger( + return ScaffoldMessenger( child: child ?? Container(), ); - - if (PlatformInfo.isMacOS) { - return Material( - color: Theme.of(context).colorScheme.surface, - child: Padding( - padding: EdgeInsets.only(top: titlebarHeight), - child: content, - ), - ); - } else { - return content; - } - } + }, ); } } diff --git a/lib/screens/channel/call/call.dart b/lib/screens/channel/call/call.dart index 50432a8..4aed7be 100644 --- a/lib/screens/channel/call/call.dart +++ b/lib/screens/channel/call/call.dart @@ -4,6 +4,7 @@ import 'dart:math' as math; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:solian/providers/content/call.dart'; +import 'package:solian/theme.dart'; import 'package:solian/widgets/chat/call/call_controls.dart'; import 'package:solian/widgets/chat/call/call_participant.dart'; import 'package:solian/widgets/prev_page.dart'; @@ -55,7 +56,9 @@ class _CallScreenState extends State { color: Theme.of(context).colorScheme.surface, child: Scaffold( appBar: AppBar( - centerTitle: true, + centerTitle: false, + titleSpacing: SolianTheme.titleSpacing(context), + toolbarHeight: SolianTheme.toolbarHeight(context), title: RichText( textAlign: TextAlign.center, text: TextSpan(children: [ diff --git a/lib/screens/channel/channel_chat.dart b/lib/screens/channel/channel_chat.dart index b092f81..b40c26f 100644 --- a/lib/screens/channel/channel_chat.dart +++ b/lib/screens/channel/channel_chat.dart @@ -17,6 +17,7 @@ import 'package:solian/providers/content/channel.dart'; import 'package:solian/router.dart'; import 'package:solian/screens/channel/channel_detail.dart'; import 'package:solian/theme.dart'; +import 'package:solian/widgets/app_bar_title.dart'; import 'package:solian/widgets/chat/call/call_prejoin.dart'; import 'package:solian/widgets/chat/call/chat_call_action.dart'; import 'package:solian/widgets/chat/chat_message.dart'; @@ -305,8 +306,10 @@ class _ChannelChatScreenState extends State { return Scaffold( appBar: AppBar( - title: Text(title), + title: AppBarTitle(title), centerTitle: false, + titleSpacing: SolianTheme.titleSpacing(context), + toolbarHeight: SolianTheme.toolbarHeight(context), actions: [ const BackgroundStateWidget(), Builder(builder: (context) { diff --git a/lib/screens/channel/channel_organize.dart b/lib/screens/channel/channel_organize.dart index 5c7a4a7..ad2892c 100644 --- a/lib/screens/channel/channel_organize.dart +++ b/lib/screens/channel/channel_organize.dart @@ -7,6 +7,8 @@ import 'package:solian/models/realm.dart'; import 'package:solian/providers/auth.dart'; import 'package:solian/providers/content/channel.dart'; import 'package:solian/router.dart'; +import 'package:solian/theme.dart'; +import 'package:solian/widgets/app_bar_title.dart'; import 'package:solian/widgets/prev_page.dart'; import 'package:uuid/uuid.dart'; @@ -107,7 +109,9 @@ class _ChannelOrganizeScreenState extends State { color: Theme.of(context).colorScheme.surface, child: Scaffold( appBar: AppBar( - title: Text('channelOrganizing'.tr), + title: AppBarTitle('channelOrganizing'.tr), + centerTitle: false, + toolbarHeight: SolianTheme.toolbarHeight(context), leading: const PrevPageButton(), actions: [ TextButton( diff --git a/lib/screens/contact.dart b/lib/screens/contact.dart index a480926..8bb913e 100644 --- a/lib/screens/contact.dart +++ b/lib/screens/contact.dart @@ -10,6 +10,7 @@ import 'package:solian/router.dart'; import 'package:solian/screens/account/notification.dart'; import 'package:solian/theme.dart'; import 'package:solian/widgets/account/signin_required_overlay.dart'; +import 'package:solian/widgets/app_bar_title.dart'; import 'package:solian/widgets/channel/channel_list.dart'; import 'package:solian/widgets/chat/call/chat_call_indicator.dart'; import 'package:solian/widgets/current_state_action.dart'; @@ -84,9 +85,11 @@ class _ContactScreenState extends State { child: CustomScrollView( slivers: [ SliverAppBar( - title: Text('contact'.tr), + title: AppBarTitle('contact'.tr), centerTitle: false, - titleSpacing: SolianTheme.isLargeScreen(context) ? null : 24, + floating: true, + titleSpacing: SolianTheme.titleSpacing(context), + toolbarHeight: SolianTheme.toolbarHeight(context), actions: [ const BackgroundStateWidget(), const NotificationButton(), diff --git a/lib/screens/posts/post_publish.dart b/lib/screens/posts/post_publish.dart index b04d183..040a468 100644 --- a/lib/screens/posts/post_publish.dart +++ b/lib/screens/posts/post_publish.dart @@ -7,7 +7,9 @@ import 'package:solian/models/post.dart'; import 'package:solian/models/realm.dart'; import 'package:solian/providers/auth.dart'; import 'package:solian/router.dart'; +import 'package:solian/theme.dart'; import 'package:solian/widgets/account/account_avatar.dart'; +import 'package:solian/widgets/app_bar_title.dart'; import 'package:solian/widgets/attachments/attachment_publish.dart'; import 'package:solian/widgets/posts/post_item.dart'; import 'package:solian/widgets/prev_page.dart'; @@ -122,7 +124,9 @@ class _PostPublishingScreenState extends State { color: Theme.of(context).colorScheme.surface, child: Scaffold( appBar: AppBar( - title: Text('postPublishing'.tr), + title: AppBarTitle('postPublishing'.tr), + centerTitle: false, + toolbarHeight: SolianTheme.toolbarHeight(context), leading: const PrevPageButton(), actions: [ TextButton( diff --git a/lib/screens/realms.dart b/lib/screens/realms.dart index 176cecd..e0aa475 100644 --- a/lib/screens/realms.dart +++ b/lib/screens/realms.dart @@ -9,6 +9,7 @@ import 'package:solian/router.dart'; import 'package:solian/screens/account/notification.dart'; import 'package:solian/theme.dart'; import 'package:solian/widgets/account/signin_required_overlay.dart'; +import 'package:solian/widgets/app_bar_title.dart'; import 'package:solian/widgets/current_state_action.dart'; class RealmListScreen extends StatefulWidget { @@ -72,9 +73,11 @@ class _RealmListScreenState extends State { child: CustomScrollView( slivers: [ SliverAppBar( - title: Text('realm'.tr), + title: AppBarTitle('realm'.tr), centerTitle: false, - titleSpacing: SolianTheme.isLargeScreen(context) ? null : 24, + floating: true, + titleSpacing: SolianTheme.titleSpacing(context), + toolbarHeight: SolianTheme.toolbarHeight(context), actions: [ const BackgroundStateWidget(), const NotificationButton(), diff --git a/lib/screens/realms/realm_organize.dart b/lib/screens/realms/realm_organize.dart index 1bc3002..68aa8da 100644 --- a/lib/screens/realms/realm_organize.dart +++ b/lib/screens/realms/realm_organize.dart @@ -5,6 +5,8 @@ import 'package:solian/exts.dart'; import 'package:solian/models/realm.dart'; import 'package:solian/providers/auth.dart'; import 'package:solian/router.dart'; +import 'package:solian/theme.dart'; +import 'package:solian/widgets/app_bar_title.dart'; import 'package:solian/widgets/prev_page.dart'; import 'package:uuid/uuid.dart'; @@ -97,7 +99,9 @@ class _RealmOrganizeScreenState extends State { color: Theme.of(context).colorScheme.surface, child: Scaffold( appBar: AppBar( - title: Text('realmOrganizing'.tr), + title: AppBarTitle('realmOrganizing'.tr), + centerTitle: false, + toolbarHeight: SolianTheme.toolbarHeight(context), leading: const PrevPageButton(), actions: [ TextButton( diff --git a/lib/screens/social.dart b/lib/screens/social.dart index 560a701..0aeae36 100644 --- a/lib/screens/social.dart +++ b/lib/screens/social.dart @@ -3,11 +3,13 @@ import 'package:get/get.dart'; import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; import 'package:solian/models/pagination.dart'; import 'package:solian/models/post.dart'; +import 'package:solian/platform.dart'; import 'package:solian/providers/auth.dart'; import 'package:solian/providers/content/post.dart'; import 'package:solian/router.dart'; import 'package:solian/screens/account/notification.dart'; import 'package:solian/theme.dart'; +import 'package:solian/widgets/app_bar_title.dart'; import 'package:solian/widgets/current_state_action.dart'; import 'package:solian/widgets/posts/post_list.dart'; @@ -78,10 +80,11 @@ class _SocialScreenState extends State { child: CustomScrollView( slivers: [ SliverAppBar( - title: Text('social'.tr), + title: AppBarTitle('social'.tr), centerTitle: false, floating: true, - titleSpacing: SolianTheme.isLargeScreen(context) ? null : 24, + titleSpacing: SolianTheme.titleSpacing(context), + toolbarHeight: SolianTheme.toolbarHeight(context), actions: [ const BackgroundStateWidget(), const NotificationButton(), diff --git a/lib/shells/basic_shell.dart b/lib/shells/basic_shell.dart index dba9a4c..054ea0a 100644 --- a/lib/shells/basic_shell.dart +++ b/lib/shells/basic_shell.dart @@ -3,6 +3,7 @@ import 'package:get/get.dart'; import 'package:go_router/go_router.dart'; import 'package:solian/router.dart'; import 'package:solian/theme.dart'; +import 'package:solian/widgets/app_bar_title.dart'; import 'package:solian/widgets/prev_page.dart'; class BasicShell extends StatelessWidget { @@ -17,10 +18,9 @@ class BasicShell extends StatelessWidget { return Scaffold( appBar: AppBar( - title: Text(state.topRoute?.name?.tr ?? 'page'.tr), + title: AppBarTitle(state.topRoute?.name?.tr ?? 'page'.tr), centerTitle: false, - titleSpacing: canPop ? null : 24, - elevation: SolianTheme.isLargeScreen(context) ? 1 : 0, + toolbarHeight: SolianTheme.toolbarHeight(context), leading: canPop ? const PrevPageButton() : null, automaticallyImplyLeading: false, ), diff --git a/lib/theme.dart b/lib/theme.dart index a4bb55a..ee22260 100644 --- a/lib/theme.dart +++ b/lib/theme.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:solian/platform.dart'; abstract class SolianTheme { static bool isLargeScreen(BuildContext context) => @@ -7,6 +8,25 @@ abstract class SolianTheme { static bool isExtraLargeScreen(BuildContext context) => MediaQuery.of(context).size.width > 720; + static bool isSpecializedMacOS(BuildContext context) => + PlatformInfo.isMacOS && !SolianTheme.isLargeScreen(context); + + static double? titleSpacing(BuildContext context) { + if (SolianTheme.isSpecializedMacOS(context)) { + return 24; + } else { + return SolianTheme.isLargeScreen(context) ? null : 24; + } + } + + static double toolbarHeight(BuildContext context) { + if (isLargeScreen(context)) { + return kToolbarHeight; + } else { + return PlatformInfo.isMacOS ? 50 : kToolbarHeight; + } + } + static ThemeData build(Brightness brightness) { return ThemeData( brightness: brightness, diff --git a/lib/widgets/app_bar_title.dart b/lib/widgets/app_bar_title.dart new file mode 100644 index 0000000..95bcb53 --- /dev/null +++ b/lib/widgets/app_bar_title.dart @@ -0,0 +1,17 @@ +import 'package:flutter/material.dart'; +import 'package:solian/theme.dart'; + +class AppBarTitle extends StatelessWidget { + final String title; + + const AppBarTitle(this.title, {super.key}); + + @override + Widget build(BuildContext context) { + if (SolianTheme.isSpecializedMacOS(context)) { + return Text(title); + } else { + return Text(title); + } + } +}