YSWelcome.dart 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutter/services.dart';
  4. import 'package:flutter_screenutil/screenutil.dart';
  5. import 'package:flutter_swiper/flutter_swiper.dart';
  6. import 'package:ysairplane2/code/YSTabbar.dart';
  7. import 'package:ysairplane2/tools/YSNetWorking.dart';
  8. import 'package:ysairplane2/tools/YSTools.dart';
  9. class YSWelcome extends StatefulWidget {
  10. @override
  11. _YSWelcomeState createState() => _YSWelcomeState();
  12. }
  13. class _YSWelcomeState extends State<YSWelcome> {
  14. List _images = ['lib/images/1.png','lib/images/2.png','lib/images/3.png'];
  15. @override
  16. void initState() {
  17. Future.delayed(Duration(seconds: 0)).then((value){
  18. _getPrivacyAgreement();
  19. });
  20. super.initState();
  21. }
  22. _getPrivacyAgreement() async{
  23. ScreenUtil.init(context,designSize: Size(750, 1624),allowFontScaling: false);
  24. var dict = await ysRequestHttp(context, type: requestType.get, api: '/app/applets/dic/dtDic/getPrivacyAgreement', parameter: {},isLoading: false);
  25. if(dict!=null){
  26. showAgreeAlert(context,title: '用户协议与隐私政策',content: dict['data']['value'],agree: (value){
  27. if(value==false){
  28. SystemChannels.platform.invokeMethod('SystemNavigator.pop');
  29. }else{
  30. Navigator.pop(context);
  31. }
  32. },isWelcome: true);
  33. }
  34. }
  35. @override
  36. Widget build(BuildContext context) {
  37. return Scaffold(
  38. backgroundColor: Colors.white,
  39. body: Container(
  40. height: MediaQuery.of(context).size.height,
  41. width: MediaQuery.of(context).size.width,
  42. child: Swiper(
  43. itemBuilder: (BuildContext context, int index) {
  44. return Stack(
  45. children: [
  46. Image(
  47. height: MediaQuery.of(context).size.height,
  48. width: MediaQuery.of(context).size.width,
  49. fit: BoxFit.fill,
  50. image: AssetImage(_images[index]),
  51. ),
  52. if(index==_images.length-1)GestureDetector(
  53. onTap: (){
  54. Navigator.of(context).pushAndRemoveUntil(
  55. CupertinoPageRoute(
  56. builder: (context){
  57. return YSTabbar();
  58. }
  59. ),(route) => false);
  60. },
  61. child: Container(
  62. margin: EdgeInsets.only(top: MediaQuery.of(context).size.height-60,left: MediaQuery.of(context).size.width/2-50),
  63. height: 35,
  64. width: 100,
  65. decoration: BoxDecoration(
  66. color: Color(0xFF3676EC),
  67. borderRadius: BorderRadius.all(Radius.circular(50))
  68. ),
  69. alignment: Alignment.center,
  70. child: Text('立即体验',style: TextStyle(color: Colors.white,fontSize: 14,fontWeight: FontWeight.bold),),
  71. ),
  72. )
  73. ],
  74. );
  75. },
  76. itemCount: _images.length,
  77. scrollDirection: Axis.horizontal,
  78. loop: false,
  79. duration: 300,
  80. autoplay: false,
  81. pagination: SwiperPagination(
  82. alignment: Alignment.bottomCenter,
  83. builder: DotSwiperPaginationBuilder(
  84. color: Color(0xFCE1E1E1),
  85. activeColor: Color(0xFF3676EC),
  86. size: 5.0,
  87. activeSize: 10.0,
  88. ),
  89. margin: EdgeInsets.only(bottom: 80)
  90. ),
  91. autoplayDisableOnInteraction : true,
  92. ),
  93. ),
  94. );
  95. }
  96. }