diff --git a/lib/pages/guide_page/guide_page.dart b/lib/pages/guide_page/guide_page.dart index ac10484..837e140 100644 --- a/lib/pages/guide_page/guide_page.dart +++ b/lib/pages/guide_page/guide_page.dart @@ -1,10 +1,15 @@ +import 'dart:io'; import 'dart:typed_data'; import 'package:flutter/material.dart'; +import 'package:zhiying_base_widget/dialog/global_dialog/policy_dialog/policy_dialog.dart'; import 'package:zhiying_base_widget/models/app_config_model.dart'; import 'package:flutter_swiper/flutter_swiper.dart'; +import 'package:zhiying_base_widget/utils/contants.dart'; import 'package:zhiying_base_widget/widgets/home/home_quick_entry/cached_network_image_util.dart'; +import 'package:zhiying_comm/util/shared_prefe_util.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; +import 'package:zhiying_base_widget/utils/over_scroll_behavior.dart' as Scroll; class GuidePage extends StatefulWidget { final GuideData model; @@ -18,127 +23,182 @@ class GuidePage extends StatefulWidget { } class _GuidePageState extends State { + @override + void initState() { + Future.delayed(Duration(milliseconds: 100), () { + showPlolicy(); + }); + super.initState(); + } + @override Widget build(BuildContext context) { - bool isShowIndicator = (widget.model?.indicatorType ?? '0') == '1'; List list = List.generate(widget.imageDatas?.length, (index) => index); return WillPopScope( onWillPop: () async => false, // 拦截Android返回键 child: Material( - child: Swiper( - itemBuilder: (BuildContext context, int index) { - // return CachedNetworkImage(imageUrl: widget.model.images[index],fit: BoxFit.cover,); - Uint8List bgImage; - if (widget.bgImageDatas.length > index) { - bgImage = widget?.bgImageDatas[index]; - } + color: Colors.white, + child: Theme( + data: ThemeData(splashFactory: NoSplashFactory()), + child: ScrollConfiguration( + behavior: Scroll.OverScrollBehavior(), + child: Swiper( + physics: ClampingScrollPhysics(), + itemBuilder: (BuildContext context, int index) { + // return CachedNetworkImage(imageUrl: widget.model.images[index],fit: BoxFit.cover,); + Uint8List bgImage; + if (widget.bgImageDatas.length > index) { + bgImage = widget?.bgImageDatas[index]; + } - return Stack( - alignment: Alignment.center, - children: [ - Container( - width: double.infinity, - height: double.infinity, - decoration: BoxDecoration( - image: DecorationImage( - image: Image.memory( - bgImage, - ).image, - fit: BoxFit.fill)), - child: Center( - child: Image.memory( - widget.imageDatas[index], - fit: BoxFit.fitWidth, - ))), - index == widget?.bgImageDatas?.length - 1 - ? Positioned( - left: 0, - right: 0, - bottom: 110, + return Stack( + alignment: Alignment.center, + children: [ + Container( + width: double.infinity, + height: double.infinity, + decoration: BoxDecoration( + image: DecorationImage( + image: Image.memory( + bgImage, + ).image, + fit: BoxFit.fill)), child: Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - alignment: Alignment.center, - height: 46, - width: 180, - decoration: BoxDecoration( - color: HexColor.fromHex(widget?.model?.btnBgColor ?? ""), - borderRadius: BorderRadius.circular(45), - boxShadow: [BoxShadow(color: HexColor.fromHex(widget?.model?.btnBgColor), offset: Offset(1, 2), blurRadius: 6)]), - child: Text( - widget?.model?.btnText ?? "", - style: TextStyle(color: HexColor.fromHex(widget?.model?.btnTextColor ?? ""), fontSize: 16, height: 1.1), - ), - ), - ], - ), - ), - ) - : Container() - ], - ); - }, - loop: false, - itemCount: widget.imageDatas?.length ?? 0, - pagination: widget?.model?.indicatorType != "1" - ? null - : widget?.model?.indicatorCssType == "2" - ? SwiperCustomPagination(builder: (BuildContext context, SwiperPluginConfig config) { - return Align( - alignment: Alignment(0.0, 1), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: list.map((index) { - return SafeArea( - child: Container( - margin: EdgeInsets.only(bottom: 40, left: 5, right: 5), - height: 4, - width: 20, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: index == config.activeIndex - ? HexColor.fromHex(widget?.model?.indicatorChooseColor) - : HexColor.fromHex(widget?.model?.indicatorUnchooseColor)), + child: Image.memory( + widget.imageDatas[index], + fit: BoxFit.fitWidth, + ))), + index == widget?.bgImageDatas?.length - 1 + ? Positioned( + left: 0, + right: 0, + bottom: 110, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + alignment: Alignment.center, + height: 46, + width: 180, + decoration: BoxDecoration( + color: HexColor.fromHex(widget?.model?.btnBgColor ?? ""), + borderRadius: BorderRadius.circular(45), + boxShadow: [BoxShadow(color: HexColor.fromHex(widget?.model?.btnBgColor), offset: Offset(1, 2), blurRadius: 6)]), + child: Text( + widget?.model?.btnText ?? "", + style: TextStyle(color: HexColor.fromHex(widget?.model?.btnTextColor ?? ""), fontSize: 16, height: 1.1), + ), + ), + ], ), - ); - }).toList(), - ), - ); - }) - : SwiperCustomPagination(builder: (BuildContext context, SwiperPluginConfig config) { - return Align( - alignment: Alignment(0.0, 1), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: list.map((index) { - return SafeArea( - child: Container( - margin: EdgeInsets.only(bottom: 40, left: 5, right: 5), - height: 10, - width: 10, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: index == config.activeIndex - ? HexColor.fromHex(widget?.model?.indicatorChooseColor) - : HexColor.fromHex(widget?.model?.indicatorUnchooseColor)), - ), - ); - }).toList(), - ), - ); - }), - onIndexChanged: (index) {}, - onTap: (index) { - if (index == widget.model.guideCss.length - 1) { - Navigator.pop(context, true); - } - }, + ), + ) + : Container() + ], + ); + }, + loop: false, + itemCount: widget.imageDatas?.length ?? 0, + pagination: widget?.model?.indicatorType != "1" + ? null + : widget?.model?.indicatorCssType == "2" + ? SwiperCustomPagination(builder: (BuildContext context, SwiperPluginConfig config) { + return Align( + alignment: Alignment(0.0, 1), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: list.map((index) { + return SafeArea( + child: Container( + margin: EdgeInsets.only(bottom: 40, left: 5, right: 5), + height: 4, + width: 20, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: index == config.activeIndex + ? HexColor.fromHex(widget?.model?.indicatorChooseColor) + : HexColor.fromHex(widget?.model?.indicatorUnchooseColor)), + ), + ); + }).toList(), + ), + ); + }) + : SwiperCustomPagination(builder: (BuildContext context, SwiperPluginConfig config) { + return Align( + alignment: Alignment(0.0, 1), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: list.map((index) { + return SafeArea( + child: Container( + margin: EdgeInsets.only(bottom: 40, left: 5, right: 5), + height: 10, + width: 10, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: index == config.activeIndex + ? HexColor.fromHex(widget?.model?.indicatorChooseColor) + : HexColor.fromHex(widget?.model?.indicatorUnchooseColor)), + ), + ); + }).toList(), + ), + ); + }), + onIndexChanged: (index) {}, + onTap: (index) { + if (index == widget.model.guideCss.length - 1) { + Navigator.pop(context, true); + } + }, + ), + ), ), ), ); } + + void showPlolicy() async { + ///协议弹窗 + String isShowPolicy = await SharedPreferencesUtil.getStringValue(Constants.isShowPolicy); + if (isShowPolicy == null || isShowPolicy != '1') { + NativeUtil.notifyInitSuccess(); + bool isAccept = await PolicyDialog.show(context); + if (!isAccept) { + exit(0); + } else { + await SharedPreferencesUtil.setStringValue(Constants.isShowPolicy, "1"); + } + } + } +} + +class NoSplashFactory extends InteractiveInkFeatureFactory { + InteractiveInkFeature create( + {MaterialInkController controller, + RenderBox referenceBox, + Offset position, + Color color, + TextDirection textDirection, + bool containedInkWell = false, + rectCallback, + BorderRadius borderRadius, + ShapeBorder customBorder, + double radius, + onRemoved}) { + return _NoInteractiveInkFeature(controller: controller, referenceBox: referenceBox); + } +} + +class _NoInteractiveInkFeature extends InteractiveInkFeature { + _NoInteractiveInkFeature({ + MaterialInkController controller, + RenderBox referenceBox, + }) : super(controller: controller, referenceBox: referenceBox); + + void paintFeature(Canvas canvas, Matrix4 transform) {} } diff --git a/lib/pages/launch_page/launch_page.dart b/lib/pages/launch_page/launch_page.dart index 9796f4e..0394013 100644 --- a/lib/pages/launch_page/launch_page.dart +++ b/lib/pages/launch_page/launch_page.dart @@ -59,17 +59,6 @@ class _LaunchPageState extends State with TickerProviderStateMixin { Logger.debug('ConnectivityResult.wifi'); print('ConnectivityResult.wifi'); Application.init().then((_) async { - ///协议弹窗 - String isShowPolicy = await SharedPreferencesUtil.getStringValue(Constants.isShowPolicy); - if (isShowPolicy == null || isShowPolicy != '1') { - NativeUtil.notifyInitSuccess(); - bool isAccept = await PolicyDialog.show(context); - if (!isAccept) { - exit(0); - } else { - await SharedPreferencesUtil.setStringValue(Constants.isShowPolicy, "1"); - } - } ///引导页 PackageInfo packageInfo = await PackageInfo.fromPlatform(); @@ -146,7 +135,6 @@ class _LaunchPageState extends State with TickerProviderStateMixin { } } - NativeUtil.notifyInitSuccess(); await Navigator.of(context).push(CupertinoPageRoute(builder: (context) => GuidePage(guide.guideData, guideImages,bgImages))); } @@ -159,11 +147,6 @@ class _LaunchPageState extends State with TickerProviderStateMixin { Widget build(BuildContext context) { return Container( color: Colors.white, - child: Image.asset( - 'assets/images/launch_image/launch_image.png', - package: 'zhiying_base_widget', - fit: BoxFit.fill, - ), ); } } diff --git a/lib/utils/over_scroll_behavior.dart b/lib/utils/over_scroll_behavior.dart new file mode 100644 index 0000000..df287fa --- /dev/null +++ b/lib/utils/over_scroll_behavior.dart @@ -0,0 +1,26 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class OverScrollBehavior extends ScrollBehavior{ + + @override + Widget buildViewportChrome(BuildContext context, Widget child, AxisDirection axisDirection) { + switch (getPlatform(context)) { + case TargetPlatform.iOS: + return child; + case TargetPlatform.android: + case TargetPlatform.fuchsia: + return GlowingOverscrollIndicator( + child: child, + //不显示头部水波纹 + showLeading: false, + //不显示尾部水波纹 + showTrailing: false, + axisDirection: axisDirection, + color: Theme.of(context).accentColor, + ); + } + return null; + } + +} \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index bc84990..81f0b43 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -44,12 +44,15 @@ dependencies: loading_indicator: ^1.2.0 mobpush_plugin: + + zhiying_comm: + path: ../zhiying_comm + dev_dependencies: flutter_test: sdk: flutter - zhiying_comm: - path: ../zhiying_comm + # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec