From b913c6a432d560f0d991fbc0b99489952d071d7f Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Thu, 27 Jun 2024 14:56:09 +0800 Subject: [PATCH] :sparkles: Large screen support --- lib/router.dart | 231 +++++++++++-------- lib/screens/about.dart | 103 +++++---- lib/translations.dart | 2 +- lib/widgets/sidebar/empty_placeholder.dart | 8 +- lib/widgets/sidebar/sidebar_placeholder.dart | 8 +- 5 files changed, 202 insertions(+), 150 deletions(-) diff --git a/lib/router.dart b/lib/router.dart index 97649b3..a1018cb 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -32,10 +32,48 @@ abstract class AppRouter { child: child, ), routes: [ - GoRoute( - path: '/', - name: 'social', - builder: (context, state) => const SocialScreen(), + ShellRoute( + builder: (context, state, child) => BasicShell( + state: state, + sidebarFirst: true, + showAppBar: false, + sidebar: const SocialScreen(), + child: child, + ), + routes: [ + GoRoute( + path: '/', + name: 'social', + builder: (context, state) => + SolianTheme.isExtraLargeScreen(context) + ? const EmptyPagePlaceholder() + : const SocialScreen(), + ), + GoRoute( + path: '/posts/view/:alias', + name: 'postDetail', + builder: (context, state) => TitleShell( + showAppBar: SolianTheme.isExtraLargeScreen(context), + state: state, + child: PostDetailScreen( + alias: state.pathParameters['alias']!, + ), + ), + ), + GoRoute( + path: '/posts/publish', + name: 'postPublishing', + builder: (context, state) { + final arguments = state.extra as PostPublishingArguments?; + return PostPublishingScreen( + edit: arguments?.edit, + reply: arguments?.reply, + repost: arguments?.repost, + realm: arguments?.realm, + ); + }, + ), + ], ), ShellRoute( builder: (context, state, child) => BasicShell( @@ -49,9 +87,10 @@ abstract class AppRouter { GoRoute( path: '/chat', name: 'chat', - builder: (context, state) => SolianTheme.isExtraLargeScreen(context) - ? const EmptyPagePlaceholder() - : const ChatScreen(), + builder: (context, state) => + SolianTheme.isExtraLargeScreen(context) + ? const EmptyPagePlaceholder() + : const ChatScreen(), ), GoRoute( path: '/chat/organize', @@ -92,98 +131,104 @@ abstract class AppRouter { ), ], ), - GoRoute( - path: '/realms', - name: 'realms', - builder: (context, state) => const RealmListScreen(), - ), - GoRoute( - path: '/account', - name: 'account', - builder: (context, state) => const AccountScreen(), - ), - ], - ), - ShellRoute( - builder: (context, state, child) => - BasicShell(state: state, child: child), - routes: [ - GoRoute( - path: '/posts/view/:alias', - name: 'postDetail', - builder: (context, state) => PostDetailScreen( - alias: state.pathParameters['alias']!, + ShellRoute( + builder: (context, state, child) => BasicShell( + state: state, + sidebarFirst: true, + showAppBar: false, + sidebar: const RealmListScreen(), + child: child, ), + routes: [ + GoRoute( + path: '/realms', + name: 'realms', + builder: (context, state) => + SolianTheme.isExtraLargeScreen(context) + ? const EmptyPagePlaceholder() + : const RealmListScreen(), + ), + GoRoute( + path: '/realms/:alias/detail', + name: 'realmDetail', + builder: (context, state) => TitleShell( + showAppBar: SolianTheme.isExtraLargeScreen(context), + state: state, + child: RealmDetailScreen( + realm: state.extra as Realm, + alias: state.pathParameters['alias']!, + ), + ), + ), + GoRoute( + path: '/realm/organize', + name: 'realmOrganizing', + builder: (context, state) { + final arguments = state.extra as RealmOrganizeArguments?; + return RealmOrganizeScreen( + edit: arguments?.edit, + ); + }, + ), + GoRoute( + path: '/realm/:alias', + name: 'realmView', + builder: (context, state) { + return RealmViewScreen( + alias: state.pathParameters['alias']!, + ); + }, + ), + ], ), - ], - ), - GoRoute( - path: '/posts/publish', - name: 'postPublishing', - builder: (context, state) { - final arguments = state.extra as PostPublishingArguments?; - return PostPublishingScreen( - edit: arguments?.edit, - reply: arguments?.reply, - repost: arguments?.repost, - realm: arguments?.realm, - ); - }, - ), - ShellRoute( - builder: (context, state, child) => - BasicShell(state: state, child: child), - routes: [ - GoRoute( - path: '/account/friend', - name: 'accountFriend', - builder: (context, state) => const FriendScreen(), - ), - GoRoute( - path: '/account/personalize', - name: 'accountPersonalize', - builder: (context, state) => const PersonalizeScreen(), - ), - GoRoute( - path: '/about', - name: 'about', - builder: (context, state) => const AboutScreen(), - ), - ], - ), - ShellRoute( - builder: (context, state, child) => - BasicShell(state: state, child: child), - routes: [ - GoRoute( - path: '/realms/:alias/detail', - name: 'realmDetail', - builder: (context, state) => RealmDetailScreen( - realm: state.extra as Realm, - alias: state.pathParameters['alias']!, + ShellRoute( + builder: (context, state, child) => BasicShell( + state: state, + sidebarFirst: true, + showAppBar: false, + sidebar: const AccountScreen(), + child: child, ), + routes: [ + GoRoute( + path: '/account', + name: 'account', + builder: (context, state) => + SolianTheme.isExtraLargeScreen(context) + ? const EmptyPagePlaceholder() + : const AccountScreen(), + ), + GoRoute( + path: '/account/friend', + name: 'accountFriend', + builder: (context, state) => TitleShell( + showAppBar: SolianTheme.isExtraLargeScreen(context), + state: state, + child: const FriendScreen(), + ), + ), + GoRoute( + path: '/account/personalize', + name: 'accountPersonalize', + builder: (context, state) => TitleShell( + showAppBar: SolianTheme.isExtraLargeScreen(context), + state: state, + child: const PersonalizeScreen(), + ), + ), + GoRoute( + path: '/about', + name: 'about', + builder: (context, state) => TitleShell( + showAppBar: SolianTheme.isExtraLargeScreen(context), + state: state, + child: const AboutScreen(), + ), + ), + ], ), ], ), - GoRoute( - path: '/realm/organize', - name: 'realmOrganizing', - builder: (context, state) { - final arguments = state.extra as RealmOrganizeArguments?; - return RealmOrganizeScreen( - edit: arguments?.edit, - ); - }, - ), - GoRoute( - path: '/realm/:alias', - name: 'realmView', - builder: (context, state) { - return RealmViewScreen( - alias: state.pathParameters['alias']!, - ); - }, - ), ], ); } diff --git a/lib/screens/about.dart b/lib/screens/about.dart index 09171a9..95fa90d 100644 --- a/lib/screens/about.dart +++ b/lib/screens/about.dart @@ -12,57 +12,60 @@ class AboutScreen extends StatelessWidget { return Material( color: Theme.of(context).colorScheme.surface, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Image.asset('assets/logo.png', width: 64, height: 64), - Text( - 'Solian', - style: Theme.of(context).textTheme.headlineMedium, - ), - const Text( - 'The Solar Network', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16), - ), - const SizedBox(height: 8), - FutureBuilder( - future: PackageInfo.fromPlatform(), - builder: (context, snapshot) { - if (!snapshot.hasData) { - return const SizedBox(); - } - - return Text( - 'v${snapshot.data!.version} · ${snapshot.data!.buildNumber}', - style: const TextStyle(fontFamily: 'monospace'), - ); - }, - ), - Text('Copyright © ${DateTime.now().year} Solsynth LLC'), - const SizedBox(height: 16), - TextButton( - style: denseButtonStyle, - child: const Text('More Information'), - onPressed: () { - launchUrlString('https://solsynth.dev/products/solar-network'); - }, - ), - TextButton( - style: denseButtonStyle, - onPressed: () { - launchUrlString('https://solsynth.dev'); - }, - child: const Text('Official Website'), - ), - const SizedBox(height: 16), - const Text( - 'Open-sourced under AGPLv3', - style: TextStyle( - fontWeight: FontWeight.w300, - fontSize: 12, + child: SizedBox( + width: double.infinity, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset('assets/logo.png', width: 64, height: 64), + Text( + 'Solian', + style: Theme.of(context).textTheme.headlineMedium, ), - ), - ], + const Text( + 'The Solar Network', + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16), + ), + const SizedBox(height: 8), + FutureBuilder( + future: PackageInfo.fromPlatform(), + builder: (context, snapshot) { + if (!snapshot.hasData) { + return const SizedBox(); + } + + return Text( + 'v${snapshot.data!.version} · ${snapshot.data!.buildNumber}', + style: const TextStyle(fontFamily: 'monospace'), + ); + }, + ), + Text('Copyright © ${DateTime.now().year} Solsynth LLC'), + const SizedBox(height: 16), + TextButton( + style: denseButtonStyle, + child: const Text('More Information'), + onPressed: () { + launchUrlString('https://solsynth.dev/products/solar-network'); + }, + ), + TextButton( + style: denseButtonStyle, + onPressed: () { + launchUrlString('https://solsynth.dev'); + }, + child: const Text('Official Website'), + ), + const SizedBox(height: 16), + const Text( + 'Open-sourced under AGPLv3', + style: TextStyle( + fontWeight: FontWeight.w300, + fontSize: 12, + ), + ), + ], + ), ), ); } diff --git a/lib/translations.dart b/lib/translations.dart index c374182..52717fc 100644 --- a/lib/translations.dart +++ b/lib/translations.dart @@ -76,7 +76,7 @@ class SolianMessages extends Translations { 'postInRealm': 'In realm @realm', 'postDetail': 'Post', 'postReplies': 'Replies', - 'postPublishing': 'Post post', + 'postPublishing': 'Post a post', 'postIdentityNotify': 'You will post this post as', 'postContentPlaceholder': 'What\'s happened?!', 'postReaction': 'Reactions of the Post', diff --git a/lib/widgets/sidebar/empty_placeholder.dart b/lib/widgets/sidebar/empty_placeholder.dart index e18fad0..d012cb9 100644 --- a/lib/widgets/sidebar/empty_placeholder.dart +++ b/lib/widgets/sidebar/empty_placeholder.dart @@ -1,13 +1,15 @@ import 'package:flutter/material.dart'; -import 'package:get/get.dart'; class EmptyPagePlaceholder extends StatelessWidget { const EmptyPagePlaceholder({super.key}); @override Widget build(BuildContext context) { - return Center( - child: Image.asset('assets/logo.png', width: 80, height: 80), + return Material( + color: Theme.of(context).colorScheme.surface, + child: Center( + child: Image.asset('assets/logo.png', width: 80, height: 80), + ), ); } } diff --git a/lib/widgets/sidebar/sidebar_placeholder.dart b/lib/widgets/sidebar/sidebar_placeholder.dart index eee00ed..17003ee 100644 --- a/lib/widgets/sidebar/sidebar_placeholder.dart +++ b/lib/widgets/sidebar/sidebar_placeholder.dart @@ -1,13 +1,15 @@ import 'package:flutter/material.dart'; -import 'package:get/get.dart'; class SidebarPlaceholder extends StatelessWidget { const SidebarPlaceholder({super.key}); @override Widget build(BuildContext context) { - return const Center( - child: Icon(Icons.menu_open, size: 50), + return Material( + color: Theme.of(context).colorScheme.surface, + child: const Center( + child: Icon(Icons.menu_open, size: 50), + ), ); } }