GuidePage.dart 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutter_swiper/flutter_swiper.dart';
  4. class GuidePage extends StatefulWidget {
  5. @override
  6. _GuidePageState createState() => _GuidePageState();
  7. }
  8. class _GuidePageState extends State<GuidePage> with WidgetsBindingObserver {
  9. int swiperIndex = 0;
  10. @override
  11. Widget build(BuildContext context) {
  12. return GestureDetector(
  13. onTap: () {
  14. // Navigator.of(context).pop();
  15. },
  16. child: Scaffold(
  17. backgroundColor: Color(0xCC000000),
  18. body: Container(
  19. child: new Swiper(
  20. itemBuilder: (BuildContext context, int index) {
  21. return GuidItem(index);
  22. },
  23. itemCount: 3,
  24. loop: false,
  25. onIndexChanged: (index) {
  26. setState(() {
  27. swiperIndex = index;
  28. });
  29. },
  30. pagination: new SwiperCustomPagination(
  31. builder: (BuildContext context, SwiperPluginConfig config) {
  32. return Stack(
  33. children: <Widget>[
  34. Positioned(
  35. right: 20,
  36. top: 20,
  37. child: Image.asset('images/yindao_logo.png'),
  38. ),
  39. Positioned(
  40. right: 20,
  41. top: 60,
  42. child: Container(
  43. width: 47,
  44. height: 26,
  45. decoration: BoxDecoration(
  46. color: Colors.black12,
  47. borderRadius: BorderRadius.all(Radius.circular(13)),
  48. ),
  49. child: Center(
  50. child: InkWell(
  51. onTap: () {
  52. Navigator.of(context).pop();
  53. },
  54. child: Text('跳过', style: TextStyle(color: Colors.white, fontSize: 13), textAlign: TextAlign.center)),
  55. )))
  56. ],
  57. );
  58. },
  59. )),
  60. ),
  61. floatingActionButton: MyFloat(swiperIndex),
  62. floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
  63. ),
  64. );
  65. }
  66. }
  67. class GuidItem extends StatelessWidget {
  68. GuidItem(this.index);
  69. int index;
  70. List<String> bgImageList = ['images/yindao_bg_01.png', 'images/yindao_bg_02.png', 'images/yindao_bg_03.png'];
  71. List<String> textImageList = ['images/yindao_text_01.png', 'images/yindao_text_02.png', 'images/yindao_text_03.png'];
  72. @override
  73. Widget build(BuildContext context) {
  74. return Container(
  75. decoration: BoxDecoration(image: DecorationImage(image: AssetImage(bgImageList[index]), fit: BoxFit.fill)),
  76. child: Stack(
  77. children: <Widget>[
  78. Positioned(
  79. bottom: 70,
  80. left: 0,
  81. child: Container(
  82. width: 375,
  83. child: Center(
  84. child: Image.asset(textImageList[index]),
  85. ),
  86. ),
  87. )
  88. ],
  89. ),
  90. );
  91. }
  92. }
  93. class MyFloat extends StatelessWidget {
  94. MyFloat(this.index);
  95. int index;
  96. @override
  97. Widget build(BuildContext context) {
  98. return Container(
  99. height: 70,
  100. // color: Colors.black,
  101. child: Center(
  102. child: Row(
  103. mainAxisAlignment: MainAxisAlignment.center,
  104. children: index < 2
  105. ? <Widget>[_dot(0, index), _dot(1, index), _dot(2, index)]
  106. : <Widget>[
  107. InkWell(
  108. child: Image.asset('images/icon_inter_000.png'),
  109. onTap: () {
  110. Navigator.of(context).pop();
  111. },
  112. )
  113. ],
  114. )),
  115. );
  116. }
  117. Widget _dot(index, activeIndex) {
  118. return Container(
  119. margin: EdgeInsets.all(2),
  120. decoration: BoxDecoration(
  121. color: (index == activeIndex ? Colors.white : Colors.white24),
  122. borderRadius: BorderRadius.all(Radius.circular(2)),
  123. ),
  124. width: 8,
  125. height: 4,
  126. );
  127. }
  128. }