소스 검색

设置列表

周睿 1 년 전
부모
커밋
f819acbfb5
2개의 변경된 파일22개의 추가작업 그리고 12개의 파일을 삭제
  1. 1 0
      app_business/lib/service/api.dart
  2. 21 12
      app_business/lib/view/home/event_manage/dialog_settings.dart

+ 1 - 0
app_business/lib/service/api.dart

@@ -299,6 +299,7 @@ class EventRegisterInfo {
 
 class Rule {
   var id = 0;
+  var idx = 0;
   var name = '';
   RuleValue value = RuleValueBool();
 }

+ 21 - 12
app_business/lib/view/home/event_manage/dialog_settings.dart

@@ -14,9 +14,10 @@ class SettingsController extends GetxController {
         .toActivityRulesQuery(IdRequest()..id = Int64(id))
         .then((p0) {
       rules.update((val) {
-        for (final e in p0.list) {
+        for (final (i, e) in p0.list.indexed) {
           val![e.arrId] = Rule()
             ..id = e.arrId
+            ..idx = i
             ..name = e.arName
             ..value = e.arType == 1
                 ? (RuleValueBool()..value = e.arValue == 'true')
@@ -49,7 +50,7 @@ class DialogSettings extends GetView<SettingsController> {
             content: Column(
               mainAxisSize: MainAxisSize.min,
               children: [
-                Obx(() => _list()),
+                Obx(() => _list(context)),
                 Padding(
                     padding: const EdgeInsets.symmetric(horizontal: 45),
                     child: AppButton.confirm(
@@ -66,13 +67,16 @@ class DialogSettings extends GetView<SettingsController> {
         });
   }
 
-  Widget _list() {
-    return Column(
-      mainAxisSize: MainAxisSize.min,
-      crossAxisAlignment: CrossAxisAlignment.start,
-      children:
-          controller.rules.value.values.map((data) => _RuleElem(data)).toList(),
-    );
+  Widget _list(BuildContext context) {
+    final l = controller.rules.value.values.toList();
+    l.sort((a, b) => a.idx.compareTo(b.idx));
+
+    return SizedBox(
+        height: context.height * 0.6,
+        width: 420,
+        child: ListView(
+          children: l.map((data) => _RuleElem(data)).toList(),
+        ));
   }
 }
 
@@ -102,7 +106,8 @@ class _RuleElem extends GetView<SettingsController> {
         mainAxisSize: MainAxisSize.min,
         children: value.options
             .map((e) => _Radio(
-                value: e.show,
+                value: e.value,
+                show: e.show,
                 groupValue: value.value,
                 onChanged: (v) {
                   if (v != null) {
@@ -129,8 +134,12 @@ class _RuleElem extends GetView<SettingsController> {
 
 class _Radio extends StatelessWidget {
   const _Radio(
-      {required this.value, required this.groupValue, required this.onChanged});
+      {required this.value,
+      required this.show,
+      required this.groupValue,
+      required this.onChanged});
   final String value;
+  final String show;
   final String groupValue;
   final void Function(String?) onChanged;
 
@@ -144,7 +153,7 @@ class _Radio extends StatelessWidget {
             value: value,
             groupValue: groupValue,
             onChanged: onChanged),
-        Text(value),
+        Text(show),
       ],
     );
   }