GuidePage.dart 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutter_swiper/flutter_swiper.dart';
  4. import '../model/PopNotice.dart';
  5. class GuidePage extends StatefulWidget {
  6. GuidePage(this.popNoticeList);
  7. List<PopNotice> popNoticeList;
  8. @override
  9. _GuidePageState createState() => _GuidePageState();
  10. }
  11. class _GuidePageState extends State<GuidePage> with WidgetsBindingObserver {
  12. int swiperIndex = 0;
  13. @override
  14. Widget build(BuildContext context) {
  15. return Scaffold(
  16. backgroundColor: Color(0xCC000000),
  17. body: WillPopScope(
  18. child: Center(
  19. child: Column(
  20. crossAxisAlignment: CrossAxisAlignment.center,
  21. mainAxisAlignment: MainAxisAlignment.center,
  22. children: <Widget>[
  23. Container(
  24. width: 320,
  25. height: 420,
  26. child: new Swiper(
  27. itemBuilder: (BuildContext context, int index) {
  28. return Image.network(
  29. widget.popNoticeList[index].image,
  30. fit: BoxFit.fill,
  31. );
  32. },
  33. itemCount: widget.popNoticeList.length,
  34. loop: false,
  35. onIndexChanged: (index) {
  36. setState(() {
  37. swiperIndex = index;
  38. });
  39. },
  40. pagination: SwiperCustomPagination(builder: (BuildContext context, SwiperPluginConfig config) {
  41. Color activeColor = Color(0xFFD4504B);
  42. Color color = Colors.white;
  43. List<Widget> list = [];
  44. int itemCount = config.itemCount;
  45. int activeIndex = config.activeIndex;
  46. for (int i = 0; i < itemCount; ++i) {
  47. bool active = i == activeIndex;
  48. list.add(
  49. Container(
  50. key: Key("pagination_$i"),
  51. margin: EdgeInsets.symmetric(vertical: 3, horizontal: 2),
  52. child: Container(
  53. width: active ? 12 : 4,
  54. height: 4,
  55. decoration: BoxDecoration(color: active ? activeColor : color, borderRadius: BorderRadius.all(Radius.circular(3))),
  56. )),
  57. );
  58. }
  59. return Container(
  60. margin: EdgeInsets.only(top: 406),
  61. child: Row(
  62. mainAxisAlignment: MainAxisAlignment.center,
  63. children: list,
  64. ),
  65. );
  66. })),
  67. ),
  68. Container(
  69. height: 20,
  70. ),
  71. InkWell(
  72. child: Image.asset('images/icon_xiayiye1.png'),
  73. onTap: () {
  74. Navigator.of(context).pop(true);
  75. },
  76. )
  77. ],
  78. ),
  79. ),
  80. onWillPop: () {}));
  81. }
  82. }
  83. class GuidItem extends StatelessWidget {
  84. GuidItem(this.index);
  85. int index;
  86. List<String> bgImageList = ['images/yindao_bg_01.png', 'images/yindao_bg_02.png', 'images/yindao_bg_03.png'];
  87. List<String> textImageList = ['images/yindao_text_01.png', 'images/yindao_text_02.png', 'images/yindao_text_03.png'];
  88. @override
  89. Widget build(BuildContext context) {
  90. return Container(
  91. decoration: BoxDecoration(image: DecorationImage(image: AssetImage(bgImageList[index]), fit: BoxFit.fill)),
  92. child: Stack(
  93. children: <Widget>[
  94. Positioned(
  95. bottom: 70,
  96. left: 0,
  97. child: Container(
  98. width: 375,
  99. child: Center(
  100. child: Image.asset(textImageList[index]),
  101. ),
  102. ),
  103. )
  104. ],
  105. ),
  106. );
  107. }
  108. }
  109. class MyFloat extends StatelessWidget {
  110. MyFloat(this.index);
  111. int index;
  112. @override
  113. Widget build(BuildContext context) {
  114. return Container(
  115. height: 70,
  116. // color: Colors.black,
  117. child: Center(
  118. child: Row(
  119. mainAxisAlignment: MainAxisAlignment.center,
  120. children: index < 2
  121. ? <Widget>[_dot(0, index), _dot(1, index), _dot(2, index)]
  122. : <Widget>[
  123. InkWell(
  124. child: Image.asset('images/icon_inter_000.png'),
  125. onTap: () {
  126. Navigator.of(context).pop(true);
  127. },
  128. )
  129. ],
  130. )),
  131. );
  132. }
  133. Widget _dot(index, activeIndex) {
  134. return Container(
  135. margin: EdgeInsets.all(2),
  136. decoration: BoxDecoration(
  137. color: (index == activeIndex ? Colors.white : Colors.white24),
  138. borderRadius: BorderRadius.all(Radius.circular(2)),
  139. ),
  140. width: 8,
  141. height: 4,
  142. );
  143. }
  144. }