splash_page.dart 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. import 'dart:async';
  2. import 'package:flutter/gestures.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter/services.dart';
  5. import 'package:flutter_screenutil/flutter_screenutil.dart';
  6. import 'package:go_router/go_router.dart';
  7. import 'package:news_app/widget/my_txt.dart';
  8. import '../../constant/color_res.dart';
  9. import '../../gen/assets.gen.dart';
  10. import '../../util/shared_prefs_instance_util.dart';
  11. /// @author: bo.zeng
  12. /// @email: cnhbwds@gmail.com
  13. /// @date: 2025 2025/4/9 16:00
  14. /// @description:
  15. class SplashPage extends StatefulWidget {
  16. const SplashPage({super.key});
  17. @override
  18. State<SplashPage> createState() => _SplashPageState();
  19. }
  20. class _SplashPageState extends State<SplashPage> {
  21. TapGestureRecognizer? aa;
  22. @override
  23. void initState() {
  24. super.initState();
  25. // 延迟 3 秒执行跳转逻辑
  26. Future.delayed(const Duration(seconds: 3), () async {
  27. bool? first = await getIsFirst();
  28. // 确保页面未被销毁
  29. if (!mounted) return;
  30. if (first == true) {
  31. context.go('/main');
  32. } else {
  33. _showFirstDialog(context);
  34. }
  35. });
  36. }
  37. @override
  38. void dispose() {
  39. aa?.dispose();
  40. super.dispose();
  41. }
  42. void _showFirstDialog(BuildContext context) {
  43. aa = TapGestureRecognizer();
  44. aa?.onTap = () {
  45. context.push("/user/privacy");
  46. };
  47. showDialog(
  48. context: context,
  49. builder: (context) {
  50. return AlertDialog(
  51. content: SizedBox(
  52. height: 200.h,
  53. width: 220.w,
  54. child: SingleChildScrollView(
  55. child: Column(
  56. children: [
  57. Text(
  58. "个人信息保护提示",
  59. style: TextStyle(fontSize: 14.sp, color: Colors.black),
  60. ),
  61. Text.rich(
  62. TextSpan(
  63. children: [
  64. TextSpan(
  65. text: "欢迎使用新消费传媒!我们将通过",
  66. style: TextStyle(
  67. fontSize: 12.sp,
  68. color: Colors.black,
  69. ),
  70. ),
  71. TextSpan(
  72. text: "《用户协议》",
  73. style: TextStyle(fontSize: 12.sp, color: Colors.blue),
  74. recognizer: aa,
  75. // recognizer: _tapRecognizer
  76. ),
  77. TextSpan(
  78. text: "和",
  79. style: TextStyle(
  80. fontSize: 12.sp,
  81. color: Colors.black,
  82. ),
  83. ),
  84. TextSpan(
  85. text: "《隐私政策》",
  86. style: TextStyle(fontSize: 12.sp, color: Colors.blue),
  87. recognizer: aa,
  88. ),
  89. TextSpan(
  90. text:
  91. "和帮助您了解我们为您提供的服务、"
  92. "我们如何处理个人信息以及您享有的权利。我们会严格按照相关法律法规要求,采取各种安全措施来保护您的个人信息。\n"
  93. "点击“同意”按钮,表示您已知情并同意以上协议和以下约定。\n"
  94. "1.为了保障软件的安全运行和账户安全我们会申请收集您的设备信息、IP地址WLAN MAC地址。\n"
  95. "2.上传或拍摄图片、视频,需要使用您的媒体影音、图片、视频、音频、相机、麦克风权限。\n"
  96. "3.我们可能会申请位置权限,用于为您推荐您可能感兴趣的内容。\n"
  97. "4.我们尊重您的选择权,您可以访问、修改、删除您的个人信息并管理您的授权,我们也为您提供注销、投诉渠道。",
  98. style: TextStyle(
  99. fontSize: 12.sp,
  100. color: Colors.black,
  101. ),
  102. ),
  103. ],
  104. ),
  105. ),
  106. ],
  107. ),
  108. ),
  109. ),
  110. actions: [
  111. GestureDetector(
  112. onTap: () {
  113. saveIsFirst();
  114. context.go('/main');
  115. },
  116. child: Container(
  117. alignment: Alignment.center,
  118. padding: EdgeInsets.symmetric(vertical: 6.h),
  119. decoration: BoxDecoration(
  120. color: colorE71717,
  121. borderRadius: BorderRadius.circular(10.r),
  122. ),
  123. child: myTxt(text: "同意", color: Colors.white, fontSize: 14.sp),
  124. ),
  125. ),
  126. GestureDetector(
  127. onTap: () {
  128. SystemNavigator.pop();
  129. },
  130. child: Container(
  131. margin: EdgeInsets.only(top: 5.h),
  132. padding: EdgeInsets.symmetric(vertical: 6.h),
  133. alignment: Alignment.center,
  134. child: myTxt(text: "不同意", color: Colors.black, fontSize: 14.sp),
  135. ),
  136. ),
  137. ],
  138. );
  139. },
  140. );
  141. }
  142. @override
  143. Widget build(BuildContext context) {
  144. double w = MediaQuery.of(context).size.width;
  145. double h = MediaQuery.of(context).size.height;
  146. return Scaffold(
  147. body: Center(
  148. child: Stack(
  149. alignment: Alignment.center,
  150. children: [
  151. Image.asset(
  152. Assets.images.splashBg.path,
  153. fit: BoxFit.cover,
  154. width: w,
  155. height: h,
  156. ),
  157. ],
  158. ),
  159. ),
  160. );
  161. }
  162. }