基础组件库
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

guide_page.dart 8.6 KiB

4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. import 'dart:io';
  2. import 'dart:typed_data';
  3. import 'package:flutter/material.dart';
  4. import 'package:zhiying_base_widget/dialog/global_dialog/policy_dialog/policy_dialog.dart';
  5. import 'package:zhiying_base_widget/models/app_config_model.dart';
  6. import 'package:flutter_swiper/flutter_swiper.dart';
  7. import 'package:zhiying_base_widget/utils/contants.dart';
  8. import 'package:zhiying_base_widget/widgets/home/home_quick_entry/cached_network_image_util.dart';
  9. import 'package:zhiying_comm/util/shared_prefe_util.dart';
  10. import 'package:zhiying_comm/zhiying_comm.dart';
  11. import 'package:zhiying_base_widget/utils/over_scroll_behavior.dart' as Scroll;
  12. class GuidePage extends StatefulWidget {
  13. final GuideData model;
  14. final List<Uint8List> imageDatas;
  15. final List<Uint8List> bgImageDatas;
  16. const GuidePage(this.model, this.imageDatas, this.bgImageDatas, {Key key}) : super(key: key);
  17. @override
  18. State<StatefulWidget> createState() => _GuidePageState();
  19. }
  20. class _GuidePageState extends State<GuidePage> {
  21. @override
  22. void initState() {
  23. Future.delayed(Duration(milliseconds: 100), () {
  24. showPlolicy();
  25. });
  26. super.initState();
  27. }
  28. @override
  29. Widget build(BuildContext context) {
  30. List<int> list = List.generate(widget.imageDatas?.length, (index) => index);
  31. return WillPopScope(
  32. onWillPop: () async => false, // 拦截Android返回键
  33. child: Material(
  34. color: Colors.white,
  35. child: Theme(
  36. data: ThemeData(splashFactory: NoSplashFactory()),
  37. child: ScrollConfiguration(
  38. behavior: Scroll.OverScrollBehavior(),
  39. child: Swiper(
  40. physics: ClampingScrollPhysics(),
  41. itemBuilder: (BuildContext context, int index) {
  42. // return CachedNetworkImage(imageUrl: widget.model.images[index],fit: BoxFit.cover,);
  43. Uint8List bgImage;
  44. if (widget.bgImageDatas.length > index) {
  45. bgImage = widget?.bgImageDatas[index];
  46. }
  47. return Stack(
  48. alignment: Alignment.center,
  49. children: <Widget>[
  50. Container(
  51. width: double.infinity,
  52. height: double.infinity,
  53. decoration: BoxDecoration(
  54. image: DecorationImage(
  55. image: Image.memory(
  56. bgImage,
  57. ).image,
  58. fit: BoxFit.fill)),
  59. child: Center(
  60. child: Image.memory(
  61. widget.imageDatas[index],
  62. fit: BoxFit.fitWidth,
  63. ))),
  64. index == widget?.bgImageDatas?.length - 1
  65. ? Positioned(
  66. left: 0,
  67. right: 0,
  68. bottom: 110,
  69. child: Center(
  70. child: Row(
  71. mainAxisAlignment: MainAxisAlignment.center,
  72. children: <Widget>[
  73. Container(
  74. alignment: Alignment.center,
  75. height: 46,
  76. width: 180,
  77. decoration: BoxDecoration(
  78. color: HexColor.fromHex(widget?.model?.btnBgColor ?? ""),
  79. borderRadius: BorderRadius.circular(45),
  80. boxShadow: [BoxShadow(color: HexColor.fromHex(widget?.model?.btnBgColor), offset: Offset(1, 2), blurRadius: 6)]),
  81. child: Text(
  82. widget?.model?.btnText ?? "",
  83. style: TextStyle(color: HexColor.fromHex(widget?.model?.btnTextColor ?? ""), fontSize: 16, height: 1.1),
  84. ),
  85. ),
  86. ],
  87. ),
  88. ),
  89. )
  90. : Container()
  91. ],
  92. );
  93. },
  94. loop: false,
  95. itemCount: widget.imageDatas?.length ?? 0,
  96. pagination: widget?.model?.indicatorType != "1"
  97. ? null
  98. : widget?.model?.indicatorCssType == "2"
  99. ? SwiperCustomPagination(builder: (BuildContext context, SwiperPluginConfig config) {
  100. return Align(
  101. alignment: Alignment(0.0, 1),
  102. child: Row(
  103. mainAxisAlignment: MainAxisAlignment.center,
  104. crossAxisAlignment: CrossAxisAlignment.center,
  105. children: list.map((index) {
  106. return SafeArea(
  107. child: Container(
  108. margin: EdgeInsets.only(bottom: 40, left: 5, right: 5),
  109. height: 4,
  110. width: 20,
  111. decoration: BoxDecoration(
  112. borderRadius: BorderRadius.circular(10),
  113. color: index == config.activeIndex
  114. ? HexColor.fromHex(widget?.model?.indicatorChooseColor)
  115. : HexColor.fromHex(widget?.model?.indicatorUnchooseColor)),
  116. ),
  117. );
  118. }).toList(),
  119. ),
  120. );
  121. })
  122. : SwiperCustomPagination(builder: (BuildContext context, SwiperPluginConfig config) {
  123. return Align(
  124. alignment: Alignment(0.0, 1),
  125. child: Row(
  126. mainAxisAlignment: MainAxisAlignment.center,
  127. crossAxisAlignment: CrossAxisAlignment.center,
  128. children: list.map((index) {
  129. return SafeArea(
  130. child: Container(
  131. margin: EdgeInsets.only(bottom: 40, left: 5, right: 5),
  132. height: 10,
  133. width: 10,
  134. decoration: BoxDecoration(
  135. borderRadius: BorderRadius.circular(10),
  136. color: index == config.activeIndex
  137. ? HexColor.fromHex(widget?.model?.indicatorChooseColor)
  138. : HexColor.fromHex(widget?.model?.indicatorUnchooseColor)),
  139. ),
  140. );
  141. }).toList(),
  142. ),
  143. );
  144. }),
  145. onIndexChanged: (index) {},
  146. onTap: (index) {
  147. if (index == widget.model.guideCss.length - 1) {
  148. Navigator.pop(context, true);
  149. }
  150. },
  151. ),
  152. ),
  153. ),
  154. ),
  155. );
  156. }
  157. void showPlolicy() async {
  158. ///协议弹窗
  159. String isShowPolicy = await SharedPreferencesUtil.getStringValue(Constants.isShowPolicy);
  160. if (isShowPolicy == null || isShowPolicy != '1') {
  161. NativeUtil.notifyInitSuccess();
  162. bool isAccept = await PolicyDialog.show(context);
  163. if (!isAccept) {
  164. exit(0);
  165. } else {
  166. await SharedPreferencesUtil.setStringValue(Constants.isShowPolicy, "1");
  167. }
  168. }
  169. }
  170. }
  171. class NoSplashFactory extends InteractiveInkFeatureFactory {
  172. InteractiveInkFeature create(
  173. {MaterialInkController controller,
  174. RenderBox referenceBox,
  175. Offset position,
  176. Color color,
  177. TextDirection textDirection,
  178. bool containedInkWell = false,
  179. rectCallback,
  180. BorderRadius borderRadius,
  181. ShapeBorder customBorder,
  182. double radius,
  183. onRemoved}) {
  184. return _NoInteractiveInkFeature(controller: controller, referenceBox: referenceBox);
  185. }
  186. }
  187. class _NoInteractiveInkFeature extends InteractiveInkFeature {
  188. _NoInteractiveInkFeature({
  189. MaterialInkController controller,
  190. RenderBox referenceBox,
  191. }) : super(controller: controller, referenceBox: referenceBox);
  192. void paintFeature(Canvas canvas, Matrix4 transform) {}
  193. }