From 27ce7ff12f02bb05263e7752433034a3827c407f Mon Sep 17 00:00:00 2001 From: urmilshroff Date: Sat, 29 Jun 2019 12:03:47 +0530 Subject: [PATCH] Improved code formatting --- lib/main.dart | 27 +-- lib/pages/about_page.dart | 334 +++++++++++++++++++------------------- lib/pages/edit_page.dart | 58 +++---- lib/pages/goals_page.dart | 128 +++++++-------- lib/utils/widgets.dart | 23 +-- 5 files changed, 289 insertions(+), 281 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 58cd5ea..5176ee6 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -9,18 +9,19 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return DynamicTheme( - defaultBrightness: Brightness.light, - data: (brightness) => new ThemeData( - primaryColor: MyColors.primaryColor, - accentColor: MyColors.accentColor, - brightness: brightness, - ), - themedWidgetBuilder: (context, theme) { - return MaterialApp( - title: "Goalkeeper", - theme: theme, - home: GoalsPage(), - ); - }); + defaultBrightness: Brightness.light, + data: (brightness) => new ThemeData( + primaryColor: MyColors.primaryColor, + accentColor: MyColors.accentColor, + brightness: brightness, + ), + themedWidgetBuilder: (context, theme) { + return MaterialApp( + title: "Goalkeeper", + theme: theme, + home: GoalsPage(), + ); + }, + ); } } diff --git a/lib/pages/about_page.dart b/lib/pages/about_page.dart index 2c1c90b..fae3151 100644 --- a/lib/pages/about_page.dart +++ b/lib/pages/about_page.dart @@ -14,195 +14,199 @@ Widget buildAboutPage(BuildContext context) { Padding( padding: const EdgeInsets.all(10.0), child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - width: 75.0, - height: 75.0, - decoration: BoxDecoration( - shape: BoxShape.circle, - image: DecorationImage( - image: AssetImage("assets/urmil-vector.png")))), - SizedBox( - height: 10, - ), - Center( - child: Text(" by", - style: TextStyle( - color: invertColors(context), - fontWeight: FontWeight.w500)), - ), - SizedBox( - height: 5, - ), - Center( - child: Text("Urmil Shroff", - style: TextStyle( - color: invertColors(context), - fontWeight: FontWeight.w600, - fontSize: 20.0)), - ), - ]), + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + width: 75.0, + height: 75.0, + decoration: BoxDecoration( + shape: BoxShape.circle, + image: DecorationImage( + image: AssetImage("assets/urmil-vector.png")))), + SizedBox( + height: 10, + ), + Center( + child: Text(" by", + style: TextStyle( + color: invertColors(context), + fontWeight: FontWeight.w500)), + ), + SizedBox( + height: 5, + ), + Center( + child: Text("Urmil Shroff", + style: TextStyle( + color: invertColors(context), + fontWeight: FontWeight.w600, + fontSize: 20.0)), + ), + ], + ), ), ), buildTile( Padding( padding: const EdgeInsets.all(10.0), child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Center( - child: Text("Connect", - style: TextStyle( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Center( + child: Text("Connect", + style: TextStyle( + color: invertColors(context), + fontWeight: FontWeight.w500)), + ), + SizedBox( + height: 5, + ), + Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + GestureDetector( + child: IconButton( + icon: Icon(EvaIcons.person), color: invertColors(context), - fontWeight: FontWeight.w500)), - ), - SizedBox( - height: 5, - ), - Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - GestureDetector( - child: IconButton( - icon: Icon(EvaIcons.person), - color: invertColors(context), - onPressed: () => - launchURL('https://urmilshroff.tech/')), - ), - GestureDetector( - child: IconButton( - icon: Icon(EvaIcons.twitter), - color: invertColors(context), - onPressed: () => - launchURL('https://twitter.com/urmilshroff')), - ), - GestureDetector( - child: IconButton( - icon: Icon(EvaIcons.github), - color: invertColors(context), - onPressed: () => - launchURL('https://github.com/urmilshroff')), - ), - ], - ), + onPressed: () => + launchURL('https://urmilshroff.tech/')), + ), + GestureDetector( + child: IconButton( + icon: Icon(EvaIcons.twitter), + color: invertColors(context), + onPressed: () => + launchURL('https://twitter.com/urmilshroff')), + ), + GestureDetector( + child: IconButton( + icon: Icon(EvaIcons.github), + color: invertColors(context), + onPressed: () => + launchURL('https://github.com/urmilshroff')), + ), + ], ), - ]), + ), + ], + ), ), ), buildTile( Padding( padding: const EdgeInsets.all(10.0), child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Center( - child: Text("Support", - style: TextStyle( - color: invertColors(context), - fontWeight: FontWeight.w500)), - ), - SizedBox( - height: 5, - ), - Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - width: _width, - child: Column( - children: [ - Text( - "Like the app? Show your support by writing" - " a review on the Play Store, starring it on" - " GitHub and sharing it with your " - "friends!", - style: TextStyle( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Center( + child: Text("Support", + style: TextStyle( + color: invertColors(context), + fontWeight: FontWeight.w500)), + ), + SizedBox( + height: 5, + ), + Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + width: _width, + child: Column( + children: [ + Text( + "Like the app? Show your support by writing" + " a review on the Play Store, starring it on" + " GitHub and sharing it with your " + "friends!", + style: TextStyle( + color: invertColors(context), + fontSize: 16.0)), + Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + GestureDetector( + child: IconButton( + icon: Icon(EvaIcons.edit), + color: invertColors(context), + onPressed: () => launchURL( + 'https://play.google.com/store/apps/details?id=tech.urmilshroff.goalkeeper')), + ), + GestureDetector( + child: IconButton( + icon: Icon(EvaIcons.star), color: invertColors(context), - fontSize: 16.0)), - Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - GestureDetector( - child: IconButton( - icon: Icon(EvaIcons.edit), - color: invertColors(context), - onPressed: () => launchURL( - 'https://play.google.com/store/apps/details?id=tech.urmilshroff.goalkeeper')), - ), - GestureDetector( - child: IconButton( - icon: Icon(EvaIcons.star), - color: invertColors(context), - onPressed: () => launchURL( - 'https://github.com/urmilshroff/goalkeeper')), - ), - ], - ) - ], - ), - ) - ], - ), + onPressed: () => launchURL( + 'https://github.com/urmilshroff/goalkeeper')), + ), + ], + ) + ], + ), + ) + ], ), - ]), + ), + ], + ), ), ), buildTile( Padding( padding: const EdgeInsets.all(10.0), child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Center( - child: Text("Feedback", - style: TextStyle( - color: invertColors(context), - fontWeight: FontWeight.w500)), - ), - SizedBox( - height: 5, - ), - Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - width: _width, - child: Column( - children: [ - Text( - "Bugs found? Feature suggestions? Create a " - "new issue on GitHub to let me know, or" - " contribute by forking and sending a " - "PR!", - style: TextStyle( - color: invertColors(context), - fontSize: 16.0)), - GestureDetector( - child: IconButton( - icon: Icon(EvaIcons.github), + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Center( + child: Text("Feedback", + style: TextStyle( + color: invertColors(context), + fontWeight: FontWeight.w500)), + ), + SizedBox( + height: 5, + ), + Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + width: _width, + child: Column( + children: [ + Text( + "Bugs found? Feature suggestions? Create a " + "new issue on GitHub to let me know, or" + " contribute by forking and sending a " + "PR!", + style: TextStyle( color: invertColors(context), - onPressed: () => launchURL( - 'https://github.com/urmilshroff/goalkeeper')), - ), - ], - ), - ) - ], - ), + fontSize: 16.0)), + GestureDetector( + child: IconButton( + icon: Icon(EvaIcons.github), + color: invertColors(context), + onPressed: () => launchURL( + 'https://github.com/urmilshroff/goalkeeper')), + ), + ], + ), + ) + ], ), - ]), + ), + ], + ), ), ), SizedBox( diff --git a/lib/pages/edit_page.dart b/lib/pages/edit_page.dart index 3929369..c7372c2 100644 --- a/lib/pages/edit_page.dart +++ b/lib/pages/edit_page.dart @@ -178,34 +178,36 @@ class EditGoalState extends State { void deleteGoal() async { showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - title: Text("Done with \'${goal.title}\'?", - style: TextStyle( - color: invertColors(context), - fontWeight: FontWeight.w600)), - content: Text("This goal will be deleted!", + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: Text("Done with \'${goal.title}\'?", + style: TextStyle( + color: invertColors(context), fontWeight: FontWeight.w600)), + content: Text("This goal will be deleted!", + style: TextStyle( + color: invertColors(context), + )), + actions: [ + FlatButton( + child: Text('CANCEL', + style: TextStyle( + color: invertColors(context), + fontWeight: FontWeight.w500)), + onPressed: () => Navigator.of(context).pop()), + FlatButton( + child: Text('DELETE', style: TextStyle( - color: invertColors(context), - )), - actions: [ - FlatButton( - child: Text('CANCEL', - style: TextStyle( - color: invertColors(context), - fontWeight: FontWeight.w500)), - onPressed: () => Navigator.of(context).pop()), - FlatButton( - child: Text('DELETE', - style: TextStyle( - color: MyColors.red, fontWeight: FontWeight.w500)), - onPressed: () async { - Navigator.of(context).pop(); - Navigator.of(context).pop(); - await helper.deleteGoal(goal.id); - }) - ]); - }); + color: MyColors.red, fontWeight: FontWeight.w500)), + onPressed: () async { + Navigator.of(context).pop(); + Navigator.of(context).pop(); + await helper.deleteGoal(goal.id); + }, + ), + ], + ); + }, + ); } } diff --git a/lib/pages/goals_page.dart b/lib/pages/goals_page.dart index a9e3c48..5c769c7 100644 --- a/lib/pages/goals_page.dart +++ b/lib/pages/goals_page.dart @@ -70,71 +70,71 @@ class _GoalsPageState extends State { Padding( padding: const EdgeInsets.all(10.0), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Column( - children: [ - Hero( - tag: "dartIcon${this.goalsList[id].index}", - child: Container( - width: 40.0, - height: 40.0, - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage("assets/icon.png")))), + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Column( + children: [ + Hero( + tag: "dartIcon${this.goalsList[id].index}", + child: Container( + width: 40.0, + height: 40.0, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/icon.png")))), + ), + ], + ), + SizedBox( + width: 10.0, + ), + Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text("Goal #${id + 1}", + style: TextStyle( + color: MyColors.accentColor, + fontWeight: FontWeight.w500)), + SizedBox( + height: 3.0, + ), + Container( + width: _width, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + this.goalsList[id].title, + style: TextStyle( + color: invertColors(context), + fontWeight: FontWeight.w600, + fontSize: 20.0), + softWrap: false, + overflow: TextOverflow.ellipsis, + maxLines: 1, + ), + SizedBox( + height: 3.0, + ), + Text( + this.goalsList[id].body, + style: TextStyle( + color: invertColors(context), fontSize: 16.0), + softWrap: true, + overflow: TextOverflow.ellipsis, + maxLines: 5, + ), + ], ), - ], - ), - SizedBox( - width: 10.0, - ), - Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text("Goal #${id + 1}", - style: TextStyle( - color: MyColors.accentColor, - fontWeight: FontWeight.w500)), - SizedBox( - height: 3.0, - ), - Container( - width: _width, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - this.goalsList[id].title, - style: TextStyle( - color: invertColors(context), - fontWeight: FontWeight.w600, - fontSize: 20.0), - softWrap: false, - overflow: TextOverflow.ellipsis, - maxLines: 1, - ), - SizedBox( - height: 3.0, - ), - Text( - this.goalsList[id].body, - style: TextStyle( - color: invertColors(context), - fontSize: 16.0), - softWrap: true, - overflow: TextOverflow.ellipsis, - maxLines: 5, - ), - ], - ), - ), - ], - ), - Spacer(), - ]), + ), + ], + ), + Spacer(), + ], + ), ), onTap: () => navigateToEditGoal(this.goalsList[id]), ); diff --git a/lib/utils/widgets.dart b/lib/utils/widgets.dart index b1b5035..320a89b 100644 --- a/lib/utils/widgets.dart +++ b/lib/utils/widgets.dart @@ -9,17 +9,18 @@ Widget buildTile(Widget widgetContent, {Function() onTap}) { return Container( margin: const EdgeInsets.all(5.0), child: Material( - elevation: 3.0, - borderRadius: BorderRadius.circular(8.0), - child: InkWell( - onTap: onTap != null - ? () => onTap() - : () { - print("Nothing set"); - }, - child: widgetContent, - splashColor: MyColors.accentColor, - )), + elevation: 3.0, + borderRadius: BorderRadius.circular(8.0), + child: InkWell( + onTap: onTap != null + ? () => onTap() + : () { + print("Nothing set"); + }, + child: widgetContent, + splashColor: MyColors.accentColor, + ), + ), ); } //build material goal card