周睿 1 рік тому
батько
коміт
51de7fcefb

+ 39 - 5
app_business/lib/view/home/event_manage/event_manage.dart

@@ -69,14 +69,48 @@ class EventManage extends GetView<EventManagerController> {
     return Column(
       children: [
         Expanded(
-            child: Obx(() => ListView(
-                  children: controller.userList
-                      .map((e) => Text('${e.name}'))
-                      .toList(),
-                )))
+            child: ListView(
+          children: [
+            Obx(() => LineChart(titles: rightTitles(), children: rightUsers()))
+          ],
+        ))
       ],
     );
   }
+
+  Iterable<LineChartTitle> rightTitles() {
+    return [
+      LineChartTitle(
+          title: Checkbox(value: true, onChanged: (v) {}), width: 32),
+      const LineChartTitle(title: Text('序号'), width: 42),
+      const LineChartTitle(title: Text('用户名'), width: 70),
+      const LineChartTitle(title: Text('手机号'), flex: 1),
+      const LineChartTitle(title: Text('签到时间'), flex: 1),
+      const LineChartTitle(title: Text('删除'), width: 67),
+    ];
+  }
+
+  Iterable<LineChartElem> rightUsers() {
+    return controller.userList.indexed.map((e) {
+      final (i, one) = e;
+
+      return LineChartElem([
+        Checkbox(value: false, onChanged: (v) {}),
+        Text('${i + 1}'),
+        Text(one.name),
+        Text(one.phone),
+        Text(one.checkTime),
+        SizedBox(
+            width: 51.2,
+            height: 22.76,
+            child: SmallButton(
+              color: const Color(0xffff0000),
+              onPressed: () {},
+              child: Text('删除'),
+            ))
+      ]);
+    });
+  }
 }
 
 class EventTitle extends GetView<EventManagerController> {

+ 1 - 0
app_business/lib/view/home/event_manage/event_manage_controller.dart

@@ -19,6 +19,7 @@ class UserInManage {
   var name = '';
   var phone = '';
   var checkTime = '';
+  var routeName = '';
 }
 
 class EventManagerController extends GetxController {

+ 1 - 0
libs/track_common/lib/widget.dart

@@ -3,4 +3,5 @@ export 'package:get/get.dart';
 
 export 'widget/app_title_list.dart';
 export 'widget/level2_view.dart';
+export 'widget/line_chart.dart';
 export 'widget/title_point.dart';

+ 93 - 0
libs/track_common/lib/widget/line_chart.dart

@@ -0,0 +1,93 @@
+import 'package:flutter/material.dart';
+
+class LineChartTitle {
+  const LineChartTitle({required this.title, this.width, this.flex});
+
+  final Widget title;
+  final double? width;
+  final int? flex;
+}
+
+class LineChartElem {
+  const LineChartElem(this.cols);
+
+  final Iterable<Widget> cols;
+}
+
+class LineChart extends StatelessWidget {
+  const LineChart(
+      {super.key,
+      required this.titles,
+      required this.children,
+      this.lineHeight});
+
+  final Iterable<LineChartTitle> titles;
+  final Iterable<LineChartElem> children;
+  final double? lineHeight;
+  final dividerWidth = 0.71;
+  final borderWidth = 0.71;
+
+  @override
+  Widget build(BuildContext context) {
+    final lineHeight = this.lineHeight ?? 38.5;
+    final titlesChildren = <Widget>[];
+    for (var (i, e) in titles.indexed) {
+      titlesChildren.add(e.width != null
+          ? Container(
+              alignment: Alignment.center, width: e.width!, child: e.title)
+          : Expanded(
+              flex: e.flex!,
+              child: Center(child: e.title),
+            ));
+      if (i < titles.length - 1) {
+        titlesChildren.add(SizedBox(
+          width: dividerWidth,
+        ));
+      }
+    }
+
+    final title = Container(
+        margin: EdgeInsets.all(borderWidth),
+        height: lineHeight,
+        child: Row(
+          children: titlesChildren,
+        ));
+    final children = <Widget>[
+      title,
+    ];
+
+    children.addAll(this.children.map((e) {
+      final row = <Widget>[];
+      for (var (i, one) in e.cols.indexed) {
+        final t = titles.elementAt(i);
+        row.add(t.width != null
+            ? Container(
+                width: t.width!, alignment: Alignment.center, child: one)
+            : Expanded(flex: t.flex!, child: Center(child: one)));
+        if (i != e.cols.length - 1) {
+          row.add(SizedBox(
+              height: 17.78, child: VerticalDivider(width: dividerWidth)));
+        }
+      }
+
+      return Container(
+          margin: const EdgeInsets.only(top: 2),
+          decoration: BoxDecoration(
+              color: Colors.white,
+              border: Border.all(
+                  color: const Color(0xffe9e9e9), width: borderWidth),
+              boxShadow: const [
+                BoxShadow(color: Color(0x4d000000), blurRadius: 0.71)
+              ]),
+          height: lineHeight,
+          child: Row(
+            children: row,
+          ));
+    }));
+
+    return Column(
+      mainAxisSize: MainAxisSize.min,
+      children: children,
+    );
+  }
+}