admin
2021-11-03 0daa197dbaf611eacdf9eeb3763ddcb10038585b
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
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: '权限设置',
      home: PermissionPage(title: ''),
    );
  }
}
 
class PermissionPage extends StatefulWidget {
  PermissionPage({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
  _PermissionPageState createState() => _PermissionPageState();
}
 
class _PermissionPageState extends State<PermissionPage>
    with SingleTickerProviderStateMixin {
  bool location = 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: "权限设置"),
              Container(
                padding: EdgeInsets.fromLTRB(20, 22, 20, 24),
                child: Text(
                  "受手机运行机制以及手机系统的影响,后台定位功能可能会出现不稳定,需要按照下方进行设置,以确保定位信息实时稳定。",
                  style: TextStyle(color: Color(0xFF666666), fontSize: 12),
                ),
              ),
              getItemView(
                title: '位置权限',
                subTitle: '关闭后,21:00-09:00不接受任何推送\n获取轨迹以及实时位置信息',
                notify: '建议开启',
                checked: location,
                changed: (bool value) {
                  setState(() {
                    location = value;
                  });
                },
              ),
              getItemView(
                title: '设备唯一识别码',
                subTitle: '判断设备唯一性,确保账号安全必备权限\n获取设备MAC信息',
                notify: '建议开启',
                checked: true,
                changed: (bool value) {},
              ),
              getItemView(
                title: '省电模式',
                subTitle: '此模式下本软件运行可能会收到限制\n定位期间尽量确保电量充足',
                notify: '建议勿开启',
                checked: true,
                changed: (bool value) {},
              ),
              getItemView(
                title: '电池优化白名单',
                subTitle: '此模式下本软件运行可能会收到限制\n定位期间尽量确保电量充足',
                notify: '快速设置',
                checked: true,
                changed: (bool value) {},
              ),
              getItemView(
                title: '应用启动管理',
                subTitle: '此模式下本软件运行可能会收到限制\n定位期间尽量确保电量充足',
                notify: '快速设置',
                checked: true,
                changed: (bool value) {},
              ),
            ],
          ),
        ));
  }
 
  Widget getItemView(
      {required String title,
      required String subTitle,
      required String notify,
      bool checked = false,
      required ValueChanged<bool> changed,
      double marginTop = 0,
      double marginBottom = 1}) {
    return Container(
        height: 80,
        color: Colors.white,
        padding: EdgeInsets.fromLTRB(20, 0, 20, 0),
        margin: EdgeInsets.fromLTRB(0, marginTop, 0, marginBottom),
        child: Flex(direction: Axis.horizontal, children: [
          Flex(
            crossAxisAlignment: CrossAxisAlignment.start,
            mainAxisAlignment: MainAxisAlignment.center,
            direction: Axis.vertical,
            children: [
              Text(
                title,
                style: TextStyle(fontSize: 16, color: Color(0xFF333333)),
              ),
              Container(
                child: Text(subTitle,
                    style: TextStyle(fontSize: 9, color: Color(0xFF999999))),
                margin: EdgeInsets.fromLTRB(0, 2, 0, 0),
              )
            ],
          ),
          Expanded(child: Container()),
          Flex(
              direction: Axis.vertical,
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                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,
                    )),
                Container(
                    margin: EdgeInsets.fromLTRB(0, 2, 0, 0),
                    child: Text(
                      notify,
                      style: TextStyle(color: Color(0xFF666666), fontSize: 10),
                    ))
              ])
        ]));
  }
}