From 4cd4ba7fc80c3af8183792b0dfe0e7aab1e0fc9c Mon Sep 17 00:00:00 2001 From: Enzo Conty Date: Wed, 27 Dec 2023 11:21:25 +0100 Subject: [PATCH 1/2] fix: Fixing the window name in mission control --- packages/app_center/lib/src/l10n/app_en.arb | 1 + .../app_center/lib/src/store/store_app.dart | 101 ++++++++++-------- packages/app_center/pubspec.yaml | 3 +- 3 files changed, 62 insertions(+), 43 deletions(-) diff --git a/packages/app_center/lib/src/l10n/app_en.arb b/packages/app_center/lib/src/l10n/app_en.arb index 10b927704..61cf0767c 100644 --- a/packages/app_center/lib/src/l10n/app_en.arb +++ b/packages/app_center/lib/src/l10n/app_en.arb @@ -1,4 +1,5 @@ { + "appCenterLabel": "App Center", "appstreamSearchGreylist": "app;application;package;program;programme;suite;tool", "snapPageChannelLabel": "Channel", "snapPageConfinementLabel": "Confinement", diff --git a/packages/app_center/lib/src/store/store_app.dart b/packages/app_center/lib/src/store/store_app.dart index 0d1e727f7..406f9d763 100644 --- a/packages/app_center/lib/src/store/store_app.dart +++ b/packages/app_center/lib/src/store/store_app.dart @@ -43,55 +43,72 @@ class _StoreAppState extends ConsumerState { localizationsDelegates: localizationsDelegates, navigatorKey: ref.watch(materialAppNavigatorKeyProvider), supportedLocales: supportedLocales, - home: Scaffold( - appBar: YaruWindowTitleBar( - title: ConstrainedBox( - constraints: const BoxConstraints(maxWidth: kSearchBarWidth), - child: SearchField( - onSearch: (query) => - _navigator.pushAndRemoveSearch(query: query), - onSnapSelected: (name) => _navigator.pushSnap(name: name), - onDebSelected: (id) => _navigator.pushDeb(id: id), + home: YaruWindowTitleSetter( + child: Scaffold( + appBar: YaruWindowTitleBar( + title: ConstrainedBox( + constraints: const BoxConstraints(maxWidth: kSearchBarWidth), + child: SearchField( + onSearch: (query) => + _navigator.pushAndRemoveSearch(query: query), + onSnapSelected: (name) => _navigator.pushSnap(name: name), + onDebSelected: (id) => _navigator.pushDeb(id: id), + ), ), ), - ), - body: YaruMasterDetailPage( - navigatorKey: _navigatorKey, - navigatorObservers: [StoreObserver(ref)], - initialRoute: ref.watch(initialRouteProvider), - length: pages.length, - tileBuilder: (context, index, selected, availableWidth) => - pages[index].tileBuilder(context, selected), - pageBuilder: (context, index) => pages[index].pageBuilder(context), - layoutDelegate: const YaruMasterFixedPaneDelegate( - paneWidth: kPaneWidth, - ), - breakpoint: 0, // always landscape - onGenerateRoute: (settings) => - switch (StoreRoutes.routeOf(settings)) { - StoreRoutes.deb => MaterialPageRoute( - settings: settings, - builder: (_) => DebPage( - id: StoreRoutes.debOf(settings)!, - )), - StoreRoutes.snap => MaterialPageRoute( - settings: settings, - builder: (_) => SnapPage( - snapName: StoreRoutes.snapOf(settings)!, + body: YaruMasterDetailPage( + navigatorKey: _navigatorKey, + navigatorObservers: [StoreObserver(ref)], + initialRoute: ref.watch(initialRouteProvider), + length: pages.length, + tileBuilder: (context, index, selected, availableWidth) => + pages[index].tileBuilder(context, selected), + pageBuilder: (context, index) => + pages[index].pageBuilder(context), + layoutDelegate: const YaruMasterFixedPaneDelegate( + paneWidth: kPaneWidth, + ), + breakpoint: 0, // always landscape + onGenerateRoute: (settings) => + switch (StoreRoutes.routeOf(settings)) { + StoreRoutes.deb => MaterialPageRoute( + settings: settings, + builder: (_) => DebPage( + id: StoreRoutes.debOf(settings)!, + )), + StoreRoutes.snap => MaterialPageRoute( + settings: settings, + builder: (_) => SnapPage( + snapName: StoreRoutes.snapOf(settings)!, + ), ), - ), - StoreRoutes.search => MaterialPageRoute( - settings: settings, - builder: (_) => SearchPage( - query: StoreRoutes.queryOf(settings), - category: StoreRoutes.categoryOf(settings), + StoreRoutes.search => MaterialPageRoute( + settings: settings, + builder: (_) => SearchPage( + query: StoreRoutes.queryOf(settings), + category: StoreRoutes.categoryOf(settings), + ), ), - ), - _ => null, - }, + _ => null, + }, + ), ), ), ), ); } } + +class YaruWindowTitleSetter extends StatelessWidget { + const YaruWindowTitleSetter({required this.child, super.key}); + + final Widget child; + + @override + Widget build(BuildContext context) { + final l10n = AppLocalizations.of(context); + YaruWindow.of(context).setTitle(l10n.appCenterLabel); + + return child; + } +} diff --git a/packages/app_center/pubspec.yaml b/packages/app_center/pubspec.yaml index 1bfebcf6d..56296b25a 100644 --- a/packages/app_center/pubspec.yaml +++ b/packages/app_center/pubspec.yaml @@ -49,7 +49,8 @@ dependencies: yaru: ^1.2.0 yaru_icons: ^2.2.2 yaru_test: ^0.1.5 - yaru_widgets: ^3.3.0 + yaru_widgets: ^3.4.0 + yaru_window: ^0.2.0 dev_dependencies: build_runner: ^2.4.6 From 7495da3c856c24799dc712718637b350f80b2188 Mon Sep 17 00:00:00 2001 From: Enzo Conty Date: Wed, 27 Dec 2023 12:56:27 +0100 Subject: [PATCH 2/2] fix: sidebar navigation highlight --- .../app_center/lib/src/explore/explore_page.dart | 11 +++++++++-- packages/app_center/lib/src/store/store_app.dart | 5 ++++- packages/app_center/lib/src/store/store_pages.dart | 14 ++++++++------ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/packages/app_center/lib/src/explore/explore_page.dart b/packages/app_center/lib/src/explore/explore_page.dart index 6009f5a4a..b23cb9a0c 100644 --- a/packages/app_center/lib/src/explore/explore_page.dart +++ b/packages/app_center/lib/src/explore/explore_page.dart @@ -1,6 +1,7 @@ import 'package:app_center/l10n.dart'; import 'package:app_center/layout.dart'; import 'package:app_center/snapd.dart'; +import 'package:app_center/src/store/store_pages.dart'; import 'package:app_center/store.dart'; import 'package:app_center/widgets.dart'; import 'package:collection/collection.dart'; @@ -172,8 +173,14 @@ class _CategoryBanner extends ConsumerWidget { snaps: featuredSnaps?.take(kNumberOfBannerSnaps).toList() ?? [], slogan: category.slogan(l10n), buttonLabel: category.buttonLabel(l10n), - onPressed: () => - StoreNavigator.pushSearch(context, category: category.categoryName), + onPressed: () { + if (displayedCategories.contains(category)) { + ref.read(yaruPageControllerProvider).index = + displayedCategories.indexOf(category) + 1; + } else { + StoreNavigator.pushSearch(context, category: category.categoryName); + } + }, colors: category.bannerColors, ); } diff --git a/packages/app_center/lib/src/store/store_app.dart b/packages/app_center/lib/src/store/store_app.dart index 406f9d763..30179df6b 100644 --- a/packages/app_center/lib/src/store/store_app.dart +++ b/packages/app_center/lib/src/store/store_app.dart @@ -17,6 +17,9 @@ import 'package:yaru_widgets/yaru_widgets.dart'; final materialAppNavigatorKeyProvider = Provider((ref) => GlobalKey()); +final yaruPageControllerProvider = + Provider((ref) => YaruPageController(length: pages.length)); + class StoreApp extends ConsumerStatefulWidget { const StoreApp({super.key}); @@ -60,7 +63,7 @@ class _StoreAppState extends ConsumerState { navigatorKey: _navigatorKey, navigatorObservers: [StoreObserver(ref)], initialRoute: ref.watch(initialRouteProvider), - length: pages.length, + controller: ref.watch(yaruPageControllerProvider), tileBuilder: (context, index, selected, availableWidth) => pages[index].tileBuilder(context, selected), pageBuilder: (context, index) => diff --git a/packages/app_center/lib/src/store/store_pages.dart b/packages/app_center/lib/src/store/store_pages.dart index d520eb227..e406cae0e 100644 --- a/packages/app_center/lib/src/store/store_pages.dart +++ b/packages/app_center/lib/src/store/store_pages.dart @@ -8,6 +8,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:yaru_widgets/yaru_widgets.dart'; +final displayedCategories = [ + SnapCategoryEnum.featured, + SnapCategoryEnum.productivity, + SnapCategoryEnum.development, + SnapCategoryEnum.games, +]; + typedef StorePage = ({ Widget Function(BuildContext context, bool selected) tileBuilder, WidgetBuilder pageBuilder, @@ -21,12 +28,7 @@ final pages = [ ), pageBuilder: (_) => const ExplorePage(), ), - for (final category in [ - SnapCategoryEnum.featured, - SnapCategoryEnum.productivity, - SnapCategoryEnum.development, - SnapCategoryEnum.games, - ]) + for (final category in displayedCategories) ( tileBuilder: (context, selected) => YaruMasterTile( leading: Icon(category.icon(true)),