From 319e35cd512225829e8e891dd4758ff2e428055e Mon Sep 17 00:00:00 2001 From: MrBananaPants Date: Sat, 6 Mar 2021 09:38:18 +0100 Subject: [PATCH] Updated and migrated to Flutter 2.0 --- lib/AboutPage.dart | 2 +- lib/SettingsPage.dart | 139 +++++------- lib/main.dart | 507 ++++++++++++++++------------------------- lib/mainBackup.dart | 516 +++++++++++++++++++----------------------- pubspec.lock | 47 ++-- 5 files changed, 522 insertions(+), 689 deletions(-) diff --git a/lib/AboutPage.dart b/lib/AboutPage.dart index 84bc314..f64e91c 100644 --- a/lib/AboutPage.dart +++ b/lib/AboutPage.dart @@ -119,7 +119,7 @@ class MyAppState extends State { Padding( padding: const EdgeInsets.fromLTRB(0, 0, 0, 0), child: Text( - "Flutter: 1.22.6", + "Flutter: 2.0.1", style: TextStyle( color: Theme.of(context).textTheme.bodyText1.color, ), diff --git a/lib/SettingsPage.dart b/lib/SettingsPage.dart index f3dedd8..db62b58 100644 --- a/lib/SettingsPage.dart +++ b/lib/SettingsPage.dart @@ -91,8 +91,7 @@ class SettingsPageState extends State { title: Text( 'Arduino LED', style: TextStyle( - color: - Theme.of(context).textTheme.bodyText1.color, + color: Theme.of(context).textTheme.bodyText1.color, ), ), ), @@ -101,92 +100,74 @@ class SettingsPageState extends State { cases: [ Case( buttonThema == true, - builder: () => ButtonBar( - buttonHeight: 40, - buttonMinWidth: - SizeConfig.blockSizeHorizontal * 38, - alignment: MainAxisAlignment.spaceBetween, - children: [ - OutlineButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7), - ), - child: Text( - 'AAN', - style: TextStyle( - color: Theme.of(context) - .textTheme - .bodyText2 - .color, + builder: () => Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + OutlinedButton( + style: OutlinedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), + child: Text( + 'AAN', + style: TextStyle( + color: Theme.of(context).textTheme.bodyText2.color, + ), ), + onPressed: () { + setState(() { + changeThemeToAAN(); + }); + }, ), - onPressed: () { - setState(() { - changeThemeToAAN(); - }); - }, - ), - RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7), + ElevatedButton( + style: ElevatedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), + child: const Text('UIT'), + onPressed: () { + setState(() { + changeThemeToUIT(); + }); + }, ), - color: Color(0xFF3D5AFE), - child: const Text('UIT'), - onPressed: () { - setState(() { - changeThemeToUIT(); - }); - }, - ), - ], + ], + ), ), ), Case( buttonThema == false, - builder: () => ButtonBar( - buttonHeight: 40, - buttonMinWidth: - SizeConfig.blockSizeHorizontal * 38, - alignment: MainAxisAlignment.spaceBetween, - children: [ - RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7)), - color: Color(0xFF3D5AFE), - child: const Text('AAN'), - onPressed: () { - setState( - () { - changeThemeToAAN(); - }, - ); - }, - ), - OutlineButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7)), - child: Text( - 'UIT', - style: TextStyle( - color: Theme.of(context) - .textTheme - .bodyText2 - .color, + builder: () => Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + ElevatedButton( + style: ElevatedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), + child: const Text('AAN'), + onPressed: () { + setState( + () { + changeThemeToAAN(); + }, + ); + }, + ), + OutlinedButton( + style: OutlinedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), + child: Text( + 'UIT', + style: TextStyle( + color: Theme.of(context).textTheme.bodyText2.color, + ), ), + onPressed: () { + setState( + () { + changeThemeToUIT(); + }, + ); + }, ), - onPressed: () { - setState( - () { - changeThemeToUIT(); - }, - ); - }, - ), - ], + ], + ), ), ), ], diff --git a/lib/main.dart b/lib/main.dart index cf42890..96211b9 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -19,32 +19,30 @@ void main() { MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData( - //Light theme data - textTheme: TextTheme( - bodyText2: TextStyle(color: Color(0xFF3D5AFE)), - bodyText1: TextStyle(color: Colors.black), - headline3: TextStyle(color: Colors.black)), - - scaffoldBackgroundColor: Color(0xFFf3f3f8), - cardColor: Colors.white, - shadowColor: Color(0xFFe2f1fd), - iconTheme: IconThemeData(color: Colors.black), - appBarTheme: AppBarTheme(color: Color(0xFFf3f3f8)), - bottomAppBarColor: Colors.white, - buttonTheme: ButtonThemeData( - buttonColor: Color(0xFF3D5AFE), - shape: RoundedRectangleBorder(), - textTheme: ButtonTextTheme.primary, - ), - floatingActionButtonTheme: - FloatingActionButtonThemeData(backgroundColor: Color(0xFF3D5AFE)), - ), + //Light theme data + textTheme: + TextTheme(bodyText2: TextStyle(color: Color(0xFF3D5AFE)), bodyText1: TextStyle(color: Colors.black), headline3: TextStyle(color: Colors.black)), + scaffoldBackgroundColor: Color(0xFFf3f3f8), + cardColor: Colors.white, + shadowColor: Color(0xFFe2f1fd), + iconTheme: IconThemeData(color: Colors.black), + appBarTheme: AppBarTheme(color: Color(0xFFf3f3f8)), + bottomAppBarColor: Colors.white, + // outlinedButtonTheme: OutlinedButtonThemeData(style: ButtonStyle( ),), + elevatedButtonTheme: ElevatedButtonThemeData( + style: ElevatedButton.styleFrom( + primary: Color(0xFF3D5AFE), shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(7))))), + outlinedButtonTheme: + OutlinedButtonThemeData(style: ElevatedButton.styleFrom(shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(7))))), + buttonTheme: ButtonThemeData( + buttonColor: Color(0xFF3D5AFE), + shape: RoundedRectangleBorder(), + textTheme: ButtonTextTheme.primary, + ), + floatingActionButtonTheme: FloatingActionButtonThemeData(backgroundColor: Color(0xFF3D5AFE))), darkTheme: ThemeData( //Dark theme data - textTheme: TextTheme( - bodyText2: TextStyle(color: Colors.white), - bodyText1: TextStyle(color: Colors.white), - headline3: TextStyle(color: Colors.white)), + textTheme: TextTheme(bodyText2: TextStyle(color: Colors.white), bodyText1: TextStyle(color: Colors.white), headline3: TextStyle(color: Colors.white)), scaffoldBackgroundColor: Color(0xFF2b2b2b), backgroundColor: Colors.black, @@ -52,12 +50,8 @@ void main() { iconTheme: IconThemeData(color: Colors.white), appBarTheme: AppBarTheme(color: Color(0xFF2b2b2b)), bottomAppBarColor: Color(0xFF454545), - buttonTheme: ButtonThemeData( - buttonColor: Color(0xFF3D5AFE), - shape: RoundedRectangleBorder(), - textTheme: ButtonTextTheme.primary), - floatingActionButtonTheme: - FloatingActionButtonThemeData(backgroundColor: Color(0xFF3D5AFE)), + buttonTheme: ButtonThemeData(buttonColor: Color(0xFF3D5AFE), shape: RoundedRectangleBorder(), textTheme: ButtonTextTheme.primary), + floatingActionButtonTheme: FloatingActionButtonThemeData(backgroundColor: Color(0xFF3D5AFE)), ), home: BodyOfApp(), ), @@ -216,38 +210,29 @@ class BodyOfAppState extends State { title: Text( 'Status', style: TextStyle( - color: - Theme.of(context).textTheme.bodyText1.color, + color: Theme.of(context).textTheme.bodyText1.color, ), ), ), Container( child: Conditioned( - cases: [ - Case( - buttonStatus == true, - builder: () => ButtonBar( - buttonHeight: 40, - buttonMinWidth: - SizeConfig.blockSizeHorizontal * 38, - alignment: MainAxisAlignment.spaceBetween, + cases: [ + Case( + buttonStatus == true, + builder: () => Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - OutlineButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7), - ), + OutlinedButton( + style: OutlinedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), child: Text( 'AAN', style: TextStyle( - color: Theme.of(context) - .textTheme - .bodyText2 - .color, + color: Theme.of(context).textTheme.bodyText2.color, ), ), onPressed: () { - //if (buttonStatus = true) {} setState( () { changeStateToUIT(); @@ -257,27 +242,13 @@ class BodyOfAppState extends State { ); if (timerStream == null) { timerStream = stopWatchStream(); - timerSubscription = - timerStream.listen( + timerSubscription = timerStream.listen( (int newTick) { setState( () { - hoursStr = ((newTick / - (60 * 60)) % - 60) - .floor() - .toString() - .padLeft(2, '0'); - minutesStr = - ((newTick / 60) % 60) - .floor() - .toString() - .padLeft(2, '0'); - secondsStr = - (newTick % 60) - .floor() - .toString() - .padLeft(2, '0'); + hoursStr = ((newTick / (60 * 60)) % 60).floor().toString().padLeft(2, '0'); + minutesStr = ((newTick / 60) % 60).floor().toString().padLeft(2, '0'); + secondsStr = (newTick % 60).floor().toString().padLeft(2, '0'); }, ); }, @@ -285,11 +256,8 @@ class BodyOfAppState extends State { } }, ), - RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7), - ), + ElevatedButton( + style: ElevatedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), child: Text( 'UIT', ), @@ -315,19 +283,16 @@ class BodyOfAppState extends State { ], ), ), - Case( - buttonStatus == false, - builder: () => ButtonBar( - buttonHeight: 40, - buttonMinWidth: - SizeConfig.blockSizeHorizontal * 38, - alignment: MainAxisAlignment.spaceBetween, + ), + Case( + buttonStatus == false, + builder: () => Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7), - ), + ElevatedButton( + style: ElevatedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), child: const Text('AAN'), onPressed: () { setState( @@ -339,27 +304,13 @@ class BodyOfAppState extends State { ); if (timerStream == null) { timerStream = stopWatchStream(); - timerSubscription = - timerStream.listen( + timerSubscription = timerStream.listen( (int newTick) { setState( () { - hoursStr = ((newTick / - (60 * 60)) % - 60) - .floor() - .toString() - .padLeft(2, '0'); - minutesStr = - ((newTick / 60) % 60) - .floor() - .toString() - .padLeft(2, '0'); - secondsStr = - (newTick % 60) - .floor() - .toString() - .padLeft(2, '0'); + hoursStr = ((newTick / (60 * 60)) % 60).floor().toString().padLeft(2, '0'); + minutesStr = ((newTick / 60) % 60).floor().toString().padLeft(2, '0'); + secondsStr = (newTick % 60).floor().toString().padLeft(2, '0'); }, ); }, @@ -367,18 +318,12 @@ class BodyOfAppState extends State { } }, ), - OutlineButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7), - ), + OutlinedButton( + style: OutlinedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), child: Text( 'UIT', style: TextStyle( - color: Theme.of(context) - .textTheme - .bodyText2 - .color, + color: Theme.of(context).textTheme.bodyText2.color, ), ), onPressed: () { @@ -403,10 +348,12 @@ class BodyOfAppState extends State { ], ), ), - ], - defaultBuilder: () { - return Text("Null value returned"); - }), + ), + ], + defaultBuilder: () { + return Text("Null value returned"); + }, + ), ), ], ), @@ -430,8 +377,7 @@ class BodyOfAppState extends State { title: Text( 'Snelheid', style: TextStyle( - color: - Theme.of(context).textTheme.bodyText1.color, + color: Theme.of(context).textTheme.bodyText1.color, ), ), ), @@ -439,102 +385,76 @@ class BodyOfAppState extends State { child: Conditioned( cases: [ Case(buttonSnelheid == true, - builder: () => ButtonBar( - buttonHeight: 40, - buttonMinWidth: - SizeConfig.blockSizeHorizontal * - 38, - alignment: - MainAxisAlignment.spaceBetween, - children: [ - OutlineButton( - // borderSide: BorderSide( - // width: 1, - // color: Color(0xFF3D5AFE), - // ), - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7), - ), - child: Text( - 'TRAAG', - style: TextStyle( - color: Theme.of(context) - .textTheme - .bodyText2 - .color, + builder: () => Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + OutlinedButton( + style: OutlinedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), + child: Text( + 'TRAAG', + style: TextStyle( + color: Theme.of(context).textTheme.bodyText2.color, + ), ), + onPressed: () { + setState(() { + changeStateToSNEL(); + requestURLIndex = 2; + buttonPressed(); + }); + }, ), - onPressed: () { - setState(() { - changeStateToSNEL(); - requestURLIndex = 2; - buttonPressed(); - }); - }, - ), - RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7), + ElevatedButton( + style: ElevatedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), + child: const Text('SNEL'), + onPressed: () { + setState(() { + changeStateToTRAAG(); + requestURLIndex = 3; + buttonPressed(); + }); + }, ), - child: const Text('SNEL'), - onPressed: () { - setState(() { - changeStateToTRAAG(); - requestURLIndex = 3; - buttonPressed(); - }); - }, - ), - ], + ], + ), )), Case(buttonSnelheid == false, - builder: () => ButtonBar( - buttonHeight: 40, - buttonMinWidth: - SizeConfig.blockSizeHorizontal * - 38, - alignment: - MainAxisAlignment.spaceBetween, - children: [ - RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7), - ), - child: const Text('TRAAG'), - onPressed: () { - setState(() { - changeStateToSNEL(); - requestURLIndex = 2; - buttonPressed(); - }); - }, - ), - OutlineButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7), + builder: () => Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + ElevatedButton( + style: OutlinedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), + child: const Text('TRAAG'), + onPressed: () { + setState(() { + changeStateToSNEL(); + requestURLIndex = 2; + buttonPressed(); + }); + }, ), - child: Text( - 'SNEL', - style: TextStyle( - color: Theme.of(context) - .textTheme - .bodyText2 - .color, + OutlinedButton( + style: OutlinedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), + child: Text( + 'SNEL', + style: TextStyle( + color: Theme.of(context).textTheme.bodyText2.color, + ), ), + onPressed: () { + setState(() { + changeStateToTRAAG(); + requestURLIndex = 3; + buttonPressed(); + }); + }, ), - onPressed: () { - setState(() { - changeStateToTRAAG(); - requestURLIndex = 3; - buttonPressed(); - }); - }, - ), - ], + ], + ), )), ], defaultBuilder: () => Text("Null value returned"), @@ -562,8 +482,7 @@ class BodyOfAppState extends State { title: Text( 'Richting', style: TextStyle( - color: - Theme.of(context).textTheme.bodyText1.color, + color: Theme.of(context).textTheme.bodyText1.color, ), ), ), @@ -572,100 +491,82 @@ class BodyOfAppState extends State { cases: [ Case( buttonRichting == true, - builder: () => ButtonBar( - buttonHeight: 40, - buttonMinWidth: - SizeConfig.blockSizeHorizontal * 38, - alignment: MainAxisAlignment.spaceBetween, - children: [ - OutlineButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7), - ), - child: Text( - 'OMHOOG', - style: TextStyle( - color: Theme.of(context) - .textTheme - .bodyText2 - .color, + builder: () => Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + OutlinedButton( + style: OutlinedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), + child: Text( + 'OMHOOG', + style: TextStyle( + color: Theme.of(context).textTheme.bodyText2.color, + ), ), + onPressed: () { + setState(() { + changeStateToOMLAAG(); + requestURLIndex = 4; + buttonPressed(); + }); + }, ), - onPressed: () { - setState(() { - changeStateToOMLAAG(); - requestURLIndex = 4; - buttonPressed(); - }); - }, - ), - RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7), + ElevatedButton( + style: ElevatedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), + child: const Text('OMLAAG'), + onPressed: () { + setState( + () { + changeStateToOMHOOG(); + requestURLIndex = 5; + buttonPressed(); + }, + ); + }, ), - child: const Text('OMLAAG'), - onPressed: () { - setState( - () { - changeStateToOMHOOG(); - requestURLIndex = 5; - buttonPressed(); - }, - ); - }, - ), - ], + ], + ), ), ), Case( buttonRichting == false, - builder: () => ButtonBar( - buttonHeight: 40, - buttonMinWidth: - SizeConfig.blockSizeHorizontal * 38, - alignment: MainAxisAlignment.spaceBetween, - children: [ - RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7), - ), - child: const Text('OMHOOG'), - onPressed: () { - setState( - () { - changeStateToOMLAAG(); - requestURLIndex = 4; - buttonPressed(); - }, - ); - }, - ), - OutlineButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7), + builder: () => Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + ElevatedButton( + style: ElevatedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), + child: const Text('OMHOOG'), + onPressed: () { + setState( + () { + changeStateToOMLAAG(); + requestURLIndex = 4; + buttonPressed(); + }, + ); + }, ), - child: Text( - 'OMLAAG', - style: TextStyle( - color: Theme.of(context) - .textTheme - .bodyText2 - .color, + OutlinedButton( + style: OutlinedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), + child: Text( + 'OMLAAG', + style: TextStyle( + color: Theme.of(context).textTheme.bodyText2.color, + ), ), + onPressed: () { + setState(() { + changeStateToOMHOOG(); + requestURLIndex = 5; + buttonPressed(); + }); + }, ), - onPressed: () { - setState(() { - changeStateToOMHOOG(); - requestURLIndex = 5; - buttonPressed(); - }); - }, - ), - ], + ], + ), ), ), ], @@ -693,8 +594,7 @@ class BodyOfAppState extends State { title: Text( 'Timer', style: TextStyle( - color: - Theme.of(context).textTheme.bodyText1.color, + color: Theme.of(context).textTheme.bodyText1.color, ), ), ), @@ -704,8 +604,7 @@ class BodyOfAppState extends State { "$hoursStr:$minutesStr:$secondsStr", style: TextStyle( fontSize: 16.0, - color: - Theme.of(context).textTheme.bodyText1.color, + color: Theme.of(context).textTheme.bodyText1.color, ), ), ), @@ -771,8 +670,7 @@ class BodyOfAppState extends State { IconButton( icon: Icon(Icons.settings), onPressed: () { - Navigator.push(context, - CupertinoPageRoute(builder: (context) => SettingsPage())); + Navigator.push(context, CupertinoPageRoute(builder: (context) => SettingsPage())); }, ) ], @@ -796,16 +694,9 @@ class BodyOfAppState extends State { (int newTick) { setState( () { - hoursStr = ((newTick / (60 * 60)) % 60) - .floor() - .toString() - .padLeft(2, '0'); - minutesStr = ((newTick / 60) % 60) - .floor() - .toString() - .padLeft(2, '0'); - secondsStr = - (newTick % 60).floor().toString().padLeft(2, '0'); + hoursStr = ((newTick / (60 * 60)) % 60).floor().toString().padLeft(2, '0'); + minutesStr = ((newTick / 60) % 60).floor().toString().padLeft(2, '0'); + secondsStr = (newTick % 60).floor().toString().padLeft(2, '0'); }, ); }, diff --git a/lib/mainBackup.dart b/lib/mainBackup.dart index 22f5091..96211b9 100644 --- a/lib/mainBackup.dart +++ b/lib/mainBackup.dart @@ -19,49 +19,47 @@ void main() { MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData( - //Light theme data - textTheme: TextTheme( - bodyText1: TextStyle(), - headline3: TextStyle(), - ).apply(bodyColor: Colors.black), - scaffoldBackgroundColor: Color(0xFFf3f3f8), - cardColor: Colors.white, - shadowColor: Color(0xFFe2f1fd), - iconTheme: IconThemeData(color: Colors.black), - appBarTheme: AppBarTheme(color: Color(0xFFf3f3f8)), - bottomAppBarColor: Colors.white, - buttonTheme: ButtonThemeData( - buttonColor: Color(0xFF3D5AFE), - shape: RoundedRectangleBorder(), - textTheme: ButtonTextTheme.primary, - ), - floatingActionButtonTheme: - FloatingActionButtonThemeData(backgroundColor: Color(0xFF3D5AFE)), - ), + //Light theme data + textTheme: + TextTheme(bodyText2: TextStyle(color: Color(0xFF3D5AFE)), bodyText1: TextStyle(color: Colors.black), headline3: TextStyle(color: Colors.black)), + scaffoldBackgroundColor: Color(0xFFf3f3f8), + cardColor: Colors.white, + shadowColor: Color(0xFFe2f1fd), + iconTheme: IconThemeData(color: Colors.black), + appBarTheme: AppBarTheme(color: Color(0xFFf3f3f8)), + bottomAppBarColor: Colors.white, + // outlinedButtonTheme: OutlinedButtonThemeData(style: ButtonStyle( ),), + elevatedButtonTheme: ElevatedButtonThemeData( + style: ElevatedButton.styleFrom( + primary: Color(0xFF3D5AFE), shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(7))))), + outlinedButtonTheme: + OutlinedButtonThemeData(style: ElevatedButton.styleFrom(shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(7))))), + buttonTheme: ButtonThemeData( + buttonColor: Color(0xFF3D5AFE), + shape: RoundedRectangleBorder(), + textTheme: ButtonTextTheme.primary, + ), + floatingActionButtonTheme: FloatingActionButtonThemeData(backgroundColor: Color(0xFF3D5AFE))), darkTheme: ThemeData( //Dark theme data - textTheme: TextTheme( - bodyText1: TextStyle(), - headline3: TextStyle(), - ).apply(bodyColor: Colors.white), + textTheme: TextTheme(bodyText2: TextStyle(color: Colors.white), bodyText1: TextStyle(color: Colors.white), headline3: TextStyle(color: Colors.white)), + scaffoldBackgroundColor: Color(0xFF2b2b2b), backgroundColor: Colors.black, cardColor: Color(0xFF454545), iconTheme: IconThemeData(color: Colors.white), appBarTheme: AppBarTheme(color: Color(0xFF2b2b2b)), bottomAppBarColor: Color(0xFF454545), - buttonTheme: ButtonThemeData( - buttonColor: Color(0xFF3D5AFE), - shape: RoundedRectangleBorder(), - textTheme: ButtonTextTheme.primary), - floatingActionButtonTheme: - FloatingActionButtonThemeData(backgroundColor: Color(0xFF3D5AFE)), + buttonTheme: ButtonThemeData(buttonColor: Color(0xFF3D5AFE), shape: RoundedRectangleBorder(), textTheme: ButtonTextTheme.primary), + floatingActionButtonTheme: FloatingActionButtonThemeData(backgroundColor: Color(0xFF3D5AFE)), ), home: BodyOfApp(), ), ); } +bool timerIsRunning = true; + class BodyOfApp extends StatefulWidget { @override BodyOfAppState createState() => BodyOfAppState(); @@ -169,6 +167,8 @@ class BodyOfAppState extends State { return streamController.stream; } + void startStopWatch() {} + @override Widget build(BuildContext context) { SizeConfig().init(context); @@ -210,29 +210,27 @@ class BodyOfAppState extends State { title: Text( 'Status', style: TextStyle( - color: - Theme.of(context).textTheme.bodyText1.color, + color: Theme.of(context).textTheme.bodyText1.color, ), ), ), Container( child: Conditioned( - cases: [ - Case( - buttonStatus == true, - builder: () => ButtonBar( - buttonHeight: 40, - buttonMinWidth: - SizeConfig.blockSizeHorizontal * 38, - alignment: MainAxisAlignment.spaceBetween, + cases: [ + Case( + buttonStatus == true, + builder: () => Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - OutlineButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7), - ), - child: const Text( + OutlinedButton( + style: OutlinedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), + child: Text( 'AAN', + style: TextStyle( + color: Theme.of(context).textTheme.bodyText2.color, + ), ), onPressed: () { setState( @@ -242,38 +240,24 @@ class BodyOfAppState extends State { buttonPressed(); }, ); - timerStream = stopWatchStream(); - timerSubscription = - timerStream.listen( - (int newTick) { - setState( - () { - hoursStr = - ((newTick / (60 * 60)) % - 60) - .floor() - .toString() - .padLeft(2, '0'); - minutesStr = - ((newTick / 60) % 60) - .floor() - .toString() - .padLeft(2, '0'); - secondsStr = (newTick % 60) - .floor() - .toString() - .padLeft(2, '0'); - }, - ); - }, - ); + if (timerStream == null) { + timerStream = stopWatchStream(); + timerSubscription = timerStream.listen( + (int newTick) { + setState( + () { + hoursStr = ((newTick / (60 * 60)) % 60).floor().toString().padLeft(2, '0'); + minutesStr = ((newTick / 60) % 60).floor().toString().padLeft(2, '0'); + secondsStr = (newTick % 60).floor().toString().padLeft(2, '0'); + }, + ); + }, + ); + } }, ), - RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7), - ), + ElevatedButton( + style: ElevatedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), child: Text( 'UIT', ), @@ -299,19 +283,16 @@ class BodyOfAppState extends State { ], ), ), - Case( - buttonStatus == false, - builder: () => ButtonBar( - buttonHeight: 40, - buttonMinWidth: - SizeConfig.blockSizeHorizontal * 38, - alignment: MainAxisAlignment.spaceBetween, + ), + Case( + buttonStatus == false, + builder: () => Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7), - ), + ElevatedButton( + style: ElevatedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), child: const Text('AAN'), onPressed: () { setState( @@ -321,39 +302,30 @@ class BodyOfAppState extends State { buttonPressed(); }, ); - timerStream = stopWatchStream(); - timerSubscription = - timerStream.listen( - (int newTick) { - setState( - () { - hoursStr = - ((newTick / (60 * 60)) % - 60) - .floor() - .toString() - .padLeft(2, '0'); - minutesStr = - ((newTick / 60) % 60) - .floor() - .toString() - .padLeft(2, '0'); - secondsStr = (newTick % 60) - .floor() - .toString() - .padLeft(2, '0'); - }, - ); - }, - ); + if (timerStream == null) { + timerStream = stopWatchStream(); + timerSubscription = timerStream.listen( + (int newTick) { + setState( + () { + hoursStr = ((newTick / (60 * 60)) % 60).floor().toString().padLeft(2, '0'); + minutesStr = ((newTick / 60) % 60).floor().toString().padLeft(2, '0'); + secondsStr = (newTick % 60).floor().toString().padLeft(2, '0'); + }, + ); + }, + ); + } }, ), - OutlineButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7), + OutlinedButton( + style: OutlinedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), + child: Text( + 'UIT', + style: TextStyle( + color: Theme.of(context).textTheme.bodyText2.color, + ), ), - child: const Text('UIT'), onPressed: () { setState( () { @@ -376,10 +348,12 @@ class BodyOfAppState extends State { ], ), ), - ], - defaultBuilder: () { - return Text("Null value returned"); - }), + ), + ], + defaultBuilder: () { + return Text("Null value returned"); + }, + ), ), ], ), @@ -403,8 +377,7 @@ class BodyOfAppState extends State { title: Text( 'Snelheid', style: TextStyle( - color: - Theme.of(context).textTheme.bodyText1.color, + color: Theme.of(context).textTheme.bodyText1.color, ), ), ), @@ -412,82 +385,76 @@ class BodyOfAppState extends State { child: Conditioned( cases: [ Case(buttonSnelheid == true, - builder: () => ButtonBar( - buttonHeight: 40, - buttonMinWidth: - SizeConfig.blockSizeHorizontal * - 38, - alignment: - MainAxisAlignment.spaceBetween, - children: [ - OutlineButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7), + builder: () => Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + OutlinedButton( + style: OutlinedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), + child: Text( + 'TRAAG', + style: TextStyle( + color: Theme.of(context).textTheme.bodyText2.color, + ), + ), + onPressed: () { + setState(() { + changeStateToSNEL(); + requestURLIndex = 2; + buttonPressed(); + }); + }, ), - child: const Text('TRAAG'), - onPressed: () { - setState(() { - changeStateToSNEL(); - requestURLIndex = 2; - buttonPressed(); - }); - }, - ), - RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7), + ElevatedButton( + style: ElevatedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), + child: const Text('SNEL'), + onPressed: () { + setState(() { + changeStateToTRAAG(); + requestURLIndex = 3; + buttonPressed(); + }); + }, ), - child: const Text('SNEL'), - onPressed: () { - setState(() { - changeStateToTRAAG(); - requestURLIndex = 3; - buttonPressed(); - }); - }, - ), - ], + ], + ), )), Case(buttonSnelheid == false, - builder: () => ButtonBar( - buttonHeight: 40, - buttonMinWidth: - SizeConfig.blockSizeHorizontal * - 38, - alignment: - MainAxisAlignment.spaceBetween, - children: [ - RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7), + builder: () => Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + ElevatedButton( + style: OutlinedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), + child: const Text('TRAAG'), + onPressed: () { + setState(() { + changeStateToSNEL(); + requestURLIndex = 2; + buttonPressed(); + }); + }, ), - child: const Text('TRAAG'), - onPressed: () { - setState(() { - changeStateToSNEL(); - requestURLIndex = 2; - buttonPressed(); - }); - }, - ), - OutlineButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7), + OutlinedButton( + style: OutlinedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), + child: Text( + 'SNEL', + style: TextStyle( + color: Theme.of(context).textTheme.bodyText2.color, + ), + ), + onPressed: () { + setState(() { + changeStateToTRAAG(); + requestURLIndex = 3; + buttonPressed(); + }); + }, ), - child: const Text('SNEL'), - onPressed: () { - setState(() { - changeStateToTRAAG(); - requestURLIndex = 3; - buttonPressed(); - }); - }, - ), - ], + ], + ), )), ], defaultBuilder: () => Text("Null value returned"), @@ -515,8 +482,7 @@ class BodyOfAppState extends State { title: Text( 'Richting', style: TextStyle( - color: - Theme.of(context).textTheme.bodyText1.color, + color: Theme.of(context).textTheme.bodyText1.color, ), ), ), @@ -525,84 +491,82 @@ class BodyOfAppState extends State { cases: [ Case( buttonRichting == true, - builder: () => ButtonBar( - buttonHeight: 40, - buttonMinWidth: - SizeConfig.blockSizeHorizontal * 38, - alignment: MainAxisAlignment.spaceBetween, - children: [ - OutlineButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7), + builder: () => Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + OutlinedButton( + style: OutlinedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), + child: Text( + 'OMHOOG', + style: TextStyle( + color: Theme.of(context).textTheme.bodyText2.color, + ), + ), + onPressed: () { + setState(() { + changeStateToOMLAAG(); + requestURLIndex = 4; + buttonPressed(); + }); + }, ), - child: const Text('OMHOOG'), - onPressed: () { - setState(() { - changeStateToOMLAAG(); - requestURLIndex = 4; - buttonPressed(); - }); - }, - ), - RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7), + ElevatedButton( + style: ElevatedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), + child: const Text('OMLAAG'), + onPressed: () { + setState( + () { + changeStateToOMHOOG(); + requestURLIndex = 5; + buttonPressed(); + }, + ); + }, ), - child: const Text('OMLAAG'), - onPressed: () { - setState( - () { - changeStateToOMHOOG(); - requestURLIndex = 5; - buttonPressed(); - }, - ); - }, - ), - ], + ], + ), ), ), Case( buttonRichting == false, - builder: () => ButtonBar( - buttonHeight: 40, - buttonMinWidth: - SizeConfig.blockSizeHorizontal * 38, - alignment: MainAxisAlignment.spaceBetween, - children: [ - RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7), + builder: () => Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + ElevatedButton( + style: ElevatedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), + child: const Text('OMHOOG'), + onPressed: () { + setState( + () { + changeStateToOMLAAG(); + requestURLIndex = 4; + buttonPressed(); + }, + ); + }, ), - child: const Text('OMHOOG'), - onPressed: () { - setState( - () { - changeStateToOMLAAG(); - requestURLIndex = 4; + OutlinedButton( + style: OutlinedButton.styleFrom(minimumSize: Size(SizeConfig.blockSizeHorizontal * 38, 40)), + child: Text( + 'OMLAAG', + style: TextStyle( + color: Theme.of(context).textTheme.bodyText2.color, + ), + ), + onPressed: () { + setState(() { + changeStateToOMHOOG(); + requestURLIndex = 5; buttonPressed(); - }, - ); - }, - ), - OutlineButton( - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(7), + }); + }, ), - child: const Text('OMLAAG'), - onPressed: () { - setState(() { - changeStateToOMHOOG(); - requestURLIndex = 5; - buttonPressed(); - }); - }, - ), - ], + ], + ), ), ), ], @@ -630,8 +594,7 @@ class BodyOfAppState extends State { title: Text( 'Timer', style: TextStyle( - color: - Theme.of(context).textTheme.bodyText1.color, + color: Theme.of(context).textTheme.bodyText1.color, ), ), ), @@ -641,8 +604,7 @@ class BodyOfAppState extends State { "$hoursStr:$minutesStr:$secondsStr", style: TextStyle( fontSize: 16.0, - color: - Theme.of(context).textTheme.bodyText1.color, + color: Theme.of(context).textTheme.bodyText1.color, ), ), ), @@ -653,7 +615,7 @@ class BodyOfAppState extends State { height: 15, ), SizedBox( - height: 200, + height: 150, ), ], ), @@ -708,8 +670,7 @@ class BodyOfAppState extends State { IconButton( icon: Icon(Icons.settings), onPressed: () { - Navigator.push(context, - CupertinoPageRoute(builder: (context) => SettingsPage())); + Navigator.push(context, CupertinoPageRoute(builder: (context) => SettingsPage())); }, ) ], @@ -733,16 +694,9 @@ class BodyOfAppState extends State { (int newTick) { setState( () { - hoursStr = ((newTick / (60 * 60)) % 60) - .floor() - .toString() - .padLeft(2, '0'); - minutesStr = ((newTick / 60) % 60) - .floor() - .toString() - .padLeft(2, '0'); - secondsStr = - (newTick % 60).floor().toString().padLeft(2, '0'); + hoursStr = ((newTick / (60 * 60)) % 60).floor().toString().padLeft(2, '0'); + minutesStr = ((newTick / 60) % 60).floor().toString().padLeft(2, '0'); + secondsStr = (newTick % 60).floor().toString().padLeft(2, '0'); }, ); }, diff --git a/pubspec.lock b/pubspec.lock index dab4287..e5e44cf 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,42 +7,42 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.1" + version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.3" + version: "1.15.0" condition: dependency: "direct main" description: @@ -63,7 +63,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -93,27 +93,34 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.4" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.3" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.1" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.1" + version: "1.8.0" pedantic: dependency: transitive description: @@ -139,49 +146,49 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.2" + version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.1" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.2" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" url_launcher: dependency: "direct main" description: @@ -230,7 +237,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" weather: dependency: "direct main" description: @@ -239,5 +246,5 @@ packages: source: hosted version: "1.2.4" sdks: - dart: ">=2.10.0-110 <2.11.0" - flutter: ">=1.22.0 <2.0.0" + dart: ">=2.12.0-0.0 <3.0.0" + flutter: ">=1.22.0"