gaol преди 1 седмица
родител
ревизия
17dd74df95

+ 73 - 10
packages/cpt_community/lib/modules/garagesale/garagesale_post/garagesale_post_page.dart

@@ -12,6 +12,10 @@ import 'package:widgets/my_appbar.dart';
 import 'package:widgets/my_button.dart';
 import 'package:widgets/my_text_field.dart';
 import 'package:widgets/widget_export.dart';
+import 'package:widgets/shatter/picker_container.dart';
+import 'package:widgets/shatter/form_require_text.dart';
+import 'package:widgets/ext/ex_widget.dart';
+
 
 import 'garagesale_post_vm.dart';
 
@@ -35,7 +39,7 @@ class GaragesalePostPage extends HookConsumerWidget {
     return Scaffold(
       appBar: MyAppBar.appBar(
         context,
-        "Create Post",
+        "Garagesale Post",
         backgroundColor: context.appColors.whiteBG,
       ),
       backgroundColor: Colors.white,
@@ -48,17 +52,52 @@ class GaragesalePostPage extends HookConsumerWidget {
                     clipBehavior: Clip.none,
                     child: Column(
                         children: [
-                          // mind textearea
+                          // sale 选择
+                          Container(
+                            margin: const EdgeInsets.only(left:15, right:15, top: 5),
+                            child: _buildSaleInputSelectCmp(context, ref),
+                          ),
+                          // category 选择
+                          Container(
+                            margin: const EdgeInsets.only(left:15, right:15, top: 5),
+                            child: _buildCategoryInputSelectCmp(context, ref),
+                          ),
+                          // title
+                          Container(
+                            margin: const EdgeInsets.only(left:15, right:15, top: 20),
+                            child: Column(
+                              crossAxisAlignment: CrossAxisAlignment.start,
+                              children: [
+                                FormRequireText(
+                                  text: "Title",
+                                  textColor: context.appColors.textBlack,
+                                  fontSize: 17,
+                                ).marginOnly(bottom: 14.5),
+                                _buildInputLayout(context, ref, 'title'),
+                              ]
+                            )
+                          ),
+                          // description
                           Container(
                             margin: const EdgeInsets.only(left:15, right:15,top: 20),
-                            child: _buildTextArea(context, ref),
+                            child: Column(
+                                crossAxisAlignment: CrossAxisAlignment.start,
+                                children: [
+                                  FormRequireText(
+                                    text: "Description",
+                                    textColor: context.appColors.textBlack,
+                                    fontSize: 17,
+                                  ).marginOnly(bottom: 14.5),
+                                  _buildTextArea(context, ref, 'description'),
+                                ]
+                            )
+
                           ),
                           Container(
                             width: double.infinity,
                             height: 200,
                             color: Colors.white,
-                            margin: const EdgeInsets.only(left:15, right:15, top: 20, bottom: 20),
-                            padding: const EdgeInsets.all(15),
+                            margin: const EdgeInsets.only(left:15, right:15, top: 10, bottom: 20),
                             // 选择图片上传 控件
                             child: _buildImageSelectCmp(context, ref,vm),
                           ),
@@ -81,6 +120,7 @@ class GaragesalePostPage extends HookConsumerWidget {
                         fontSize: 16,
                         onPressed: (){
                           // Navigator.pop(context);
+                          vm.submitGaragesalePost();
                         },
                       ),
                     ),
@@ -93,8 +133,7 @@ class GaragesalePostPage extends HookConsumerWidget {
   }
 
   /// textarea
-  Widget _buildTextArea(BuildContext context, WidgetRef ref){
-
+  Widget _buildTextArea(BuildContext context, WidgetRef ref, key){
     final state = ref.watch(garagesalePostVmProvider);
     final vm = ref.read(garagesalePostVmProvider.notifier);
 
@@ -103,7 +142,7 @@ class GaragesalePostPage extends HookConsumerWidget {
       height: 200,
       padding: const EdgeInsets.all(15),
       decoration: BoxDecoration(
-        color: Colors.white,
+        color: context.appColors.authFiledBG,
         borderRadius: BorderRadius.circular(5),
         // boxShadow: [
         //   BoxShadow(
@@ -117,7 +156,7 @@ class GaragesalePostPage extends HookConsumerWidget {
       child: _buildTextAreaLayout(
         context,
         ref,
-        'mind',
+        key,
       ),
     );
   }
@@ -193,11 +232,34 @@ class GaragesalePostPage extends HookConsumerWidget {
     );
   }
 
+  /// sale 选择
+  Widget _buildSaleInputSelectCmp(BuildContext context, WidgetRef ref, ){
+    final vm = ref.read(garagesalePostVmProvider.notifier);
+    final state = ref.watch(garagesalePostVmProvider);
+    return PickerContainer(
+      content: state.saleSelectedOption ?? "",
+      hint: S.current.choose_category,
+      margin: const EdgeInsets.only(top: 16),
+      onClick: vm.pickSaleCallback,
+    );
+  }
+
+  /// category 选择
+  Widget _buildCategoryInputSelectCmp(BuildContext context, WidgetRef ref, ){
+    final vm = ref.read(garagesalePostVmProvider.notifier);
+    final state = ref.watch(garagesalePostVmProvider);
+    return PickerContainer(
+      content: state.categorySelectedOption ?? "",
+      hint: S.current.choose_category,
+      margin: const EdgeInsets.only(top: 16),
+      onClick: vm.pickCategoryCallback,
+    );
+  }
 
   /// 单行输入框
   Widget _buildInputLayout(
       BuildContext context,
-      state,
+      WidgetRef ref,
       String key,
       {
         double height = 48,
@@ -211,6 +273,7 @@ class GaragesalePostPage extends HookConsumerWidget {
         TextInputAction textInputAction = TextInputAction.done,
         Function? onSubmit,
       }) {
+    final state = ref.watch(garagesalePostVmProvider);
     return IgnoreKeyboardDismiss(
       child: MyTextField(
         key,

+ 14 - 5
packages/cpt_community/lib/modules/garagesale/garagesale_post/garagesale_post_vm.dart

@@ -74,7 +74,7 @@ class GaragesalePostVm extends _$GaragesalePostVm {
   }
 
   //catogery 选择选项
-  void pickCategory() {
+  void pickCategoryCallback() {
     _dismissKeyboard(keyStr: 'title');
     _dismissKeyboard(keyStr: 'description');
 
@@ -88,7 +88,7 @@ class GaragesalePostVm extends _$GaragesalePostVm {
   }
 
   //sale 选择选项
-  void pickSale() {
+  void pickSaleCallback() {
     _dismissKeyboard(keyStr: 'title');
     _dismissKeyboard(keyStr: 'description');
 
@@ -144,21 +144,30 @@ class GaragesalePostVm extends _$GaragesalePostVm {
 
   ///提交反馈
   void submitGaragesalePost() {
+    Log.d("GaragesalePostPageState 提交表单");
     state = state.copyWith(fieldErrorText: null);
 
     _dismissKeyboard();
 
     // 获取表单的值
-    String mindValue = _getFormFieldValue(keyStr: 'mind');
+    String  saleValue= _getFormFieldValue(keyStr: 'sale');
+    String  categoryValue= _getFormFieldValue(keyStr: 'category');
+    String  titleValue= _getFormFieldValue(keyStr: 'title');
+    String  descriptionValue= _getFormFieldValue(keyStr: 'description');
 
-    Log.d('当前待提交的 mind:$mindValue  imgList:${state.imgList}');
+    Log.d('当前待提交的 sale:$saleValue category:$categoryValue title:$titleValue description:$descriptionValue  imgList:${state.imgList}');
 
 
-    if (Utils.isEmpty(mindValue)) {
+    if (Utils.isEmpty(saleValue)) {
       state = state.copyWith(fieldErrorText: "Title cannot be empty!");
       return;
     }
 
+    if (Utils.isEmpty(categoryValue)) {
+      state = state.copyWith(fieldErrorText: "category cannot be empty!");
+      return;
+    }
+
     //去成功页面
     // FeedbackCreateSuccessPage.startInstance();
     // 返回上一页