#
whycq
2025-03-03 6a90c5bde0facc8330ce4c7c7d89292717b7ac65
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
 
import '../../common/page_config.dart';
import 'card_item.dart';
 
class MatCard extends StatefulWidget {
  final Map<String, dynamic> item;
  final bool isEdit;
 
  final VoidCallback? update;
  final VoidCallback? delete;
 
  const MatCard({super.key, required this.item, this.update, this.delete,required this.isEdit});
 
  @override
  State<MatCard> createState() => _MatCardState();
}
 
class _MatCardState extends State<MatCard> {
  Widget BtnSpace({
    required update,
    required delete,
    required isEdit,
  }) {
    if (isEdit == true) {
      return Row(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: [
          IconButton(
              onPressed: widget.update,
              icon: Icon(
                Icons.create,
                color: Colors.green,
              )),
          IconButton(
              onPressed: widget.delete,
              icon: Icon(
                Icons.delete_sweep,
                color: Colors.red,
              )),
        ],
      );
    } else {
      return SizedBox.shrink();
    }
 
  }
  @override
  Widget build(BuildContext context) {
    var showList = [];
    pageConfig.forEach((element) {
      widget.item.forEach((key, value) {
        if (element['title'] == key) {
          element['value'] = value;
        }
      });
      if (element['isShow'] == true) {
        showList.add(element);
      }
    });
 
    return Container(
        margin: EdgeInsets.only(left: 0, top: 8, right: 0, bottom: 8),
        padding: EdgeInsets.all(8),
        decoration: BoxDecoration(
            color: Colors.white, borderRadius: BorderRadius.circular(10)),
        constraints: BoxConstraints(),
        child: Row(
          children: [
            Expanded(
                child: Container(
                    child: Column(
              children: List.generate(showList.length, (index) {
                var title = showList[index]['title'];
                var propName = showList[index]['propName'];
                var value = widget.item[propName];
                var isShow = showList[index]['isShow'];
                if (isShow == false) {
                  return SizedBox.shrink();
                } else {
                  return CardItem(title: title, value: value);
                }
              }),
            ))),
            Container(
              child: BtnSpace(isEdit: widget.isEdit, update: widget.update,delete: widget.delete),
            )
          ],
        ));
  }
}