diff --git a/lib/screens/explore.dart b/lib/screens/explore.dart index d56ffb3..a175afd 100644 --- a/lib/screens/explore.dart +++ b/lib/screens/explore.dart @@ -43,8 +43,10 @@ class ExploreScreen extends StatefulWidget { // Cuz the global key make the selected category not update to child widget when the category is changed. SnPostCategory? _selectedCategory; -class _ExploreScreenState extends State with SingleTickerProviderStateMixin { - late final TabController _tabController = TabController(length: 4, vsync: this); +class _ExploreScreenState extends State + with SingleTickerProviderStateMixin { + late final TabController _tabController = + TabController(length: 4, vsync: this); final _fabKey = GlobalKey(); final _listKeys = List.generate(4, (_) => GlobalKey<_PostListWidgetState>()); @@ -57,7 +59,10 @@ class _ExploreScreenState extends State with SingleTickerProvider final sn = context.read(); final resp = await sn.client.get('/cgi/co/categories?take=100'); setState(() { - _categories.addAll(resp.data.map((e) => SnPostCategory.fromJson(e)).cast() ?? []); + _categories.addAll(resp.data + .map((e) => SnPostCategory.fromJson(e)) + .cast() ?? + []); }); } catch (err) { if (mounted) context.showErrorDialog(err); @@ -94,20 +99,27 @@ class _ExploreScreenState extends State with SingleTickerProvider type: ExpandableFabType.up, childrenAnimation: ExpandableFabAnimation.none, overlayStyle: ExpandableFabOverlayStyle( - color: Theme.of(context).colorScheme.surface.withAlpha((255 * 0.5).round()), + color: Theme.of(context) + .colorScheme + .surface + .withAlpha((255 * 0.5).round()), ), openButtonBuilder: RotateFloatingActionButtonBuilder( child: const Icon(Symbols.add, size: 28), fabSize: ExpandableFabSize.regular, - foregroundColor: Theme.of(context).floatingActionButtonTheme.foregroundColor, - backgroundColor: Theme.of(context).floatingActionButtonTheme.backgroundColor, + foregroundColor: + Theme.of(context).floatingActionButtonTheme.foregroundColor, + backgroundColor: + Theme.of(context).floatingActionButtonTheme.backgroundColor, shape: const CircleBorder(), ), closeButtonBuilder: DefaultFloatingActionButtonBuilder( child: const Icon(Symbols.close, size: 28), fabSize: ExpandableFabSize.regular, - foregroundColor: Theme.of(context).floatingActionButtonTheme.foregroundColor, - backgroundColor: Theme.of(context).floatingActionButtonTheme.backgroundColor, + foregroundColor: + Theme.of(context).floatingActionButtonTheme.foregroundColor, + backgroundColor: + Theme.of(context).floatingActionButtonTheme.backgroundColor, shape: const CircleBorder(), ), children: [ @@ -241,13 +253,18 @@ class _ExploreScreenState extends State with SingleTickerProvider mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Icon(Symbols.globe, size: 20, color: Theme.of(context).appBarTheme.foregroundColor), + Icon(Symbols.globe, + size: 20, + color: Theme.of(context) + .appBarTheme + .foregroundColor), const Gap(8), Flexible( child: Text( 'postChannelGlobal', maxLines: 1, - ).tr().textColor(Theme.of(context).appBarTheme.foregroundColor), + ).tr().textColor( + Theme.of(context).appBarTheme.foregroundColor), ), ], ), @@ -257,14 +274,19 @@ class _ExploreScreenState extends State with SingleTickerProvider mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Icon(Symbols.group, size: 20, color: Theme.of(context).appBarTheme.foregroundColor), + Icon(Symbols.group, + size: 20, + color: Theme.of(context) + .appBarTheme + .foregroundColor), const Gap(8), Flexible( child: Text( 'postChannelFriends', maxLines: 1, textAlign: TextAlign.center, - ).tr().textColor(Theme.of(context).appBarTheme.foregroundColor), + ).tr().textColor( + Theme.of(context).appBarTheme.foregroundColor), ), ], ), @@ -274,13 +296,18 @@ class _ExploreScreenState extends State with SingleTickerProvider mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Icon(Symbols.subscriptions, size: 20, color: Theme.of(context).appBarTheme.foregroundColor), + Icon(Symbols.subscriptions, + size: 20, + color: Theme.of(context) + .appBarTheme + .foregroundColor), const Gap(8), Flexible( child: Text( 'postChannelFollowing', maxLines: 1, - ).tr().textColor(Theme.of(context).appBarTheme.foregroundColor), + ).tr().textColor( + Theme.of(context).appBarTheme.foregroundColor), ), ], ), @@ -290,13 +317,18 @@ class _ExploreScreenState extends State with SingleTickerProvider mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Icon(Symbols.workspaces, size: 20, color: Theme.of(context).appBarTheme.foregroundColor), + Icon(Symbols.workspaces, + size: 20, + color: Theme.of(context) + .appBarTheme + .foregroundColor), const Gap(8), Flexible( child: Text( 'postChannelRealm', maxLines: 1, - ).tr().textColor(Theme.of(context).appBarTheme.foregroundColor), + ).tr().textColor( + Theme.of(context).appBarTheme.foregroundColor), ), ], ), @@ -341,7 +373,11 @@ class _PostListWidget extends StatefulWidget { final bool withRealm; final Function onClearFilter; - const _PostListWidget({super.key, this.channel, this.withRealm = false, required this.onClearFilter}); + const _PostListWidget( + {super.key, + this.channel, + this.withRealm = false, + required this.onClearFilter}); @override State<_PostListWidget> createState() => _PostListWidgetState(); @@ -420,11 +456,13 @@ class _PostListWidgetState extends State<_PostListWidget> { content: Text( 'postFilterWithCategory'.tr(args: [ 'postCategory${_selectedCategory!.alias.capitalize()}'.trExists() - ? 'postCategory${_selectedCategory!.alias.capitalize()}'.tr() + ? 'postCategory${_selectedCategory!.alias.capitalize()}' + .tr() : _selectedCategory!.name, ]), ), - leading: Icon(kCategoryIcons[_selectedCategory!.alias] ?? Symbols.question_mark), + leading: Icon(kCategoryIcons[_selectedCategory!.alias] ?? + Symbols.question_mark), actions: [ IconButton( icon: const Icon(Symbols.clear), @@ -486,7 +524,8 @@ class _PostListWidgetState extends State<_PostListWidget> { itemCount: _posts.length, isLoading: _isBusy, centerLoading: true, - hasReachedMax: _postCount != null && _posts.length >= _postCount!, + hasReachedMax: + _postCount != null && _posts.length >= _postCount!, onFetchData: _fetchPosts, itemBuilder: (context, idx) { return OpenablePostItem( @@ -526,7 +565,9 @@ class _PostCategoryPickerPopup extends StatelessWidget { children: [ const Icon(Symbols.category, size: 24), const Gap(16), - Text('postCategory').tr().textStyle(Theme.of(context).textTheme.titleLarge!), + Text('postCategory') + .tr() + .textStyle(Theme.of(context).textTheme.titleLarge!), ], ).padding(horizontal: 20, top: 16, bottom: 12), ListTile( @@ -539,40 +580,46 @@ class _PostCategoryPickerPopup extends StatelessWidget { }, ), const Divider(height: 1), - GridView.count( - crossAxisCount: 4, - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - childAspectRatio: 1, - children: categories - .map( - (ele) => InkWell( - onTap: () { - _selectedCategory = ele; - Navigator.pop(context, ele); - }, - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - kCategoryIcons[ele.alias] ?? Symbols.question_mark, - color: selected == ele ? Theme.of(context).colorScheme.primary : null, - ), - const Gap(4), - Text( - 'postCategory${ele.alias.capitalize()}'.trExists() - ? 'postCategory${ele.alias.capitalize()}'.tr() - : ele.name, - ) - .textStyle(Theme.of(context).textTheme.titleMedium!) - .textColor(selected == ele ? Theme.of(context).colorScheme.primary : null), - ], + Expanded( + child: GridView.count( + crossAxisCount: 4, + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + childAspectRatio: 1, + children: categories + .map( + (ele) => InkWell( + onTap: () { + _selectedCategory = ele; + Navigator.pop(context, ele); + }, + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + kCategoryIcons[ele.alias] ?? Symbols.question_mark, + color: selected == ele + ? Theme.of(context).colorScheme.primary + : null, + ), + const Gap(4), + Text( + 'postCategory${ele.alias.capitalize()}'.trExists() + ? 'postCategory${ele.alias.capitalize()}'.tr() + : ele.name, + ) + .textStyle(Theme.of(context).textTheme.titleMedium!) + .textColor(selected == ele + ? Theme.of(context).colorScheme.primary + : null), + ], + ), ), - ), - ) - .toList(), + ) + .toList(), + ), ), ], ); diff --git a/lib/widgets/navigation/app_scaffold.dart b/lib/widgets/navigation/app_scaffold.dart index 1e0de55..38ea820 100644 --- a/lib/widgets/navigation/app_scaffold.dart +++ b/lib/widgets/navigation/app_scaffold.dart @@ -61,7 +61,9 @@ class AppScaffold extends StatelessWidget { isRoot: true, child: Column( children: [ - IgnorePointer(child: SizedBox(height: appBar != null ? appBarHeight + safeTop : 0)), + IgnorePointer( + child: SizedBox( + height: appBar != null ? appBarHeight + safeTop : 0)), if (body != null) Expanded(child: body!), ], ), @@ -107,11 +109,19 @@ class AppRootScaffold extends StatelessWidget { final isCollapseDrawer = cfg.drawerIsCollapsed; final isExpandedDrawer = cfg.drawerIsExpanded; - final routeName = GoRouter.of(context).routerDelegate.currentConfiguration.last.route.name; - final isShowBottomNavigation = NavigationProvider.kShowBottomNavScreen.contains(routeName) - ? ResponsiveBreakpoints.of(context).smallerOrEqualTo(MOBILE) - : false; - final isPopable = !NavigationProvider.kAllDestination.map((ele) => ele.screen).contains(routeName); + final routeName = GoRouter.of(context) + .routerDelegate + .currentConfiguration + .last + .route + .name; + final isShowBottomNavigation = + NavigationProvider.kShowBottomNavScreen.contains(routeName) + ? ResponsiveBreakpoints.of(context).smallerOrEqualTo(MOBILE) + : false; + final isPopable = !NavigationProvider.kAllDestination + .map((ele) => ele.screen) + .contains(routeName); final innerWidget = isCollapseDrawer ? body @@ -126,7 +136,9 @@ class AppRootScaffold extends StatelessWidget { ), ), ), - child: isExpandedDrawer ? AppNavigationDrawer(elevation: 0) : AppRailNavigation(), + child: isExpandedDrawer + ? AppNavigationDrawer(elevation: 0) + : AppRailNavigation(), ), Expanded(child: body), ], @@ -150,7 +162,8 @@ class AppRootScaffold extends StatelessWidget { children: [ Column( children: [ - if (!kIsWeb && (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) + if (!kIsWeb && + (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) WindowTitleBarBox( child: Container( decoration: BoxDecoration( @@ -164,12 +177,19 @@ class AppRootScaffold extends StatelessWidget { child: MoveWindow( child: Row( crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: Platform.isMacOS ? MainAxisAlignment.center : MainAxisAlignment.start, + mainAxisAlignment: Platform.isMacOS + ? MainAxisAlignment.center + : MainAxisAlignment.start, children: [ Expanded( child: Text( 'Solar Network', style: GoogleFonts.spaceGrotesk(), + textAlign: !kIsWeb + ? Platform.isMacOS + ? TextAlign.center + : null + : null, ).padding(horizontal: 12, vertical: 5), ), if (!Platform.isMacOS) @@ -179,9 +199,12 @@ class AppRootScaffold extends StatelessWidget { Expanded(child: MoveWindow()), Row( children: [ - MinimizeWindowButton(colors: windowButtonColor), - MaximizeWindowButton(colors: windowButtonColor), - CloseWindowButton(colors: windowButtonColor), + MinimizeWindowButton( + colors: windowButtonColor), + MaximizeWindowButton( + colors: windowButtonColor), + CloseWindowButton( + colors: windowButtonColor), ], ), ], @@ -194,16 +217,28 @@ class AppRootScaffold extends StatelessWidget { Expanded(child: innerWidget), ], ), - Positioned(top: safeTop > 0 ? safeTop : 16, right: 8, child: NotifyIndicator()), + Positioned( + top: safeTop > 0 ? safeTop : 16, + right: 8, + child: NotifyIndicator()), if (ResponsiveBreakpoints.of(context).smallerOrEqualTo(MOBILE)) - Positioned(bottom: safeBottom > 0 ? safeBottom : 16, left: 0, right: 0, child: ConnectionIndicator()) + Positioned( + bottom: safeBottom > 0 ? safeBottom : 16, + left: 0, + right: 0, + child: ConnectionIndicator()) else - Positioned(top: safeTop > 0 ? safeTop : 16, left: 0, right: 0, child: ConnectionIndicator()), + Positioned( + top: safeTop > 0 ? safeTop : 16, + left: 0, + right: 0, + child: ConnectionIndicator()), ], ), drawer: !isExpandedDrawer ? AppNavigationDrawer() : null, drawerEdgeDragWidth: isPopable ? 0 : null, - bottomNavigationBar: isShowBottomNavigation ? AppBottomNavigationBar() : null, + bottomNavigationBar: + isShowBottomNavigation ? AppBottomNavigationBar() : null, ); } } diff --git a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 48eca57..98eb9be 100644 --- a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -59,6 +59,7 @@ ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" debugServiceExtension = "internal" + enableGPUValidationMode = "1" allowLocationSimulation = "YES">