admin
2021-10-28 34b9ee85d5f1302a5d770b0ee5e62aec8a3c190f
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
import 'dart:ui';
 
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:location/ui/widget/nav.dart';
 
void main() {
  runApp(MyApp());
}
 
class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '设置',
      theme: ThemeData(primaryColor: Color(0xFFF5F5F5)),
      home: SettingPage(title: ''),
    );
  }
}
 
class SettingPage extends StatefulWidget {
  SettingPage({Key? key, required this.title}) : super(key: key);
 
  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.
 
  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".
 
  final String title;
 
  @override
  _SettingPageState createState() => _SettingPageState();
}
 
class _SettingPageState extends State<SettingPage>
    with SingleTickerProviderStateMixin {
  bool msg = false;
  bool ad = false;
 
  @override
  void initState() {
    super.initState();
  }
 
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: Color(0xFFF5F5F5),
        body: Container(
          child: Flex(
            direction: Axis.vertical,
            children: [
              TopNavBar(title: "设置"),
              getBigItemView(
                  title: "推送免打扰",
                  content: "关闭后,21:00-09:00不接受任何推送",
                  marginTop: 14,
                  marginBottom: 1,
                  checked: msg,
                  changed: (bool value) {
                    print(value);
                    setState(() {
                      msg = value;
                    });
                  }),
              getBigItemView(
                  title: "个性化广告推荐",
                  content: "关闭后,广告数量将不变,但内容相关度会降低",
                  marginTop: 0,
                  marginBottom: 16,
                  checked: ad,
                  changed: (bool value) {
                    print(value);
                    setState(() {
                      ad = value;
                    });
                  }),
              getCommonItemView(
                  title: "清理缓存",
                  content: "551.4MB",
                  onClick: () {
                    print("清理缓存");
                  }),
              getCommonItemView(
                  title: "检查更新",
                  content: "版本号2.0.0",
                  onClick: () {
                    print("检查更新");
                  }),
              getCommonItemView(
                  title: "账户注销",
                  content: "",
                  onClick: () {
                    print("账户注销");
                  }),
              getCommonItemView(
                  title: "隐私投诉",
                  content: "",
                  onClick: () {
                    print("隐私投诉");
                  }),
              getCommonItemView(
                  title: "第三方SDK列表",
                  content: "",
                  onClick: () {
                    print("第三方SDK列表");
                  }),
              Expanded(
                child: Container(),
              ),
              Container(
                  child: Stack(
                children: [
                  InkWell(
                      onTap: () {
                        print("退出登录");
                      },
                      child: Container(
                          alignment: Alignment.center,
                          height: 48,
                          color: Colors.white,
                          child: Text(
                            "退出登录",
                            style: TextStyle(
                                color: Color(0xFF0E95FE), fontSize: 16),
                          )))
                ],
              )),
            ],
          ),
        ));
  }
 
  Widget getCommonItemView(
      {required String title,
      String content = "",
      required GestureTapCallback onClick}) {
    return Container(
      height: 53,
      margin: EdgeInsets.fromLTRB(0, 0, 0, 1),
      color: Colors.white,
      child: InkWell(
        onTap: () {
          onClick();
        },
        child: Container(
            padding: EdgeInsets.fromLTRB(20, 0, 20, 0),
            child: Flex(
              crossAxisAlignment: CrossAxisAlignment.center,
              direction: Axis.horizontal,
              children: [
                Text(
                  title,
                  style: TextStyle(fontSize: 16, color: Color(0xFF333333)),
                ),
                Expanded(
                    child: Flex(
                  direction: Axis.horizontal,
                  mainAxisAlignment: MainAxisAlignment.end,
                  children: [
                    Container(
                      child: Text(content,
                          style: TextStyle(
                              fontSize: 14, color: Color(0xFF959595))),
                      margin: EdgeInsets.fromLTRB(0, 0, 13.5, 0),
                    ),
                    Image.asset(
                      "assets/images/common/icon_array_right.png",
                      height: 13.5,
                    )
                  ],
                ))
              ],
            )),
      ),
    );
  }
 
  Widget getBigItemView(
      {required String title,
      String content = "",
      bool checked = false,
      required ValueChanged<bool> changed,
      double marginTop = 0,
      double marginBottom = 0}) {
    return Container(
      height: 68,
      margin: EdgeInsets.fromLTRB(0, marginTop, 0, marginBottom),
      color: Colors.white,
      child: Container(
          padding: EdgeInsets.fromLTRB(20, 0, 20, 0),
          child: Stack(children: [
            Flex(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisAlignment: MainAxisAlignment.center,
              direction: Axis.vertical,
              children: [
                Text(
                  title,
                  style: TextStyle(fontSize: 16, color: Color(0xFF333333)),
                ),
                Container(
                  child: Text(content,
                      style: TextStyle(fontSize: 9, color: Color(0xFF959595))),
                  margin: EdgeInsets.fromLTRB(0, 5, 0, 0),
                )
              ],
            ),
            Container(),
            Positioned(
                right: 0,
                top: 0,
                bottom: 0,
                child: InkWell(
                    onTap: () {
                      changed(!checked);
                    },
                    child: Image.asset(
                      checked
                          ? "assets/images/common/icon_check_true.png"
                          : "assets/images/common/icon_check_false.png",
                      height: 30,
                      width: 60,
                    )))
          ])),
    );
  }
}