diff --git a/.fvm/flutter_sdk b/.fvm/flutter_sdk new file mode 120000 index 0000000..a008640 --- /dev/null +++ b/.fvm/flutter_sdk @@ -0,0 +1 @@ +/Users/azaderdogan/fvm/stable \ No newline at end of file diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json new file mode 100644 index 0000000..b3db758 --- /dev/null +++ b/.fvm/fvm_config.json @@ -0,0 +1,4 @@ +{ + "flutterSdkVersion": "stable", + "flavors": {} +} \ No newline at end of file diff --git a/example/.flutter-plugins-dependencies b/example/.flutter-plugins-dependencies index 9c09763..16dca1d 100644 --- a/example/.flutter-plugins-dependencies +++ b/example/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider","path":"/Users/akshath/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.28/","dependencies":[]},{"name":"sqflite","path":"/Users/akshath/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+4/","dependencies":[]}],"android":[{"name":"path_provider","path":"/Users/akshath/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.28/","dependencies":[]},{"name":"sqflite","path":"/Users/akshath/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+4/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/Users/akshath/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.4+8/","dependencies":[]},{"name":"sqflite","path":"/Users/akshath/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.2+4/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/akshath/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-0.0.1+2/","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/akshath/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-0.0.5/","dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2021-04-26 22:43:13.474041","version":"2.0.5"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider","path":"/Users/azaderdogan/.pub-cache/hosted/pub.dev/path_provider-1.6.28/","native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/azaderdogan/.pub-cache/hosted/pub.dev/sqflite-1.3.2+4/","native_build":true,"dependencies":[]}],"android":[{"name":"path_provider","path":"/Users/azaderdogan/.pub-cache/hosted/pub.dev/path_provider-1.6.28/","native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/azaderdogan/.pub-cache/hosted/pub.dev/sqflite-1.3.2+4/","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/Users/azaderdogan/.pub-cache/hosted/pub.dev/path_provider_macos-0.0.4+8/","native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/azaderdogan/.pub-cache/hosted/pub.dev/sqflite-1.3.2+4/","native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/azaderdogan/.pub-cache/hosted/pub.dev/path_provider_linux-0.0.1+2/","native_build":false,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/azaderdogan/.pub-cache/hosted/pub.dev/path_provider_windows-0.0.5/","native_build":false,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"sqflite","dependencies":[]}],"date_created":"2023-05-22 09:36:38.761668","version":"3.7.12"} \ No newline at end of file diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 9367d48..9625e10 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 8.0 + 11.0 diff --git a/example/ios/Flutter/Flutter.podspec b/example/ios/Flutter/Flutter.podspec index 2c4421c..8ce4394 100644 --- a/example/ios/Flutter/Flutter.podspec +++ b/example/ios/Flutter/Flutter.podspec @@ -6,12 +6,12 @@ Pod::Spec.new do |s| s.name = 'Flutter' s.version = '1.0.0' - s.summary = 'High-performance, high-fidelity mobile apps.' - s.homepage = 'https://flutter.io' - s.license = { :type => 'MIT' } + s.summary = 'A UI toolkit for beautiful and fast apps.' + s.homepage = 'https://flutter.dev' + s.license = { :type => 'BSD' } s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' } s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s } - s.ios.deployment_target = '8.0' + s.ios.deployment_target = '11.0' # Framework linking is handled by Flutter tooling, not CocoaPods. # Add a placeholder to satisfy `s.dependency 'Flutter'` plugin podspecs. s.vendored_frameworks = 'path/to/nothing' diff --git a/example/ios/Podfile b/example/ios/Podfile index 1e8c3c9..88359b2 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '9.0' +# platform :ios, '11.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index c1ebe49..537e200 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -156,7 +156,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1020; + LastUpgradeCheck = 1300; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -239,6 +239,7 @@ }; 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -253,6 +254,7 @@ }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -340,7 +342,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; SUPPORTED_PLATFORMS = iphoneos; @@ -414,7 +416,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; @@ -463,7 +465,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; SUPPORTED_PLATFORMS = iphoneos; diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index a28140c..3db53b6 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ UIViewControllerBasedStatusBarAppearance + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + diff --git a/lib/src/panel.dart b/lib/src/panel.dart index 3e8c4b4..b3fa6fe 100644 --- a/lib/src/panel.dart +++ b/lib/src/panel.dart @@ -61,7 +61,7 @@ class SlidingUpPanel extends StatefulWidget { final double minHeight; /// The height of the sliding panel when fully open. - final double maxHeight; + double maxHeight; /// A point between [minHeight] and [maxHeight] that the panel snaps to /// while animating. A fast swipe on the panel will disregard this point @@ -214,11 +214,12 @@ class _SlidingUpPanelState extends State VelocityTracker _vt = new VelocityTracker.withKind(PointerDeviceKind.touch); bool _isPanelVisible = true; - + GlobalKey sliderPartKey = GlobalKey(); + double _maxHeight = 0.0; @override void initState() { super.initState(); - + _maxHeight = widget.maxHeight; _ac = new AnimationController( vsync: this, duration: const Duration(milliseconds: 300), @@ -242,7 +243,6 @@ class _SlidingUpPanelState extends State _sc.addListener(() { if (widget.isDraggable && !_scrollingEnabled) _sc.jumpTo(0); }); - widget.controller?._addState(this); } @@ -308,53 +308,32 @@ class _SlidingUpPanelState extends State !_isPanelVisible ? Container() : _gestureHandler( - child: AnimatedBuilder( - animation: _ac, - builder: (context, child) { - return Container( - height: - _ac.value * (widget.maxHeight - widget.minHeight) + + child: StatefulBuilder( + key: sliderPartKey, + builder: (context, setSliderPartState) { + return AnimatedBuilder( + animation: _ac, + builder: (context, child) { + return Container( + height: _ac.value * (_maxHeight - widget.minHeight) + widget.minHeight, - margin: widget.margin, - padding: widget.padding, - decoration: widget.renderPanelSheet - ? BoxDecoration( - border: widget.border, - borderRadius: widget.borderRadius, - boxShadow: widget.boxShadow, - color: widget.color, - ) - : null, - child: child, - ); - }, - child: Stack( - children: [ - //open panel - Positioned( - top: widget.slideDirection == SlideDirection.UP - ? 0.0 - : null, - bottom: widget.slideDirection == SlideDirection.DOWN - ? 0.0 + margin: widget.margin, + padding: widget.padding, + decoration: widget.renderPanelSheet + ? BoxDecoration( + border: widget.border, + borderRadius: widget.borderRadius, + boxShadow: widget.boxShadow, + color: widget.color, + ) : null, - width: MediaQuery.of(context).size.width - - (widget.margin != null - ? widget.margin!.horizontal - : 0) - - (widget.padding != null - ? widget.padding!.horizontal - : 0), - child: Container( - height: widget.maxHeight, - child: widget.panel != null - ? widget.panel - : widget.panelBuilder!(_sc), - )), - - // header - widget.header != null - ? Positioned( + child: child, + ); + }, + child: Stack( + children: [ + //open panel + Positioned( top: widget.slideDirection == SlideDirection.UP ? 0.0 : null, @@ -362,56 +341,84 @@ class _SlidingUpPanelState extends State widget.slideDirection == SlideDirection.DOWN ? 0.0 : null, - child: widget.header ?? SizedBox(), - ) - : Container(), - - // footer - widget.footer != null - ? Positioned( - top: widget.slideDirection == SlideDirection.UP - ? null - : 0.0, - bottom: - widget.slideDirection == SlideDirection.DOWN + width: MediaQuery.of(context).size.width - + (widget.margin != null + ? widget.margin!.horizontal + : 0) - + (widget.padding != null + ? widget.padding!.horizontal + : 0), + child: Container( + height: _maxHeight, + child: widget.panel != null + ? widget.panel + : widget.panelBuilder!(_sc), + )), + + // header + widget.header != null + ? Positioned( + top: + widget.slideDirection == SlideDirection.UP + ? 0.0 + : null, + bottom: widget.slideDirection == + SlideDirection.DOWN + ? 0.0 + : null, + child: widget.header ?? SizedBox(), + ) + : Container(), + + // footer + widget.footer != null + ? Positioned( + top: + widget.slideDirection == SlideDirection.UP + ? null + : 0.0, + bottom: widget.slideDirection == + SlideDirection.DOWN ? null : 0.0, - child: widget.footer ?? SizedBox()) - : Container(), - - // collapsed panel - Positioned( - top: widget.slideDirection == SlideDirection.UP - ? 0.0 - : null, - bottom: widget.slideDirection == SlideDirection.DOWN - ? 0.0 - : null, - width: MediaQuery.of(context).size.width - - (widget.margin != null - ? widget.margin!.horizontal - : 0) - - (widget.padding != null - ? widget.padding!.horizontal - : 0), - child: Container( - height: widget.minHeight, - child: widget.collapsed == null - ? Container() - : FadeTransition( - opacity: - Tween(begin: 1.0, end: 0.0).animate(_ac), - - // if the panel is open ignore pointers (touch events) on the collapsed - // child so that way touch events go through to whatever is underneath - child: IgnorePointer( - ignoring: _isPanelOpen, - child: widget.collapsed), - ), - ), + child: widget.footer ?? SizedBox()) + : Container(), + + // collapsed panel + Positioned( + top: widget.slideDirection == SlideDirection.UP + ? 0.0 + : null, + bottom: widget.slideDirection == SlideDirection.DOWN + ? 0.0 + : null, + width: MediaQuery.of(context).size.width - + (widget.margin != null + ? widget.margin!.horizontal + : 0) - + (widget.padding != null + ? widget.padding!.horizontal + : 0), + child: Container( + height: widget.minHeight, + child: widget.collapsed == null + ? Container() + : FadeTransition( + opacity: Tween(begin: 1.0, end: 0.0) + .animate(_ac), + + // if the panel is open ignore pointers (touch events) on the collapsed + // child so that way touch events go through to whatever is underneath + child: IgnorePointer( + ignoring: _isPanelOpen, + child: widget.collapsed), + ), + ), + ), + ], ), - ], - ), + ); + }, ), ), ], @@ -427,11 +434,11 @@ class _SlidingUpPanelState extends State double _getParallax() { if (widget.slideDirection == SlideDirection.UP) return -_ac.value * - (widget.maxHeight - widget.minHeight) * + (_maxHeight - widget.minHeight) * widget.parallaxOffset; else return _ac.value * - (widget.maxHeight - widget.minHeight) * + (_maxHeight - widget.minHeight) * widget.parallaxOffset; } @@ -470,9 +477,9 @@ class _SlidingUpPanelState extends State // only slide the panel if scrolling is not enabled if (!_scrollingEnabled) { if (widget.slideDirection == SlideDirection.UP) - _ac.value -= dy / (widget.maxHeight - widget.minHeight); + _ac.value -= dy / (_maxHeight - widget.minHeight); else - _ac.value += dy / (widget.maxHeight - widget.minHeight); + _ac.value += dy / (_maxHeight - widget.minHeight); } // if the panel is open and the user hasn't scrolled, we need to determine @@ -503,7 +510,7 @@ class _SlidingUpPanelState extends State //check if the velocity is sufficient to constitute fling to end double visualVelocity = - -v.pixelsPerSecond.dy / (widget.maxHeight - widget.minHeight); + -v.pixelsPerSecond.dy / (_maxHeight - widget.minHeight); // reverse visual velocity to account for slide direction if (widget.slideDirection == SlideDirection.DOWN) @@ -665,8 +672,20 @@ class PanelController { /// Opens the sliding panel fully /// (i.e. to the maxHeight) - Future open() { + Future open({double? maxHeight}) { assert(isAttached, "PanelController must be attached to a SlidingUpPanel"); + double defaultHeight = _panelState!.widget.maxHeight; + bool hasChanges = false; + if (maxHeight == null && defaultHeight != _panelState!._maxHeight) { + _panelState!._maxHeight = defaultHeight; + hasChanges = true; + } else if (maxHeight != null && maxHeight != _panelState!._maxHeight) { + _panelState!._maxHeight = maxHeight; + hasChanges = true; + } + if (hasChanges) { + _panelState!.sliderPartKey.currentState?.setState(() {}); + } return _panelState!._open(); }