|
@@ -22,6 +22,7 @@ class GaragesalePostVm extends _$GaragesalePostVm {
|
|
|
GaragesalePostPageState initState() {
|
|
|
return GaragesalePostPageState(
|
|
|
titleErrorText: null,
|
|
|
+ contactInfoErrorText: null,
|
|
|
priceErrorText: null,
|
|
|
descriptionErrorText: '',
|
|
|
formData: {
|
|
@@ -46,6 +47,20 @@ class GaragesalePostVm extends _$GaragesalePostVm {
|
|
|
'focusNode': FocusNode(),
|
|
|
'obsecure': false,
|
|
|
},
|
|
|
+ 'contactInfoType': {
|
|
|
+ 'value': '',
|
|
|
+ 'controller': TextEditingController(),
|
|
|
+ 'hintText': '',
|
|
|
+ 'focusNode': FocusNode(),
|
|
|
+ 'obsecure': false,
|
|
|
+ },
|
|
|
+ 'contactInfo': {
|
|
|
+ 'value': '',
|
|
|
+ 'controller': TextEditingController(),
|
|
|
+ 'hintText': '',
|
|
|
+ 'focusNode': FocusNode(),
|
|
|
+ 'obsecure': false,
|
|
|
+ },
|
|
|
'price': {
|
|
|
'value': '',
|
|
|
'controller': TextEditingController(),
|
|
@@ -85,6 +100,8 @@ class GaragesalePostVm extends _$GaragesalePostVm {
|
|
|
//catogery 选择选项
|
|
|
void pickCategoryCallback() {
|
|
|
_dismissKeyboard(keyStr: 'title');
|
|
|
+ _dismissKeyboard(keyStr: 'price');
|
|
|
+ _dismissKeyboard(keyStr: 'contactInfo');
|
|
|
_dismissKeyboard(keyStr: 'description');
|
|
|
|
|
|
OptionPickerUtil.showCupertinoOptionPicker(
|
|
@@ -100,6 +117,7 @@ class GaragesalePostVm extends _$GaragesalePostVm {
|
|
|
void pickSaleCallback() {
|
|
|
_dismissKeyboard(keyStr: 'title');
|
|
|
_dismissKeyboard(keyStr: 'price');
|
|
|
+ _dismissKeyboard(keyStr: 'contactInfo');
|
|
|
_dismissKeyboard(keyStr: 'description');
|
|
|
|
|
|
OptionPickerUtil.showCupertinoOptionPicker(
|
|
@@ -111,6 +129,22 @@ class GaragesalePostVm extends _$GaragesalePostVm {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ //sale 选择选项
|
|
|
+ void pickContactTypeCallback() {
|
|
|
+ _dismissKeyboard(keyStr: 'title');
|
|
|
+ _dismissKeyboard(keyStr: 'price');
|
|
|
+ _dismissKeyboard(keyStr: 'contactInfo');
|
|
|
+ _dismissKeyboard(keyStr: 'description');
|
|
|
+
|
|
|
+ OptionPickerUtil.showCupertinoOptionPicker(
|
|
|
+ items: state.contactTypeOptionsList,
|
|
|
+ initialSelectIndex: 0,
|
|
|
+ onPickerChanged: (_, index) {
|
|
|
+ state = state.copyWith(contactTypeSelectedOption: state.contactTypeOptionsList[index]);
|
|
|
+ },
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
// 获取聚焦的node
|
|
|
FocusNode getFocusNode(Map<String, dynamic> formData, String keyStr) {
|
|
|
return formData![keyStr]!['focusNode'];
|
|
@@ -163,18 +197,28 @@ class GaragesalePostVm extends _$GaragesalePostVm {
|
|
|
// 获取表单的值
|
|
|
String saleValue= state.saleSelectedOption ?? "";
|
|
|
String categoryValue= state.categorySelectedOption ?? "";
|
|
|
+ String contactTypeValue= state.contactTypeSelectedOption ?? "";
|
|
|
|
|
|
String titleValue= _getFormFieldValue(keyStr: 'title');
|
|
|
+ String contactInfoValue= _getFormFieldValue(keyStr: 'contactInfo');
|
|
|
String priceValue= _getFormFieldValue(keyStr: 'price');
|
|
|
String descriptionValue= _getFormFieldValue(keyStr: 'description');
|
|
|
|
|
|
- Log.d('当前待提交的 sale:$saleValue category:$categoryValue title:$titleValue price:$priceValue description:$descriptionValue imgList:${state.imgList}');
|
|
|
+ Log.d('当前待提交的 sale:$saleValue category:$categoryValue contactTypeValue:$contactTypeValue title:$titleValue contactInfoValue:$contactInfoValue price:$priceValue description:$descriptionValue imgList:${state.imgList}');
|
|
|
|
|
|
|
|
|
if (Utils.isEmpty(saleValue)) {
|
|
|
ToastEngine.show('Sale is empty');
|
|
|
return;
|
|
|
}
|
|
|
+ if (Utils.isEmpty(categoryValue)) {
|
|
|
+ ToastEngine.show('Category is empty');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (Utils.isEmpty(contactTypeValue)) {
|
|
|
+ ToastEngine.show('ContactType is empty');
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
if (Utils.isEmpty(titleValue)) {
|
|
|
state = state.copyWith(titleErrorText: 'Title is empty',);
|
|
@@ -184,6 +228,14 @@ class GaragesalePostVm extends _$GaragesalePostVm {
|
|
|
state = state.copyWith(titleErrorText: null);
|
|
|
}
|
|
|
|
|
|
+ if (Utils.isEmpty(contactInfoValue)) {
|
|
|
+ state = state.copyWith(contactInfoErrorText: 'ContactInfo is empty',);
|
|
|
+ return;
|
|
|
+ }else {
|
|
|
+ state.contactInfoErrorText = null;
|
|
|
+ state = state.copyWith(contactInfoErrorText: null);
|
|
|
+ }
|
|
|
+
|
|
|
if (Utils.isEmpty(priceValue)) {
|
|
|
state = state.copyWith(priceErrorText: 'Price is empty',);
|
|
|
return;
|
|
@@ -215,18 +267,25 @@ class GaragesalePostVm extends _$GaragesalePostVm {
|
|
|
|
|
|
// 获取表单的焦点节点
|
|
|
final FocusNode focusNode = getFocusNode(state.formData, 'title');
|
|
|
+ final FocusNode focusNodeContactInfo = getFocusNode(state.formData, 'contactInfo');
|
|
|
final FocusNode focusNodePrice = getFocusNode(state.formData, 'price');
|
|
|
|
|
|
focusNode.addListener(() {
|
|
|
// 获取焦点的时候清空错误文本
|
|
|
if (focusNode.hasFocus) {
|
|
|
- state = state.copyWith(titleErrorText: null, priceErrorText:null, descriptionErrorText: null);
|
|
|
+ state = state.copyWith(contactInfoErrorText: null, titleErrorText: null, priceErrorText:null, descriptionErrorText: null);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ focusNodeContactInfo.addListener(() {
|
|
|
+ // 获取焦点的时候清空错误文本
|
|
|
+ if (focusNodeContactInfo.hasFocus) {
|
|
|
+ state = state.copyWith(contactInfoErrorText: null, titleErrorText: null, priceErrorText:null, descriptionErrorText: null);
|
|
|
}
|
|
|
});
|
|
|
focusNodePrice.addListener(() {
|
|
|
// 获取焦点的时候清空错误文本
|
|
|
if(focusNodePrice.hasFocus){
|
|
|
- state = state.copyWith(titleErrorText: null,priceErrorText: null, descriptionErrorText: null);
|
|
|
+ state = state.copyWith(contactInfoErrorText: null, titleErrorText: null, priceErrorText:null, descriptionErrorText: null);
|
|
|
}
|
|
|
});
|
|
|
}
|