| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- import 'dart:async';
- import 'package:flutter/gestures.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:go_router/go_router.dart';
- import 'package:news_app/widget/my_txt.dart';
- import '../../constant/color_res.dart';
- import '../../gen/assets.gen.dart';
- import '../../util/shared_prefs_instance_util.dart';
- /// @author: bo.zeng
- /// @email: cnhbwds@gmail.com
- /// @date: 2025 2025/4/9 16:00
- /// @description:
- class SplashPage extends StatefulWidget {
- const SplashPage({super.key});
- @override
- State<SplashPage> createState() => _SplashPageState();
- }
- class _SplashPageState extends State<SplashPage> {
- TapGestureRecognizer? aa;
- @override
- void initState() {
- super.initState();
- // 延迟 3 秒执行跳转逻辑
- Future.delayed(const Duration(seconds: 3), () async {
- bool? first = await getIsFirst();
- // 确保页面未被销毁
- if (!mounted) return;
- if (first == true) {
- context.go('/main');
- } else {
- _showFirstDialog(context);
- }
- });
- }
- @override
- void dispose() {
- aa?.dispose();
- super.dispose();
- }
- void _showFirstDialog(BuildContext context) {
- aa = TapGestureRecognizer();
- aa?.onTap = () {
- context.push("/user/privacy");
- };
- showDialog(
- context: context,
- builder: (context) {
- return AlertDialog(
- content: SizedBox(
- height: 200.h,
- width: 220.w,
- child: SingleChildScrollView(
- child: Column(
- children: [
- Text(
- "个人信息保护提示",
- style: TextStyle(fontSize: 14.sp, color: Colors.black),
- ),
- Text.rich(
- TextSpan(
- children: [
- TextSpan(
- text: "欢迎使用新消费传媒!我们将通过",
- style: TextStyle(
- fontSize: 12.sp,
- color: Colors.black,
- ),
- ),
- TextSpan(
- text: "《用户协议》",
- style: TextStyle(fontSize: 12.sp, color: Colors.blue),
- recognizer: aa,
- // recognizer: _tapRecognizer
- ),
- TextSpan(
- text: "和",
- style: TextStyle(
- fontSize: 12.sp,
- color: Colors.black,
- ),
- ),
- TextSpan(
- text: "《隐私政策》",
- style: TextStyle(fontSize: 12.sp, color: Colors.blue),
- recognizer: aa,
- ),
- TextSpan(
- text:
- "和帮助您了解我们为您提供的服务、"
- "我们如何处理个人信息以及您享有的权利。我们会严格按照相关法律法规要求,采取各种安全措施来保护您的个人信息。\n"
- "点击“同意”按钮,表示您已知情并同意以上协议和以下约定。\n"
- "1.为了保障软件的安全运行和账户安全我们会申请收集您的设备信息、IP地址WLAN MAC地址。\n"
- "2.上传或拍摄图片、视频,需要使用您的媒体影音、图片、视频、音频、相机、麦克风权限。\n"
- "3.我们可能会申请位置权限,用于为您推荐您可能感兴趣的内容。\n"
- "4.我们尊重您的选择权,您可以访问、修改、删除您的个人信息并管理您的授权,我们也为您提供注销、投诉渠道。",
- style: TextStyle(
- fontSize: 12.sp,
- color: Colors.black,
- ),
- ),
- ],
- ),
- ),
- ],
- ),
- ),
- ),
- actions: [
- GestureDetector(
- onTap: () {
- saveIsFirst();
- context.go('/main');
- },
- child: Container(
- alignment: Alignment.center,
- padding: EdgeInsets.symmetric(vertical: 6.h),
- decoration: BoxDecoration(
- color: colorE71717,
- borderRadius: BorderRadius.circular(10.r),
- ),
- child: myTxt(text: "同意", color: Colors.white, fontSize: 14.sp),
- ),
- ),
- GestureDetector(
- onTap: () {
- SystemNavigator.pop();
- },
- child: Container(
- margin: EdgeInsets.only(top: 5.h),
- padding: EdgeInsets.symmetric(vertical: 6.h),
- alignment: Alignment.center,
- child: myTxt(text: "不同意", color: Colors.black, fontSize: 14.sp),
- ),
- ),
- ],
- );
- },
- );
- }
- @override
- Widget build(BuildContext context) {
- double w = MediaQuery.of(context).size.width;
- double h = MediaQuery.of(context).size.height;
- return Scaffold(
- body: Center(
- child: Stack(
- alignment: Alignment.center,
- children: [
- Image.asset(
- Assets.images.splashBg.path,
- fit: BoxFit.cover,
- width: w,
- height: h,
- ),
- ],
- ),
- ),
- );
- }
- }
|