Hibok
您不能選擇超過 %s 個話題 話題必須以字母或數字為開頭,可包含連接號 ('-') 且最長為 35 個字
 
 
 
 
 
 

156 行
4.6 KiB

  1. import 'package:chat/generated/i18n.dart';
  2. import 'package:chat/utils/LoadingDialog.dart';
  3. import 'package:chat/utils/screen.dart';
  4. import 'package:chat/utils/sp_utils.dart';
  5. import 'package:flutter/cupertino.dart';
  6. import 'package:flutter/material.dart';
  7. import '../data/constants.dart';
  8. import 'IndexPage.dart';
  9. class SplashPage extends StatefulWidget {
  10. @override
  11. State<StatefulWidget> createState() {
  12. return SplashPageState();
  13. }
  14. }
  15. class SplashBean {
  16. String icon;
  17. String title;
  18. String content;
  19. Color titleColor;
  20. SplashBean(this.icon, this.title, this.content, this.titleColor);
  21. }
  22. class SplashPageState extends State<SplashPage> {
  23. List<SplashBean> list = [];
  24. int currentIndex = 0;
  25. PageController pageController;
  26. @override
  27. void initState() {
  28. super.initState();
  29. list.add(SplashBean('assets/images/img_splash_1.png',I18n.of( LoadingManage.context).splash_tips1 , I18n.of( LoadingManage.context).splash_tips_content1,
  30. Color(0xffEC527D)));
  31. list.add(SplashBean('assets/images/img_splash_2.png', I18n.of( LoadingManage.context).splash_tips2, I18n.of( LoadingManage.context).splash_tips_content2,
  32. Color(0xffB439EB)));
  33. list.add(SplashBean('assets/images/img_splash_3.png', I18n.of( LoadingManage.context).splash_tips3, I18n.of( LoadingManage.context).splash_tips_content3,
  34. Color(0xff2B79F7)));
  35. pageController = PageController(
  36. initialPage: 0,
  37. );
  38. }
  39. @override
  40. Widget build(BuildContext context) {
  41. return Scaffold(
  42. body: Container(
  43. color: Colors.white,
  44. child: SafeArea(
  45. child: Container(
  46. color: Colors.white,
  47. child: Stack(
  48. children: <Widget>[
  49. PageView.builder(
  50. controller: pageController,
  51. itemBuilder: _buildItem,
  52. itemCount: list.length,
  53. onPageChanged: (int index) {
  54. setState(() {
  55. currentIndex = index;
  56. });
  57. },
  58. ),
  59. Container(
  60. child: Column(
  61. children: <Widget>[
  62. Expanded(child: Container()),
  63. currentIndex != 2 ? getIndicator() : Container(),
  64. currentIndex == 2
  65. ? InkWell(onTap: ()async{
  66. await SPUtils.saveBool(Constants.Splash_OPENED, true);
  67. Navigator.of(context).push(
  68. MaterialPageRoute(
  69. builder: (_) => IndexPage(),
  70. ),
  71. );
  72. },child: Padding(
  73. padding: EdgeInsets.only(bottom: 40),
  74. child: Container(
  75. padding: EdgeInsets.only(left: 16,right: 16,top: 5,bottom: 5),
  76. decoration: BoxDecoration(
  77. border: Border.all(
  78. color: Color(0xff2B79F7), width: 1),borderRadius: BorderRadius.circular(16)),
  79. child: Text(I18n.of(context).splash_go,style: TextStyle(fontSize: 18,color: Color(0xff2B79F7)),),
  80. ),
  81. ),)
  82. : Container(),
  83. ],
  84. ),
  85. )
  86. ],
  87. ),
  88. )),
  89. ),
  90. );
  91. }
  92. Widget getIndicator() {
  93. List<Widget> pointList = [];
  94. for (int k = 0; k < list.length; k++) {
  95. pointList.add(Padding(
  96. padding: EdgeInsets.only(left: 6, right: 6),
  97. child: ClipOval(
  98. child: Container(
  99. color: k == currentIndex ? Color(0xff2B79F7) : Color(0xffBFBEBE),
  100. width: 10,
  101. height: 10,
  102. ),
  103. ),
  104. ));
  105. }
  106. return Padding(
  107. padding: EdgeInsets.only(bottom: 40),
  108. child: Container(
  109. width: Screen.width,
  110. child: Row(
  111. mainAxisAlignment: MainAxisAlignment.center,
  112. children: pointList,
  113. ),
  114. ),
  115. );
  116. }
  117. Widget _buildItem(BuildContext context, int index) {
  118. SplashBean data = list[index];
  119. return Container(
  120. child: Column(
  121. children: <Widget>[
  122. Padding(
  123. padding: EdgeInsets.only(top: 30, bottom: 40),
  124. child: Image.asset(
  125. data.icon,
  126. height: 400,
  127. ),
  128. ),
  129. Text(
  130. data.title,
  131. style: TextStyle(color: data.titleColor, fontSize: 30),
  132. ),
  133. SizedBox(height: 6,),
  134. Text(data.content,
  135. style: TextStyle(color: Color(0xff999999), fontSize: 15)),
  136. ],
  137. ),
  138. );
  139. }
  140. }