From acbf04dfbda515aa9d049594a66e66cb4b71ebe2 Mon Sep 17 00:00:00 2001 From: Odinachi David Date: Wed, 3 May 2023 19:51:38 +0100 Subject: [PATCH] added child and optional droplet --- example/ios/Flutter/AppFrameworkInfo.plist | 2 +- example/ios/Runner.xcodeproj/project.pbxproj | 6 +- example/ios/Runner/Info.plist | 92 ++++++++++---------- example/lib/main.dart | 1 + lib/liquid_pull_to_refresh.dart | 88 +++++++++++-------- 5 files changed, 105 insertions(+), 84 deletions(-) diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 8d4492f..9625e10 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 9.0 + 11.0 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index f10afee..6ad63eb 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -284,7 +284,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -361,7 +361,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -408,7 +408,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index a8e3946..aaf9403 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -1,45 +1,47 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - example - CFBundlePackageType - APPL - CFBundleShortVersionString - $(FLUTTER_BUILD_NAME) - CFBundleSignature - ???? - CFBundleVersion - $(FLUTTER_BUILD_NUMBER) - LSRequiresIPhoneOS - - UILaunchStoryboardName - LaunchScreen - UIMainStoryboardFile - Main - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UIViewControllerBasedStatusBarAppearance - - - + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + example + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + CADisableMinimumFrameDurationOnPhone + + + diff --git a/example/lib/main.dart b/example/lib/main.dart index 3403f39..0057820 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -108,6 +108,7 @@ class _MyHomePageState extends State { ), ), body: LiquidPullToRefresh( + showDroplet: false, key: _refreshIndicatorKey, onRefresh: _handleRefresh, showChildOpacityTransition: false, diff --git a/lib/liquid_pull_to_refresh.dart b/lib/liquid_pull_to_refresh.dart index 90b2c33..6577afb 100644 --- a/lib/liquid_pull_to_refresh.dart +++ b/lib/liquid_pull_to_refresh.dart @@ -44,18 +44,20 @@ enum _LiquidPullToRefreshMode { } class LiquidPullToRefresh extends StatefulWidget { - const LiquidPullToRefresh({ - Key? key, - this.animSpeedFactor = 1.0, - required this.child, - required this.onRefresh, - this.color, - this.backgroundColor, - this.height, - this.springAnimationDurationInMilliseconds = 1000, - this.borderWidth = 2.0, - this.showChildOpacityTransition = true, - }) : assert(animSpeedFactor >= 1.0), + const LiquidPullToRefresh( + {Key? key, + this.animSpeedFactor = 1.0, + required this.child, + required this.onRefresh, + this.color, + this.backgroundColor, + this.height, + this.springAnimationDurationInMilliseconds = 1000, + this.borderWidth = 2.0, + this.showChildOpacityTransition = true, + this.showDroplet = true, + this.loaderWidget}) + : assert(animSpeedFactor >= 1.0), super(key: key); /// The widget below this widget in the tree. @@ -107,6 +109,12 @@ class LiquidPullToRefresh extends StatefulWidget { /// [ThemeData.canvasColor] by default. final Color? backgroundColor; + /// show the animated droplet, the default is true + final bool showDroplet; + + /// the default is a container with the specified color + final Widget? loaderWidget; + @override LiquidPullToRefreshState createState() => LiquidPullToRefreshState(); } @@ -596,6 +604,7 @@ class LiquidPullToRefreshState extends State : 1.0, child: child); } + return Transform.translate( offset: new Offset(0.0, _positionController.value * height * 1.5), child: child, @@ -613,7 +622,7 @@ class LiquidPullToRefreshState extends State clipper: CurveHillClipper( centreHeight: height, curveHeight: height / 2 * _springAnimation.value, // 50.0 - peakHeight: height * + peakHeight: (widget.showDroplet ? height : 0) * 3 / 10 * ((_peakHeightUpAnimation.value != 1.0) //30.0 @@ -649,28 +658,37 @@ class LiquidPullToRefreshState extends State (0.36 * _indicatorTranslateWithPeakAnimation.value) - (0.64 * _indicatorTranslateAnimation.value)), ), - child: Transform( - transform: Matrix4.identity() - ..rotateZ(_progressingRotateAnimation.value * 5 * pi / 6), - alignment: FractionalOffset.center, - child: CircularProgress( - backgroundColor: backgroundColor, - progressCircleOpacity: _ringOpacityAnimation.value, - innerCircleRadius: height * - 15 / - 100 * // 15.0 - ((_mode != _LiquidPullToRefreshMode.done) - ? _indicatorRadiusWithPeakAnimation.value - : _radiusAnimation.value), - progressCircleBorderWidth: widget.borderWidth, - //2.0 - progressCircleRadius: (_ringOpacityAnimation.value != 0.0) - ? (height * 2 / 10) * _ringRadiusAnimation.value //20.0 - : 0.0, - startAngle: _progressingStartAngleAnimation.value * pi, - progressPercent: _progressingPercentAnimation.value, - ), - ), + child: widget.loaderWidget != null + ? Opacity( + opacity: _indicatorMoveWithPeakController.value, + child: widget.loaderWidget, + ) + : Transform( + transform: Matrix4.identity() + ..rotateZ( + _progressingRotateAnimation.value * 5 * pi / 6), + alignment: FractionalOffset.center, + child: CircularProgress( + backgroundColor: backgroundColor, + progressCircleOpacity: _ringOpacityAnimation.value, + innerCircleRadius: height * + 15 / + 100 * // 15.0 + ((_mode != _LiquidPullToRefreshMode.done) + ? _indicatorRadiusWithPeakAnimation.value + : _radiusAnimation.value), + progressCircleBorderWidth: widget.borderWidth, + //2.0 + progressCircleRadius: + (_ringOpacityAnimation.value != 0.0) + ? (height * 2 / 10) * + _ringRadiusAnimation.value //20.0 + : 0.0, + startAngle: + _progressingStartAngleAnimation.value * pi, + progressPercent: _progressingPercentAnimation.value, + ), + ), ); }, ),