admin
2022-01-20 d8ef9a783b9e0b2a495f02fdf3daaf27ef49e99d
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
import 'dart:async';
import 'dart:io';
import 'dart:ui';
 
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import './api/http.dart';
import './utils/ad_util.dart';
import './utils/app_util.dart';
import './utils/config_util.dart';
import './utils/pageutils.dart';
import './utils/permission_util.dart';
import './utils/ui_utils.dart';
import './utils/user_util.dart';
import 'package:permission_handler/permission_handler.dart';
 
import 'ui/main/main.dart';
import 'ui/widget/dialog.dart';
import 'utils/ui_constant.dart';
import 'utils/global.dart';
 
void main() {
  if (Platform.isAndroid) {
    SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
      statusBarColor: Colors.transparent,
      systemNavigationBarColor: Colors.white,
      systemNavigationBarDividerColor: null,
      systemNavigationBarIconBrightness: Brightness.light,
      statusBarIconBrightness: Brightness.dark,
      statusBarBrightness: Brightness.light,
    ));
  }
  runApp(MyApp());
}
 
class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: Constant.APP_NAME,
        theme: ThemeData(
            // This is the theme of your application.
            //
            // Try running your application with "flutter run". You'll see the
            // application has a blue toolbar. Then, without quitting the app, try
            // changing the primarySwatch below to Colors.green and then invoke
            // "hot reload" (press "r" in the console where you ran "flutter run",
            // or simply save your changes to "hot reload" in a Flutter IDE).
            // Notice that the counter didn't reset back to zero; the application
            // is not restarted.
 
            primaryColor: const Color(0xFFFFFFFF)),
        home: SplashPage(title: ''),
        navigatorKey: navigatorKey);
  }
}
 
class SplashPage extends StatefulWidget {
  SplashPage({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
  _SplashPageState createState() => _SplashPageState();
}
 
class _SplashPageState extends State<SplashPage>
    with SingleTickerProviderStateMixin {
  int selectIndex = 1;
  Widget? _splash;
 
  @override
  void initState() {
    super.initState();
  }
 
  bool _jumpToMain = false;
 
  void init() async {
    //请求配置信息
    var value = await ConfigApiUtil.getConfig();
    if (value != null) {
      ConfigUtil.saveConfig(value["data"]);
    }
 
    await AppUtil.initApp(context);
 
    Widget splash = AdUtil.loadSplash(
        await AdUtil.getAdInfo(AdPosition.splash),
        MediaQuery.of(context).size.width,
        MediaQuery.of(context).size.height - 94, (success, msg) {
      if (_jumpToMain == true) {
        return;
      }
      _jumpToMain = true;
      if (success) {
        NavigatorUtil.navigateToNextPageWithFinish(context,
            CupertinoPageRoute(builder: (context) {
          return MainPage(title: "");
        }));
      } else {
        Future.delayed(const Duration(seconds: 2), () {
          NavigatorUtil.navigateToNextPageWithFinish(context,
              CupertinoPageRoute(builder: (context) {
            return MainPage(title: "");
          }));
        });
      }
    });
 
    setState(() {
      _splash = splash;
    });
  }
 
  Future requestPermission() async {
    await PermissionUtil.openPermission(Permission.phone);
    // await PermissionUtil.openPermission(PermissionUtil.getLocationPermission());
    return;
  }
 
  @override
  Widget build(BuildContext context) {
    UserUtil.isAgreeProtocol().then((value) {
      if (!value) {
        //弹出用户协议框
        String content = "尊敬的用户:<br>" +
            "感谢您对定位App一直以来的信任!<br>" +
            "我们非常重视保护您的个人信息和隐私。在您使用我们的软件前,为了更好的保障您的权利,请务必阅读<a href='${Constant.PROTOCOL_URL}'>《用户协议》</a>和<a href='${Constant.PRIVACY_URL}'>《隐私政策》</a>,您同意并接受所有条款后,才能使用我们软件。若您注册成为本软件会员或接受好友的邀请即表明您允许向本软件中的好友提供您的地理位置和轨迹等信息。为确保软件正常运行我们需要获得,尤其是:<br>" +
            "1、我们对您的个人信息(包括但不限于<b style='color:red'>设备MAC地址、IMEI/Android ID、位置信息</b>等信息)的收集/保存/使用/对外提供/保护等规则条款,以及您的用户权利等条款;<br>" +
            "2、约定我们的限制责任、免责条款;<br>" +
            "3、其他以加粗或斜体字进行标识的重要条款。<br>" +
            "4、特别申明:本软件定位守护等功能需双方都下载本软件并同意授权后才可正常使用,不涉及侵犯个人隐私问题。获取地理信息必须在用户双方知情并同意的情况下进行,本软件仅限用于家庭/亲友/熟人/朋友间使用。<br>" +
            "如您对协议有任何疑虑,可通过电子邮箱:dw365@foxmail.com 向我们询问,我们将为您竭诚解答。您点击“同意并继续”的行为代表您已阅读完毕并接受以上协议全部条款。如您同意以上协议内容,请您点击“同意并继续”,开始使用本软件。";
 
        DialogUtil.showDialog(
            context,
            NotifyDialog("用户协议&隐私政策", content, () {
              SystemNavigator.pop();
            }, () {
              UserUtil.setAgreeProtocol().then((value) {
                if (value) {
                  //弹出权限框
                  DialogUtil.showDialog(context, PermissionNotifyDialog(() {
                    Navigator.of(context).pop();
                    requestPermission().then((value) {
                      init();
                    });
                  }));
                } else {}
              });
            },
                richText: true,
                height: 400,
                cancelName: "不同意",
                sureName: "同意并继续"));
      } else {
        //已经同意了
        init();
      }
    });
 
    return WillPopScope(
        onWillPop: () async {
          return false;
        },
        child: Scaffold(
            backgroundColor: Colors.white,
            body: Flex(
              direction: Axis.vertical,
              children: [
                Expanded(
                    child: Stack(children: [
                  Container(
                    alignment: Alignment.center,
                    padding: const EdgeInsets.all(72),
                    color: Colors.white,
                    child: Image.asset("assets/images/ic_splash.png"),
                  ),
                  _splash != null ? _splash! : Container()
                ])),
                Container(
                  alignment: Alignment.center,
                  color: const Color(0xFFF8F8F8),
                  height: 94,
                  child: Flex(
                    direction: Axis.vertical,
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: const [
                      Text(
                        Constant.APP_NAME,
                        style:
                            TextStyle(color: Color(0xFF03B5FF), fontSize: 23),
                      ),
                      SizedBox(
                        height: 15,
                      ),
                      Text(
                        "腾讯云提供网络服务",
                        style: TextStyle(color: Color(0xFF999999), fontSize: 9),
                      ),
                    ],
                  ),
                )
              ],
            )));
  }
}