|
|
|
@@ -1,12 +1,15 @@ |
|
|
|
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/widget_loading.dart'; |
|
|
|
import 'package:farm_tpf/presentation/custom_widgets/widget_toast.dart'; |
|
|
|
import 'package:farm_tpf/presentation/screens/actions/state_management_helper/change_supply.dart'; |
|
|
|
import 'package:farm_tpf/presentation/screens/location_unit/sc_location.dart'; |
|
|
|
import 'package:farm_tpf/presentation/screens/profile/controller/check_change_another_dropdown.dart'; |
|
|
|
import 'package:farm_tpf/presentation/screens/profile/sc_change_password.dart'; |
|
|
|
import 'package:farm_tpf/utils/const_color.dart'; |
|
|
|
import 'package:farm_tpf/utils/const_common.dart'; |
|
|
|
import 'package:farm_tpf/utils/const_string.dart'; |
|
|
|
import 'package:farm_tpf/utils/const_style.dart'; |
|
|
|
import 'package:farm_tpf/utils/validators.dart'; |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
@@ -38,6 +41,7 @@ class _UpdateProfileScreenState extends State<UpdateProfileScreen> { |
|
|
|
TextEditingController _fullNameController = TextEditingController(); |
|
|
|
TextEditingController _emailController = TextEditingController(); |
|
|
|
TextEditingController _addressController = TextEditingController(); |
|
|
|
var checkChangeLocation = Get.put(CheckChangeAnotherDropdown()); |
|
|
|
|
|
|
|
PackageInfo _packageInfo = PackageInfo( |
|
|
|
version: '1.0.0', |
|
|
|
@@ -54,6 +58,7 @@ class _UpdateProfileScreenState extends State<UpdateProfileScreen> { |
|
|
|
@override |
|
|
|
void initState() { |
|
|
|
super.initState(); |
|
|
|
checkChangeLocation.initValue(); |
|
|
|
_initPackageInfo(); |
|
|
|
flutterToast = FlutterToast(context); |
|
|
|
getAccountBloc.getAccount((data) { |
|
|
|
@@ -62,6 +67,14 @@ class _UpdateProfileScreenState extends State<UpdateProfileScreen> { |
|
|
|
_fullNameController.text = _account.fullName.toString(); |
|
|
|
_emailController.text = _account.email.toString(); |
|
|
|
_addressController.text = _account.address; |
|
|
|
checkChangeLocation.changeCountryByIdAndName( |
|
|
|
_account.countryId, _account.countryName); |
|
|
|
checkChangeLocation.changeProvinceByIdAndName( |
|
|
|
_account.cityId, _account.cityName); |
|
|
|
checkChangeLocation.changeDistrictByIdAndName( |
|
|
|
_account.districtId, _account.districtName); |
|
|
|
checkChangeLocation.changeWardByIdAndName( |
|
|
|
_account.wardId, _account.wardName); |
|
|
|
}, (err) { |
|
|
|
flutterToast.showToast(child: WidgetToast(message: "Lỗi tải dữ liệu")); |
|
|
|
}); |
|
|
|
@@ -146,21 +159,27 @@ class _UpdateProfileScreenState extends State<UpdateProfileScreen> { |
|
|
|
} |
|
|
|
|
|
|
|
Widget _btnSelectCountry() { |
|
|
|
return GetBuilder<ChangeSupply>(builder: (data) { |
|
|
|
return GetBuilder<CheckChangeAnotherDropdown>(builder: (data) { |
|
|
|
return FlatButton( |
|
|
|
padding: |
|
|
|
EdgeInsets.only(top: 0.0, right: 0.0, bottom: 0.0, left: 0.0), |
|
|
|
onPressed: () { |
|
|
|
if (Get.isSnackbarOpen) { |
|
|
|
Get.back(); |
|
|
|
} |
|
|
|
Navigator.of(context) |
|
|
|
.push(MaterialPageRoute( |
|
|
|
builder: (_) => LocationScreen( |
|
|
|
titleName: "Quốc gia", |
|
|
|
type: LocationType.country, |
|
|
|
filterId: null, |
|
|
|
selectedId: null), |
|
|
|
selectedId: checkChangeLocation.currentCountry.id), |
|
|
|
fullscreenDialog: false)) |
|
|
|
.then((value) { |
|
|
|
if (value != null) {} |
|
|
|
if (value != null) { |
|
|
|
var result = value as LocationUnit; |
|
|
|
checkChangeLocation.changeCountry(result); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
child: Container( |
|
|
|
@@ -173,7 +192,9 @@ class _UpdateProfileScreenState extends State<UpdateProfileScreen> { |
|
|
|
children: [ |
|
|
|
GetBuilder<ChangeSupply>( |
|
|
|
builder: (_) => Expanded( |
|
|
|
child: Text("sdfd" ?? "Quốc gia", |
|
|
|
child: Text( |
|
|
|
checkChangeLocation.currentCountry.name ?? |
|
|
|
"Quốc gia", |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 14.0, color: Colors.black87)))), |
|
|
|
Icon( |
|
|
|
@@ -186,22 +207,33 @@ class _UpdateProfileScreenState extends State<UpdateProfileScreen> { |
|
|
|
} |
|
|
|
|
|
|
|
Widget _btnSelectProvince() { |
|
|
|
return GetBuilder<ChangeSupply>(builder: (data) { |
|
|
|
return GetBuilder<CheckChangeAnotherDropdown>(builder: (data) { |
|
|
|
return FlatButton( |
|
|
|
padding: |
|
|
|
EdgeInsets.only(top: 0.0, right: 0.0, bottom: 0.0, left: 0.0), |
|
|
|
onPressed: () { |
|
|
|
Navigator.of(context) |
|
|
|
.push(MaterialPageRoute( |
|
|
|
builder: (_) => LocationScreen( |
|
|
|
titleName: "Tỉnh/Thành phố", |
|
|
|
type: LocationType.province, |
|
|
|
filterId: 1, |
|
|
|
selectedId: null), |
|
|
|
fullscreenDialog: false)) |
|
|
|
.then((value) { |
|
|
|
if (value != null) {} |
|
|
|
}); |
|
|
|
if (Get.isSnackbarOpen) { |
|
|
|
Get.back(); |
|
|
|
} |
|
|
|
if (checkChangeLocation.currentCountry.id != null) { |
|
|
|
Navigator.of(context) |
|
|
|
.push(MaterialPageRoute( |
|
|
|
builder: (_) => LocationScreen( |
|
|
|
titleName: "Tỉnh/Thành phố", |
|
|
|
type: LocationType.province, |
|
|
|
filterId: checkChangeLocation.currentCountry.id, |
|
|
|
selectedId: checkChangeLocation.currentProvince.id), |
|
|
|
fullscreenDialog: false)) |
|
|
|
.then((value) { |
|
|
|
if (value != null) { |
|
|
|
var result = value as LocationUnit; |
|
|
|
checkChangeLocation.changeProvince(result); |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
Get.snackbar(label_country_empty, label_country_empty_message, |
|
|
|
snackPosition: SnackPosition.BOTTOM); |
|
|
|
} |
|
|
|
}, |
|
|
|
child: Container( |
|
|
|
padding: EdgeInsets.only( |
|
|
|
@@ -213,7 +245,9 @@ class _UpdateProfileScreenState extends State<UpdateProfileScreen> { |
|
|
|
children: [ |
|
|
|
GetBuilder<ChangeSupply>( |
|
|
|
builder: (_) => Expanded( |
|
|
|
child: Text("sdfd" ?? "Tỉnh/Thành Phố", |
|
|
|
child: Text( |
|
|
|
checkChangeLocation.currentProvince.name ?? |
|
|
|
"Tỉnh/Thành Phố", |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 14.0, color: Colors.black87)))), |
|
|
|
Icon( |
|
|
|
@@ -226,22 +260,31 @@ class _UpdateProfileScreenState extends State<UpdateProfileScreen> { |
|
|
|
} |
|
|
|
|
|
|
|
Widget _btnSelectDistrict() { |
|
|
|
return GetBuilder<ChangeSupply>(builder: (data) { |
|
|
|
return GetBuilder<CheckChangeAnotherDropdown>(builder: (data) { |
|
|
|
return FlatButton( |
|
|
|
padding: |
|
|
|
EdgeInsets.only(top: 0.0, right: 0.0, bottom: 0.0, left: 0.0), |
|
|
|
onPressed: () { |
|
|
|
Navigator.of(context) |
|
|
|
.push(MaterialPageRoute( |
|
|
|
builder: (_) => LocationScreen( |
|
|
|
titleName: "Quận/Huyện", |
|
|
|
type: LocationType.district, |
|
|
|
filterId: 79, |
|
|
|
selectedId: null), |
|
|
|
fullscreenDialog: false)) |
|
|
|
.then((value) { |
|
|
|
if (value != null) {} |
|
|
|
}); |
|
|
|
if (Get.isSnackbarOpen) Get.back(); |
|
|
|
if (checkChangeLocation.currentProvince.id != null) { |
|
|
|
Navigator.of(context) |
|
|
|
.push(MaterialPageRoute( |
|
|
|
builder: (_) => LocationScreen( |
|
|
|
titleName: "Quận/Huyện", |
|
|
|
type: LocationType.district, |
|
|
|
filterId: checkChangeLocation.currentProvince.id, |
|
|
|
selectedId: checkChangeLocation.currentDistrict.id), |
|
|
|
fullscreenDialog: false)) |
|
|
|
.then((value) { |
|
|
|
if (value != null) { |
|
|
|
var result = value as LocationUnit; |
|
|
|
checkChangeLocation.changeDistrict(result); |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
Get.snackbar(label_province_empty, label_province_empty_message, |
|
|
|
snackPosition: SnackPosition.BOTTOM); |
|
|
|
} |
|
|
|
}, |
|
|
|
child: Container( |
|
|
|
padding: EdgeInsets.only( |
|
|
|
@@ -253,7 +296,9 @@ class _UpdateProfileScreenState extends State<UpdateProfileScreen> { |
|
|
|
children: [ |
|
|
|
GetBuilder<ChangeSupply>( |
|
|
|
builder: (_) => Expanded( |
|
|
|
child: Text("sdfd" ?? "Quận/Huyện", |
|
|
|
child: Text( |
|
|
|
checkChangeLocation.currentDistrict.name ?? |
|
|
|
"Quận/Huyện", |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 14.0, color: Colors.black87)))), |
|
|
|
Icon( |
|
|
|
@@ -266,22 +311,31 @@ class _UpdateProfileScreenState extends State<UpdateProfileScreen> { |
|
|
|
} |
|
|
|
|
|
|
|
Widget _btnSelectWard() { |
|
|
|
return GetBuilder<ChangeSupply>(builder: (data) { |
|
|
|
return GetBuilder<CheckChangeAnotherDropdown>(builder: (data) { |
|
|
|
return FlatButton( |
|
|
|
padding: |
|
|
|
EdgeInsets.only(top: 0.0, right: 0.0, bottom: 0.0, left: 0.0), |
|
|
|
onPressed: () { |
|
|
|
Navigator.of(context) |
|
|
|
.push(MaterialPageRoute( |
|
|
|
builder: (_) => LocationScreen( |
|
|
|
titleName: "Phường/Xã", |
|
|
|
type: LocationType.ward, |
|
|
|
filterId: 760, |
|
|
|
selectedId: null), |
|
|
|
fullscreenDialog: false)) |
|
|
|
.then((value) { |
|
|
|
if (value != null) {} |
|
|
|
}); |
|
|
|
if (Get.isSnackbarOpen) Get.back(); |
|
|
|
if (checkChangeLocation.currentDistrict.id != null) { |
|
|
|
Navigator.of(context) |
|
|
|
.push(MaterialPageRoute( |
|
|
|
builder: (_) => LocationScreen( |
|
|
|
titleName: "Phường/Xã", |
|
|
|
type: LocationType.ward, |
|
|
|
filterId: checkChangeLocation.currentDistrict.id, |
|
|
|
selectedId: checkChangeLocation.currentWard.id), |
|
|
|
fullscreenDialog: false)) |
|
|
|
.then((value) { |
|
|
|
if (value != null) { |
|
|
|
var result = value as LocationUnit; |
|
|
|
checkChangeLocation.changeWard(result); |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
Get.snackbar(label_district_empty, label_district_empty_message, |
|
|
|
snackPosition: SnackPosition.BOTTOM); |
|
|
|
} |
|
|
|
}, |
|
|
|
child: Container( |
|
|
|
padding: EdgeInsets.only( |
|
|
|
@@ -293,7 +347,9 @@ class _UpdateProfileScreenState extends State<UpdateProfileScreen> { |
|
|
|
children: [ |
|
|
|
GetBuilder<ChangeSupply>( |
|
|
|
builder: (_) => Expanded( |
|
|
|
child: Text("sdfd" ?? "Phường/Xã", |
|
|
|
child: Text( |
|
|
|
checkChangeLocation.currentWard.name ?? |
|
|
|
"Phường/Xã", |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 14.0, color: Colors.black87)))), |
|
|
|
Icon( |