From d2d92ed8bb73d95bdae2ac33a2b3d198cd012c14 Mon Sep 17 00:00:00 2001 From: Frederik Benoist Date: Sat, 3 Jun 2023 23:33:39 +0200 Subject: [PATCH] refactor: delete account information --- .../account_information.dart | 269 ------------------ .../account_information/edit_email.dart | 129 --------- .../account_information/edit_name.dart | 92 ------ .../edit_phone_number.dart | 122 -------- lib/ui/account/tab_account.dart | 43 +-- 5 files changed, 8 insertions(+), 647 deletions(-) delete mode 100644 lib/ui/account/account_information/account_information.dart delete mode 100644 lib/ui/account/account_information/edit_email.dart delete mode 100644 lib/ui/account/account_information/edit_name.dart delete mode 100644 lib/ui/account/account_information/edit_phone_number.dart diff --git a/lib/ui/account/account_information/account_information.dart b/lib/ui/account/account_information/account_information.dart deleted file mode 100644 index 796a791..0000000 --- a/lib/ui/account/account_information/account_information.dart +++ /dev/null @@ -1,269 +0,0 @@ -import 'package:mobdr/config/constant.dart'; -import 'package:mobdr/config/global_style.dart'; -import 'package:mobdr/service/shared_prefs.dart'; -import 'package:mobdr/ui/account/account_information/edit_email.dart'; -import 'package:mobdr/ui/account/account_information/edit_name.dart'; -import 'package:mobdr/ui/account/account_information/edit_phone_number.dart'; -import 'package:mobdr/ui/reusable/reusable_widget.dart'; -import 'package:mobdr/ui/reusable/cache_image_network.dart'; -import 'package:flutter/material.dart'; -import 'package:fluttertoast/fluttertoast.dart'; - -class AccountInformationPage extends StatefulWidget { - @override - _AccountInformationPageState createState() => _AccountInformationPageState(); -} - -class _AccountInformationPageState extends State { - // initialize reusable widget - final _reusableWidget = ReusableWidget(); - @override - void initState() { - super.initState(); - } - - @override - void dispose() { - super.dispose(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - iconTheme: IconThemeData( - color: GlobalStyle.appBarIconThemeColor, - ), - elevation: GlobalStyle.appBarElevation, - title: Text( - 'Account Information', - style: GlobalStyle.appBarTitle, - ), - backgroundColor: GlobalStyle.appBarBackgroundColor, - systemOverlayStyle: GlobalStyle.appBarSystemOverlayStyle, - bottom: _reusableWidget.bottomAppBar(), - ), - body: Container( - margin: EdgeInsets.fromLTRB(16, 0, 16, 16), - child: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - _createProfilePicture(), - SizedBox(height: 40), - Text( - 'Name', - style: GlobalStyle.accountInformationLabel, - ), - SizedBox( - height: 8, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: Text( - "${SharedPrefs().prenom} ${SharedPrefs().nom}", - style: GlobalStyle.accountInformationValue, - ), - ), - GestureDetector( - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => EditNamePage())); - }, - child: Text('Edit', - style: GlobalStyle.accountInformationEdit), - ) - ], - ), - SizedBox( - height: 24, - ), - Row( - children: [ - Text( - 'Email', - style: GlobalStyle.accountInformationLabel, - ), - SizedBox( - width: 8, - ), - _verifiedLabel() - ], - ), - SizedBox( - height: 8, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: Text( - 'robert.steven@ijtechnology.net', - style: GlobalStyle.accountInformationValue, - ), - ), - GestureDetector( - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => EditEmailPage())); - }, - child: Text('Edit', - style: GlobalStyle.accountInformationEdit), - ) - ], - ), - SizedBox( - height: 24, - ), - Row( - children: [ - Text( - 'Phone Number', - style: GlobalStyle.accountInformationLabel, - ), - SizedBox( - width: 8, - ), - _verifiedLabel() - ], - ), - SizedBox(height: 8), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: Text( - '0811888999', - style: GlobalStyle.accountInformationValue, - ), - ), - GestureDetector( - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => EditPhoneNumberPage())); - }, - child: Text('Edit', - style: GlobalStyle.accountInformationEdit), - ) - ], - ), - ], - ), - ), - )); - } - - Widget _createProfilePicture() { - final double profilePictureSize = MediaQuery.of(context).size.width / 3; - return Align( - alignment: Alignment.center, - child: Container( - margin: EdgeInsets.only(top: 40), - width: profilePictureSize, - height: profilePictureSize, - child: GestureDetector( - onTap: () { - _showPopupUpdatePicture(); - }, - child: Stack( - children: [ - CircleAvatar( - backgroundColor: Colors.white, - radius: (profilePictureSize), - child: Hero( - tag: 'profilePicture', - child: ClipOval( - child: buildCacheNetworkImage( - width: profilePictureSize, - height: profilePictureSize, - url: GLOBAL_URL + '/user/avatar.png')), - ), - ), - // create edit icon in the picture - Container( - width: 30, - height: 30, - margin: EdgeInsets.only( - top: 0, left: MediaQuery.of(context).size.width / 4), - child: Card( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(30), - ), - elevation: 1, - child: Icon(Icons.edit, size: 12, color: CHARCOAL), - ), - ), - ], - ), - ), - ), - ); - } - - Widget _verifiedLabel() { - return Container( - padding: EdgeInsets.fromLTRB(8, 2, 8, 2), - decoration: BoxDecoration( - color: SOFT_BLUE, borderRadius: BorderRadius.circular(2)), - child: Row( - children: [ - Text('verified', style: TextStyle(color: Colors.white, fontSize: 11)), - SizedBox( - width: 4, - ), - Icon(Icons.done, color: Colors.white, size: 11) - ], - ), - ); - } - - void _showPopupUpdatePicture() { - // set up the buttons - Widget cancelButton = TextButton( - onPressed: () { - Navigator.pop(context); - }, - child: Text('No', style: TextStyle(color: SOFT_BLUE))); - Widget continueButton = TextButton( - onPressed: () { - Navigator.pop(context); - Fluttertoast.showToast( - msg: 'Click edit profile picture', - toastLength: Toast.LENGTH_SHORT); - }, - child: Text('Yes', style: TextStyle(color: SOFT_BLUE))); - - // set up the AlertDialog - AlertDialog alert = AlertDialog( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), - ), - title: Text( - 'Edit Profile Picture', - style: TextStyle(fontSize: 18), - ), - content: Text('Do you want to edit profile picture ?', - style: TextStyle(fontSize: 13, color: BLACK_GREY)), - actions: [ - cancelButton, - continueButton, - ], - ); - - // show the dialog - showDialog( - context: context, - builder: (BuildContext context) { - return alert; - }, - ); - } -} diff --git a/lib/ui/account/account_information/edit_email.dart b/lib/ui/account/account_information/edit_email.dart deleted file mode 100644 index 401323c..0000000 --- a/lib/ui/account/account_information/edit_email.dart +++ /dev/null @@ -1,129 +0,0 @@ -/* -This is edit email page - -include file in reuseable/global_function.dart to call function from GlobalFunction -include file in reuseable/global_widget.dart to call function from GlobalWidget - */ - -import 'package:mobdr/config/constant.dart'; -import 'package:mobdr/config/global_style.dart'; -import 'package:mobdr/ui/reusable/reusable_widget.dart'; -import 'package:mobdr/ui/reusable/global_function.dart'; -import 'package:flutter/material.dart'; - -class EditEmailPage extends StatefulWidget { - @override - _EditEmailPageState createState() => _EditEmailPageState(); -} - -class _EditEmailPageState extends State { - // initialize reusable widget and global function - final _reusableWidget = ReusableWidget(); - final _globalFunction = GlobalFunction(); - - TextEditingController _etEmail = TextEditingController(); - bool _buttonDisabled = true; - - @override - void initState() { - _etEmail = TextEditingController(text: 'robert.steven@ijtechnology.net'); - - if (_globalFunction.validateEmail(_etEmail.text)) { - _buttonDisabled = false; - } else { - _buttonDisabled = true; - } - super.initState(); - } - - @override - void dispose() { - _etEmail.dispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - iconTheme: IconThemeData( - color: GlobalStyle.appBarIconThemeColor, - ), - elevation: GlobalStyle.appBarElevation, - title: Text( - 'Edit Email', - style: GlobalStyle.appBarTitle, - ), - backgroundColor: GlobalStyle.appBarBackgroundColor, - systemOverlayStyle: GlobalStyle.appBarSystemOverlayStyle, - bottom: _reusableWidget.bottomAppBar(), - ), - body: ListView( - padding: EdgeInsets.all(16), - children: [ - TextFormField( - keyboardType: TextInputType.emailAddress, - controller: _etEmail, - style: TextStyle(color: CHARCOAL), - onChanged: (textValue) { - setState(() { - if (_globalFunction.validateEmail(textValue)) { - _buttonDisabled = false; - } else { - _buttonDisabled = true; - } - }); - }, - decoration: InputDecoration( - focusedBorder: UnderlineInputBorder( - borderSide: BorderSide(color: PRIMARY_COLOR, width: 2.0)), - enabledBorder: UnderlineInputBorder( - borderSide: BorderSide(color: Color(0xFFCCCCCC)), - ), - labelText: 'Email', - labelStyle: TextStyle(color: BLACK_GREY)), - ), - SizedBox( - height: 40, - ), - Container( - child: TextButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.resolveWith( - (Set states) => - states.contains(MaterialState.disabled) - ? Colors.grey[300]! - : _buttonDisabled - ? Colors.grey[300]! - : PRIMARY_COLOR, - ), - overlayColor: - MaterialStateProperty.all(Colors.transparent), - shape: MaterialStateProperty.all(RoundedRectangleBorder( - borderRadius: BorderRadius.circular(3.0), - )), - ), - onPressed: () { - if (!_buttonDisabled) { - _reusableWidget.startLoading( - context, 'Edit Email Success', 1); - FocusScope.of(context).unfocus(); - } - }, - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 5.0), - child: Text( - 'Save', - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold, - color: _buttonDisabled - ? Colors.grey[600] - : Colors.white), - textAlign: TextAlign.center, - ), - ))), - ], - )); - } -} diff --git a/lib/ui/account/account_information/edit_name.dart b/lib/ui/account/account_information/edit_name.dart deleted file mode 100644 index c5f9077..0000000 --- a/lib/ui/account/account_information/edit_name.dart +++ /dev/null @@ -1,92 +0,0 @@ -import 'package:mobdr/config/constant.dart'; -import 'package:mobdr/config/global_style.dart'; -import 'package:mobdr/ui/reusable/reusable_widget.dart'; -import 'package:flutter/material.dart'; - -class EditNamePage extends StatefulWidget { - @override - _EditNamePageState createState() => _EditNamePageState(); -} - -class _EditNamePageState extends State { - // initialize reusable widget - final _reusableWidget = ReusableWidget(); - - TextEditingController _etName = TextEditingController(); - - @override - void initState() { - _etName = TextEditingController(text: 'Robert Steven'); - super.initState(); - } - - @override - void dispose() { - _etName.dispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - iconTheme: IconThemeData( - color: GlobalStyle.appBarIconThemeColor, - ), - elevation: GlobalStyle.appBarElevation, - title: Text( - 'Edit Name', - style: GlobalStyle.appBarTitle, - ), - backgroundColor: GlobalStyle.appBarBackgroundColor, - systemOverlayStyle: GlobalStyle.appBarSystemOverlayStyle, - bottom: _reusableWidget.bottomAppBar(), - ), - body: ListView( - padding: EdgeInsets.all(16), - children: [ - TextField( - controller: _etName, - decoration: InputDecoration( - focusedBorder: UnderlineInputBorder( - borderSide: BorderSide(color: PRIMARY_COLOR, width: 2.0)), - enabledBorder: UnderlineInputBorder( - borderSide: BorderSide(color: Color(0xFFCCCCCC)), - ), - labelText: 'Name', - labelStyle: TextStyle(color: BLACK_GREY)), - ), - SizedBox( - height: 40, - ), - Container( - child: TextButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.resolveWith( - (Set states) => PRIMARY_COLOR, - ), - overlayColor: MaterialStateProperty.all(Colors.transparent), - shape: MaterialStateProperty.all(RoundedRectangleBorder( - borderRadius: BorderRadius.circular(3.0), - )), - ), - onPressed: () { - _reusableWidget.startLoading( - context, 'Edit Name Success', 1); - }, - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 5.0), - child: Text( - 'Save', - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold, - color: Colors.white), - textAlign: TextAlign.center, - ), - )), - ), - ], - )); - } -} diff --git a/lib/ui/account/account_information/edit_phone_number.dart b/lib/ui/account/account_information/edit_phone_number.dart deleted file mode 100644 index 4af1388..0000000 --- a/lib/ui/account/account_information/edit_phone_number.dart +++ /dev/null @@ -1,122 +0,0 @@ -import 'package:mobdr/config/constant.dart'; -import 'package:mobdr/config/global_style.dart'; -import 'package:mobdr/ui/reusable/reusable_widget.dart'; -import 'package:mobdr/ui/reusable/global_function.dart'; -import 'package:flutter/material.dart'; - -class EditPhoneNumberPage extends StatefulWidget { - @override - _EditPhoneNumberPageState createState() => _EditPhoneNumberPageState(); -} - -class _EditPhoneNumberPageState extends State { - // initialize reusable widget and global function - final _reusableWidget = ReusableWidget(); - final _globalFunction = GlobalFunction(); - - TextEditingController _etPhoneNumber = TextEditingController(); - bool _buttonDisabled = true; - - @override - void initState() { - _etPhoneNumber = TextEditingController(text: '0811888999'); - - if (_globalFunction.validateMobileNumber(_etPhoneNumber.text)) { - _buttonDisabled = false; - } else { - _buttonDisabled = true; - } - super.initState(); - } - - @override - void dispose() { - _etPhoneNumber.dispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - iconTheme: IconThemeData( - color: GlobalStyle.appBarIconThemeColor, - ), - elevation: GlobalStyle.appBarElevation, - title: Text( - 'Edit Phone Number', - style: GlobalStyle.appBarTitle, - ), - backgroundColor: GlobalStyle.appBarBackgroundColor, - systemOverlayStyle: GlobalStyle.appBarSystemOverlayStyle, - bottom: _reusableWidget.bottomAppBar(), - ), - body: ListView( - padding: EdgeInsets.all(16), - children: [ - TextFormField( - keyboardType: TextInputType.number, - controller: _etPhoneNumber, - style: TextStyle(color: CHARCOAL), - onChanged: (textValue) { - setState(() { - if (_globalFunction.validateMobileNumber(textValue)) { - _buttonDisabled = false; - } else { - _buttonDisabled = true; - } - }); - }, - decoration: InputDecoration( - focusedBorder: UnderlineInputBorder( - borderSide: BorderSide(color: PRIMARY_COLOR, width: 2.0)), - enabledBorder: UnderlineInputBorder( - borderSide: BorderSide(color: Color(0xFFCCCCCC)), - ), - labelText: 'Phone Number', - labelStyle: TextStyle(color: BLACK_GREY)), - ), - SizedBox( - height: 40, - ), - Container( - child: TextButton( - style: ButtonStyle( - backgroundColor: MaterialStateProperty.resolveWith( - (Set states) => - states.contains(MaterialState.disabled) - ? Colors.grey[300]! - : _buttonDisabled - ? Colors.grey[300]! - : PRIMARY_COLOR, - ), - overlayColor: MaterialStateProperty.all(Colors.transparent), - shape: MaterialStateProperty.all(RoundedRectangleBorder( - borderRadius: BorderRadius.circular(3.0), - )), - ), - onPressed: () { - if (!_buttonDisabled) { - _reusableWidget.startLoading( - context, 'Edit Phone Number Success', 1); - FocusScope.of(context).unfocus(); - } - }, - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 5), - child: Text( - 'Save', - style: TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold, - color: _buttonDisabled - ? Colors.grey[600] - : Colors.white), - textAlign: TextAlign.center, - ), - )), - ), - ], - )); - } -} diff --git a/lib/ui/account/tab_account.dart b/lib/ui/account/tab_account.dart index f11e748..c47414c 100644 --- a/lib/ui/account/tab_account.dart +++ b/lib/ui/account/tab_account.dart @@ -7,7 +7,6 @@ import 'package:mobdr/config/constant.dart'; import 'package:mobdr/config/global_style.dart'; import 'package:mobdr/service/shared_prefs.dart'; import 'package:mobdr/ui/account/about.dart'; -import 'package:mobdr/ui/account/account_information/account_information.dart'; import 'package:mobdr/ui/account/notification_setting.dart'; import 'package:mobdr/ui/account/log.dart'; import 'package:mobdr/ui/general/notification.dart'; @@ -129,23 +128,15 @@ class _TabAccountPageState extends State Container( width: profilePictureSize, height: profilePictureSize, - child: GestureDetector( - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => AccountInformationPage())); - }, + child: CircleAvatar( + backgroundColor: Colors.grey[200], + radius: profilePictureSize, child: CircleAvatar( - backgroundColor: Colors.grey[200], - radius: profilePictureSize, - child: CircleAvatar( - backgroundColor: Colors.white, - radius: profilePictureSize - 4, - child: Hero( - tag: 'profilePicture', - child: ClipOval(child: imageFromBase64String()), - ), + backgroundColor: Colors.white, + radius: profilePictureSize - 4, + child: Hero( + tag: 'profilePicture', + child: ClipOval(child: imageFromBase64String()), ), ), ), @@ -163,24 +154,6 @@ class _TabAccountPageState extends State SizedBox( height: 8, ), - GestureDetector( - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => AccountInformationPage())); - }, - child: Row( - children: [ - Text('Account Information', - style: TextStyle(fontSize: 14, color: BLACK_GREY)), - SizedBox( - width: 8, - ), - Icon(Icons.chevron_right, size: 20, color: SOFT_GREY) - ], - ), - ) ], ), )