|
|
|
@ -51,112 +51,116 @@ class _AddItemDetailsFragmentState extends State<AddItemDetailsFragment> {
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return SingleChildScrollView(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
"Add details".toText20(isBold: true).paddingOnly(top: 24, left: 21, right: 21),
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
DynamicTextFieldWidget(
|
|
|
|
|
"Title",
|
|
|
|
|
itemTitle.isEmpty ? "Item title" : itemTitle,
|
|
|
|
|
isEnable: true,
|
|
|
|
|
suffixIconData: Icons.search,
|
|
|
|
|
isPopup: false,
|
|
|
|
|
lines: 1,
|
|
|
|
|
isInputTypeNum: false,
|
|
|
|
|
isReadOnly: false,
|
|
|
|
|
onChange: (String value) {
|
|
|
|
|
itemTitle = value;
|
|
|
|
|
},
|
|
|
|
|
).paddingOnly(),
|
|
|
|
|
DynamicTextFieldWidget(
|
|
|
|
|
"Description",
|
|
|
|
|
itemDescription.isEmpty ? "Item description" : itemDescription,
|
|
|
|
|
isEnable: true,
|
|
|
|
|
suffixIconData: Icons.search,
|
|
|
|
|
isPopup: false,
|
|
|
|
|
lines: 4,
|
|
|
|
|
isInputTypeNum: false,
|
|
|
|
|
isReadOnly: false,
|
|
|
|
|
onChange: (String value) {
|
|
|
|
|
itemDescription = value;
|
|
|
|
|
},
|
|
|
|
|
).paddingOnly(top: 12),
|
|
|
|
|
"Item Condition".toText14(isBold: true).paddingOnly(top: 21),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
ShowRadio(title: "New", value: "new", groupValue: selectedItemCondition, selectedColor: MyColors.gradiantStartColor).onPress(() {
|
|
|
|
|
selectedItemCondition = "new";
|
|
|
|
|
setState(() {});
|
|
|
|
|
}),
|
|
|
|
|
12.width,
|
|
|
|
|
ShowRadio(title: "Used", value: "used", groupValue: selectedItemCondition, selectedColor: MyColors.gradiantStartColor).onPress(() {
|
|
|
|
|
selectedItemCondition = "used";
|
|
|
|
|
return Column(
|
|
|
|
|
children: [
|
|
|
|
|
ListView(
|
|
|
|
|
padding: const EdgeInsets.only(left: 21, right: 21, bottom: 21),
|
|
|
|
|
children: [
|
|
|
|
|
LocaleKeys.addDetails.tr().toText20(),
|
|
|
|
|
12.height,
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
DynamicTextFieldWidget(
|
|
|
|
|
LocaleKeys.title.tr(),
|
|
|
|
|
itemTitle.isEmpty ? LocaleKeys.itemTitle.tr() : itemTitle,
|
|
|
|
|
isEnable: true,
|
|
|
|
|
suffixIconData: Icons.search,
|
|
|
|
|
isPopup: false,
|
|
|
|
|
lines: 1,
|
|
|
|
|
isInputTypeNum: false,
|
|
|
|
|
isReadOnly: false,
|
|
|
|
|
onChange: (String value) {
|
|
|
|
|
itemTitle = value;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
DynamicTextFieldWidget(
|
|
|
|
|
LocaleKeys.description.tr(),
|
|
|
|
|
itemDescription.isEmpty ? LocaleKeys.itemDescription.tr() : itemDescription,
|
|
|
|
|
isEnable: true,
|
|
|
|
|
suffixIconData: Icons.search,
|
|
|
|
|
isPopup: false,
|
|
|
|
|
lines: 4,
|
|
|
|
|
isInputTypeNum: false,
|
|
|
|
|
isReadOnly: false,
|
|
|
|
|
onChange: (String value) {
|
|
|
|
|
itemDescription = value;
|
|
|
|
|
},
|
|
|
|
|
).paddingOnly(top: 12),
|
|
|
|
|
LocaleKeys.itemCondition.tr().toText14().paddingOnly(top: 21),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
ShowRadio(title: LocaleKeys.newString.tr(), value: "new", groupValue: selectedItemCondition, selectedColor: MyColors.gradiantStartColor).onPress(() {
|
|
|
|
|
selectedItemCondition = "new";
|
|
|
|
|
setState(() {});
|
|
|
|
|
}),
|
|
|
|
|
12.width,
|
|
|
|
|
ShowRadio(title: LocaleKeys.used.tr(), value: "used", groupValue: selectedItemCondition, selectedColor: MyColors.gradiantStartColor).onPress(() {
|
|
|
|
|
selectedItemCondition = "used";
|
|
|
|
|
setState(() {});
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
).paddingOnly(top: 12),
|
|
|
|
|
PopupMenuButton(
|
|
|
|
|
child: DynamicTextFieldWidget(
|
|
|
|
|
LocaleKeys.region.tr(),
|
|
|
|
|
selectedRegion.regionName ?? LocaleKeys.selectRegion.tr(),
|
|
|
|
|
isEnable: false,
|
|
|
|
|
isPopup: true,
|
|
|
|
|
isInputTypeNum: true,
|
|
|
|
|
isReadOnly: false,
|
|
|
|
|
),
|
|
|
|
|
itemBuilder: (_) => <PopupMenuItem<int>>[
|
|
|
|
|
for (int i = 0; i < getRegionsList!.length; i++) PopupMenuItem<int>(child: Text(getRegionsList[i].regionName!), value: i),
|
|
|
|
|
],
|
|
|
|
|
onSelected: (int popupIndex) {
|
|
|
|
|
selectedRegion = getRegionsList![popupIndex];
|
|
|
|
|
setState(() {});
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
).paddingOnly(top: 12),
|
|
|
|
|
PopupMenuButton(
|
|
|
|
|
child: DynamicTextFieldWidget(
|
|
|
|
|
"Region",
|
|
|
|
|
selectedRegion.regionName ?? "Select Region",
|
|
|
|
|
isEnable: false,
|
|
|
|
|
isPopup: true,
|
|
|
|
|
},
|
|
|
|
|
).paddingOnly(top: 21),
|
|
|
|
|
DynamicTextFieldWidget(
|
|
|
|
|
LocaleKeys.itemPrice.tr(),
|
|
|
|
|
itemPrice == 0 ? LocaleKeys.price.tr() : itemPrice.toString(),
|
|
|
|
|
isEnable: true,
|
|
|
|
|
suffixIconData: Icons.search,
|
|
|
|
|
isPopup: false,
|
|
|
|
|
lines: 1,
|
|
|
|
|
isInputTypeNum: true,
|
|
|
|
|
isReadOnly: false,
|
|
|
|
|
),
|
|
|
|
|
itemBuilder: (_) => <PopupMenuItem<int>>[
|
|
|
|
|
for (int i = 0; i < getRegionsList!.length; i++) PopupMenuItem<int>(child: Text(getRegionsList[i].regionName!), value: i),
|
|
|
|
|
],
|
|
|
|
|
onSelected: (int popupIndex) {
|
|
|
|
|
selectedRegion = getRegionsList![popupIndex];
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
).paddingOnly(top: 21),
|
|
|
|
|
DynamicTextFieldWidget(
|
|
|
|
|
"Item Price",
|
|
|
|
|
itemPrice == 0 ? "Price" : itemPrice.toString(),
|
|
|
|
|
isEnable: true,
|
|
|
|
|
suffixIconData: Icons.search,
|
|
|
|
|
isPopup: false,
|
|
|
|
|
lines: 1,
|
|
|
|
|
isInputTypeNum: true,
|
|
|
|
|
isReadOnly: false,
|
|
|
|
|
onChange: (String value) {
|
|
|
|
|
itemPrice = num.parse(value);
|
|
|
|
|
},
|
|
|
|
|
).paddingOnly(top: 12),
|
|
|
|
|
"Item Photos".toText14(isBold: true).paddingOnly(top: 16),
|
|
|
|
|
attachmentView("Attachments").paddingOnly(top: 12),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
DefaultButton(
|
|
|
|
|
LocaleKeys.cancel.tr(),
|
|
|
|
|
() async {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
onChange: (String value) {
|
|
|
|
|
itemPrice = num.parse(value);
|
|
|
|
|
},
|
|
|
|
|
).paddingOnly(top: 12),
|
|
|
|
|
LocaleKeys.itemPhotos.tr().toText14().paddingOnly(top: 21),
|
|
|
|
|
attachmentView(LocaleKeys.attachments.tr()).paddingOnly(top: 12),
|
|
|
|
|
],
|
|
|
|
|
).objectContainerView(title: LocaleKeys.itemInfo.tr()),
|
|
|
|
|
],
|
|
|
|
|
).expanded,
|
|
|
|
|
1.divider,
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
DefaultButton(
|
|
|
|
|
LocaleKeys.cancel.tr(),
|
|
|
|
|
() async {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
},
|
|
|
|
|
colors: const [Color(0xffD02127), Color(0xffD02127)],
|
|
|
|
|
).expanded,
|
|
|
|
|
8.width,
|
|
|
|
|
DefaultButton(
|
|
|
|
|
LocaleKeys.next.tr(),
|
|
|
|
|
isButtonDisabled()
|
|
|
|
|
? null
|
|
|
|
|
: () async {
|
|
|
|
|
AddItemDetailsFragment.itemReviewModel = getItemReviewObject();
|
|
|
|
|
widget.changePageViewIndex(2);
|
|
|
|
|
},
|
|
|
|
|
colors: const [Color(0xffD02127), Color(0xffD02127)],
|
|
|
|
|
).expanded,
|
|
|
|
|
12.width,
|
|
|
|
|
DefaultButton(
|
|
|
|
|
LocaleKeys.next.tr(),
|
|
|
|
|
isButtonDisabled()
|
|
|
|
|
? null
|
|
|
|
|
: () async {
|
|
|
|
|
AddItemDetailsFragment.itemReviewModel = getItemReviewObject();
|
|
|
|
|
widget.changePageViewIndex(2);
|
|
|
|
|
},
|
|
|
|
|
disabledColor: MyColors.lightGrayColor,
|
|
|
|
|
).expanded
|
|
|
|
|
],
|
|
|
|
|
).paddingOnly(top: 21),
|
|
|
|
|
],
|
|
|
|
|
).objectContainerView(title: "Item Info").paddingAll(21),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
disabledColor: MyColors.lightGrayColor,
|
|
|
|
|
).expanded
|
|
|
|
|
],
|
|
|
|
|
).insideContainer
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -174,82 +178,70 @@ class _AddItemDetailsFragmentState extends State<AddItemDetailsFragment> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget attachmentView(String title) {
|
|
|
|
|
return Container(
|
|
|
|
|
padding: const EdgeInsets.only(top: 15, bottom: 15, left: 14, right: 14),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
borderRadius: BorderRadius.circular(15),
|
|
|
|
|
boxShadow: [
|
|
|
|
|
BoxShadow(
|
|
|
|
|
color: const Color(0xff000000).withOpacity(.05),
|
|
|
|
|
blurRadius: 26,
|
|
|
|
|
offset: const Offset(0, -3),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
title.toText16().expanded,
|
|
|
|
|
6.width,
|
|
|
|
|
SimpleButton(LocaleKeys.add.tr(), () async {
|
|
|
|
|
ImageOptions.showImageOptions(context, (String image, File file) {
|
|
|
|
|
setState(() {
|
|
|
|
|
images.add(image);
|
|
|
|
|
});
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
title.toText16().expanded,
|
|
|
|
|
6.width,
|
|
|
|
|
SimpleButton(LocaleKeys.add.tr(), () async {
|
|
|
|
|
ImageOptions.showImageOptions(context, (String image, File file) {
|
|
|
|
|
setState(() {
|
|
|
|
|
images.add(image);
|
|
|
|
|
});
|
|
|
|
|
}, fontSize: 14),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
if (images.isNotEmpty) 12.height,
|
|
|
|
|
if (images.isNotEmpty)
|
|
|
|
|
ListView.separated(
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
itemBuilder: (cxt, index) {
|
|
|
|
|
return Container(
|
|
|
|
|
margin: const EdgeInsets.all(10),
|
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
const Icon(Icons.attach_file_sharp),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
width: 8,
|
|
|
|
|
),
|
|
|
|
|
'image ${index + 1}.png'.toText16(),
|
|
|
|
|
],
|
|
|
|
|
});
|
|
|
|
|
}, fontSize: 14),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
if (images.isNotEmpty) 12.height,
|
|
|
|
|
if (images.isNotEmpty)
|
|
|
|
|
ListView.separated(
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
itemBuilder: (cxt, index) {
|
|
|
|
|
return Container(
|
|
|
|
|
margin: const EdgeInsets.all(10),
|
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
const Icon(Icons.attach_file_sharp),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
width: 8,
|
|
|
|
|
),
|
|
|
|
|
'image ${index + 1}.png'.toText16(),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
InkWell(
|
|
|
|
|
onTap: () {
|
|
|
|
|
setState(() {
|
|
|
|
|
images.remove(images[index]);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
child: Icon(
|
|
|
|
|
Icons.delete_sharp,
|
|
|
|
|
color: Colors.red[300],
|
|
|
|
|
),
|
|
|
|
|
InkWell(
|
|
|
|
|
onTap: () {
|
|
|
|
|
setState(() {
|
|
|
|
|
images.remove(images[index]);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
child: Icon(
|
|
|
|
|
Icons.delete_sharp,
|
|
|
|
|
color: Colors.red[300],
|
|
|
|
|
))
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
separatorBuilder: (cxt, index) => 6.height,
|
|
|
|
|
itemCount: images.length),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
separatorBuilder: (cxt, index) => 6.height,
|
|
|
|
|
itemCount: images.length),
|
|
|
|
|
],
|
|
|
|
|
).objectContainerView();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void getAdDetails() async {
|
|
|
|
|
Future<void> getAdDetails() async {
|
|
|
|
|
// todo need to change this method later , its not a good approach to do it like this.
|
|
|
|
|
String details = await Utils.getStringFromPrefs(SharedPrefsConsts.editItemForSale);
|
|
|
|
|
var body = json.decode(details);
|
|
|
|
|
|
|
|
|
@ -274,17 +266,15 @@ class _AddItemDetailsFragmentState extends State<AddItemDetailsFragment> {
|
|
|
|
|
|
|
|
|
|
AddItemDetailsFragment.itemReviewModel = itemReviewModel;
|
|
|
|
|
SelectCategoryFragment.selectedSaleCategory = selectedSaleCategoryAd;
|
|
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void getRegions() async {
|
|
|
|
|
try {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
getRegionsList = await ItemsForSaleApiClient().getRegions();
|
|
|
|
|
await getAdDetails();
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
setState(() {});
|
|
|
|
|
getAdDetails();
|
|
|
|
|
} catch (ex) {
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
Utils.handleException(ex, context, null);
|
|
|
|
|