summaryrefslogtreecommitdiffstats
path: root/lib/presentation/screens
diff options
context:
space:
mode:
Diffstat (limited to 'lib/presentation/screens')
-rw-r--r--lib/presentation/screens/apps/apps_content.dart58
-rw-r--r--lib/presentation/screens/home/home.dart1
2 files changed, 33 insertions, 26 deletions
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<Apps> createState() => _AppsState();
+ ConsumerState<Apps> createState() => _AppsState();
}
-class _AppsState extends State<Apps> {
- onPressed({required String type}) {
- if (type == "weather") {
- context.flow<AppState>().update((next) => AppState.weather);
- } else if (type == "clock") {
- context.flow<AppState>().update((next) => AppState.clock);
+class _AppsState extends ConsumerState<Apps> {
+ onPressed({required bool internal, required String id}) {
+ if (internal) {
+ if (id == "weather") {
+ context.flow<AppState>().update((next) => AppState.weather);
+ } else if (id == "clock") {
+ context.flow<AppState>().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<HomeScreen> {
@override
void initState() {
+ ref.read(appLauncherProvider).run();
super.initState();
}