Hibok
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 
 

155 行
4.6 KiB

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