From 008f625c89e0bb930dbb4b92c502e3a273b27807 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Wed, 3 Jun 2020 19:45:38 +0530 Subject: Fixes type issue and adds style to the dark mode button --- lib/pages/Home.dart | 69 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 24 deletions(-) (limited to 'lib/pages') 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( 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), ); -- cgit v1.3.1