aboutsummaryrefslogtreecommitdiff
path: root/lib/main.dart
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2020-06-03 14:39:52 +0530
committerAkshay Nair <phenax5@gmail.com>2020-06-03 14:39:52 +0530
commit871706b606c77eeac13bfcea67c3ce1d71203d2c (patch)
tree82d3ca8b51cc001606f5412a20730a813b7d9e2d /lib/main.dart
parentc745b90dfdc97a2e04582051b01fde83883d8e3e (diff)
downloaddaft-launcher-871706b606c77eeac13bfcea67c3ce1d71203d2c.tar.gz
daft-launcher-871706b606c77eeac13bfcea67c3ce1d71203d2c.zip
Adds shared preferences for config/theme storage + refactors a streamstate
Diffstat (limited to '')
-rw-r--r--lib/main.dart52
1 files changed, 50 insertions, 2 deletions
diff --git a/lib/main.dart b/lib/main.dart
index 2ad0fb9..40aa069 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -4,23 +4,67 @@ import 'package:flutter/material.dart';
import 'pages/Home.dart';
import 'pages/Apps.dart';
+import 'data/config.dart';
+import 'helpers/StreamState.dart';
+
void main() {
runApp(MyApp());
}
-class MyApp extends StatelessWidget {
- final Stream<DateTime> time$ = Stream.periodic(Duration(seconds: 1), (_x) => DateTime.now()).asBroadcastStream();
+class MyAppState extends StreamState<MyApp> {
+ // Streams
+ StreamStateValue<Config> config = StreamStateValue<Config>(stream$: getConfig$(), value: Config());
+ final Stream<DateTime> time$ =
+ Stream.periodic(Duration(seconds: 1), (_x) => DateTime.now()).asBroadcastStream();
+
+ void initState() {
+ super.initState();
+ initStateValue(config);
+ }
@override
void dispose() {
+ super.dispose();
time$.drain();
}
+ ThemeData getLightTheme() {
+ return ThemeData(brightness: Brightness.light);
+ }
+
+ ThemeData getDarkTheme() {
+ Color fg = Color(0xFFD8DEE9);
+ return ThemeData(
+ backgroundColor: Color(0xFF0F1215),
+ scaffoldBackgroundColor: Color(0xFF0F1215),
+ accentColor: fg,
+ primaryColor: Color(0xFF5E81AC),
+ textTheme: TextTheme(
+ headline1: TextStyle(color: fg),
+ headline2: TextStyle(color: fg),
+ headline3: TextStyle(color: fg),
+ headline4: TextStyle(color: fg),
+ headline5: TextStyle(color: fg),
+ headline6: TextStyle(color: fg),
+ subtitle1: TextStyle(color: fg),
+ subtitle2: TextStyle(color: fg),
+ bodyText1: TextStyle(color: fg),
+ bodyText2: TextStyle(color: fg),
+ button: TextStyle(color: fg),
+ caption: TextStyle(color: fg),
+ overline: TextStyle(color: fg),
+ ),
+ );
+ }
+
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'owyn launcher',
+ theme: getLightTheme(),
+ darkTheme: getDarkTheme(),
+ themeMode: config.value.isDarkMode() ? ThemeMode.dark : ThemeMode.light,
home: Scaffold(
body: PageView(
controller: PageController(keepPage: true),
@@ -33,3 +77,7 @@ class MyApp extends StatelessWidget {
);
}
}
+
+class MyApp extends StatefulWidget {
+ MyAppState createState() => MyAppState();
+}