基础组件库
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

78 righe
2.9 KiB

  1. import 'dart:typed_data';
  2. import 'package:flutter/material.dart';
  3. import 'package:zhiying_base_widget/models/app_config_model.dart';
  4. import 'package:flutter_swiper/flutter_swiper.dart';
  5. import 'package:zhiying_base_widget/widgets/home/home_quick_entry/cached_network_image_util.dart';
  6. import 'package:zhiying_comm/zhiying_comm.dart';
  7. class GuidePage extends StatefulWidget {
  8. final AppConfigGuideModel model;
  9. final List<Uint8List> imageDatas;
  10. const GuidePage(this.model, this.imageDatas, {Key key}) : super(key: key);
  11. @override
  12. State<StatefulWidget> createState() => _GuidePageState();
  13. }
  14. class _GuidePageState extends State<GuidePage> {
  15. @override
  16. Widget build(BuildContext context) {
  17. bool isShowIndicator = (widget.model?.isShowIndicator ?? '0') == '1';
  18. List<int> list = List.generate(widget.imageDatas?.length, (index) => index);
  19. return WillPopScope(
  20. onWillPop: () async => false,// 拦截Android返回键
  21. child: Material(
  22. child: Swiper(
  23. itemBuilder: (BuildContext context, int index) {
  24. // return CachedNetworkImage(imageUrl: widget.model.images[index],fit: BoxFit.cover,);
  25. return Image.memory(widget.imageDatas[index], fit: BoxFit.cover,);
  26. },
  27. loop: false,
  28. itemCount: widget.imageDatas?.length ?? 0,
  29. pagination: isShowIndicator ? SwiperCustomPagination(builder: (BuildContext context, SwiperPluginConfig config) {
  30. return Align(
  31. alignment: Alignment(0.0, 1),
  32. child: Row(
  33. mainAxisAlignment: MainAxisAlignment.center,
  34. crossAxisAlignment: CrossAxisAlignment.center,
  35. children: list.map((index) {
  36. var borderRadius;
  37. if (index == 0) {
  38. borderRadius = BorderRadius.only(topLeft: Radius.circular(2), bottomLeft: Radius.circular(2));
  39. }
  40. if (index == list.length - 1) {
  41. borderRadius = BorderRadius.only(topRight: Radius.circular(2), bottomRight: Radius.circular(2));
  42. }
  43. if (index == config.activeIndex) {
  44. borderRadius = BorderRadius.all(Radius.circular(2));
  45. }
  46. return SafeArea(
  47. child: Container(
  48. margin: EdgeInsets.only(bottom: 40),
  49. height: 4,
  50. width: 25,
  51. decoration: BoxDecoration(borderRadius: borderRadius, color: index == config.activeIndex ? HexColor.fromHex('#FF4242') : HexColor.fromHex('#FFFFFF')),
  52. ),
  53. );
  54. }).toList() ,
  55. ),
  56. );
  57. }) : null,
  58. onIndexChanged: (index) {
  59. },
  60. onTap: (index) {
  61. if (index == widget.model.images.length - 1) {
  62. Navigator.pop(context, true);
  63. }
  64. },
  65. ),
  66. ),
  67. );
  68. }
  69. }