Browse Source

screen update profile, change password

master
daivph 5 years ago
parent
commit
6e07679c66
5 changed files with 88 additions and 53 deletions
  1. +8
    -1
      lib/presentation/custom_widgets/app_bar_widget.dart
  2. +27
    -0
      lib/presentation/custom_widgets/button_widget.dart
  3. +4
    -1
      lib/presentation/screens/account/sc_account.dart
  4. +18
    -3
      lib/presentation/screens/profile/sc_change_password.dart
  5. +31
    -48
      lib/presentation/screens/profile/sc_update_profile.dart

+ 8
- 1
lib/presentation/custom_widgets/app_bar_widget.dart View File

@@ -4,7 +4,8 @@ import 'package:get/get.dart';

class AppBarWidget extends StatelessWidget implements PreferredSizeWidget {
final bool isBack;
AppBarWidget({this.isBack = true});
final Widget action;
AppBarWidget({this.isBack = true, this.action});
@override
Widget build(BuildContext context) {
return Container(
@@ -29,6 +30,11 @@ class AppBarWidget extends StatelessWidget implements PreferredSizeWidget {
color: AppColors.YELLOW,
fontWeight: FontWeight.normal),
),
Expanded(
child: Align(
alignment: Alignment.centerRight,
child: action ?? SizedBox(),
))
],
),
onTap: () {
@@ -38,6 +44,7 @@ class AppBarWidget extends StatelessWidget implements PreferredSizeWidget {
)
: SizedBox(),
automaticallyImplyLeading: false,
actions: [SizedBox()],
),
);
}

+ 27
- 0
lib/presentation/custom_widgets/button_widget.dart View File

@@ -0,0 +1,27 @@
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)),
),
);
}
}

+ 4
- 1
lib/presentation/screens/account/sc_account.dart View File

@@ -1,5 +1,6 @@
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/screens/profile/sc_change_password.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_icons.dart';
@@ -64,7 +65,9 @@ class _AccountScreenState extends State<AccountScreen> {
trailingIcon: AppIcons.icArrowRight,
isTopBorder: false,
isBottomBorder: false,
onTap: () {}),
onTap: () {
Get.to(ChangePasswordScreen());
}),
Container(
width: double.infinity,
height: 20,

+ 18
- 3
lib/presentation/screens/profile/sc_change_password.dart View File

@@ -1,8 +1,8 @@
import 'package:farm_tpf/custom_model/password.dart';
import 'package:farm_tpf/data/api/app_exception.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_toast.dart';
import 'package:farm_tpf/presentation/custom_widgets/widget_utils.dart';
import 'package:farm_tpf/utils/const_color.dart';
import 'package:farm_tpf/utils/validators.dart';
@@ -118,8 +118,11 @@ class _ChangePasswordScreenState extends State<ChangePasswordScreen> {
@override
Widget build(BuildContext context) => KeyboardDismisser(
child: Scaffold(
backgroundColor: Colors.white,
key: _scaffoldKey,
appBar: AppBar(centerTitle: true, title: Text("Cập nhật mật khẩu")),
appBar: AppBarWidget(
isBack: true,
),
body: KeyboardDismisser(
child: Form(
key: _formKey,
@@ -127,7 +130,19 @@ class _ChangePasswordScreenState extends State<ChangePasswordScreen> {
child: SingleChildScrollView(
padding: EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
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(),
SizedBox(
height: 8.0,
@@ -138,7 +153,7 @@ class _ChangePasswordScreenState extends State<ChangePasswordScreen> {
),
_confirmPasswordField(),
SizedBox(
height: 8.0,
height: 20.0,
),
_btnSubmit()
],

+ 31
- 48
lib/presentation/screens/profile/sc_update_profile.dart View File

@@ -1,6 +1,8 @@
import 'package:farm_tpf/custom_model/LocationUnit.dart';
import 'package:farm_tpf/custom_model/account.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_toast.dart';
import 'package:farm_tpf/presentation/custom_widgets/widget_utils.dart';
@@ -338,57 +340,23 @@ class _UpdateProfileScreenState extends State<UpdateProfileScreen> {
);
}

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
Widget build(BuildContext context) => KeyboardDismisser(
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,
body: _buildContent()));
@@ -404,7 +372,13 @@ class _UpdateProfileScreenState extends State<UpdateProfileScreen> {
child: SingleChildScrollView(
padding: EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Tài khoản',
style: TextStyle(
fontWeight: FontWeight.w500, fontSize: 22),
),
_userNameField(),
SizedBox(
height: 8.0,
@@ -460,7 +434,16 @@ class _UpdateProfileScreenState extends State<UpdateProfileScreen> {
SizedBox(
height: 16.0,
),
_btnChangePassword(),
ButtonWidget(
title: 'CẬP NHẬT',
onPressed: () {
FocusScopeNode currentFocus =
FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
_validateInputs();
}),
],
),
));

Loading…
Cancel
Save