|
|
|
|
@ -45,9 +45,7 @@ class _CreateBranchViewState extends State<CreateBranchView> {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: CustomAppBar(
|
|
|
|
|
title: LocaleKeys.createBranch.tr(),
|
|
|
|
|
),
|
|
|
|
|
appBar: CustomAppBar(title: LocaleKeys.defineBranches.tr()),
|
|
|
|
|
body: Consumer<ServiceVM>(builder: (context, serviceVM, _) {
|
|
|
|
|
return SizedBox(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
@ -56,152 +54,148 @@ class _CreateBranchViewState extends State<CreateBranchView> {
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.all(20.0),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
// LocaleKeys.chooseCountry.tr().toText(fontSize: 14, color: MyColors.lightTextColor),
|
|
|
|
|
// 8.height,
|
|
|
|
|
serviceVM.country != null
|
|
|
|
|
? DropdownField(
|
|
|
|
|
(DropValue value) {
|
|
|
|
|
serviceVM.countryValue = DropValue(value.id, value.value, "");
|
|
|
|
|
serviceVM.countryCode = value.subValue;
|
|
|
|
|
serviceVM.countryId = value.id;
|
|
|
|
|
serviceVM.getAllCities(widget.branchData, EasyLocalization.of(context)?.currentLocale?.countryCode ?? "SA");
|
|
|
|
|
},
|
|
|
|
|
isSelectAble: widget.branchData == null ? true : false,
|
|
|
|
|
list: serviceVM.countryDropList,
|
|
|
|
|
dropdownValue: serviceVM.countryValue,
|
|
|
|
|
hint: "${LocaleKeys.chooseCountry.tr()}*",
|
|
|
|
|
)
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
12.height,
|
|
|
|
|
serviceVM.country != null
|
|
|
|
|
? DropdownField(
|
|
|
|
|
(DropValue value) {
|
|
|
|
|
serviceVM.countryValue = DropValue(value.id, value.value, "");
|
|
|
|
|
serviceVM.countryCode = value.subValue;
|
|
|
|
|
serviceVM.countryId = value.id;
|
|
|
|
|
serviceVM.getAllCities(widget.branchData, EasyLocalization.of(context)?.currentLocale?.countryCode ?? "SA");
|
|
|
|
|
},
|
|
|
|
|
isSelectAble: widget.branchData == null ? true : false,
|
|
|
|
|
list: serviceVM.countryDropList,
|
|
|
|
|
dropdownValue: serviceVM.countryValue,
|
|
|
|
|
hint: "${LocaleKeys.chooseCountry.tr()}*",
|
|
|
|
|
)
|
|
|
|
|
: const CircularProgressIndicator(),
|
|
|
|
|
12.height,
|
|
|
|
|
if (serviceVM.countryId != -1)
|
|
|
|
|
serviceVM.cities != null
|
|
|
|
|
? serviceVM.citiesDropList.isEmpty
|
|
|
|
|
? Text(LocaleKeys.no_city_available.tr())
|
|
|
|
|
: DropdownField(
|
|
|
|
|
(DropValue value) {
|
|
|
|
|
serviceVM.cityValue = DropValue(value.id, value.value, "");
|
|
|
|
|
serviceVM.setOnlyState(ViewState.busy);
|
|
|
|
|
serviceVM.cityId = value.id;
|
|
|
|
|
serviceVM.setState(ViewState.idle);
|
|
|
|
|
},
|
|
|
|
|
list: serviceVM.citiesDropList,
|
|
|
|
|
dropdownValue: serviceVM.cityValue,
|
|
|
|
|
hint: "${LocaleKeys.chooseCity.tr()}*",
|
|
|
|
|
)
|
|
|
|
|
: const CircularProgressIndicator(),
|
|
|
|
|
12.height,
|
|
|
|
|
if (serviceVM.countryId != -1)
|
|
|
|
|
serviceVM.cities != null
|
|
|
|
|
? serviceVM.citiesDropList.isEmpty
|
|
|
|
|
? Text(LocaleKeys.no_city_available.tr())
|
|
|
|
|
: DropdownField(
|
|
|
|
|
(DropValue value) {
|
|
|
|
|
serviceVM.cityValue = DropValue(value.id, value.value, "");
|
|
|
|
|
serviceVM.setOnlyState(ViewState.busy);
|
|
|
|
|
serviceVM.cityId = value.id;
|
|
|
|
|
serviceVM.setState(ViewState.idle);
|
|
|
|
|
},
|
|
|
|
|
list: serviceVM.citiesDropList,
|
|
|
|
|
dropdownValue: serviceVM.cityValue,
|
|
|
|
|
hint: "${LocaleKeys.chooseCity.tr()}*",
|
|
|
|
|
)
|
|
|
|
|
: const CircularProgressIndicator(),
|
|
|
|
|
12.height,
|
|
|
|
|
if (serviceVM.cityId != -1)
|
|
|
|
|
Column(
|
|
|
|
|
children: [
|
|
|
|
|
TxtField(
|
|
|
|
|
hint: "${LocaleKeys.branchName.tr()}*",
|
|
|
|
|
value: serviceVM.branchName,
|
|
|
|
|
onChanged: (v) {
|
|
|
|
|
serviceVM.branchName = v;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
TxtField(
|
|
|
|
|
hint: "${LocaleKeys.branchDescription.tr()}*",
|
|
|
|
|
value: serviceVM.branchDescription,
|
|
|
|
|
onChanged: (v) {
|
|
|
|
|
serviceVM.branchDescription = v;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
TxtField(
|
|
|
|
|
hint: LocaleKeys.address.tr(),
|
|
|
|
|
isNeedClickAll: false,
|
|
|
|
|
maxLines: 3,
|
|
|
|
|
value: serviceVM.address,
|
|
|
|
|
onChanged: (v) {
|
|
|
|
|
serviceVM.address = v;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
InkWell(
|
|
|
|
|
onTap: () {
|
|
|
|
|
navigateTo(
|
|
|
|
|
context,
|
|
|
|
|
PickLocationPage(
|
|
|
|
|
onPickAddress: (double latitude, double longitude, String address) {
|
|
|
|
|
serviceVM.latitude = latitude;
|
|
|
|
|
serviceVM.longitude = longitude;
|
|
|
|
|
serviceVM.address = address;
|
|
|
|
|
serviceVM.setState(ViewState.idle);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
child: Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: 45,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.transparent,
|
|
|
|
|
border: Border.all(color: MyColors.darkPrimaryColor, width: 2),
|
|
|
|
|
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
|
|
|
|
12.height,
|
|
|
|
|
if (serviceVM.cityId != -1)
|
|
|
|
|
Column(
|
|
|
|
|
children: [
|
|
|
|
|
TxtField(
|
|
|
|
|
hint: "${LocaleKeys.branchName.tr()}*",
|
|
|
|
|
value: serviceVM.branchName,
|
|
|
|
|
onChanged: (v) {
|
|
|
|
|
serviceVM.branchName = v;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
TxtField(
|
|
|
|
|
hint: "${LocaleKeys.branchDescription.tr()}*",
|
|
|
|
|
value: serviceVM.branchDescription,
|
|
|
|
|
onChanged: (v) {
|
|
|
|
|
serviceVM.branchDescription = v;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
TxtField(
|
|
|
|
|
hint: LocaleKeys.address.tr(),
|
|
|
|
|
isNeedClickAll: false,
|
|
|
|
|
maxLines: 3,
|
|
|
|
|
value: serviceVM.address,
|
|
|
|
|
onChanged: (v) {
|
|
|
|
|
serviceVM.address = v;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
InkWell(
|
|
|
|
|
onTap: () {
|
|
|
|
|
navigateTo(
|
|
|
|
|
context,
|
|
|
|
|
PickLocationPage(
|
|
|
|
|
onPickAddress: (double latitude, double longitude, String address) {
|
|
|
|
|
serviceVM.latitude = latitude;
|
|
|
|
|
serviceVM.longitude = longitude;
|
|
|
|
|
serviceVM.address = address;
|
|
|
|
|
serviceVM.setState(ViewState.idle);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
const Icon(
|
|
|
|
|
Icons.place_outlined,
|
|
|
|
|
size: 18,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
child: Container(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: 45,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.transparent,
|
|
|
|
|
border: Border.all(color: MyColors.darkPrimaryColor, width: 2),
|
|
|
|
|
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
|
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
const Icon(
|
|
|
|
|
Icons.place_outlined,
|
|
|
|
|
size: 18,
|
|
|
|
|
color: MyColors.darkPrimaryColor,
|
|
|
|
|
),
|
|
|
|
|
8.width,
|
|
|
|
|
Text(
|
|
|
|
|
LocaleKeys.pickAddress.tr(),
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
color: MyColors.darkPrimaryColor,
|
|
|
|
|
),
|
|
|
|
|
8.width,
|
|
|
|
|
Text(
|
|
|
|
|
LocaleKeys.pickAddress.tr(),
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
color: MyColors.darkPrimaryColor,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
DottedRectContainer(
|
|
|
|
|
onTap: () => serviceVM.pickMultipleImages(),
|
|
|
|
|
text: LocaleKeys.attachImage.tr(),
|
|
|
|
|
icon: MyAssets.attachmentIcon.buildSvg(),
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
DottedRectContainer(
|
|
|
|
|
onTap: () => serviceVM.pickMultipleImages(),
|
|
|
|
|
text: LocaleKeys.attachImage.tr(),
|
|
|
|
|
icon: MyAssets.attachmentIcon.buildSvg(),
|
|
|
|
|
),
|
|
|
|
|
if (serviceVM.branchImageError != "") ...[
|
|
|
|
|
10.height,
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
|
children: [
|
|
|
|
|
serviceVM.branchImageError.toText(fontSize: 14, color: Colors.red),
|
|
|
|
|
],
|
|
|
|
|
).paddingOnly(right: 10)
|
|
|
|
|
],
|
|
|
|
|
if (serviceVM.pickedBranchImages.isNotEmpty) ...[
|
|
|
|
|
16.height,
|
|
|
|
|
PickedFilesContainer(
|
|
|
|
|
pickedFiles: serviceVM.pickedBranchImages,
|
|
|
|
|
onCrossPressedPrimary: serviceVM.removeImageFromList,
|
|
|
|
|
onAddFilePressed: () {
|
|
|
|
|
serviceVM.pickMultipleImages();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
if (serviceVM.branchImageError != "") ...[
|
|
|
|
|
10.height,
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
|
children: [
|
|
|
|
|
serviceVM.branchImageError.toText(fontSize: 14, color: Colors.red),
|
|
|
|
|
],
|
|
|
|
|
).paddingOnly(right: 10)
|
|
|
|
|
],
|
|
|
|
|
if (serviceVM.pickedBranchImages.isNotEmpty) ...[
|
|
|
|
|
16.height,
|
|
|
|
|
PickedFilesContainer(
|
|
|
|
|
pickedFiles: serviceVM.pickedBranchImages,
|
|
|
|
|
onCrossPressedPrimary: serviceVM.removeImageFromList,
|
|
|
|
|
onAddFilePressed: () {
|
|
|
|
|
serviceVM.pickMultipleImages();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).horPaddingMain(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
if (widget.branchData == null || widget.branchData!.id == null) ...[
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.only(left: 20, right: 20, bottom: 20),
|
|
|
|
|
padding: const EdgeInsets.only(left: 20, right: 20, bottom: 10),
|
|
|
|
|
child: ShowFillButton(
|
|
|
|
|
maxHeight: 55,
|
|
|
|
|
title: LocaleKeys.createBranch.tr(),
|
|
|
|
|
@ -222,25 +216,24 @@ class _CreateBranchViewState extends State<CreateBranchView> {
|
|
|
|
|
] else ...[
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.only(left: 20, right: 20, bottom: 20),
|
|
|
|
|
child: ShowFillButton(
|
|
|
|
|
maxHeight: 55,
|
|
|
|
|
title: widget.branchData != null ? (widget.branchData!.id == null ? LocaleKeys.createBranch.tr() : LocaleKeys.updateBranch.tr()) : LocaleKeys.createBranch.tr(),
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
await serviceVM.updateBranch(
|
|
|
|
|
widget.branchData!.id ?? 0,
|
|
|
|
|
serviceVM.branchName,
|
|
|
|
|
serviceVM.branchDescription,
|
|
|
|
|
serviceVM.cityId.toString(),
|
|
|
|
|
serviceVM.address,
|
|
|
|
|
serviceVM.latitude.toString(),
|
|
|
|
|
serviceVM.longitude.toString(),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: ShowFillButton(
|
|
|
|
|
maxHeight: 55,
|
|
|
|
|
title: LocaleKeys.updateBranch.tr(),
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
await serviceVM.onUpdateBranchPressed(
|
|
|
|
|
context: context,
|
|
|
|
|
branchID: widget.branchData!.id ?? 0,
|
|
|
|
|
branchName: widget.branchData!.branchName ?? "",
|
|
|
|
|
branchDesc: widget.branchData!.branchDescription ?? "",
|
|
|
|
|
cityID: widget.branchData!.cityId ?? 0,
|
|
|
|
|
address: widget.branchData!.address ?? "",
|
|
|
|
|
latitude: widget.branchData!.latitude ?? "0",
|
|
|
|
|
longitude: widget.branchData!.longitude ?? "0",
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
).horPaddingMain(),
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
|