From 1da9658cf63e3fe09cc4b362a65e9111ca289c1f Mon Sep 17 00:00:00 2001 From: samdid Date: Tue, 23 Mar 2021 00:14:09 +0530 Subject: [PATCH 1/2] Added the change username and password screen --- lib/main.dart | 2 +- lib/views/change_username_password.dart | 284 ++++++++++++++++++++++++ lib/views/settings.dart | 4 +- 3 files changed, 288 insertions(+), 2 deletions(-) create mode 100644 lib/views/change_username_password.dart diff --git a/lib/main.dart b/lib/main.dart index 3c64f32..8f1a9d4 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,4 +1,3 @@ -import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:provider/provider.dart'; @@ -6,6 +5,7 @@ import 'package:retro_shopping/helpers/ad_state.dart'; import 'package:retro_shopping/helpers/constants.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart'; import 'package:retro_shopping/views/login.dart'; +import 'package:firebase_core/firebase_core.dart'; import 'dashboard.dart'; diff --git a/lib/views/change_username_password.dart b/lib/views/change_username_password.dart new file mode 100644 index 0000000..d0aa29d --- /dev/null +++ b/lib/views/change_username_password.dart @@ -0,0 +1,284 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:retro_shopping/helpers/constants.dart'; +import 'package:retro_shopping/views/settings.dart'; +import 'package:retro_shopping/widgets/retro_button.dart'; + + +class ChangeUsername extends StatefulWidget{ + @override + State createState() { + return ChangeUsernameState(); + } +} + +TextEditingController _userNameController = TextEditingController(); +TextEditingController _passwordController = TextEditingController(); +TextEditingController _confirmPasswordController = TextEditingController(); + + +String _username = ""; +String _password = ""; +String _confirmPassword = ""; + +class ChangeUsernameState extends State{ + @override + Widget build(BuildContext context) { + final double height = MediaQuery.of(context).size.height; + final double width = MediaQuery.of(context).size.width; + + return Scaffold( + appBar: AppBar( + backgroundColor: RelicColors.backgroundColor, + leading: Padding( + padding: const EdgeInsets.all(8.0), + child: GestureDetector( + onTap: () { + Navigator.pop(context); + }, + child: RetroButton( + upperColor: Colors.white, + lowerColor: Colors.black, + width: 35, + height: 35, + borderColor: Colors.white, + child: const Icon( + Icons.arrow_back, + color: Colors.black, + ), + ), + ), + ), + elevation: 0.0, + ), + body: Stack( + // ignore: always_specify_types + children: [ + Positioned( + top: 70, + right: 20, + child: Center( + child: Stack( + // ignore: always_specify_types + children: [ + Transform.translate( + offset: const Offset(5,5), + child: Container( + width: width * 0.88, + height: height * 0.615, + decoration: const BoxDecoration(color: Colors.black), + ), + ), + Container( + height: height * 0.61, + //height: 458, + width: width * 0.87, + decoration: const BoxDecoration(color: RelicColors.primaryColor), + child: Center( + child: SingleChildScrollView( + child: Column( + // ignore: always_specify_types + children: [ + Padding( + padding: const EdgeInsets.symmetric(horizontal: 20,vertical: 10.0), + child: Row( + // ignore: always_specify_types, prefer_const_literals_to_create_immutables + children: [ + // ignore: prefer_const_literals_to_create_immutables, + const Expanded( + child: Text('Change Username or Password', + style: TextStyle( + fontSize: 35, + color: Colors.white, + fontFamily: 'pix M 8pt', + fontWeight: FontWeight.bold + ),), + ), + ], + ), + ), + SizedBox( + height: height*0.011, + ), + Stack( + // ignore: always_specify_types + children:[ + Transform.translate( + offset: const Offset(25,10), + child: Container( + color: Colors.black, + width: width * 0.77, + height: height * 0.065, + ), + ), + Padding( + padding: const EdgeInsets.only(left:20.0, right: 20.0), + // ignore: sized_box_for_whitespace + child: Container( + height: height*0.07, + child: TextFormField( + controller: _userNameController, + onChanged: (String value){ + _username = value; + }, + decoration: const InputDecoration( + labelText: 'Username', + labelStyle: TextStyle( + fontSize: 20.0, + color: Colors.black + ), + filled: true, + fillColor: Colors.white, + border: OutlineInputBorder( + borderRadius: BorderRadius.zero + ) + ) + ), + ), + ), + ] + ), + + SizedBox( + height: height*0.030, + ), + Stack( + // ignore: always_specify_types + children:[ + Transform.translate( + offset: const Offset(25,10), + child: Container( + color: Colors.black, + width: width * 0.77, + height: height * 0.065, + ), + ), + Padding( + padding: const EdgeInsets.only(left:20.0, right: 20.0), + // ignore: sized_box_for_whitespace + child: Container( + height: height*0.07, + child: TextFormField( + controller: _passwordController, + onChanged: (String value){ + _password = value; + }, + + decoration: const InputDecoration( + labelText: 'Password', + labelStyle: TextStyle( + fontSize: 20.0, + color: Colors.black + ), + filled: true, + fillColor: Colors.white, + border: OutlineInputBorder( + borderRadius: BorderRadius.zero + ) + ) + ), + ), + ), + ] + ), + SizedBox( + height: height*0.030, + ), + Stack( + // ignore: always_specify_types + children:[ + Transform.translate( + offset: const Offset(25,10), + child: Container( + color: Colors.black, + width: width * 0.77, + height: height * 0.065, + ), + ), + Padding( + padding: const EdgeInsets.only(left:20.0, right: 20.0), + // ignore: sized_box_for_whitespace + child: Container( + height: height*0.07, + child: TextFormField( + controller: _confirmPasswordController, + onChanged: (String value){ + _confirmPassword = value; + }, + // ignore: missing_return + decoration: const InputDecoration( + labelText: 'Confirm Password', + labelStyle: TextStyle( + fontSize: 20.0, + color: Colors.black + ), + filled: true, + fillColor: Colors.white, + border: OutlineInputBorder( + borderRadius: BorderRadius.zero + ) + ) + ), + ), + ), + ] + ), + SizedBox( + height: height*0.030, + ), + Row( + // ignore: always_specify_types + children: [ + Padding( + padding: const EdgeInsets.only(left:20.0, right: 20.0), + child: InkWell( + onTap: (){ + debugPrint('Save!!'); + // ignore: always_specify_types + // ignore: always_specify_types + Navigator.push(context, MaterialPageRoute( + builder: (BuildContext context){ + return Settings(); + }) + ) + ; + }, + child: RetroButton( + upperColor: Colors.black, + lowerColor: Colors.white, + height: height * 0.065, + width: width * 0.40, + borderColor: Colors.white, + child: const Center( + child: Text( + 'Save', + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: Colors.white, + ), + ), + ), + ), + ), + ), + ], + ), + SizedBox( + height: height*0.040, + ), + + ], + ), + ), + ) + ), + ], + ), + ), + ), + ], + ), + ); + } +} \ No newline at end of file diff --git a/lib/views/settings.dart b/lib/views/settings.dart index 2274e91..82bb2ec 100644 --- a/lib/views/settings.dart +++ b/lib/views/settings.dart @@ -3,6 +3,7 @@ import 'package:retro_shopping/helpers/constants.dart'; import 'package:retro_shopping/views/address_screen.dart'; import 'package:retro_shopping/views/faqs_screen.dart'; import 'package:retro_shopping/views/orders.dart'; +import 'package:retro_shopping/views/change_username_password.dart'; import 'package:retro_shopping/widgets/retro_button.dart'; import 'package:retro_shopping/widgets/settings_item.dart'; @@ -77,7 +78,8 @@ class _SettingsState extends State { child: divider(), ), settingsItem(context, 'Change Username/\nPassword', - Icons.person), + Icons.person, + tags: ChangeUsername()), Padding( padding: const EdgeInsets.only(left: 16.0, right: 16.0), From a7f57e7ce12fa4454a7ed3d4905e9ac67ff570ef Mon Sep 17 00:00:00 2001 From: samdid Date: Thu, 25 Mar 2021 12:46:49 +0530 Subject: [PATCH 2/2] resolved all the warnings --- lib/helpers/constants.dart | 3 +- lib/helpers/route_page.dart | 6 +- lib/views/change_username_password.dart | 163 +++++++----------- lib/views/profile/settings/settings_view.dart | 2 + 4 files changed, 75 insertions(+), 99 deletions(-) diff --git a/lib/helpers/constants.dart b/lib/helpers/constants.dart index 0e92324..9073531 100644 --- a/lib/helpers/constants.dart +++ b/lib/helpers/constants.dart @@ -20,7 +20,8 @@ class RouteConstant { static const String ADDRESS_SCREEN = '/address-screen'; static const String SIGN_UP_SCREEN = '/sign-up-screen'; static const String MANAGE_ADDRESS_SCREEN = '/manage-address-screen'; - static const String PAYMENT_SUCCESSFULL = '/payment-successfull'; + static const String PAYMENT_SUCCESSFULL = '/payment-successful'; + static const String CHANGE_USERNAME_SCREEN = '/change_username'; } class RelicColors { diff --git a/lib/helpers/route_page.dart b/lib/helpers/route_page.dart index eef15a5..77b49a5 100644 --- a/lib/helpers/route_page.dart +++ b/lib/helpers/route_page.dart @@ -5,7 +5,7 @@ import 'package:retro_shopping/helpers/slide_route.dart'; import 'package:retro_shopping/model/product_model.dart'; import 'package:retro_shopping/views/auth/signup_view.dart'; import 'package:retro_shopping/views/profile/orders.dart'; - +import 'package:retro_shopping/views/change_username_password.dart'; import 'package:retro_shopping/views/auth/login_view.dart'; import 'package:retro_shopping/views/cart_view.dart'; @@ -91,6 +91,10 @@ class RoutePage { return SlideLeftRoute( page: FaqsScreen(), ); + case RouteConstant.CHANGE_USERNAME_SCREEN: + return SlideLeftRoute( + page: ChangeUsername(), + ); case RouteConstant.ADDRESS_SCREEN: return SlideLeftRoute( page: AddressScreen(), diff --git a/lib/views/change_username_password.dart b/lib/views/change_username_password.dart index d0aa29d..c4de0dd 100644 --- a/lib/views/change_username_password.dart +++ b/lib/views/change_username_password.dart @@ -1,7 +1,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:retro_shopping/helpers/constants.dart'; -import 'package:retro_shopping/views/settings.dart'; import 'package:retro_shopping/widgets/retro_button.dart'; @@ -17,9 +16,9 @@ TextEditingController _passwordController = TextEditingController(); TextEditingController _confirmPasswordController = TextEditingController(); -String _username = ""; -String _password = ""; -String _confirmPassword = ""; +String _username = ''; +String _password = ''; +String _confirmPassword = ''; class ChangeUsernameState extends State{ @override @@ -52,15 +51,13 @@ class ChangeUsernameState extends State{ elevation: 0.0, ), body: Stack( - // ignore: always_specify_types - children: [ + children: [ Positioned( top: 70, right: 20, child: Center( child: Stack( - // ignore: always_specify_types - children: [ + children:[ Transform.translate( offset: const Offset(5,5), child: Container( @@ -77,15 +74,12 @@ class ChangeUsernameState extends State{ child: Center( child: SingleChildScrollView( child: Column( - // ignore: always_specify_types - children: [ + children: [ Padding( padding: const EdgeInsets.symmetric(horizontal: 20,vertical: 10.0), child: Row( - // ignore: always_specify_types, prefer_const_literals_to_create_immutables - children: [ - // ignore: prefer_const_literals_to_create_immutables, - const Expanded( + children:const [ + Expanded( child: Text('Change Username or Password', style: TextStyle( fontSize: 35, @@ -101,39 +95,34 @@ class ChangeUsernameState extends State{ height: height*0.011, ), Stack( - // ignore: always_specify_types - children:[ + children:[ Transform.translate( offset: const Offset(25,10), child: Container( color: Colors.black, width: width * 0.77, - height: height * 0.065, + height: height * 0.08, ), ), Padding( padding: const EdgeInsets.only(left:20.0, right: 20.0), - // ignore: sized_box_for_whitespace - child: Container( - height: height*0.07, - child: TextFormField( - controller: _userNameController, - onChanged: (String value){ - _username = value; - }, - decoration: const InputDecoration( - labelText: 'Username', - labelStyle: TextStyle( - fontSize: 20.0, - color: Colors.black - ), - filled: true, - fillColor: Colors.white, - border: OutlineInputBorder( - borderRadius: BorderRadius.zero - ) - ) - ), + child: TextFormField( + controller: _userNameController, + onChanged: (String value){ + _username = value; + }, + decoration: const InputDecoration( + labelText: 'Username', + labelStyle: TextStyle( + fontSize: 20.0, + color: Colors.black + ), + filled: true, + fillColor: Colors.white, + border: OutlineInputBorder( + borderRadius: BorderRadius.zero + ) + ) ), ), ] @@ -143,40 +132,35 @@ class ChangeUsernameState extends State{ height: height*0.030, ), Stack( - // ignore: always_specify_types - children:[ + children:[ Transform.translate( offset: const Offset(25,10), child: Container( color: Colors.black, width: width * 0.77, - height: height * 0.065, + height: height * 0.08, ), ), Padding( padding: const EdgeInsets.only(left:20.0, right: 20.0), - // ignore: sized_box_for_whitespace - child: Container( - height: height*0.07, - child: TextFormField( - controller: _passwordController, - onChanged: (String value){ - _password = value; - }, + child: TextFormField( + controller: _passwordController, + onChanged: (String value){ + _password = value; + }, - decoration: const InputDecoration( - labelText: 'Password', - labelStyle: TextStyle( - fontSize: 20.0, - color: Colors.black - ), - filled: true, - fillColor: Colors.white, - border: OutlineInputBorder( - borderRadius: BorderRadius.zero - ) - ) - ), + decoration: const InputDecoration( + labelText: 'Password', + labelStyle: TextStyle( + fontSize: 20.0, + color: Colors.black + ), + filled: true, + fillColor: Colors.white, + border: OutlineInputBorder( + borderRadius: BorderRadius.zero + ) + ) ), ), ] @@ -185,40 +169,34 @@ class ChangeUsernameState extends State{ height: height*0.030, ), Stack( - // ignore: always_specify_types - children:[ + children:[ Transform.translate( offset: const Offset(25,10), child: Container( color: Colors.black, width: width * 0.77, - height: height * 0.065, + height: height * 0.08, ), ), Padding( padding: const EdgeInsets.only(left:20.0, right: 20.0), - // ignore: sized_box_for_whitespace - child: Container( - height: height*0.07, - child: TextFormField( - controller: _confirmPasswordController, - onChanged: (String value){ - _confirmPassword = value; - }, - // ignore: missing_return - decoration: const InputDecoration( - labelText: 'Confirm Password', - labelStyle: TextStyle( - fontSize: 20.0, - color: Colors.black - ), - filled: true, - fillColor: Colors.white, - border: OutlineInputBorder( - borderRadius: BorderRadius.zero - ) - ) - ), + child: TextFormField( + controller: _confirmPasswordController, + onChanged: (String value){ + _confirmPassword = value; + }, + decoration: const InputDecoration( + labelText: 'Confirm Password', + labelStyle: TextStyle( + fontSize: 20.0, + color: Colors.black + ), + filled: true, + fillColor: Colors.white, + border: OutlineInputBorder( + borderRadius: BorderRadius.zero + ) + ) ), ), ] @@ -227,21 +205,12 @@ class ChangeUsernameState extends State{ height: height*0.030, ), Row( - // ignore: always_specify_types - children: [ + children: [ Padding( padding: const EdgeInsets.only(left:20.0, right: 20.0), child: InkWell( onTap: (){ debugPrint('Save!!'); - // ignore: always_specify_types - // ignore: always_specify_types - Navigator.push(context, MaterialPageRoute( - builder: (BuildContext context){ - return Settings(); - }) - ) - ; }, child: RetroButton( upperColor: Colors.black, diff --git a/lib/views/profile/settings/settings_view.dart b/lib/views/profile/settings/settings_view.dart index 3fc1274..b16a890 100644 --- a/lib/views/profile/settings/settings_view.dart +++ b/lib/views/profile/settings/settings_view.dart @@ -80,6 +80,8 @@ class _SettingsState extends State { context, 'Change Username/\nPassword', Icons.person, + routeName: RouteConstant.CHANGE_USERNAME_SCREEN, + push: true, ), Padding( padding: const EdgeInsets.only(left: 16.0, right: 16.0),