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),
|
),
|
],
|
),
|
)
|
],
|
)));
|
}
|
}
|