199 lines
7.1 KiB
Dart
199 lines
7.1 KiB
Dart
import 'dart:io';
|
||
|
||
import 'package:flutter/cupertino.dart';
|
||
import 'package:flutter/gestures.dart';
|
||
import 'package:flutter/material.dart';
|
||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||
import 'package:get/get.dart';
|
||
import 'package:tencent_chat_push_for_china/tencent_chat_push_for_china.dart';
|
||
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
||
|
||
import '../../common/values/pushconfig.dart';
|
||
import '../../util/SharedPreferencesHelper.dart';
|
||
import '../../util/device.dart';
|
||
import '../../util/util.dart';
|
||
|
||
class YesAgreementDialog extends StatefulWidget {
|
||
@override
|
||
_CustomDialogState createState() => _CustomDialogState();
|
||
}
|
||
|
||
double myProgress = 0;
|
||
|
||
class _CustomDialogState extends State<YesAgreementDialog> {
|
||
bool isDownload = false;
|
||
|
||
void incrementCounter() {}
|
||
|
||
void setDownloadUi() {
|
||
setState(() {
|
||
isDownload = true;
|
||
});
|
||
}
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return WillPopScope(
|
||
onWillPop: () async {
|
||
|
||
print(getAgreemement());
|
||
return false;
|
||
},
|
||
child: Dialog(
|
||
backgroundColor: Colors.transparent,
|
||
child: Container(
|
||
height: 277.sp,
|
||
padding: const EdgeInsets.all(1.0),
|
||
child: Stack(
|
||
children: [
|
||
Container(
|
||
decoration: BoxDecoration(
|
||
shape: BoxShape.rectangle,
|
||
borderRadius: BorderRadius.circular(10.0),
|
||
gradient: const LinearGradient(
|
||
colors: [Color(0xFFDD3DF4), Color(0xFF30FFD9)],
|
||
begin: Alignment.topCenter,
|
||
end: Alignment.bottomCenter,
|
||
),
|
||
),
|
||
),
|
||
Container(
|
||
margin: EdgeInsets.all(1.sp),
|
||
decoration: BoxDecoration(
|
||
shape: BoxShape.rectangle,
|
||
borderRadius: BorderRadius.circular(10.0),
|
||
gradient: const LinearGradient(
|
||
colors: [Color(0xFF4C3E5F), Color(0xFF324140)],
|
||
begin: Alignment.topCenter,
|
||
end: Alignment.bottomCenter,
|
||
),
|
||
),
|
||
),
|
||
Column(
|
||
mainAxisAlignment: MainAxisAlignment.center,
|
||
crossAxisAlignment: CrossAxisAlignment.center,
|
||
children: [
|
||
Container(
|
||
margin: EdgeInsets.only(left: 10.sp, right: 10.sp),
|
||
child: RichText(
|
||
text: TextSpan(
|
||
text: "感谢您信任并使用跨友APP,在你使用跨友的服务之前,请认真阅读",
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
fontSize: 14.sp,
|
||
),
|
||
children: [
|
||
TextSpan(
|
||
text: "《用户协议》",
|
||
style: TextStyle(
|
||
color: Color(0xFF21BEAB),
|
||
),
|
||
recognizer: TapGestureRecognizer()
|
||
..onTap = () {
|
||
navigateToUserAgreement();
|
||
},
|
||
),
|
||
TextSpan(
|
||
text: "和",
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
),
|
||
),
|
||
TextSpan(
|
||
text: "《隐私政策》",
|
||
style: TextStyle(
|
||
color: Color(0xFF21BEAB),
|
||
),
|
||
recognizer: TapGestureRecognizer()
|
||
..onTap = () {
|
||
navigateToPrivacyPolicy();
|
||
},
|
||
),
|
||
TextSpan(
|
||
text:
|
||
"的全部内容,以了解用户权力义务和个人信息处理规则。跨友仅会将您的信息用于提供服务和改善体验,我们将权力保障您的信息安全,请同意后使用,若您不同意本隐私政策,很遗憾,我们将无法为您提供完整的产品和服务。",
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
fontSize: 14.sp,
|
||
),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
),
|
||
SizedBox(height: 10.sp),
|
||
GestureDetector(
|
||
onTap: () async {
|
||
// 点击操作
|
||
var sp = await SharedPreferencesHelper.getInstance();
|
||
sp.setBool(SharedPreferencesHelper.AGREEMENT, true);
|
||
pushLoginPage();
|
||
uploadBuzIDAndToken();
|
||
},
|
||
child: Container(
|
||
width: 240.sp,
|
||
padding: EdgeInsets.symmetric(
|
||
vertical: 10,
|
||
horizontal: 44,
|
||
),
|
||
decoration: BoxDecoration(
|
||
gradient: LinearGradient(
|
||
colors: [Color(0xFFDD3DF4), Color(0xFF30FFD9)],
|
||
begin: Alignment.centerLeft,
|
||
end: Alignment.centerRight,
|
||
),
|
||
borderRadius: BorderRadius.circular(30),
|
||
),
|
||
child: Center(
|
||
child: Text(
|
||
"同意并继续使用",
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
fontSize: 16.sp,
|
||
),
|
||
),
|
||
),
|
||
),
|
||
),
|
||
TextButton(
|
||
onPressed: () {
|
||
// 点击不同意按钮的操作
|
||
exit(1);
|
||
},
|
||
child: Text(
|
||
"不同意并退出应用",
|
||
style: TextStyle(
|
||
color: Color(0xFFB8C2CC),
|
||
fontSize: 16.sp,
|
||
),
|
||
),
|
||
),
|
||
],
|
||
),
|
||
],
|
||
),
|
||
),
|
||
),
|
||
);
|
||
}
|
||
|
||
|
||
void uploadBuzIDAndToken() async {
|
||
final CoreServicesImpl coreInstance = TIMUIKitCore.getInstance();
|
||
await ChannelPush.init((msg) {});
|
||
|
||
int? businessID = await TimUiKitPushPlugin.getBuzId(PushConfig.appInfo);
|
||
|
||
String token = await ChannelPush.getDeviceToken();
|
||
ChannelPush.uploadToken();
|
||
|
||
print("token=" + token);
|
||
if (token != "") {
|
||
V2TimCallback res = await coreInstance.setOfflinePushConfig(
|
||
token: token, businessID: businessID);
|
||
|
||
print("token=" + res.code.toString());
|
||
}
|
||
}
|
||
}
|