aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2020-06-03 19:45:38 +0530
committerAkshay Nair <phenax5@gmail.com>2020-06-03 19:45:38 +0530
commit008f625c89e0bb930dbb4b92c502e3a273b27807 (patch)
tree26015d454303fd5db838dac5b4f63366f607ae03
parent871706b606c77eeac13bfcea67c3ce1d71203d2c (diff)
downloaddaft-launcher-008f625c89e0bb930dbb4b92c502e3a273b27807.tar.gz
daft-launcher-008f625c89e0bb930dbb4b92c502e3a273b27807.zip
Fixes type issue and adds style to the dark mode button
-rw-r--r--.flutter-plugins-dependencies2
-rw-r--r--lib/data/config.dart2
-rw-r--r--lib/main.dart3
-rw-r--r--lib/pages/Home.dart69
-rw-r--r--pubspec.yaml2
5 files changed, 50 insertions, 28 deletions
diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies
index 3881cb6..c793bfa 100644
--- a/.flutter-plugins-dependencies
+++ b/.flutter-plugins-dependencies
@@ -1 +1 @@
-{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"shared_preferences","path":"/home/akshayn/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.4.3/","dependencies":[]}],"android":[{"name":"android_intent","path":"/home/akshayn/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.7+2/","dependencies":[]},{"name":"device_apps","path":"/home/akshayn/.pub-cache/hosted/pub.dartlang.org/device_apps-1.0.9/","dependencies":[]},{"name":"shared_preferences","path":"/home/akshayn/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.4.3/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"android_intent","dependencies":[]},{"name":"device_apps","dependencies":[]},{"name":"shared_preferences","dependencies":[]}],"date_created":"2020-06-03 14:35:47.788356","version":"1.19.0-2.0.pre.214"} \ No newline at end of file
+{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"shared_preferences","path":"/home/akshayn/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.4.3/","dependencies":[]}],"android":[{"name":"android_intent","path":"/home/akshayn/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.7+2/","dependencies":[]},{"name":"device_apps","path":"/home/akshayn/.pub-cache/hosted/pub.dartlang.org/device_apps-1.0.9/","dependencies":[]},{"name":"shared_preferences","path":"/home/akshayn/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.4.3/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"android_intent","dependencies":[]},{"name":"device_apps","dependencies":[]},{"name":"shared_preferences","dependencies":[]}],"date_created":"2020-06-03 19:31:00.053777","version":"1.19.0-2.0.pre.214"} \ No newline at end of file
diff --git a/lib/data/config.dart b/lib/data/config.dart
index 0dd33cd..cef3eb4 100644
--- a/lib/data/config.dart
+++ b/lib/data/config.dart
@@ -8,7 +8,7 @@ class Config {
Config({ this.theme }) {}
bool isDarkMode() {
- return theme == 'dark';
+ return theme != 'light';
}
}
diff --git a/lib/main.dart b/lib/main.dart
index 40aa069..d98a1b1 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -13,10 +13,11 @@ void main() {
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();
+ // State
+ StreamStateValue<Config> config = StreamStateValue<Config>(stream$: getConfig$(), value: Config());
void initState() {
super.initState();
initStateValue(config);
diff --git a/lib/pages/Home.dart b/lib/pages/Home.dart
index 8efa86e..b9663fd 100644
--- a/lib/pages/Home.dart
+++ b/lib/pages/Home.dart
@@ -16,6 +16,8 @@ class StatusInfoCard extends StatelessWidget {
@override
Widget build(BuildContext ctx) {
+ ThemeData theme = Theme.of(ctx);
+
return StreamBuilder<DateTime>(
stream: time$,
initialData: defaultTime,
@@ -23,36 +25,55 @@ class StatusInfoCard extends StatelessWidget {
Widget child = Text('Loading...', key: Key('loading'));
if (snapshot.hasData) {
- child = Column(
- mainAxisAlignment: MainAxisAlignment.start,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(timeFormat.format(snapshot.data),
- key: Key('time'),
- textAlign: TextAlign.left,
- style: const TextStyle(
- fontSize: 32.0,
- fontWeight: FontWeight.bold,
+ child = Row(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Expanded(child: Column(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(timeFormat.format(snapshot.data),
+ key: Key('time'),
+ textAlign: TextAlign.left,
+ style: const TextStyle(
+ fontSize: 32.0,
+ fontWeight: FontWeight.bold,
+ ),
),
- ),
- Text(dateFormat.format(snapshot.data),
- key: Key('date'),
- textAlign: TextAlign.left,
- style: const TextStyle(
- fontSize: 16.0,
- fontWeight: FontWeight.w300,
+ Text(dateFormat.format(snapshot.data),
+ key: Key('date'),
+ textAlign: TextAlign.left,
+ style: const TextStyle(
+ fontSize: 16.0,
+ fontWeight: FontWeight.w300,
+ ),
),
- ),
- FlatButton(
- child: Text('Theme'),
- onPressed: () { toggleTheme(); }
- ),
- ]
+ ]
+ )),
+ Container(
+ width: 40,
+ height: 30,
+ child: IconButton(
+ padding: const EdgeInsets.all(0.0),
+ visualDensity: const VisualDensity(vertical: 0.0, horizontal: 0.0),
+ icon: Icon(
+ Icons.brightness_4,
+ color: theme.primaryColor,
+ size: 16.0,
+ semanticLabel: 'Toggle dark mode',
+ ),
+ tooltip: 'Toggle dark mode',
+ enableFeedback: true,
+ onPressed: () { toggleTheme(); }
+ ),
+ ),
+ ],
);
}
return Container(
- height: 300,
+ height: 100,
padding: EdgeInsets.symmetric(vertical: 8.0),
child: Align(alignment: Alignment.topLeft, child: child),
);
diff --git a/pubspec.yaml b/pubspec.yaml
index f14d60b..0fdeb79 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -41,7 +41,7 @@ flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
- uses-material-design: false
+ uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets: