| class AppBarWidget extends StatelessWidget implements PreferredSizeWidget { | class AppBarWidget extends StatelessWidget implements PreferredSizeWidget { | ||||
| final bool isBack; | final bool isBack; | ||||
| AppBarWidget({this.isBack = true}); | |||||
| final Widget action; | |||||
| AppBarWidget({this.isBack = true, this.action}); | |||||
| @override | @override | ||||
| Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
| return Container( | return Container( | ||||
| color: AppColors.YELLOW, | color: AppColors.YELLOW, | ||||
| fontWeight: FontWeight.normal), | fontWeight: FontWeight.normal), | ||||
| ), | ), | ||||
| Expanded( | |||||
| child: Align( | |||||
| alignment: Alignment.centerRight, | |||||
| child: action ?? SizedBox(), | |||||
| )) | |||||
| ], | ], | ||||
| ), | ), | ||||
| onTap: () { | onTap: () { | ||||
| ) | ) | ||||
| : SizedBox(), | : SizedBox(), | ||||
| automaticallyImplyLeading: false, | automaticallyImplyLeading: false, | ||||
| actions: [SizedBox()], | |||||
| ), | ), | ||||
| ); | ); | ||||
| } | } |
| import 'package:farm_tpf/utils/const_color.dart'; | |||||
| import 'package:flutter/material.dart'; | |||||
| class ButtonWidget extends StatelessWidget { | |||||
| final Function onPressed; | |||||
| final String title; | |||||
| ButtonWidget({@required this.title, @required this.onPressed}); | |||||
| @override | |||||
| Widget build(BuildContext context) { | |||||
| return SizedBox( | |||||
| width: double.infinity, | |||||
| height: 55, | |||||
| child: FlatButton( | |||||
| onPressed: onPressed, | |||||
| color: AppColors.DEFAULT, | |||||
| shape: RoundedRectangleBorder( | |||||
| borderRadius: new BorderRadius.circular(7.0), | |||||
| ), | |||||
| child: Text(title.toUpperCase(), | |||||
| style: TextStyle( | |||||
| fontWeight: FontWeight.bold, | |||||
| color: AppColors.WHITE, | |||||
| fontSize: 18)), | |||||
| ), | |||||
| ); | |||||
| } | |||||
| } |
| import 'package:farm_tpf/presentation/custom_widgets/app_bar_widget.dart'; | import 'package:farm_tpf/presentation/custom_widgets/app_bar_widget.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/button_icon_widget.dart'; | import 'package:farm_tpf/presentation/custom_widgets/button_icon_widget.dart'; | ||||
| import 'package:farm_tpf/presentation/screens/profile/sc_change_password.dart'; | |||||
| import 'package:farm_tpf/presentation/screens/profile/sc_update_profile.dart'; | import 'package:farm_tpf/presentation/screens/profile/sc_update_profile.dart'; | ||||
| import 'package:farm_tpf/utils/const_color.dart'; | import 'package:farm_tpf/utils/const_color.dart'; | ||||
| import 'package:farm_tpf/utils/const_icons.dart'; | import 'package:farm_tpf/utils/const_icons.dart'; | ||||
| trailingIcon: AppIcons.icArrowRight, | trailingIcon: AppIcons.icArrowRight, | ||||
| isTopBorder: false, | isTopBorder: false, | ||||
| isBottomBorder: false, | isBottomBorder: false, | ||||
| onTap: () {}), | |||||
| onTap: () { | |||||
| Get.to(ChangePasswordScreen()); | |||||
| }), | |||||
| Container( | Container( | ||||
| width: double.infinity, | width: double.infinity, | ||||
| height: 20, | height: 20, |
| import 'package:farm_tpf/custom_model/password.dart'; | import 'package:farm_tpf/custom_model/password.dart'; | ||||
| import 'package:farm_tpf/data/api/app_exception.dart'; | import 'package:farm_tpf/data/api/app_exception.dart'; | ||||
| import 'package:farm_tpf/data/repository/user_repository.dart'; | import 'package:farm_tpf/data/repository/user_repository.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/app_bar_widget.dart'; | |||||
| import 'package:farm_tpf/presentation/custom_widgets/widget_loading.dart'; | import 'package:farm_tpf/presentation/custom_widgets/widget_loading.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/widget_toast.dart'; | |||||
| import 'package:farm_tpf/presentation/custom_widgets/widget_utils.dart'; | import 'package:farm_tpf/presentation/custom_widgets/widget_utils.dart'; | ||||
| import 'package:farm_tpf/utils/const_color.dart'; | import 'package:farm_tpf/utils/const_color.dart'; | ||||
| import 'package:farm_tpf/utils/validators.dart'; | import 'package:farm_tpf/utils/validators.dart'; | ||||
| @override | @override | ||||
| Widget build(BuildContext context) => KeyboardDismisser( | Widget build(BuildContext context) => KeyboardDismisser( | ||||
| child: Scaffold( | child: Scaffold( | ||||
| backgroundColor: Colors.white, | |||||
| key: _scaffoldKey, | key: _scaffoldKey, | ||||
| appBar: AppBar(centerTitle: true, title: Text("Cập nhật mật khẩu")), | |||||
| appBar: AppBarWidget( | |||||
| isBack: true, | |||||
| ), | |||||
| body: KeyboardDismisser( | body: KeyboardDismisser( | ||||
| child: Form( | child: Form( | ||||
| key: _formKey, | key: _formKey, | ||||
| child: SingleChildScrollView( | child: SingleChildScrollView( | ||||
| padding: EdgeInsets.all(8.0), | padding: EdgeInsets.all(8.0), | ||||
| child: Column( | child: Column( | ||||
| crossAxisAlignment: CrossAxisAlignment.start, | |||||
| children: <Widget>[ | children: <Widget>[ | ||||
| Text( | |||||
| 'Bảo mật', | |||||
| style: TextStyle( | |||||
| fontWeight: FontWeight.w500, fontSize: 22), | |||||
| ), | |||||
| Text( | |||||
| 'Cập nhật mật khẩu cho tài khoản của bạn. Mật khẩu bao gồm cả chữ và số, độ dài tối thiểu 8 ký tự', | |||||
| style: TextStyle( | |||||
| fontSize: 15, | |||||
| fontWeight: FontWeight.w200, | |||||
| color: Colors.black54)), | |||||
| _currentPasswordField(), | _currentPasswordField(), | ||||
| SizedBox( | SizedBox( | ||||
| height: 8.0, | height: 8.0, | ||||
| ), | ), | ||||
| _confirmPasswordField(), | _confirmPasswordField(), | ||||
| SizedBox( | SizedBox( | ||||
| height: 8.0, | |||||
| height: 20.0, | |||||
| ), | ), | ||||
| _btnSubmit() | _btnSubmit() | ||||
| ], | ], |
| import 'package:farm_tpf/custom_model/LocationUnit.dart'; | import 'package:farm_tpf/custom_model/LocationUnit.dart'; | ||||
| import 'package:farm_tpf/custom_model/account.dart'; | import 'package:farm_tpf/custom_model/account.dart'; | ||||
| import 'package:farm_tpf/data/repository/user_repository.dart'; | import 'package:farm_tpf/data/repository/user_repository.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/app_bar_widget.dart'; | |||||
| import 'package:farm_tpf/presentation/custom_widgets/button_widget.dart'; | |||||
| import 'package:farm_tpf/presentation/custom_widgets/widget_loading.dart'; | import 'package:farm_tpf/presentation/custom_widgets/widget_loading.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/widget_toast.dart'; | import 'package:farm_tpf/presentation/custom_widgets/widget_toast.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/widget_utils.dart'; | import 'package:farm_tpf/presentation/custom_widgets/widget_utils.dart'; | ||||
| ); | ); | ||||
| } | } | ||||
| Widget _btnChangePassword() { | |||||
| return FlatButton( | |||||
| padding: EdgeInsets.only(top: 0.0, right: 0.0, bottom: 0.0, left: 0.0), | |||||
| onPressed: () { | |||||
| Navigator.push( | |||||
| context, | |||||
| MaterialPageRoute(builder: (context) => ChangePasswordScreen()), | |||||
| ); | |||||
| }, | |||||
| child: Container( | |||||
| padding: | |||||
| EdgeInsets.only(top: 15.0, right: 0.0, bottom: 10.5, left: 0.0), | |||||
| decoration: BoxDecoration( | |||||
| border: | |||||
| Border(bottom: BorderSide(width: 0.5, color: Colors.grey)), | |||||
| ), | |||||
| child: Row( | |||||
| children: [ | |||||
| Expanded( | |||||
| child: Text( | |||||
| "Cập nhật mật khẩu".toUpperCase(), | |||||
| style: TextStyle( | |||||
| fontSize: 14.0, | |||||
| color: Colors.black, | |||||
| fontWeight: FontWeight.bold), | |||||
| )), | |||||
| Icon(Icons.arrow_forward_ios), | |||||
| ], | |||||
| ))); | |||||
| } | |||||
| @override | @override | ||||
| Widget build(BuildContext context) => KeyboardDismisser( | Widget build(BuildContext context) => KeyboardDismisser( | ||||
| child: Scaffold( | child: Scaffold( | ||||
| appBar: AppBar( | |||||
| centerTitle: true, | |||||
| title: Text( | |||||
| "Thông tin cá nhân", | |||||
| textAlign: TextAlign.center, | |||||
| backgroundColor: Colors.white, | |||||
| appBar: AppBarWidget( | |||||
| isBack: true, | |||||
| action: InkWell( | |||||
| child: Text( | |||||
| 'Huỷ', | |||||
| style: | |||||
| TextStyle(color: Colors.red, fontWeight: FontWeight.normal), | |||||
| ), | |||||
| onTap: () { | |||||
| if (Get.isSnackbarOpen) Get.back(); | |||||
| Get.back(); | |||||
| }, | |||||
| ), | ), | ||||
| actions: <Widget>[ | |||||
| IconButton( | |||||
| icon: Icon(Icons.done), | |||||
| onPressed: () { | |||||
| FocusScopeNode currentFocus = FocusScope.of(context); | |||||
| if (!currentFocus.hasPrimaryFocus) { | |||||
| currentFocus.unfocus(); | |||||
| } | |||||
| _validateInputs(); | |||||
| }) | |||||
| ], | |||||
| ), | ), | ||||
| key: _scaffoldKey, | key: _scaffoldKey, | ||||
| body: _buildContent())); | body: _buildContent())); | ||||
| child: SingleChildScrollView( | child: SingleChildScrollView( | ||||
| padding: EdgeInsets.all(8.0), | padding: EdgeInsets.all(8.0), | ||||
| child: Column( | child: Column( | ||||
| crossAxisAlignment: CrossAxisAlignment.start, | |||||
| children: <Widget>[ | children: <Widget>[ | ||||
| Text( | |||||
| 'Tài khoản', | |||||
| style: TextStyle( | |||||
| fontWeight: FontWeight.w500, fontSize: 22), | |||||
| ), | |||||
| _userNameField(), | _userNameField(), | ||||
| SizedBox( | SizedBox( | ||||
| height: 8.0, | height: 8.0, | ||||
| SizedBox( | SizedBox( | ||||
| height: 16.0, | height: 16.0, | ||||
| ), | ), | ||||
| _btnChangePassword(), | |||||
| ButtonWidget( | |||||
| title: 'CẬP NHẬT', | |||||
| onPressed: () { | |||||
| FocusScopeNode currentFocus = | |||||
| FocusScope.of(context); | |||||
| if (!currentFocus.hasPrimaryFocus) { | |||||
| currentFocus.unfocus(); | |||||
| } | |||||
| _validateInputs(); | |||||
| }), | |||||
| ], | ], | ||||
| ), | ), | ||||
| )); | )); |