💄 MacOS specialized window
This commit is contained in:
parent
ee1922b1b5
commit
4144bb307e
@ -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;
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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<CallScreen> {
|
||||
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: [
|
||||
|
@ -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<ChannelChatScreen> {
|
||||
|
||||
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) {
|
||||
|
@ -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<ChannelOrganizeScreen> {
|
||||
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(
|
||||
|
@ -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<ContactScreen> {
|
||||
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(),
|
||||
|
@ -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<PostPublishingScreen> {
|
||||
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(
|
||||
|
@ -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<RealmListScreen> {
|
||||
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(),
|
||||
|
@ -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<RealmOrganizeScreen> {
|
||||
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(
|
||||
|
@ -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<SocialScreen> {
|
||||
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(),
|
||||
|
@ -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,
|
||||
),
|
||||
|
@ -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,
|
||||
|
17
lib/widgets/app_bar_title.dart
Normal file
17
lib/widgets/app_bar_title.dart
Normal file
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user