From 0637bd0d4ddf2d31c0ae3adcb9323a4fe57bdd19 Mon Sep 17 00:00:00 2001 From: Moutia Benachour Date: Sun, 11 Sep 2022 17:18:42 +0100 Subject: [PATCH] extract button styles --- lib/screens/login.dart | 12 +++--------- lib/screens/register/register_step_1.dart | 11 ++--------- lib/screens/register/register_step_2.dart | 10 ++-------- lib/widgets/buttons.dart | 11 +++++++++++ 4 files changed, 18 insertions(+), 26 deletions(-) create mode 100644 lib/widgets/buttons.dart diff --git a/lib/screens/login.dart b/lib/screens/login.dart index 480b49b..b1fd39d 100644 --- a/lib/screens/login.dart +++ b/lib/screens/login.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:pin_code_fields/pin_code_fields.dart'; import 'package:robo_advisory/utils/constants.dart'; import 'package:robo_advisory/config/Routes.dart'; +import 'package:robo_advisory/widgets/buttons.dart'; class LoginScreen extends StatelessWidget { bool rememberSwitch = false; @@ -21,7 +22,7 @@ class LoginScreen extends StatelessWidget { Expanded( child: Container( child: Center( - child: TextButton( + child: ElevatedButton( onPressed: () { Navigator.pushNamed(context, Routes.register); }, @@ -123,14 +124,7 @@ class LoginScreen extends StatelessWidget { SizedBox( width: double.infinity, child: ElevatedButton( - style: ElevatedButton.styleFrom( - padding: EdgeInsets.all(18.0), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(18.0), - ), - backgroundColor:Color(0xFF495057), - foregroundColor: Colors.white, - ), + style: mainButtonStyle(), onPressed: () { Navigator.pushNamed(context, Routes.dashboard); }, diff --git a/lib/screens/register/register_step_1.dart b/lib/screens/register/register_step_1.dart index a882fb4..9f10120 100644 --- a/lib/screens/register/register_step_1.dart +++ b/lib/screens/register/register_step_1.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:pin_code_fields/pin_code_fields.dart'; import 'package:robo_advisory/utils/constants.dart'; import 'package:robo_advisory/screens/register/register_step_2.dart'; +import 'package:robo_advisory/widgets/buttons.dart'; class RegisterFirstScreen extends StatelessWidget { @override @@ -90,15 +91,7 @@ class RegisterFirstScreen extends StatelessWidget { SizedBox( width: double.infinity, child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: Color(0xFF495057), - foregroundColor: Colors.white, - padding: EdgeInsets.all(18.0), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(18.0), - ), - ), - + style: mainButtonStyle(), onPressed: () { Navigator.push( context, diff --git a/lib/screens/register/register_step_2.dart b/lib/screens/register/register_step_2.dart index 034c99c..c2af72c 100644 --- a/lib/screens/register/register_step_2.dart +++ b/lib/screens/register/register_step_2.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:robo_advisory/utils/constants.dart'; import 'package:robo_advisory/config/Routes.dart'; +import 'package:robo_advisory/widgets/buttons.dart'; class RegisterSecondScreen extends StatelessWidget { @override @@ -57,14 +58,7 @@ class RegisterSecondScreen extends StatelessWidget { SizedBox( width: double.infinity, child: ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: Color(0xFF495057), - foregroundColor: Colors.white, - padding: EdgeInsets.all(18.0), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(18.0), - ), - ), + style: mainButtonStyle(), onPressed: () { Navigator.pushNamed(context, Routes.dashboard); print('Next Step'); diff --git a/lib/widgets/buttons.dart b/lib/widgets/buttons.dart new file mode 100644 index 0000000..0bf95de --- /dev/null +++ b/lib/widgets/buttons.dart @@ -0,0 +1,11 @@ +import 'package:flutter/material.dart'; + +mainButtonStyle() { + return ElevatedButton.styleFrom( + backgroundColor: Color(0xFF495057), + foregroundColor: Colors.white, + padding: EdgeInsets.all(18.0), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(18.0), + )); +}