From 1d01365f06289fccaa2685093d032f3ffeb6f0ed Mon Sep 17 00:00:00 2001 From: Melvyn Date: Thu, 3 Nov 2022 18:04:27 -0700 Subject: [PATCH] [Migration] RaisedButton to ElevatedButton and FlatButton to TextButton --- lib/screens/elements.dart | 98 +++++++++++++++++++--------------- lib/screens/onboarding.dart | 14 ++--- lib/screens/pro.dart | 14 ++--- lib/screens/register.dart | 40 ++++++++------ lib/widgets/button.dart | 15 ++++-- lib/widgets/card-shopping.dart | 42 ++++++++------- 6 files changed, 131 insertions(+), 92 deletions(-) diff --git a/lib/screens/elements.dart b/lib/screens/elements.dart index 0a91bc8..64e52bd 100644 --- a/lib/screens/elements.dart +++ b/lib/screens/elements.dart @@ -55,16 +55,18 @@ class _ElementsState extends State { child: Padding( padding: const EdgeInsets.only(left: 34.0, right: 34.0, top: 16), - child: RaisedButton( - textColor: ArgonColors.white, - color: ArgonColors.initial, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + foregroundColor: ArgonColors.white, + backgroundColor: ArgonColors.initial, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(4.0), + ), + ), onPressed: () { // Respond to button press Navigator.pushReplacementNamed(context, '/home'); }, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(4.0), - ), child: Padding( padding: EdgeInsets.only( left: 16.0, right: 16.0, top: 12, bottom: 12), @@ -79,16 +81,18 @@ class _ElementsState extends State { child: Padding( padding: const EdgeInsets.only(left: 34.0, right: 34.0, top: 8), - child: RaisedButton( - textColor: ArgonColors.text, - color: ArgonColors.secondary, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + foregroundColor: ArgonColors.text, + backgroundColor: ArgonColors.secondary, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(4.0), + ), + ), onPressed: () { // Respond to button press Navigator.pushReplacementNamed(context, '/home'); }, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(4.0), - ), child: Padding( padding: EdgeInsets.only( left: 16.0, right: 16.0, top: 12, bottom: 12), @@ -103,16 +107,18 @@ class _ElementsState extends State { child: Padding( padding: const EdgeInsets.only(left: 34.0, right: 34.0, top: 8), - child: RaisedButton( - textColor: ArgonColors.white, - color: ArgonColors.primary, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + foregroundColor: ArgonColors.white, + backgroundColor: ArgonColors.primary, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(4.0), + ), + ), onPressed: () { // Respond to button press Navigator.pushReplacementNamed(context, '/home'); }, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(4.0), - ), child: Padding( padding: EdgeInsets.only( left: 16.0, right: 16.0, top: 12, bottom: 12), @@ -127,16 +133,18 @@ class _ElementsState extends State { child: Padding( padding: const EdgeInsets.only(left: 34.0, right: 34.0, top: 8), - child: RaisedButton( - textColor: ArgonColors.white, - color: ArgonColors.info, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + foregroundColor: ArgonColors.white, + backgroundColor: ArgonColors.info, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(4.0), + ), + ), onPressed: () { // Respond to button press Navigator.pushReplacementNamed(context, '/home'); }, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(4.0), - ), child: Padding( padding: EdgeInsets.only( left: 16.0, right: 16.0, top: 12, bottom: 12), @@ -151,16 +159,18 @@ class _ElementsState extends State { child: Padding( padding: const EdgeInsets.only(left: 34.0, right: 34.0, top: 8), - child: RaisedButton( - textColor: ArgonColors.white, - color: ArgonColors.success, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + foregroundColor: ArgonColors.white, + backgroundColor: ArgonColors.success, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(4.0), + ), + ), onPressed: () { // Respond to button press Navigator.pushReplacementNamed(context, '/home'); }, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(4.0), - ), child: Padding( padding: EdgeInsets.only( left: 16.0, right: 16.0, top: 12, bottom: 12), @@ -175,16 +185,18 @@ class _ElementsState extends State { child: Padding( padding: const EdgeInsets.only(left: 34.0, right: 34.0, top: 8), - child: RaisedButton( - textColor: ArgonColors.white, - color: ArgonColors.warning, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + foregroundColor: ArgonColors.white, + backgroundColor: ArgonColors.warning, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(4.0), + ), + ), onPressed: () { // Respond to button press Navigator.pushReplacementNamed(context, '/home'); }, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(4.0), - ), child: Padding( padding: EdgeInsets.only( left: 16.0, right: 16.0, top: 12, bottom: 12), @@ -199,16 +211,18 @@ class _ElementsState extends State { child: Padding( padding: const EdgeInsets.only(left: 34.0, right: 34.0, top: 8), - child: RaisedButton( - textColor: ArgonColors.white, - color: ArgonColors.error, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + foregroundColor: ArgonColors.white, + backgroundColor: ArgonColors.error, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(4.0), + ), + ), onPressed: () { // Respond to button press Navigator.pushReplacementNamed(context, '/home'); }, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(4.0), - ), child: Padding( padding: EdgeInsets.only( left: 16.0, right: 16.0, top: 12, bottom: 12), diff --git a/lib/screens/onboarding.dart b/lib/screens/onboarding.dart index c30a437..431b15b 100644 --- a/lib/screens/onboarding.dart +++ b/lib/screens/onboarding.dart @@ -51,15 +51,17 @@ class Onboarding extends StatelessWidget { padding: const EdgeInsets.only(top: 16.0), child: SizedBox( width: double.infinity, - child: FlatButton( - textColor: ArgonColors.text, - color: ArgonColors.secondary, + child: TextButton( + style: TextButton.styleFrom( + foregroundColor: ArgonColors.text, + backgroundColor: ArgonColors.secondary, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(4.0), + ), + ), onPressed: () { Navigator.pushReplacementNamed(context, '/home'); }, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(4.0), - ), child: Padding( padding: EdgeInsets.only( left: 16.0, right: 16.0, top: 12, bottom: 12), diff --git a/lib/screens/pro.dart b/lib/screens/pro.dart index 73b0dbf..6d7dabd 100644 --- a/lib/screens/pro.dart +++ b/lib/screens/pro.dart @@ -83,13 +83,15 @@ class Pro extends StatelessWidget { padding: const EdgeInsets.only(top: 16.0), child: SizedBox( width: double.infinity, - child: FlatButton( - textColor: ArgonColors.white, - color: ArgonColors.info, - onPressed: _launchURL, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(4.0), + child: TextButton( + style: TextButton.styleFrom( + foregroundColor: ArgonColors.white, + backgroundColor: ArgonColors.info, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(4.0), + ), ), + onPressed: _launchURL, child: Padding( padding: EdgeInsets.only( left: 16.0, right: 16.0, top: 12, bottom: 12), diff --git a/lib/screens/register.dart b/lib/screens/register.dart index d859e19..43c94f5 100644 --- a/lib/screens/register.dart +++ b/lib/screens/register.dart @@ -76,13 +76,15 @@ class _RegisterState extends State { Container( // width: 0, height: 36, - child: RaisedButton( - textColor: ArgonColors.primary, - color: ArgonColors.secondary, - onPressed: () {}, - shape: RoundedRectangleBorder( + child: ElevatedButton( + style: ElevatedButton.styleFrom( + foregroundColor: ArgonColors.primary, + backgroundColor: ArgonColors.secondary, + shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(4)), + ), + onPressed: () {}, child: Padding( padding: EdgeInsets.only( bottom: 10, @@ -113,13 +115,15 @@ class _RegisterState extends State { Container( // width: 0, height: 36, - child: RaisedButton( - textColor: ArgonColors.primary, - color: ArgonColors.secondary, - onPressed: () {}, - shape: RoundedRectangleBorder( + child: ElevatedButton( + style: ElevatedButton.styleFrom( + foregroundColor: ArgonColors.primary, + backgroundColor: ArgonColors.secondary, + shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(4)), + ), + onPressed: () {}, child: Padding( padding: EdgeInsets.only( bottom: 10, @@ -260,18 +264,20 @@ class _RegisterState extends State { Padding( padding: const EdgeInsets.only(top: 16), child: Center( - child: FlatButton( - textColor: ArgonColors.white, - color: ArgonColors.primary, + child: TextButton( + style: TextButton.styleFrom( + foregroundColor: ArgonColors.white, + backgroundColor: ArgonColors.primary, + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(4.0), + ), + ), onPressed: () { // Respond to button press Navigator.pushNamed( context, '/home'); }, - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(4.0), - ), child: Padding( padding: EdgeInsets.only( left: 16.0, diff --git a/lib/widgets/button.dart b/lib/widgets/button.dart index 6d3ef45..8a0b008 100644 --- a/lib/widgets/button.dart +++ b/lib/widgets/button.dart @@ -48,10 +48,19 @@ class StretchableButton extends StatelessWidget { borderRadius: BorderRadius.circular(borderRadius), side: bs, ), - child: RaisedButton( + child: ElevatedButton( onPressed: onPressed, - color: buttonColor, - splashColor: splashColor, + style: ButtonStyle( + backgroundColor: MaterialStateProperty.resolveWith((states) { + return buttonColor; + }), + overlayColor: MaterialStateProperty.resolveWith((states) { + if (states.contains(MaterialState.pressed)) { + return splashColor; + } + return buttonColor; + }), + ), child: Row( mainAxisSize: MainAxisSize.min, children: contents, diff --git a/lib/widgets/card-shopping.dart b/lib/widgets/card-shopping.dart index 89b2237..7637c9f 100644 --- a/lib/widgets/card-shopping.dart +++ b/lib/widgets/card-shopping.dart @@ -36,13 +36,15 @@ class CardShopping extends StatelessWidget { decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(3.0)), )), - FlatButton( - textColor: ArgonColors.white, - color: ArgonColors.initial, - onPressed: () {}, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(4.0), + TextButton( + style: TextButton.styleFrom( + foregroundColor: ArgonColors.white, + backgroundColor: ArgonColors.initial, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(4.0), + ), ), + onPressed: () {}, child: Padding( padding: EdgeInsets.only( left: 5.0, right: 5.0, top: 12, bottom: 12), @@ -97,15 +99,17 @@ class CardShopping extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - FlatButton( - textColor: ArgonColors.white, - color: ArgonColors.initial, + TextButton( + style: TextButton.styleFrom( + foregroundColor: ArgonColors.white, + backgroundColor: ArgonColors.initial, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(4.0), + ), + ), onPressed: () { deleteOnPress(); }, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(4.0), - ), child: Padding( padding: EdgeInsets.only( left: 5.0, right: 5.0, top: 12, bottom: 12), @@ -114,13 +118,15 @@ class CardShopping extends StatelessWidget { fontWeight: FontWeight.w600, fontSize: 11.0))), ), - FlatButton( - textColor: ArgonColors.white, - color: ArgonColors.initial, - onPressed: () {}, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(4.0), + TextButton( + style: TextButton.styleFrom( + foregroundColor: ArgonColors.white, + backgroundColor: ArgonColors.initial, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(4.0), + ), ), + onPressed: () {}, child: Padding( padding: EdgeInsets.only( left: 5.0, right: 5.0, top: 12, bottom: 12),