From a445ffb0d847b8d1e44213b95bfbe60ecdf19952 Mon Sep 17 00:00:00 2001 From: Scott Murray Date: Thu, 21 Dec 2023 17:22:52 -0500 Subject: Add application launcher support Changes: - Add required agl-shell and applauncher gRPC API source and generated files. - Remove unused deprecated databroker gRPC API files as cleanup. - Add app launcher helper object and associated RiverPod provider. The implementation is based on code from the old Flutter homescreen. There will likely be follow up work to use the recent changes to the agl-shell gRPC API to handle display setting for applications needing remote displays. - Wire up application enumeration and starting in the app page. A placeholder generic application icon has been added that will be used for the external applications for now, as the SVG icons being used with the old homescreens are not really suitable. - Wire up activating the homescreen again if the bottom panel is touched after an external application has been started. Bug-AGL: SPEC-5026 Change-Id: I01de4760cfd098d3b5f2e6843ad9103a8ea87935 Signed-off-by: Scott Murray --- .../common_widget/custom_bottom_bar.dart | 1 + lib/presentation/screens/apps/apps_content.dart | 58 ++++++++++++---------- lib/presentation/screens/home/home.dart | 1 + 3 files changed, 34 insertions(+), 26 deletions(-) (limited to 'lib/presentation') diff --git a/lib/presentation/common_widget/custom_bottom_bar.dart b/lib/presentation/common_widget/custom_bottom_bar.dart index 64684e9..61a7e20 100644 --- a/lib/presentation/common_widget/custom_bottom_bar.dart +++ b/lib/presentation/common_widget/custom_bottom_bar.dart @@ -44,6 +44,7 @@ class CustomBottomBarState extends ConsumerState { setState(() { selectedNav = title; }); + ref.read(appLauncherProvider).activateApp("homescreen"); ref.read(currentTimeProvider.notifier).isYearChanged = false; ref.read(appProvider.notifier).update((state) => state = status); } diff --git a/lib/presentation/screens/apps/apps_content.dart b/lib/presentation/screens/apps/apps_content.dart index fe6e3b0..b0afda1 100644 --- a/lib/presentation/screens/apps/apps_content.dart +++ b/lib/presentation/screens/apps/apps_content.dart @@ -1,48 +1,54 @@ import 'package:flutter_ics_homescreen/export.dart'; import 'package:flutter_ics_homescreen/presentation/screens/apps/widgets/app_button.dart'; -class Apps extends StatefulWidget { +class Apps extends ConsumerStatefulWidget { const Apps({super.key}); @override - State createState() => _AppsState(); + ConsumerState createState() => _AppsState(); } -class _AppsState extends State { - onPressed({required String type}) { - if (type == "weather") { - context.flow().update((next) => AppState.weather); - } else if (type == "clock") { - context.flow().update((next) => AppState.clock); +class _AppsState extends ConsumerState { + onPressed({required bool internal, required String id}) { + if (internal) { + if (id == "weather") { + context.flow().update((next) => AppState.weather); + } else if (id == "clock") { + context.flow().update((next) => AppState.clock); + } + } else { + ref.read(appLauncherProvider).startApp(id); } } @override Widget build(BuildContext context) { + var apps = ref.watch(appLauncherListProvider); + return Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ const CommonTitle(title: "Applications"), Padding( padding: const EdgeInsets.symmetric(vertical: 50, horizontal: 148), - child: Wrap( - children: [ - AppButton( - image: "weather.svg", - title: "Weather", - onPressed: () { - onPressed(type: "weather"); - }, - ), - AppButton( - image: "clock.svg", - title: "Clock", - onPressed: () { - onPressed(type: "clock"); - }, - ) - ], - ), + child: GridView.builder( + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemCount: apps.length, + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3), + itemBuilder: (context, index) { + return GridTile( + child: Container( + alignment: Alignment.center, + child: AppButton( + title: apps[index].name, + image: apps[index].icon.isNotEmpty ? apps[index].icon : "app-generic.svg", + onPressed: () { + onPressed(internal: apps[index].internal, id: apps[index].id); + }, + ))); + }) ), // Center( // child: SizedBox( diff --git a/lib/presentation/screens/home/home.dart b/lib/presentation/screens/home/home.dart index 86da46f..3d80f92 100644 --- a/lib/presentation/screens/home/home.dart +++ b/lib/presentation/screens/home/home.dart @@ -13,6 +13,7 @@ class HomeScreen extends ConsumerStatefulWidget { class HomeScreenState extends ConsumerState { @override void initState() { + ref.read(appLauncherProvider).run(); super.initState(); } -- cgit 1.2.3-korg