From 4d35fbf19c0363146d4f517496bcde92d01c5f8e Mon Sep 17 00:00:00 2001 From: fujidaiti Date: Thu, 18 Apr 2024 19:19:34 +0900 Subject: [PATCH 1/9] Refactor SheetExtentFactory --- .../lib/src/draggable/draggable_sheet.dart | 13 +++++- package/lib/src/foundation/sheet_extent.dart | 40 +++++++++++-------- .../lib/src/navigation/navigation_sheet.dart | 9 ++++- .../scrollable/scrollable_sheet_extent.dart | 13 +++++- 4 files changed, 53 insertions(+), 22 deletions(-) diff --git a/package/lib/src/draggable/draggable_sheet.dart b/package/lib/src/draggable/draggable_sheet.dart index f6d2f6a0..c9ef43bb 100644 --- a/package/lib/src/draggable/draggable_sheet.dart +++ b/package/lib/src/draggable/draggable_sheet.dart @@ -72,13 +72,22 @@ class DraggableSheetExtentFactory extends SizedContentSheetExtentFactory { }); @override - SheetExtent create({required SheetContext context}) { + bool shouldRebuild(BuildContext context, SheetExtent oldExtent) { + return oldExtent is! DraggableSheetExtent || + oldExtent.minExtent != minExtent || + oldExtent.maxExtent != maxExtent || + oldExtent.initialExtent != initialExtent || + oldExtent.physics != physics; + } + + @override + SheetExtent build(BuildContext context, SheetContext sheetContext) { return DraggableSheetExtent( + context: sheetContext, initialExtent: initialExtent, minExtent: minExtent, maxExtent: maxExtent, physics: physics, - context: context, ); } } diff --git a/package/lib/src/foundation/sheet_extent.dart b/package/lib/src/foundation/sheet_extent.dart index 273c7faf..654addba 100644 --- a/package/lib/src/foundation/sheet_extent.dart +++ b/package/lib/src/foundation/sheet_extent.dart @@ -633,7 +633,8 @@ abstract class SheetContext { /// A factory that creates a [SheetExtent]. abstract class SheetExtentFactory { const SheetExtentFactory(); - SheetExtent create({required SheetContext context}); + SheetExtent build(BuildContext context, SheetContext sheetContext); + bool shouldRebuild(BuildContext context, SheetExtent oldExtent); } /// A widget that creates a [SheetExtent], manages its lifecycle, @@ -696,7 +697,7 @@ class SheetExtentScope extends StatefulWidget { class _SheetExtentScopeState extends State with TickerProviderStateMixin implements SheetContext { - late SheetExtent _extent; + SheetExtent? _extent; @override TickerProvider get vsync => this; @@ -704,35 +705,41 @@ class _SheetExtentScopeState extends State @override BuildContext? get notificationContext => mounted ? context : null; - @override - void initState() { - super.initState(); - _extent = widget.factory.create(context: this); - widget.controller?.attach(_extent); - widget.onExtentChanged?.call(_extent); - } - @override void dispose() { + assert(_extent != null); widget.onExtentChanged?.call(null); widget.controller?.detach(_extent); - _extent.dispose(); + _extent!.dispose(); super.dispose(); } + @override + void didChangeDependencies() { + super.didChangeDependencies(); + final oldExtent = _extent; + if (oldExtent == null || widget.factory.shouldRebuild(context, oldExtent)) { + final newExtent = widget.factory.build(context, this); + widget.controller?.attach(newExtent); + widget.onExtentChanged?.call(newExtent); + _extent = newExtent; + } + } + @override void didUpdateWidget(SheetExtentScope oldWidget) { super.didUpdateWidget(oldWidget); + assert(_extent != null); + final oldExtent = _extent!; - final oldExtent = _extent; - if (widget.factory != oldWidget.factory) { - _extent = widget.factory.create(context: this)..takeOver(_extent); + if (widget.factory.shouldRebuild(context, oldExtent)) { + _extent = widget.factory.build(context, this)..takeOver(oldExtent); widget.onExtentChanged?.call(_extent); } if (widget.controller != oldWidget.controller || _extent != oldExtent) { oldWidget.controller?.detach(oldExtent); - widget.controller?.attach(_extent); + widget.controller?.attach(_extent!); } if (oldExtent != _extent) { @@ -742,8 +749,9 @@ class _SheetExtentScopeState extends State @override Widget build(BuildContext context) { + assert(_extent != null); return _InheritedSheetExtent( - extent: _extent, + extent: _extent!, child: widget.child, ); } diff --git a/package/lib/src/navigation/navigation_sheet.dart b/package/lib/src/navigation/navigation_sheet.dart index c69f1a26..45d76712 100644 --- a/package/lib/src/navigation/navigation_sheet.dart +++ b/package/lib/src/navigation/navigation_sheet.dart @@ -143,9 +143,14 @@ class _NavigationSheetExtentFactory extends SheetExtentFactory { const _NavigationSheetExtentFactory(); @override - SheetExtent create({required SheetContext context}) { + bool shouldRebuild(BuildContext context, SheetExtent oldExtent) { + return oldExtent is! _NavigationSheetExtent; + } + + @override + SheetExtent build(BuildContext context, SheetContext sheetContext) { return _NavigationSheetExtent( - context: context, + context: sheetContext, // TODO: Use more appropriate physics. physics: const ClampingSheetPhysics(), ); diff --git a/package/lib/src/scrollable/scrollable_sheet_extent.dart b/package/lib/src/scrollable/scrollable_sheet_extent.dart index 322b07a8..cb600917 100644 --- a/package/lib/src/scrollable/scrollable_sheet_extent.dart +++ b/package/lib/src/scrollable/scrollable_sheet_extent.dart @@ -20,13 +20,22 @@ class ScrollableSheetExtentFactory extends SizedContentSheetExtentFactory { }); @override - SheetExtent create({required SheetContext context}) { + bool shouldRebuild(BuildContext context, SheetExtent oldExtent) { + return oldExtent is! ScrollableSheetExtent || + oldExtent.initialExtent != initialExtent || + oldExtent.minExtent != minExtent || + oldExtent.maxExtent != maxExtent || + oldExtent.physics != physics; + } + + @override + SheetExtent build(BuildContext context, SheetContext sheetContext) { return ScrollableSheetExtent( + context: sheetContext, initialExtent: initialExtent, minExtent: minExtent, maxExtent: maxExtent, physics: physics, - context: context, ); } } From e92b4d8824d21567e685184a2617baab6af3e48b Mon Sep 17 00:00:00 2001 From: fujidaiti Date: Thu, 18 Apr 2024 21:47:59 +0900 Subject: [PATCH 2/9] Remove sized_content_sheet --- .../lib/src/draggable/draggable_sheet.dart | 114 +++++-- .../src/foundation/sized_content_sheet.dart | 150 --------- .../lib/src/navigation/navigation_routes.dart | 310 +++++++++--------- .../lib/src/scrollable/scrollable_sheet.dart | 79 +++-- .../scrollable/scrollable_sheet_extent.dart | 32 +- 5 files changed, 315 insertions(+), 370 deletions(-) delete mode 100644 package/lib/src/foundation/sized_content_sheet.dart diff --git a/package/lib/src/draggable/draggable_sheet.dart b/package/lib/src/draggable/draggable_sheet.dart index c9ef43bb..5ebd06af 100644 --- a/package/lib/src/draggable/draggable_sheet.dart +++ b/package/lib/src/draggable/draggable_sheet.dart @@ -1,12 +1,11 @@ import 'package:flutter/widgets.dart'; import 'package:smooth_sheets/smooth_sheets.dart'; -import 'package:smooth_sheets/src/foundation/sized_content_sheet.dart'; /// A sheet that can be dragged. /// /// Note that this widget does not work with scrollable widgets. /// Instead, use [ScrollableSheet] for this usecase. -class DraggableSheet extends SizedContentSheet { +class DraggableSheet extends StatelessWidget { /// Creates a sheet that can be dragged. /// /// The maximum height will be equal to the [child]'s height. @@ -22,55 +21,95 @@ class DraggableSheet extends SizedContentSheet { const DraggableSheet({ super.key, this.hitTestBehavior = HitTestBehavior.translucent, - super.keyboardDismissBehavior, - super.initialExtent, - super.minExtent, - super.maxExtent, - super.physics, - super.controller, - required super.child, + this.keyboardDismissBehavior, + this.initialExtent = const Extent.proportional(1), + this.minExtent = const Extent.proportional(1), + this.maxExtent = const Extent.proportional(1), + this.physics = const StretchingSheetPhysics( + parent: SnappingSheetPhysics(), + ), + required this.child, + this.controller, }); + /// The strategy to dismiss the on-screen keyboard when the sheet is dragged. + final SheetKeyboardDismissBehavior? keyboardDismissBehavior; + + /// {@macro SizedContentSheetExtent.initialExtent} + final Extent initialExtent; + + /// {@macro SheetExtent.minExtent} + final Extent minExtent; + + /// {@macro SheetExtent.maxExtent} + final Extent maxExtent; + + /// {@macro SheetExtent.physics} + final SheetPhysics physics; + + /// An object that can be used to control and observe the sheet height. + final SheetController? controller; + + /// The content of the sheet. + final Widget child; + /// How to behave during hit testing. /// /// This value will be passed to the constructor of internal [SheetDraggable]. final HitTestBehavior hitTestBehavior; @override - SizedContentSheetState createState() { - return _DraggableSheetState(); - } -} + Widget build(BuildContext context) { + final theme = SheetTheme.maybeOf(context); + final keyboardDismissBehavior = + this.keyboardDismissBehavior ?? theme?.keyboardDismissBehavior; -class _DraggableSheetState extends SizedContentSheetState { - @override - SheetExtentFactory createExtentFactory() { - return DraggableSheetExtentFactory( - initialExtent: widget.initialExtent, - minExtent: widget.minExtent, - maxExtent: widget.maxExtent, - physics: widget.physics, + Widget result = SheetContainer( + controller: controller, + factory: DraggableSheetExtentFactory( + initialExtent: initialExtent, + minExtent: minExtent, + maxExtent: maxExtent, + physics: physics, + ), + child: SheetDraggable( + behavior: hitTestBehavior, + child: child, + ), ); - } - @override - Widget buildContent(BuildContext context) { - return SheetDraggable( - behavior: widget.hitTestBehavior, - child: super.buildContent(context), - ); + if (keyboardDismissBehavior != null) { + result = SheetKeyboardDismissible( + dismissBehavior: keyboardDismissBehavior, + child: result, + ); + } + + return result; } } /// Factory of [DraggableSheetExtent]. -class DraggableSheetExtentFactory extends SizedContentSheetExtentFactory { +class DraggableSheetExtentFactory extends SheetExtentFactory { const DraggableSheetExtentFactory({ - required super.initialExtent, - required super.minExtent, - required super.maxExtent, - required super.physics, + required this.initialExtent, + required this.minExtent, + required this.maxExtent, + required this.physics, }); + /// {@macro DraggableSheetExtent.initialExtent} + final Extent initialExtent; + + /// {@macro SheetExtent.minExtent} + final Extent minExtent; + + /// {@macro SheetExtent.maxExtent} + final Extent maxExtent; + + /// {@macro SheetExtent.physics} + final SheetPhysics physics; + @override bool shouldRebuild(BuildContext context, SheetExtent oldExtent) { return oldExtent is! DraggableSheetExtent || @@ -93,17 +132,22 @@ class DraggableSheetExtentFactory extends SizedContentSheetExtentFactory { } /// [SheetExtent] for a [DraggableSheet]. -class DraggableSheetExtent extends SizedContentSheetExtent { +class DraggableSheetExtent extends SheetExtent { DraggableSheetExtent({ required super.context, required super.physics, required super.minExtent, required super.maxExtent, - required super.initialExtent, + required this.initialExtent, }) { goIdle(); } + /// {@template DraggableSheetExtent.initialExtent} + /// The initial extent of the sheet when it is first shown. + /// {@endtemplate} + final Extent initialExtent; + @override void goIdle() { beginActivity(_IdleDraggableSheetActivity( diff --git a/package/lib/src/foundation/sized_content_sheet.dart b/package/lib/src/foundation/sized_content_sheet.dart deleted file mode 100644 index a9a931b3..00000000 --- a/package/lib/src/foundation/sized_content_sheet.dart +++ /dev/null @@ -1,150 +0,0 @@ -import 'package:flutter/widgets.dart'; -import 'package:smooth_sheets/src/foundation/framework.dart'; -import 'package:smooth_sheets/src/foundation/keyboard_dismissible.dart'; -import 'package:smooth_sheets/src/foundation/sheet_controller.dart'; -import 'package:smooth_sheets/src/foundation/sheet_extent.dart'; -import 'package:smooth_sheets/src/foundation/sheet_physics.dart'; -import 'package:smooth_sheets/src/foundation/theme.dart'; - -/// [SheetExtent] for a [SizedContentSheet]. -abstract class SizedContentSheetExtent extends SheetExtent { - /// Creates a [SheetExtent] for [SizedContentSheet]s. - SizedContentSheetExtent({ - required super.context, - required super.physics, - required super.minExtent, - required super.maxExtent, - required this.initialExtent, - }); - - /// {@template SizedContentSheetExtent.initialExtent} - /// The initial extent of the sheet when it is first shown. - /// {@endtemplate} - final Extent initialExtent; -} - -/// Factory of [SizedContentSheetExtent]. -abstract class SizedContentSheetExtentFactory extends SheetExtentFactory { - /// Creates a factory of [SizedContentSheetExtent]. - const SizedContentSheetExtentFactory({ - required this.initialExtent, - required this.minExtent, - required this.maxExtent, - required this.physics, - }); - - /// {@macro SizedContentSheetExtent.initialExtent} - final Extent initialExtent; - - /// {@macro SheetExtent.minExtent} - final Extent minExtent; - - /// {@macro SheetExtent.maxExtent} - final Extent maxExtent; - - /// {@macro SheetExtent.physics} - final SheetPhysics physics; -} - -/// A base class for sheets that have an explicit initial extent. -abstract class SizedContentSheet extends StatefulWidget { - /// Creates a sheet with an explicit initial extent. - const SizedContentSheet({ - super.key, - this.keyboardDismissBehavior, - this.initialExtent = const Extent.proportional(1), - this.minExtent = const Extent.proportional(1), - this.maxExtent = const Extent.proportional(1), - this.physics = const StretchingSheetPhysics( - parent: SnappingSheetPhysics(), - ), - this.controller, - required this.child, - }); - - /// The strategy to dismiss the on-screen keyboard when the sheet is dragged. - final SheetKeyboardDismissBehavior? keyboardDismissBehavior; - - /// {@macro SizedContentSheetExtent.initialExtent} - final Extent initialExtent; - - /// {@macro SheetExtent.minExtent} - final Extent minExtent; - - /// {@macro SheetExtent.maxExtent} - final Extent maxExtent; - - /// {@macro SheetExtent.physics} - final SheetPhysics physics; - - /// An object that can be used to control and observe the sheet height. - final SheetController? controller; - - /// The content of the sheet. - final Widget child; - - @override - SizedContentSheetState createState(); -} - -/// State for a [SizedContentSheet]. -abstract class SizedContentSheetState - extends State { - /// The factory of [SheetExtent] which drives this sheet. - /// - /// This is first created in [initState] and updated in [didUpdateWidget] - /// when the [SizedContentSheet] properties change. - SheetExtentFactory get factory => _factory; - late SheetExtentFactory _factory; - - /// Creates the factory of [SheetExtent] for this sheet. - SheetExtentFactory createExtentFactory(); - - @override - void initState() { - super.initState(); - _factory = createExtentFactory(); - } - - @override - void didUpdateWidget(T oldWidget) { - super.didUpdateWidget(oldWidget); - if (widget.initialExtent != oldWidget.initialExtent || - widget.minExtent != oldWidget.minExtent || - widget.maxExtent != oldWidget.maxExtent || - widget.physics != oldWidget.physics) { - _factory = createExtentFactory(); - } - } - - @override - Widget build(BuildContext context) { - final theme = SheetTheme.maybeOf(context); - final keyboardDismissBehavior = - widget.keyboardDismissBehavior ?? theme?.keyboardDismissBehavior; - - Widget result = SheetContainer( - factory: factory, - controller: widget.controller, - child: buildContent(context), - ); - - if (keyboardDismissBehavior != null) { - result = SheetKeyboardDismissible( - dismissBehavior: keyboardDismissBehavior, - child: result, - ); - } - - return result; - } - - /// Builds the content of the sheet. - /// - /// Consider overriding this method if you want to - /// insert widgets above the [SizedContentSheet.child]. - @protected - Widget buildContent(BuildContext context) { - return widget.child; - } -} diff --git a/package/lib/src/navigation/navigation_routes.dart b/package/lib/src/navigation/navigation_routes.dart index 0d5d55f4..19faf509 100644 --- a/package/lib/src/navigation/navigation_routes.dart +++ b/package/lib/src/navigation/navigation_routes.dart @@ -1,17 +1,10 @@ import 'package:flutter/material.dart'; -import 'package:smooth_sheets/src/draggable/draggable_sheet.dart'; -import 'package:smooth_sheets/src/draggable/sheet_draggable.dart'; -import 'package:smooth_sheets/src/foundation/sheet_extent.dart'; -import 'package:smooth_sheets/src/foundation/sheet_physics.dart'; -import 'package:smooth_sheets/src/foundation/sized_content_sheet.dart'; -import 'package:smooth_sheets/src/navigation/navigation_route.dart'; -import 'package:smooth_sheets/src/navigation/navigation_sheet.dart'; +import 'package:smooth_sheets/smooth_sheets.dart'; import 'package:smooth_sheets/src/scrollable/scrollable_sheet.dart'; -import 'package:smooth_sheets/src/scrollable/scrollable_sheet_extent.dart'; -abstract class SingleChildNavigationSheetRoute - extends NavigationSheetRoute with NavigationSheetRouteMixin { - SingleChildNavigationSheetRoute({ +class ScrollableNavigationSheetRoute extends NavigationSheetRoute + with NavigationSheetRouteMixin { + ScrollableNavigationSheetRoute({ super.settings, this.maintainState = true, this.transitionDuration = const Duration(milliseconds: 300), @@ -21,7 +14,68 @@ abstract class SingleChildNavigationSheetRoute this.physics = const StretchingSheetPhysics(parent: SnappingSheetPhysics()), this.transitionsBuilder, required this.builder, - }); + }) : pageExtentFactory = ScrollableSheetExtentFactory( + initialExtent: initialExtent, + minExtent: minExtent, + maxExtent: maxExtent, + physics: physics, + ); + + @override + final ScrollableSheetExtentFactory pageExtentFactory; + + final Extent initialExtent; + final Extent minExtent; + final Extent maxExtent; + final SheetPhysics physics; + + @override + final bool maintainState; + + @override + final Duration transitionDuration; + + final RouteTransitionsBuilder? transitionsBuilder; + + final WidgetBuilder builder; + + @override + Widget buildContent(BuildContext context) { + return PrimarySheetContentScrollController( + child: builder(context), + ); + } + + @override + Widget buildTransitions( + BuildContext context, + Animation animation, + Animation secondaryAnimation, + Widget child, + ) { + final builder = transitionsBuilder ?? super.buildTransitions; + return builder(context, animation, secondaryAnimation, child); + } +} + +class DraggableNavigationSheetRoute extends NavigationSheetRoute + with NavigationSheetRouteMixin { + DraggableNavigationSheetRoute({ + super.settings, + this.maintainState = true, + this.transitionDuration = const Duration(milliseconds: 300), + this.initialExtent = const Extent.proportional(1), + this.minExtent = const Extent.proportional(1), + this.maxExtent = const Extent.proportional(1), + this.physics = const StretchingSheetPhysics(parent: SnappingSheetPhysics()), + this.transitionsBuilder, + required this.builder, + }) : pageExtentFactory = DraggableSheetExtentFactory( + initialExtent: initialExtent, + minExtent: minExtent, + maxExtent: maxExtent, + physics: physics, + ); final Extent initialExtent; final Extent minExtent; @@ -39,7 +93,14 @@ abstract class SingleChildNavigationSheetRoute final WidgetBuilder builder; @override - SizedContentSheetExtentFactory get pageExtentFactory; + final DraggableSheetExtentFactory pageExtentFactory; + + @override + Widget buildContent(BuildContext context) { + return SheetDraggable( + child: builder(context), + ); + } @override Widget buildTransitions( @@ -53,8 +114,8 @@ abstract class SingleChildNavigationSheetRoute } } -abstract class SingleChildNavigationSheetPage extends Page { - const SingleChildNavigationSheetPage({ +class ScrollableNavigationSheetPage extends Page { + const ScrollableNavigationSheetPage({ super.key, super.name, super.arguments, @@ -84,16 +145,21 @@ abstract class SingleChildNavigationSheetPage extends Page { /// The content to be shown in the [Route] created by this page. final Widget child; + + @override + Route createRoute(BuildContext context) { + return _PageBasedScrollableNavigationSheetRoute(page: this); + } } -abstract class PageBasedSingleChildNavigationSheetRoute> +class _PageBasedScrollableNavigationSheetRoute extends NavigationSheetRoute with NavigationSheetRouteMixin { - PageBasedSingleChildNavigationSheetRoute({ - required P page, + _PageBasedScrollableNavigationSheetRoute({ + required ScrollableNavigationSheetPage page, }) : super(settings: page); - P get page => settings as P; + ScrollableNavigationSheetPage get page => + settings as ScrollableNavigationSheetPage; @override bool get maintainState => page.maintainState; @@ -102,24 +168,23 @@ abstract class PageBasedSingleChildNavigationSheetRoute page.transitionDuration; @override - SizedContentSheetExtentFactory get pageExtentFactory => _pageExtentFactory!; - SizedContentSheetExtentFactory? _pageExtentFactory; + ScrollableSheetExtentFactory get pageExtentFactory => _pageExtentFactory!; + ScrollableSheetExtentFactory? _pageExtentFactory; @override void changedInternalState() { super.changedInternalState(); - if (shouldUpdatePageExtentFactory()) { - _pageExtentFactory = createPageExtentFactory(); - } - } - - SizedContentSheetExtentFactory createPageExtentFactory(); - - bool shouldUpdatePageExtentFactory() { - return page.initialExtent != _pageExtentFactory?.initialExtent || + if (page.initialExtent != _pageExtentFactory?.initialExtent || page.minExtent != _pageExtentFactory?.minExtent || page.maxExtent != _pageExtentFactory?.maxExtent || - page.physics != _pageExtentFactory?.physics; + page.physics != _pageExtentFactory?.physics) { + _pageExtentFactory = ScrollableSheetExtentFactory( + initialExtent: page.initialExtent, + minExtent: page.minExtent, + maxExtent: page.maxExtent, + physics: page.physics, + ); + } } @override @@ -132,156 +197,101 @@ abstract class PageBasedSingleChildNavigationSheetRoute - extends SingleChildNavigationSheetRoute { - ScrollableNavigationSheetRoute({ - required super.builder, - super.settings, - super.maintainState, - super.transitionDuration, - super.initialExtent, - super.minExtent, - super.maxExtent, - super.physics, - super.transitionsBuilder, - }) : pageExtentFactory = ScrollableSheetExtentFactory( - initialExtent: initialExtent, - minExtent: minExtent, - maxExtent: maxExtent, - physics: physics, - ); - - @override - final ScrollableSheetExtentFactory pageExtentFactory; @override Widget buildContent(BuildContext context) { return PrimarySheetContentScrollController( - child: builder(context), - ); - } -} - -class DraggableNavigationSheetRoute - extends SingleChildNavigationSheetRoute { - DraggableNavigationSheetRoute({ - required super.builder, - super.settings, - super.maintainState, - super.transitionDuration, - super.initialExtent, - super.minExtent, - super.maxExtent, - super.physics, - super.transitionsBuilder, - }) : pageExtentFactory = DraggableSheetExtentFactory( - initialExtent: initialExtent, - minExtent: minExtent, - maxExtent: maxExtent, - physics: physics, - ); - - @override - final DraggableSheetExtentFactory pageExtentFactory; - - @override - Widget buildContent(BuildContext context) { - return SheetDraggable( - child: builder(context), + child: page.child, ); } } -class ScrollableNavigationSheetPage - extends SingleChildNavigationSheetPage { - const ScrollableNavigationSheetPage({ +class DraggableNavigationSheetPage extends Page { + const DraggableNavigationSheetPage({ super.key, super.name, super.arguments, super.restorationId, - super.maintainState, - super.transitionDuration, - super.initialExtent, - super.minExtent, - super.maxExtent, - super.physics, - super.transitionsBuilder, - required super.child, + this.maintainState = true, + this.transitionDuration = const Duration(milliseconds: 300), + this.initialExtent = const Extent.proportional(1), + this.minExtent = const Extent.proportional(1), + this.maxExtent = const Extent.proportional(1), + this.physics = const StretchingSheetPhysics(parent: SnappingSheetPhysics()), + this.transitionsBuilder, + required this.child, }); + /// {@macro flutter.widgets.ModalRoute.maintainState} + final bool maintainState; + + final Duration transitionDuration; + + final Extent initialExtent; + final Extent minExtent; + final Extent maxExtent; + + final SheetPhysics physics; + + final RouteTransitionsBuilder? transitionsBuilder; + + /// The content to be shown in the [Route] created by this page. + final Widget child; + @override Route createRoute(BuildContext context) { - return _PageBasedScrollableNavigationSheetRoute(page: this); + return _PageBasedDraggableNavigationSheetRoute(page: this); } } -class _PageBasedScrollableNavigationSheetRoute - extends PageBasedSingleChildNavigationSheetRoute> { - _PageBasedScrollableNavigationSheetRoute({required super.page}); +class _PageBasedDraggableNavigationSheetRoute extends NavigationSheetRoute + with NavigationSheetRouteMixin { + _PageBasedDraggableNavigationSheetRoute({ + required DraggableNavigationSheetPage page, + }) : super(settings: page); + + DraggableNavigationSheetPage get page => + settings as DraggableNavigationSheetPage; @override - SizedContentSheetExtentFactory createPageExtentFactory() { - return ScrollableSheetExtentFactory( - initialExtent: page.initialExtent, - minExtent: page.minExtent, - maxExtent: page.maxExtent, - physics: page.physics, - ); - } + bool get maintainState => page.maintainState; @override - Widget buildContent(BuildContext context) { - return PrimarySheetContentScrollController( - child: page.child, - ); - } -} + Duration get transitionDuration => page.transitionDuration; -class DraggableNavigationSheetPage - extends SingleChildNavigationSheetPage { - const DraggableNavigationSheetPage({ - super.key, - super.name, - super.arguments, - super.restorationId, - super.maintainState, - super.transitionDuration, - super.initialExtent, - super.minExtent, - super.maxExtent, - super.physics, - super.transitionsBuilder, - required super.child, - }); + @override + DraggableSheetExtentFactory get pageExtentFactory => _pageExtentFactory!; + DraggableSheetExtentFactory? _pageExtentFactory; @override - Route createRoute(BuildContext context) { - return _PageBasedDraggableNavigationSheetRoute(page: this); + void changedInternalState() { + super.changedInternalState(); + if (page.initialExtent != _pageExtentFactory?.initialExtent || + page.minExtent != _pageExtentFactory?.minExtent || + page.maxExtent != _pageExtentFactory?.maxExtent || + page.physics != _pageExtentFactory?.physics) { + _pageExtentFactory = DraggableSheetExtentFactory( + initialExtent: page.initialExtent, + minExtent: page.minExtent, + maxExtent: page.maxExtent, + physics: page.physics, + ); + } } -} - -class _PageBasedDraggableNavigationSheetRoute - extends PageBasedSingleChildNavigationSheetRoute> { - _PageBasedDraggableNavigationSheetRoute({required super.page}); @override - SizedContentSheetExtentFactory createPageExtentFactory() { - return DraggableSheetExtentFactory( - initialExtent: page.initialExtent, - minExtent: page.minExtent, - maxExtent: page.maxExtent, - physics: page.physics, - ); + Widget buildTransitions( + BuildContext context, + Animation animation, + Animation secondaryAnimation, + Widget child, + ) { + final builder = page.transitionsBuilder ?? super.buildTransitions; + return builder(context, animation, secondaryAnimation, child); } @override Widget buildContent(BuildContext context) { - return SheetDraggable( - child: page.child, - ); + return SheetDraggable(child: page.child); } } diff --git a/package/lib/src/scrollable/scrollable_sheet.dart b/package/lib/src/scrollable/scrollable_sheet.dart index 683b8df6..f26ba6f2 100644 --- a/package/lib/src/scrollable/scrollable_sheet.dart +++ b/package/lib/src/scrollable/scrollable_sheet.dart @@ -2,43 +2,68 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:meta/meta.dart'; import 'package:smooth_sheets/smooth_sheets.dart'; -import 'package:smooth_sheets/src/foundation/sized_content_sheet.dart'; import 'package:smooth_sheets/src/scrollable/scrollable_sheet_extent.dart'; -class ScrollableSheet extends SizedContentSheet { +class ScrollableSheet extends StatelessWidget { const ScrollableSheet({ super.key, - super.keyboardDismissBehavior, - super.initialExtent, - super.minExtent, - super.maxExtent, - super.physics, - super.controller, - required super.child, + this.keyboardDismissBehavior, + this.initialExtent = const Extent.proportional(1), + this.minExtent = const Extent.proportional(1), + this.maxExtent = const Extent.proportional(1), + this.physics = const StretchingSheetPhysics( + parent: SnappingSheetPhysics(), + ), + this.controller, + required this.child, }); - @override - SizedContentSheetState createState() { - return _ScrollableSheetState(); - } -} + /// The strategy to dismiss the on-screen keyboard when the sheet is dragged. + final SheetKeyboardDismissBehavior? keyboardDismissBehavior; -class _ScrollableSheetState extends SizedContentSheetState { - @override - SheetExtentFactory createExtentFactory() { - return ScrollableSheetExtentFactory( - initialExtent: widget.initialExtent, - minExtent: widget.minExtent, - maxExtent: widget.maxExtent, - physics: widget.physics, - ); - } + /// {@macro ScrollableSheetExtent.initialExtent} + final Extent initialExtent; + + /// {@macro SheetExtent.minExtent} + final Extent minExtent; + + /// {@macro SheetExtent.maxExtent} + final Extent maxExtent; + + /// {@macro SheetExtent.physics} + final SheetPhysics physics; + + /// An object that can be used to control and observe the sheet height. + final SheetController? controller; + + /// The content of the sheet. + final Widget child; @override - Widget buildContent(BuildContext context) { - return PrimarySheetContentScrollController( - child: super.buildContent(context), + Widget build(BuildContext context) { + final theme = SheetTheme.maybeOf(context); + final keyboardDismissBehavior = + this.keyboardDismissBehavior ?? theme?.keyboardDismissBehavior; + + Widget result = SheetContainer( + controller: controller, + factory: ScrollableSheetExtentFactory( + initialExtent: initialExtent, + minExtent: minExtent, + maxExtent: maxExtent, + physics: physics, + ), + child: PrimarySheetContentScrollController(child: child), ); + + if (keyboardDismissBehavior != null) { + result = SheetKeyboardDismissible( + dismissBehavior: keyboardDismissBehavior, + child: result, + ); + } + + return result; } } diff --git a/package/lib/src/scrollable/scrollable_sheet_extent.dart b/package/lib/src/scrollable/scrollable_sheet_extent.dart index cb600917..c84972d4 100644 --- a/package/lib/src/scrollable/scrollable_sheet_extent.dart +++ b/package/lib/src/scrollable/scrollable_sheet_extent.dart @@ -6,19 +6,30 @@ import 'package:smooth_sheets/src/foundation/sheet_activity.dart'; import 'package:smooth_sheets/src/foundation/sheet_extent.dart'; import 'package:smooth_sheets/src/foundation/sheet_physics.dart'; import 'package:smooth_sheets/src/foundation/sheet_status.dart'; -import 'package:smooth_sheets/src/foundation/sized_content_sheet.dart'; import 'package:smooth_sheets/src/internal/double_utils.dart'; import 'package:smooth_sheets/src/scrollable/delegatable_scroll_position.dart'; import 'package:smooth_sheets/src/scrollable/scrollable_sheet_physics.dart'; -class ScrollableSheetExtentFactory extends SizedContentSheetExtentFactory { +class ScrollableSheetExtentFactory extends SheetExtentFactory { const ScrollableSheetExtentFactory({ - required super.initialExtent, - required super.minExtent, - required super.maxExtent, - required super.physics, + required this.initialExtent, + required this.minExtent, + required this.maxExtent, + required this.physics, }); + /// {@macro ScrollableSheetExtent.initialExtent} + final Extent initialExtent; + + /// {@macro SheetExtent.minExtent} + final Extent minExtent; + + /// {@macro SheetExtent.maxExtent} + final Extent maxExtent; + + /// {@macro SheetExtent.physics} + final SheetPhysics physics; + @override bool shouldRebuild(BuildContext context, SheetExtent oldExtent) { return oldExtent is! ScrollableSheetExtent || @@ -40,9 +51,9 @@ class ScrollableSheetExtentFactory extends SizedContentSheetExtentFactory { } } -class ScrollableSheetExtent extends SizedContentSheetExtent { +class ScrollableSheetExtent extends SheetExtent { ScrollableSheetExtent({ - required super.initialExtent, + required this.initialExtent, required super.minExtent, required super.maxExtent, required super.context, @@ -55,6 +66,11 @@ class ScrollableSheetExtent extends SizedContentSheetExtent { goIdle(); } + /// {@template ScrollableSheetExtent.initialExtent} + /// The initial extent of the sheet when it is first shown. + /// {@endtemplate} + final Extent initialExtent; + ScrollPositionDelegate? get _scrollPositionDelegate { return switch (activity) { final ScrollPositionDelegate delegate => delegate, From bc8e0bd0d006c611148c93e237561f5dcb94b500 Mon Sep 17 00:00:00 2001 From: fujidaiti Date: Thu, 18 Apr 2024 22:05:33 +0900 Subject: [PATCH 3/9] Rename SheetExtentFactory to SheetExtentConfig --- .../lib/src/draggable/draggable_sheet.dart | 8 ++--- package/lib/src/foundation/framework.dart | 6 ++-- package/lib/src/foundation/sheet_extent.dart | 26 +++++++------- .../lib/src/navigation/navigation_route.dart | 4 +-- .../lib/src/navigation/navigation_routes.dart | 36 +++++++++---------- .../lib/src/navigation/navigation_sheet.dart | 6 ++-- .../lib/src/scrollable/scrollable_sheet.dart | 2 +- .../scrollable/scrollable_sheet_extent.dart | 4 +-- 8 files changed, 46 insertions(+), 46 deletions(-) diff --git a/package/lib/src/draggable/draggable_sheet.dart b/package/lib/src/draggable/draggable_sheet.dart index 5ebd06af..65079963 100644 --- a/package/lib/src/draggable/draggable_sheet.dart +++ b/package/lib/src/draggable/draggable_sheet.dart @@ -66,7 +66,7 @@ class DraggableSheet extends StatelessWidget { Widget result = SheetContainer( controller: controller, - factory: DraggableSheetExtentFactory( + config: DraggableSheetExtentConfig( initialExtent: initialExtent, minExtent: minExtent, maxExtent: maxExtent, @@ -89,9 +89,9 @@ class DraggableSheet extends StatelessWidget { } } -/// Factory of [DraggableSheetExtent]. -class DraggableSheetExtentFactory extends SheetExtentFactory { - const DraggableSheetExtentFactory({ +/// A configuration of a [DraggableSheetExtent]. +class DraggableSheetExtentConfig extends SheetExtentConfig { + const DraggableSheetExtentConfig({ required this.initialExtent, required this.minExtent, required this.maxExtent, diff --git a/package/lib/src/foundation/framework.dart b/package/lib/src/foundation/framework.dart index 926a523b..b95e5019 100644 --- a/package/lib/src/foundation/framework.dart +++ b/package/lib/src/foundation/framework.dart @@ -8,19 +8,19 @@ class SheetContainer extends StatelessWidget { super.key, this.controller, this.onExtentChanged, - required this.factory, + required this.config, required this.child, }); final SheetController? controller; final ValueChanged? onExtentChanged; - final SheetExtentFactory factory; + final SheetExtentConfig config; final Widget child; @override Widget build(BuildContext context) { return SheetExtentScope( - factory: factory, + config: config, controller: controller ?? SheetControllerScope.maybeOf(context), onExtentChanged: onExtentChanged, child: Builder( diff --git a/package/lib/src/foundation/sheet_extent.dart b/package/lib/src/foundation/sheet_extent.dart index 654addba..6659788e 100644 --- a/package/lib/src/foundation/sheet_extent.dart +++ b/package/lib/src/foundation/sheet_extent.dart @@ -630,9 +630,9 @@ abstract class SheetContext { BuildContext? get notificationContext; } -/// A factory that creates a [SheetExtent]. -abstract class SheetExtentFactory { - const SheetExtentFactory(); +/// Configuration of a [SheetExtent]. +abstract class SheetExtentConfig { + const SheetExtentConfig(); SheetExtent build(BuildContext context, SheetContext sheetContext); bool shouldRebuild(BuildContext context, SheetExtent oldExtent); } @@ -643,7 +643,7 @@ class SheetExtentScope extends StatefulWidget { /// Creates a widget that hosts a [SheetExtent]. const SheetExtentScope({ super.key, - required this.factory, + required this.config, this.controller, this.onExtentChanged, required this.child, @@ -652,11 +652,11 @@ class SheetExtentScope extends StatefulWidget { /// The [SheetController] that will be attached to the created [SheetExtent]. final SheetController? controller; - /// The factory that creates the [SheetExtent]. + /// The configuration of the [SheetExtent] manged by this widget. /// /// The [SheetExtentScope] will recreate the [SheetExtent] whenever - /// it is rebuilt with a [factory] that is not identical to the previous one. - final SheetExtentFactory factory; + /// it is rebuilt with a [config] that is not identical to the previous one. + final SheetExtentConfig config; /// Called whenever the [SheetExtent] changes. /// @@ -676,7 +676,7 @@ class SheetExtentScope extends StatefulWidget { /// that encloses the given context, if any. /// /// Use of this method will cause the given context to rebuild any time - /// that the [factory] property of the ancestor [SheetExtentScope] changes. + /// that the [config] property of the ancestor [SheetExtentScope] changes. // TODO: Add 'useRoot' option static SheetExtent? maybeOf(BuildContext context) { return context @@ -688,7 +688,7 @@ class SheetExtentScope extends StatefulWidget { /// that encloses the given context. /// /// Use of this method will cause the given context to rebuild any time - /// that the [factory] property of the ancestor [SheetExtentScope] changes. + /// that the [config] property of the ancestor [SheetExtentScope] changes. static SheetExtent of(BuildContext context) { return maybeOf(context)!; } @@ -718,8 +718,8 @@ class _SheetExtentScopeState extends State void didChangeDependencies() { super.didChangeDependencies(); final oldExtent = _extent; - if (oldExtent == null || widget.factory.shouldRebuild(context, oldExtent)) { - final newExtent = widget.factory.build(context, this); + if (oldExtent == null || widget.config.shouldRebuild(context, oldExtent)) { + final newExtent = widget.config.build(context, this); widget.controller?.attach(newExtent); widget.onExtentChanged?.call(newExtent); _extent = newExtent; @@ -732,8 +732,8 @@ class _SheetExtentScopeState extends State assert(_extent != null); final oldExtent = _extent!; - if (widget.factory.shouldRebuild(context, oldExtent)) { - _extent = widget.factory.build(context, this)..takeOver(oldExtent); + if (widget.config.shouldRebuild(context, oldExtent)) { + _extent = widget.config.build(context, this)..takeOver(oldExtent); widget.onExtentChanged?.call(_extent); } diff --git a/package/lib/src/navigation/navigation_route.dart b/package/lib/src/navigation/navigation_route.dart index 44daf37a..e4ef3291 100644 --- a/package/lib/src/navigation/navigation_route.dart +++ b/package/lib/src/navigation/navigation_route.dart @@ -6,7 +6,7 @@ import 'package:smooth_sheets/src/foundation/sheet_status.dart'; import 'package:smooth_sheets/src/navigation/navigation_sheet.dart'; mixin NavigationSheetRouteMixin on NavigationSheetRoute { - SheetExtentFactory get pageExtentFactory; + SheetExtentConfig get pageExtentConfig; @override NavigationSheetExtentDelegate get pageExtent => _pageExtent; @@ -39,7 +39,7 @@ mixin NavigationSheetRouteMixin on NavigationSheetRoute { Animation secondaryAnimation, ) { return SheetExtentScope( - factory: pageExtentFactory, + config: pageExtentConfig, onExtentChanged: (extent) => _pageExtent.source = extent, child: SheetContentViewport( child: buildContent(context), diff --git a/package/lib/src/navigation/navigation_routes.dart b/package/lib/src/navigation/navigation_routes.dart index 19faf509..d66bc0a5 100644 --- a/package/lib/src/navigation/navigation_routes.dart +++ b/package/lib/src/navigation/navigation_routes.dart @@ -14,7 +14,7 @@ class ScrollableNavigationSheetRoute extends NavigationSheetRoute this.physics = const StretchingSheetPhysics(parent: SnappingSheetPhysics()), this.transitionsBuilder, required this.builder, - }) : pageExtentFactory = ScrollableSheetExtentFactory( + }) : pageExtentConfig = ScrollableSheetExtentConfig( initialExtent: initialExtent, minExtent: minExtent, maxExtent: maxExtent, @@ -22,7 +22,7 @@ class ScrollableNavigationSheetRoute extends NavigationSheetRoute ); @override - final ScrollableSheetExtentFactory pageExtentFactory; + final ScrollableSheetExtentConfig pageExtentConfig; final Extent initialExtent; final Extent minExtent; @@ -70,7 +70,7 @@ class DraggableNavigationSheetRoute extends NavigationSheetRoute this.physics = const StretchingSheetPhysics(parent: SnappingSheetPhysics()), this.transitionsBuilder, required this.builder, - }) : pageExtentFactory = DraggableSheetExtentFactory( + }) : pageExtentConfig = DraggableSheetExtentConfig( initialExtent: initialExtent, minExtent: minExtent, maxExtent: maxExtent, @@ -93,7 +93,7 @@ class DraggableNavigationSheetRoute extends NavigationSheetRoute final WidgetBuilder builder; @override - final DraggableSheetExtentFactory pageExtentFactory; + final DraggableSheetExtentConfig pageExtentConfig; @override Widget buildContent(BuildContext context) { @@ -168,17 +168,17 @@ class _PageBasedScrollableNavigationSheetRoute Duration get transitionDuration => page.transitionDuration; @override - ScrollableSheetExtentFactory get pageExtentFactory => _pageExtentFactory!; - ScrollableSheetExtentFactory? _pageExtentFactory; + ScrollableSheetExtentConfig get pageExtentConfig => _pageExtentConfig!; + ScrollableSheetExtentConfig? _pageExtentConfig; @override void changedInternalState() { super.changedInternalState(); - if (page.initialExtent != _pageExtentFactory?.initialExtent || - page.minExtent != _pageExtentFactory?.minExtent || - page.maxExtent != _pageExtentFactory?.maxExtent || - page.physics != _pageExtentFactory?.physics) { - _pageExtentFactory = ScrollableSheetExtentFactory( + if (page.initialExtent != _pageExtentConfig?.initialExtent || + page.minExtent != _pageExtentConfig?.minExtent || + page.maxExtent != _pageExtentConfig?.maxExtent || + page.physics != _pageExtentConfig?.physics) { + _pageExtentConfig = ScrollableSheetExtentConfig( initialExtent: page.initialExtent, minExtent: page.minExtent, maxExtent: page.maxExtent, @@ -260,17 +260,17 @@ class _PageBasedDraggableNavigationSheetRoute extends NavigationSheetRoute Duration get transitionDuration => page.transitionDuration; @override - DraggableSheetExtentFactory get pageExtentFactory => _pageExtentFactory!; - DraggableSheetExtentFactory? _pageExtentFactory; + DraggableSheetExtentConfig get pageExtentConfig => _pageExtentConfig!; + DraggableSheetExtentConfig? _pageExtentConfig; @override void changedInternalState() { super.changedInternalState(); - if (page.initialExtent != _pageExtentFactory?.initialExtent || - page.minExtent != _pageExtentFactory?.minExtent || - page.maxExtent != _pageExtentFactory?.maxExtent || - page.physics != _pageExtentFactory?.physics) { - _pageExtentFactory = DraggableSheetExtentFactory( + if (page.initialExtent != _pageExtentConfig?.initialExtent || + page.minExtent != _pageExtentConfig?.minExtent || + page.maxExtent != _pageExtentConfig?.maxExtent || + page.physics != _pageExtentConfig?.physics) { + _pageExtentConfig = DraggableSheetExtentConfig( initialExtent: page.initialExtent, minExtent: page.minExtent, maxExtent: page.maxExtent, diff --git a/package/lib/src/navigation/navigation_sheet.dart b/package/lib/src/navigation/navigation_sheet.dart index 45d76712..45affe3b 100644 --- a/package/lib/src/navigation/navigation_sheet.dart +++ b/package/lib/src/navigation/navigation_sheet.dart @@ -101,7 +101,7 @@ class NavigationSheetState extends State widget.keyboardDismissBehavior ?? theme?.keyboardDismissBehavior; Widget result = SheetContainer( - factory: const _NavigationSheetExtentFactory(), + config: const _NavigationSheetExtentConfig(), controller: widget.controller, onExtentChanged: (extent) { _extent = extent as _NavigationSheetExtent?; @@ -139,8 +139,8 @@ abstract class NavigationSheetExtentDelegate implements Listenable { void beginActivity(SheetActivity activity); } -class _NavigationSheetExtentFactory extends SheetExtentFactory { - const _NavigationSheetExtentFactory(); +class _NavigationSheetExtentConfig extends SheetExtentConfig { + const _NavigationSheetExtentConfig(); @override bool shouldRebuild(BuildContext context, SheetExtent oldExtent) { diff --git a/package/lib/src/scrollable/scrollable_sheet.dart b/package/lib/src/scrollable/scrollable_sheet.dart index f26ba6f2..947f1982 100644 --- a/package/lib/src/scrollable/scrollable_sheet.dart +++ b/package/lib/src/scrollable/scrollable_sheet.dart @@ -47,7 +47,7 @@ class ScrollableSheet extends StatelessWidget { Widget result = SheetContainer( controller: controller, - factory: ScrollableSheetExtentFactory( + config: ScrollableSheetExtentConfig( initialExtent: initialExtent, minExtent: minExtent, maxExtent: maxExtent, diff --git a/package/lib/src/scrollable/scrollable_sheet_extent.dart b/package/lib/src/scrollable/scrollable_sheet_extent.dart index c84972d4..fa1d113c 100644 --- a/package/lib/src/scrollable/scrollable_sheet_extent.dart +++ b/package/lib/src/scrollable/scrollable_sheet_extent.dart @@ -10,8 +10,8 @@ import 'package:smooth_sheets/src/internal/double_utils.dart'; import 'package:smooth_sheets/src/scrollable/delegatable_scroll_position.dart'; import 'package:smooth_sheets/src/scrollable/scrollable_sheet_physics.dart'; -class ScrollableSheetExtentFactory extends SheetExtentFactory { - const ScrollableSheetExtentFactory({ +class ScrollableSheetExtentConfig extends SheetExtentConfig { + const ScrollableSheetExtentConfig({ required this.initialExtent, required this.minExtent, required this.maxExtent, From c96305a98468fed9ae53e79cbefe135ba64a3cf8 Mon Sep 17 00:00:00 2001 From: fujidaiti Date: Thu, 18 Apr 2024 22:07:42 +0900 Subject: [PATCH 4/9] Rename sheet_physics to physics --- package/lib/smooth_sheets.dart | 2 +- package/lib/src/foundation/notifications.dart | 2 +- package/lib/src/foundation/{sheet_physics.dart => physics.dart} | 0 package/lib/src/navigation/navigation_sheet.dart | 2 +- package/lib/src/scrollable/scrollable_sheet_extent.dart | 2 +- package/lib/src/scrollable/scrollable_sheet_physics.dart | 2 +- 6 files changed, 5 insertions(+), 5 deletions(-) rename package/lib/src/foundation/{sheet_physics.dart => physics.dart} (100%) diff --git a/package/lib/smooth_sheets.dart b/package/lib/smooth_sheets.dart index 76846e4f..0cb5e9b3 100644 --- a/package/lib/smooth_sheets.dart +++ b/package/lib/smooth_sheets.dart @@ -13,7 +13,7 @@ export 'src/foundation/sheet_activity.dart'; export 'src/foundation/sheet_content_scaffold.dart'; export 'src/foundation/sheet_controller.dart' hide SheetControllerScope; export 'src/foundation/sheet_extent.dart'; -export 'src/foundation/sheet_physics.dart'; +export 'src/foundation/physics.dart'; export 'src/foundation/theme.dart'; export 'src/modal/cupertino.dart'; export 'src/modal/modal_sheet.dart'; diff --git a/package/lib/src/foundation/notifications.dart b/package/lib/src/foundation/notifications.dart index 9219f044..fa69b78e 100644 --- a/package/lib/src/foundation/notifications.dart +++ b/package/lib/src/foundation/notifications.dart @@ -1,6 +1,6 @@ import 'package:flutter/widgets.dart'; import 'package:smooth_sheets/src/foundation/sheet_extent.dart'; -import 'package:smooth_sheets/src/foundation/sheet_physics.dart'; +import 'package:smooth_sheets/src/foundation/physics.dart'; /// A [Notification] that is dispatched when the sheet extent changes. /// diff --git a/package/lib/src/foundation/sheet_physics.dart b/package/lib/src/foundation/physics.dart similarity index 100% rename from package/lib/src/foundation/sheet_physics.dart rename to package/lib/src/foundation/physics.dart diff --git a/package/lib/src/navigation/navigation_sheet.dart b/package/lib/src/navigation/navigation_sheet.dart index 45affe3b..066f975e 100644 --- a/package/lib/src/navigation/navigation_sheet.dart +++ b/package/lib/src/navigation/navigation_sheet.dart @@ -7,7 +7,7 @@ import 'package:smooth_sheets/src/foundation/keyboard_dismissible.dart'; import 'package:smooth_sheets/src/foundation/sheet_activity.dart'; import 'package:smooth_sheets/src/foundation/sheet_controller.dart'; import 'package:smooth_sheets/src/foundation/sheet_extent.dart'; -import 'package:smooth_sheets/src/foundation/sheet_physics.dart'; +import 'package:smooth_sheets/src/foundation/physics.dart'; import 'package:smooth_sheets/src/foundation/sheet_status.dart'; import 'package:smooth_sheets/src/foundation/theme.dart'; import 'package:smooth_sheets/src/internal/transition_observer.dart'; diff --git a/package/lib/src/scrollable/scrollable_sheet_extent.dart b/package/lib/src/scrollable/scrollable_sheet_extent.dart index fa1d113c..cb4b2044 100644 --- a/package/lib/src/scrollable/scrollable_sheet_extent.dart +++ b/package/lib/src/scrollable/scrollable_sheet_extent.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; import 'package:meta/meta.dart'; import 'package:smooth_sheets/src/foundation/sheet_activity.dart'; import 'package:smooth_sheets/src/foundation/sheet_extent.dart'; -import 'package:smooth_sheets/src/foundation/sheet_physics.dart'; +import 'package:smooth_sheets/src/foundation/physics.dart'; import 'package:smooth_sheets/src/foundation/sheet_status.dart'; import 'package:smooth_sheets/src/internal/double_utils.dart'; import 'package:smooth_sheets/src/scrollable/delegatable_scroll_position.dart'; diff --git a/package/lib/src/scrollable/scrollable_sheet_physics.dart b/package/lib/src/scrollable/scrollable_sheet_physics.dart index ff354886..f7921997 100644 --- a/package/lib/src/scrollable/scrollable_sheet_physics.dart +++ b/package/lib/src/scrollable/scrollable_sheet_physics.dart @@ -1,5 +1,5 @@ import 'package:smooth_sheets/src/foundation/sheet_extent.dart'; -import 'package:smooth_sheets/src/foundation/sheet_physics.dart'; +import 'package:smooth_sheets/src/foundation/physics.dart'; class ScrollableSheetPhysics extends SheetPhysics { const ScrollableSheetPhysics({ From 722ccc292554af48f036ad56ec71e3cce42526d8 Mon Sep 17 00:00:00 2001 From: fujidaiti Date: Thu, 18 Apr 2024 22:14:09 +0900 Subject: [PATCH 5/9] Enable prefer_relative_imports rule --- package/analysis_options.yaml | 1 + package/lib/smooth_sheets.dart | 2 +- .../lib/src/draggable/draggable_sheet.dart | 2 +- .../lib/src/draggable/sheet_draggable.dart | 9 +++++---- package/lib/src/foundation/animation.dart | 4 ++-- package/lib/src/foundation/framework.dart | 4 ++-- .../src/foundation/keyboard_dismissible.dart | 4 ++-- package/lib/src/foundation/notifications.dart | 5 +++-- package/lib/src/foundation/physics.dart | 5 +++-- .../lib/src/foundation/sheet_activity.dart | 4 ++-- .../foundation/sheet_content_scaffold.dart | 2 +- .../lib/src/foundation/sheet_controller.dart | 2 +- package/lib/src/foundation/sheet_extent.dart | 7 ++++--- package/lib/src/foundation/theme.dart | 2 +- package/lib/src/modal/cupertino.dart | 6 +++--- package/lib/src/modal/modal_sheet.dart | 8 ++++---- .../lib/src/navigation/navigation_route.dart | 10 +++++----- .../lib/src/navigation/navigation_routes.dart | 4 ++-- .../lib/src/navigation/navigation_sheet.dart | 19 ++++++++++--------- .../lib/src/scrollable/scrollable_sheet.dart | 4 ++-- .../scrollable/scrollable_sheet_extent.dart | 15 ++++++++------- .../scrollable/scrollable_sheet_physics.dart | 4 ++-- 22 files changed, 65 insertions(+), 58 deletions(-) diff --git a/package/analysis_options.yaml b/package/analysis_options.yaml index 6a3866d3..1674b9f0 100644 --- a/package/analysis_options.yaml +++ b/package/analysis_options.yaml @@ -11,3 +11,4 @@ linter: flutter_style_todos: false cascade_invocations: false join_return_with_assignment: false + prefer_relative_imports: true diff --git a/package/lib/smooth_sheets.dart b/package/lib/smooth_sheets.dart index 0cb5e9b3..78cf0ffe 100644 --- a/package/lib/smooth_sheets.dart +++ b/package/lib/smooth_sheets.dart @@ -9,11 +9,11 @@ export 'src/foundation/animation.dart'; export 'src/foundation/framework.dart'; export 'src/foundation/keyboard_dismissible.dart'; export 'src/foundation/notifications.dart'; +export 'src/foundation/physics.dart'; export 'src/foundation/sheet_activity.dart'; export 'src/foundation/sheet_content_scaffold.dart'; export 'src/foundation/sheet_controller.dart' hide SheetControllerScope; export 'src/foundation/sheet_extent.dart'; -export 'src/foundation/physics.dart'; export 'src/foundation/theme.dart'; export 'src/modal/cupertino.dart'; export 'src/modal/modal_sheet.dart'; diff --git a/package/lib/src/draggable/draggable_sheet.dart b/package/lib/src/draggable/draggable_sheet.dart index 65079963..30f5d93d 100644 --- a/package/lib/src/draggable/draggable_sheet.dart +++ b/package/lib/src/draggable/draggable_sheet.dart @@ -1,5 +1,5 @@ import 'package:flutter/widgets.dart'; -import 'package:smooth_sheets/smooth_sheets.dart'; +import '../../smooth_sheets.dart'; /// A sheet that can be dragged. /// diff --git a/package/lib/src/draggable/sheet_draggable.dart b/package/lib/src/draggable/sheet_draggable.dart index 0c361122..d6f82ff9 100644 --- a/package/lib/src/draggable/sheet_draggable.dart +++ b/package/lib/src/draggable/sheet_draggable.dart @@ -1,10 +1,11 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/widgets.dart'; -import 'package:smooth_sheets/src/draggable/draggable_sheet.dart'; -import 'package:smooth_sheets/src/foundation/sheet_activity.dart'; -import 'package:smooth_sheets/src/foundation/sheet_extent.dart'; -import 'package:smooth_sheets/src/scrollable/scrollable_sheet.dart'; + +import '../foundation/sheet_activity.dart'; +import '../foundation/sheet_extent.dart'; +import '../scrollable/scrollable_sheet.dart'; +import 'draggable_sheet.dart'; /// A widget that makes its child as a drag-handle for a sheet. /// diff --git a/package/lib/src/foundation/animation.dart b/package/lib/src/foundation/animation.dart index 313e573a..f3ce3dc7 100644 --- a/package/lib/src/foundation/animation.dart +++ b/package/lib/src/foundation/animation.dart @@ -1,6 +1,6 @@ import 'package:flutter/animation.dart'; -import 'package:smooth_sheets/src/foundation/sheet_controller.dart'; -import 'package:smooth_sheets/src/foundation/sheet_extent.dart'; +import 'sheet_controller.dart'; +import 'sheet_extent.dart'; class ExtentDrivenAnimation extends Animation { ExtentDrivenAnimation({ diff --git a/package/lib/src/foundation/framework.dart b/package/lib/src/foundation/framework.dart index b95e5019..5c6c96bb 100644 --- a/package/lib/src/foundation/framework.dart +++ b/package/lib/src/foundation/framework.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; -import 'package:smooth_sheets/src/foundation/sheet_controller.dart'; -import 'package:smooth_sheets/src/foundation/sheet_extent.dart'; +import 'sheet_controller.dart'; +import 'sheet_extent.dart'; class SheetContainer extends StatelessWidget { const SheetContainer({ diff --git a/package/lib/src/foundation/keyboard_dismissible.dart b/package/lib/src/foundation/keyboard_dismissible.dart index 7fa656bd..c96e21b1 100644 --- a/package/lib/src/foundation/keyboard_dismissible.dart +++ b/package/lib/src/foundation/keyboard_dismissible.dart @@ -1,6 +1,6 @@ import 'package:flutter/widgets.dart'; -import 'package:smooth_sheets/src/draggable/draggable_sheet.dart'; -import 'package:smooth_sheets/src/foundation/notifications.dart'; +import '../draggable/draggable_sheet.dart'; +import 'notifications.dart'; /// A widget that dismisses the on-screen keyboard when the user /// drags the sheet below this widget. diff --git a/package/lib/src/foundation/notifications.dart b/package/lib/src/foundation/notifications.dart index fa69b78e..14c1d24f 100644 --- a/package/lib/src/foundation/notifications.dart +++ b/package/lib/src/foundation/notifications.dart @@ -1,6 +1,7 @@ import 'package:flutter/widgets.dart'; -import 'package:smooth_sheets/src/foundation/sheet_extent.dart'; -import 'package:smooth_sheets/src/foundation/physics.dart'; + +import 'physics.dart'; +import 'sheet_extent.dart'; /// A [Notification] that is dispatched when the sheet extent changes. /// diff --git a/package/lib/src/foundation/physics.dart b/package/lib/src/foundation/physics.dart index e3d20728..b6c1aaff 100644 --- a/package/lib/src/foundation/physics.dart +++ b/package/lib/src/foundation/physics.dart @@ -4,8 +4,9 @@ import 'dart:ui'; import 'package:collection/collection.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/widgets.dart'; -import 'package:smooth_sheets/src/foundation/sheet_extent.dart'; -import 'package:smooth_sheets/src/internal/double_utils.dart'; + +import '../internal/double_utils.dart'; +import 'sheet_extent.dart'; const _minSettlingDuration = Duration(milliseconds: 160); const _defaultSettlingSpeed = 600.0; // logical pixels per second diff --git a/package/lib/src/foundation/sheet_activity.dart b/package/lib/src/foundation/sheet_activity.dart index f085b6da..d70d6c2c 100644 --- a/package/lib/src/foundation/sheet_activity.dart +++ b/package/lib/src/foundation/sheet_activity.dart @@ -4,8 +4,8 @@ import 'dart:math'; import 'package:flutter/gestures.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter/widgets.dart'; -import 'package:smooth_sheets/smooth_sheets.dart'; -import 'package:smooth_sheets/src/foundation/sheet_status.dart'; +import '../../smooth_sheets.dart'; +import 'sheet_status.dart'; abstract class SheetActivity extends ChangeNotifier { bool _mounted = false; diff --git a/package/lib/src/foundation/sheet_content_scaffold.dart b/package/lib/src/foundation/sheet_content_scaffold.dart index 754a2804..f429452c 100644 --- a/package/lib/src/foundation/sheet_content_scaffold.dart +++ b/package/lib/src/foundation/sheet_content_scaffold.dart @@ -2,7 +2,7 @@ import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; -import 'package:smooth_sheets/smooth_sheets.dart'; +import '../../smooth_sheets.dart'; class SheetContentScaffold extends StatelessWidget { const SheetContentScaffold({ diff --git a/package/lib/src/foundation/sheet_controller.dart b/package/lib/src/foundation/sheet_controller.dart index d43cf9ec..5e911e1d 100644 --- a/package/lib/src/foundation/sheet_controller.dart +++ b/package/lib/src/foundation/sheet_controller.dart @@ -2,7 +2,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter/widgets.dart'; import 'package:meta/meta.dart'; -import 'package:smooth_sheets/src/foundation/sheet_extent.dart'; +import 'sheet_extent.dart'; class SheetController extends ChangeNotifier implements ValueListenable { diff --git a/package/lib/src/foundation/sheet_extent.dart b/package/lib/src/foundation/sheet_extent.dart index 6659788e..c3788406 100644 --- a/package/lib/src/foundation/sheet_extent.dart +++ b/package/lib/src/foundation/sheet_extent.dart @@ -1,7 +1,8 @@ import 'package:flutter/widgets.dart'; -import 'package:smooth_sheets/smooth_sheets.dart'; -import 'package:smooth_sheets/src/foundation/sheet_status.dart'; -import 'package:smooth_sheets/src/internal/double_utils.dart'; + +import '../../smooth_sheets.dart'; +import '../internal/double_utils.dart'; +import 'sheet_status.dart'; /// A representation of a visible height of the sheet. /// diff --git a/package/lib/src/foundation/theme.dart b/package/lib/src/foundation/theme.dart index 42546d53..d54d3e9f 100644 --- a/package/lib/src/foundation/theme.dart +++ b/package/lib/src/foundation/theme.dart @@ -1,5 +1,5 @@ import 'package:flutter/widgets.dart'; -import 'package:smooth_sheets/src/foundation/keyboard_dismissible.dart'; +import 'keyboard_dismissible.dart'; /// A theme for descendant sheets. /// diff --git a/package/lib/src/modal/cupertino.dart b/package/lib/src/modal/cupertino.dart index 3a4e8a94..9d5256c8 100644 --- a/package/lib/src/modal/cupertino.dart +++ b/package/lib/src/modal/cupertino.dart @@ -3,9 +3,9 @@ import 'dart:math'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; -import 'package:smooth_sheets/smooth_sheets.dart'; -import 'package:smooth_sheets/src/internal/double_utils.dart'; -import 'package:smooth_sheets/src/modal/modal_sheet.dart'; +import '../../smooth_sheets.dart'; +import '../internal/double_utils.dart'; +import 'modal_sheet.dart'; const _minimizedViewportScale = 0.92; const _cupertinoBarrierColor = Color(0x18000000); diff --git a/package/lib/src/modal/modal_sheet.dart b/package/lib/src/modal/modal_sheet.dart index aa1d1ae4..aaed81f5 100644 --- a/package/lib/src/modal/modal_sheet.dart +++ b/package/lib/src/modal/modal_sheet.dart @@ -3,10 +3,10 @@ import 'dart:math'; import 'dart:ui'; import 'package:flutter/material.dart'; -import 'package:smooth_sheets/src/foundation/sheet_controller.dart'; -import 'package:smooth_sheets/src/foundation/sheet_status.dart'; -import 'package:smooth_sheets/src/internal/double_utils.dart'; -import 'package:smooth_sheets/src/internal/monodrag.dart'; +import '../foundation/sheet_controller.dart'; +import '../foundation/sheet_status.dart'; +import '../internal/double_utils.dart'; +import '../internal/monodrag.dart'; const _minFlingVelocityToDismiss = 1.0; const _minDragDistanceToDismiss = 100.0; // Logical pixels. diff --git a/package/lib/src/navigation/navigation_route.dart b/package/lib/src/navigation/navigation_route.dart index e4ef3291..31e8a43e 100644 --- a/package/lib/src/navigation/navigation_route.dart +++ b/package/lib/src/navigation/navigation_route.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:smooth_sheets/src/foundation/framework.dart'; -import 'package:smooth_sheets/src/foundation/sheet_activity.dart'; -import 'package:smooth_sheets/src/foundation/sheet_extent.dart'; -import 'package:smooth_sheets/src/foundation/sheet_status.dart'; -import 'package:smooth_sheets/src/navigation/navigation_sheet.dart'; +import '../foundation/framework.dart'; +import '../foundation/sheet_activity.dart'; +import '../foundation/sheet_extent.dart'; +import '../foundation/sheet_status.dart'; +import 'navigation_sheet.dart'; mixin NavigationSheetRouteMixin on NavigationSheetRoute { SheetExtentConfig get pageExtentConfig; diff --git a/package/lib/src/navigation/navigation_routes.dart b/package/lib/src/navigation/navigation_routes.dart index d66bc0a5..4ac56306 100644 --- a/package/lib/src/navigation/navigation_routes.dart +++ b/package/lib/src/navigation/navigation_routes.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:smooth_sheets/smooth_sheets.dart'; -import 'package:smooth_sheets/src/scrollable/scrollable_sheet.dart'; +import '../../smooth_sheets.dart'; +import '../scrollable/scrollable_sheet.dart'; class ScrollableNavigationSheetRoute extends NavigationSheetRoute with NavigationSheetRouteMixin { diff --git a/package/lib/src/navigation/navigation_sheet.dart b/package/lib/src/navigation/navigation_sheet.dart index 066f975e..37476cd7 100644 --- a/package/lib/src/navigation/navigation_sheet.dart +++ b/package/lib/src/navigation/navigation_sheet.dart @@ -2,15 +2,16 @@ import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; -import 'package:smooth_sheets/src/foundation/framework.dart'; -import 'package:smooth_sheets/src/foundation/keyboard_dismissible.dart'; -import 'package:smooth_sheets/src/foundation/sheet_activity.dart'; -import 'package:smooth_sheets/src/foundation/sheet_controller.dart'; -import 'package:smooth_sheets/src/foundation/sheet_extent.dart'; -import 'package:smooth_sheets/src/foundation/physics.dart'; -import 'package:smooth_sheets/src/foundation/sheet_status.dart'; -import 'package:smooth_sheets/src/foundation/theme.dart'; -import 'package:smooth_sheets/src/internal/transition_observer.dart'; + +import '../foundation/framework.dart'; +import '../foundation/keyboard_dismissible.dart'; +import '../foundation/physics.dart'; +import '../foundation/sheet_activity.dart'; +import '../foundation/sheet_controller.dart'; +import '../foundation/sheet_extent.dart'; +import '../foundation/sheet_status.dart'; +import '../foundation/theme.dart'; +import '../internal/transition_observer.dart'; typedef NavigationSheetTransitionObserver = TransitionObserver; diff --git a/package/lib/src/scrollable/scrollable_sheet.dart b/package/lib/src/scrollable/scrollable_sheet.dart index 947f1982..a71123e0 100644 --- a/package/lib/src/scrollable/scrollable_sheet.dart +++ b/package/lib/src/scrollable/scrollable_sheet.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:meta/meta.dart'; -import 'package:smooth_sheets/smooth_sheets.dart'; -import 'package:smooth_sheets/src/scrollable/scrollable_sheet_extent.dart'; +import '../../smooth_sheets.dart'; +import 'scrollable_sheet_extent.dart'; class ScrollableSheet extends StatelessWidget { const ScrollableSheet({ diff --git a/package/lib/src/scrollable/scrollable_sheet_extent.dart b/package/lib/src/scrollable/scrollable_sheet_extent.dart index cb4b2044..26ebc3af 100644 --- a/package/lib/src/scrollable/scrollable_sheet_extent.dart +++ b/package/lib/src/scrollable/scrollable_sheet_extent.dart @@ -2,13 +2,14 @@ import 'dart:math'; import 'package:flutter/material.dart'; import 'package:meta/meta.dart'; -import 'package:smooth_sheets/src/foundation/sheet_activity.dart'; -import 'package:smooth_sheets/src/foundation/sheet_extent.dart'; -import 'package:smooth_sheets/src/foundation/physics.dart'; -import 'package:smooth_sheets/src/foundation/sheet_status.dart'; -import 'package:smooth_sheets/src/internal/double_utils.dart'; -import 'package:smooth_sheets/src/scrollable/delegatable_scroll_position.dart'; -import 'package:smooth_sheets/src/scrollable/scrollable_sheet_physics.dart'; + +import '../foundation/physics.dart'; +import '../foundation/sheet_activity.dart'; +import '../foundation/sheet_extent.dart'; +import '../foundation/sheet_status.dart'; +import '../internal/double_utils.dart'; +import 'delegatable_scroll_position.dart'; +import 'scrollable_sheet_physics.dart'; class ScrollableSheetExtentConfig extends SheetExtentConfig { const ScrollableSheetExtentConfig({ diff --git a/package/lib/src/scrollable/scrollable_sheet_physics.dart b/package/lib/src/scrollable/scrollable_sheet_physics.dart index f7921997..10f7917f 100644 --- a/package/lib/src/scrollable/scrollable_sheet_physics.dart +++ b/package/lib/src/scrollable/scrollable_sheet_physics.dart @@ -1,5 +1,5 @@ -import 'package:smooth_sheets/src/foundation/sheet_extent.dart'; -import 'package:smooth_sheets/src/foundation/physics.dart'; +import '../foundation/physics.dart'; +import '../foundation/sheet_extent.dart'; class ScrollableSheetPhysics extends SheetPhysics { const ScrollableSheetPhysics({ From 7f4880330bd04dcfe70943decb96dad794489f44 Mon Sep 17 00:00:00 2001 From: fujidaiti Date: Thu, 18 Apr 2024 22:25:15 +0900 Subject: [PATCH 6/9] Prefer to import separate libraries --- package/lib/src/draggable/draggable_sheet.dart | 11 ++++++++++- package/lib/src/foundation/sheet_activity.dart | 3 ++- .../lib/src/foundation/sheet_content_scaffold.dart | 5 ++++- package/lib/src/foundation/sheet_extent.dart | 7 ++++++- package/lib/src/modal/cupertino.dart | 2 +- package/lib/src/navigation/navigation_routes.dart | 8 +++++++- package/lib/src/scrollable/scrollable_sheet.dart | 7 ++++++- 7 files changed, 36 insertions(+), 7 deletions(-) diff --git a/package/lib/src/draggable/draggable_sheet.dart b/package/lib/src/draggable/draggable_sheet.dart index 30f5d93d..f4363f70 100644 --- a/package/lib/src/draggable/draggable_sheet.dart +++ b/package/lib/src/draggable/draggable_sheet.dart @@ -1,5 +1,14 @@ import 'package:flutter/widgets.dart'; -import '../../smooth_sheets.dart'; + +import '../foundation/framework.dart'; +import '../foundation/keyboard_dismissible.dart'; +import '../foundation/physics.dart'; +import '../foundation/sheet_activity.dart'; +import '../foundation/sheet_controller.dart'; +import '../foundation/sheet_extent.dart'; +import '../foundation/theme.dart'; +import '../scrollable/scrollable_sheet.dart'; +import 'sheet_draggable.dart'; /// A sheet that can be dragged. /// diff --git a/package/lib/src/foundation/sheet_activity.dart b/package/lib/src/foundation/sheet_activity.dart index d70d6c2c..bfe809b8 100644 --- a/package/lib/src/foundation/sheet_activity.dart +++ b/package/lib/src/foundation/sheet_activity.dart @@ -4,7 +4,8 @@ import 'dart:math'; import 'package:flutter/gestures.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter/widgets.dart'; -import '../../smooth_sheets.dart'; +import 'notifications.dart'; +import 'sheet_extent.dart'; import 'sheet_status.dart'; abstract class SheetActivity extends ChangeNotifier { diff --git a/package/lib/src/foundation/sheet_content_scaffold.dart b/package/lib/src/foundation/sheet_content_scaffold.dart index f429452c..9f2e7587 100644 --- a/package/lib/src/foundation/sheet_content_scaffold.dart +++ b/package/lib/src/foundation/sheet_content_scaffold.dart @@ -2,7 +2,10 @@ import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; -import '../../smooth_sheets.dart'; + +import '../draggable/sheet_draggable.dart'; +import 'framework.dart'; +import 'sheet_extent.dart'; class SheetContentScaffold extends StatelessWidget { const SheetContentScaffold({ diff --git a/package/lib/src/foundation/sheet_extent.dart b/package/lib/src/foundation/sheet_extent.dart index c3788406..18d6f0cd 100644 --- a/package/lib/src/foundation/sheet_extent.dart +++ b/package/lib/src/foundation/sheet_extent.dart @@ -1,7 +1,12 @@ import 'package:flutter/widgets.dart'; -import '../../smooth_sheets.dart'; +import '../draggable/draggable_sheet.dart'; import '../internal/double_utils.dart'; +import '../scrollable/scrollable_sheet.dart'; +import '../scrollable/scrollable_sheet_extent.dart'; +import 'physics.dart'; +import 'sheet_activity.dart'; +import 'sheet_controller.dart'; import 'sheet_status.dart'; /// A representation of a visible height of the sheet. diff --git a/package/lib/src/modal/cupertino.dart b/package/lib/src/modal/cupertino.dart index 9d5256c8..2df35c82 100644 --- a/package/lib/src/modal/cupertino.dart +++ b/package/lib/src/modal/cupertino.dart @@ -3,7 +3,7 @@ import 'dart:math'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; -import '../../smooth_sheets.dart'; + import '../internal/double_utils.dart'; import 'modal_sheet.dart'; diff --git a/package/lib/src/navigation/navigation_routes.dart b/package/lib/src/navigation/navigation_routes.dart index 4ac56306..b5ec3671 100644 --- a/package/lib/src/navigation/navigation_routes.dart +++ b/package/lib/src/navigation/navigation_routes.dart @@ -1,6 +1,12 @@ import 'package:flutter/material.dart'; -import '../../smooth_sheets.dart'; +import '../draggable/draggable_sheet.dart'; +import '../draggable/sheet_draggable.dart'; +import '../foundation/physics.dart'; +import '../foundation/sheet_extent.dart'; import '../scrollable/scrollable_sheet.dart'; +import '../scrollable/scrollable_sheet_extent.dart'; +import 'navigation_route.dart'; +import 'navigation_sheet.dart'; class ScrollableNavigationSheetRoute extends NavigationSheetRoute with NavigationSheetRouteMixin { diff --git a/package/lib/src/scrollable/scrollable_sheet.dart b/package/lib/src/scrollable/scrollable_sheet.dart index a71123e0..5ed0262e 100644 --- a/package/lib/src/scrollable/scrollable_sheet.dart +++ b/package/lib/src/scrollable/scrollable_sheet.dart @@ -1,7 +1,12 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:meta/meta.dart'; -import '../../smooth_sheets.dart'; +import '../foundation/framework.dart'; +import '../foundation/keyboard_dismissible.dart'; +import '../foundation/physics.dart'; +import '../foundation/sheet_controller.dart'; +import '../foundation/sheet_extent.dart'; +import '../foundation/theme.dart'; import 'scrollable_sheet_extent.dart'; class ScrollableSheet extends StatelessWidget { From aea49c1d59339d1837f45767c34bb040e77cc34d Mon Sep 17 00:00:00 2001 From: fujidaiti Date: Thu, 18 Apr 2024 22:28:10 +0900 Subject: [PATCH 7/9] Rename sheet_activity to activities --- package/lib/smooth_sheets.dart | 2 +- package/lib/src/draggable/draggable_sheet.dart | 2 +- package/lib/src/draggable/sheet_draggable.dart | 2 +- .../lib/src/foundation/{sheet_activity.dart => activities.dart} | 0 package/lib/src/foundation/sheet_extent.dart | 2 +- package/lib/src/navigation/navigation_route.dart | 2 +- package/lib/src/navigation/navigation_sheet.dart | 2 +- package/lib/src/scrollable/scrollable_sheet_extent.dart | 2 +- 8 files changed, 7 insertions(+), 7 deletions(-) rename package/lib/src/foundation/{sheet_activity.dart => activities.dart} (100%) diff --git a/package/lib/smooth_sheets.dart b/package/lib/smooth_sheets.dart index 78cf0ffe..e84ed057 100644 --- a/package/lib/smooth_sheets.dart +++ b/package/lib/smooth_sheets.dart @@ -10,7 +10,7 @@ export 'src/foundation/framework.dart'; export 'src/foundation/keyboard_dismissible.dart'; export 'src/foundation/notifications.dart'; export 'src/foundation/physics.dart'; -export 'src/foundation/sheet_activity.dart'; +export 'src/foundation/activities.dart'; export 'src/foundation/sheet_content_scaffold.dart'; export 'src/foundation/sheet_controller.dart' hide SheetControllerScope; export 'src/foundation/sheet_extent.dart'; diff --git a/package/lib/src/draggable/draggable_sheet.dart b/package/lib/src/draggable/draggable_sheet.dart index f4363f70..cc14535e 100644 --- a/package/lib/src/draggable/draggable_sheet.dart +++ b/package/lib/src/draggable/draggable_sheet.dart @@ -3,7 +3,7 @@ import 'package:flutter/widgets.dart'; import '../foundation/framework.dart'; import '../foundation/keyboard_dismissible.dart'; import '../foundation/physics.dart'; -import '../foundation/sheet_activity.dart'; +import '../foundation/activities.dart'; import '../foundation/sheet_controller.dart'; import '../foundation/sheet_extent.dart'; import '../foundation/theme.dart'; diff --git a/package/lib/src/draggable/sheet_draggable.dart b/package/lib/src/draggable/sheet_draggable.dart index d6f82ff9..efd6177f 100644 --- a/package/lib/src/draggable/sheet_draggable.dart +++ b/package/lib/src/draggable/sheet_draggable.dart @@ -2,7 +2,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/widgets.dart'; -import '../foundation/sheet_activity.dart'; +import '../foundation/activities.dart'; import '../foundation/sheet_extent.dart'; import '../scrollable/scrollable_sheet.dart'; import 'draggable_sheet.dart'; diff --git a/package/lib/src/foundation/sheet_activity.dart b/package/lib/src/foundation/activities.dart similarity index 100% rename from package/lib/src/foundation/sheet_activity.dart rename to package/lib/src/foundation/activities.dart diff --git a/package/lib/src/foundation/sheet_extent.dart b/package/lib/src/foundation/sheet_extent.dart index 18d6f0cd..d6385c77 100644 --- a/package/lib/src/foundation/sheet_extent.dart +++ b/package/lib/src/foundation/sheet_extent.dart @@ -5,7 +5,7 @@ import '../internal/double_utils.dart'; import '../scrollable/scrollable_sheet.dart'; import '../scrollable/scrollable_sheet_extent.dart'; import 'physics.dart'; -import 'sheet_activity.dart'; +import 'activities.dart'; import 'sheet_controller.dart'; import 'sheet_status.dart'; diff --git a/package/lib/src/navigation/navigation_route.dart b/package/lib/src/navigation/navigation_route.dart index 31e8a43e..69852906 100644 --- a/package/lib/src/navigation/navigation_route.dart +++ b/package/lib/src/navigation/navigation_route.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import '../foundation/framework.dart'; -import '../foundation/sheet_activity.dart'; +import '../foundation/activities.dart'; import '../foundation/sheet_extent.dart'; import '../foundation/sheet_status.dart'; import 'navigation_sheet.dart'; diff --git a/package/lib/src/navigation/navigation_sheet.dart b/package/lib/src/navigation/navigation_sheet.dart index 37476cd7..4985a4d7 100644 --- a/package/lib/src/navigation/navigation_sheet.dart +++ b/package/lib/src/navigation/navigation_sheet.dart @@ -6,7 +6,7 @@ import 'package:flutter/widgets.dart'; import '../foundation/framework.dart'; import '../foundation/keyboard_dismissible.dart'; import '../foundation/physics.dart'; -import '../foundation/sheet_activity.dart'; +import '../foundation/activities.dart'; import '../foundation/sheet_controller.dart'; import '../foundation/sheet_extent.dart'; import '../foundation/sheet_status.dart'; diff --git a/package/lib/src/scrollable/scrollable_sheet_extent.dart b/package/lib/src/scrollable/scrollable_sheet_extent.dart index 26ebc3af..0a6c859b 100644 --- a/package/lib/src/scrollable/scrollable_sheet_extent.dart +++ b/package/lib/src/scrollable/scrollable_sheet_extent.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; import 'package:meta/meta.dart'; import '../foundation/physics.dart'; -import '../foundation/sheet_activity.dart'; +import '../foundation/activities.dart'; import '../foundation/sheet_extent.dart'; import '../foundation/sheet_status.dart'; import '../internal/double_utils.dart'; From d6048d9179c37d40986251b993056396d269ac57 Mon Sep 17 00:00:00 2001 From: fujidaiti Date: Thu, 18 Apr 2024 22:28:38 +0900 Subject: [PATCH 8/9] Rename animation to animations --- package/lib/smooth_sheets.dart | 2 +- package/lib/src/foundation/{animation.dart => animations.dart} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename package/lib/src/foundation/{animation.dart => animations.dart} (100%) diff --git a/package/lib/smooth_sheets.dart b/package/lib/smooth_sheets.dart index e84ed057..6baab637 100644 --- a/package/lib/smooth_sheets.dart +++ b/package/lib/smooth_sheets.dart @@ -5,7 +5,7 @@ library smooth_sheets; export 'src/draggable/draggable_sheet.dart'; export 'src/draggable/sheet_draggable.dart'; -export 'src/foundation/animation.dart'; +export 'src/foundation/animations.dart'; export 'src/foundation/framework.dart'; export 'src/foundation/keyboard_dismissible.dart'; export 'src/foundation/notifications.dart'; diff --git a/package/lib/src/foundation/animation.dart b/package/lib/src/foundation/animations.dart similarity index 100% rename from package/lib/src/foundation/animation.dart rename to package/lib/src/foundation/animations.dart From a5a36436c484ba99dd8fa3d7d358f50d006e9579 Mon Sep 17 00:00:00 2001 From: fujidaiti Date: Thu, 18 Apr 2024 22:29:54 +0900 Subject: [PATCH 9/9] Apply directives_ordering rule --- package/lib/smooth_sheets.dart | 2 +- package/lib/src/draggable/draggable_sheet.dart | 2 +- package/lib/src/foundation/sheet_extent.dart | 2 +- package/lib/src/navigation/navigation_route.dart | 3 ++- package/lib/src/navigation/navigation_sheet.dart | 2 +- package/lib/src/scrollable/scrollable_sheet_extent.dart | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/package/lib/smooth_sheets.dart b/package/lib/smooth_sheets.dart index 6baab637..db9b24c9 100644 --- a/package/lib/smooth_sheets.dart +++ b/package/lib/smooth_sheets.dart @@ -5,12 +5,12 @@ library smooth_sheets; export 'src/draggable/draggable_sheet.dart'; export 'src/draggable/sheet_draggable.dart'; +export 'src/foundation/activities.dart'; export 'src/foundation/animations.dart'; export 'src/foundation/framework.dart'; export 'src/foundation/keyboard_dismissible.dart'; export 'src/foundation/notifications.dart'; export 'src/foundation/physics.dart'; -export 'src/foundation/activities.dart'; export 'src/foundation/sheet_content_scaffold.dart'; export 'src/foundation/sheet_controller.dart' hide SheetControllerScope; export 'src/foundation/sheet_extent.dart'; diff --git a/package/lib/src/draggable/draggable_sheet.dart b/package/lib/src/draggable/draggable_sheet.dart index cc14535e..68874834 100644 --- a/package/lib/src/draggable/draggable_sheet.dart +++ b/package/lib/src/draggable/draggable_sheet.dart @@ -1,9 +1,9 @@ import 'package:flutter/widgets.dart'; +import '../foundation/activities.dart'; import '../foundation/framework.dart'; import '../foundation/keyboard_dismissible.dart'; import '../foundation/physics.dart'; -import '../foundation/activities.dart'; import '../foundation/sheet_controller.dart'; import '../foundation/sheet_extent.dart'; import '../foundation/theme.dart'; diff --git a/package/lib/src/foundation/sheet_extent.dart b/package/lib/src/foundation/sheet_extent.dart index d6385c77..274d501c 100644 --- a/package/lib/src/foundation/sheet_extent.dart +++ b/package/lib/src/foundation/sheet_extent.dart @@ -4,8 +4,8 @@ import '../draggable/draggable_sheet.dart'; import '../internal/double_utils.dart'; import '../scrollable/scrollable_sheet.dart'; import '../scrollable/scrollable_sheet_extent.dart'; -import 'physics.dart'; import 'activities.dart'; +import 'physics.dart'; import 'sheet_controller.dart'; import 'sheet_status.dart'; diff --git a/package/lib/src/navigation/navigation_route.dart b/package/lib/src/navigation/navigation_route.dart index 69852906..64f964d7 100644 --- a/package/lib/src/navigation/navigation_route.dart +++ b/package/lib/src/navigation/navigation_route.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; -import '../foundation/framework.dart'; + import '../foundation/activities.dart'; +import '../foundation/framework.dart'; import '../foundation/sheet_extent.dart'; import '../foundation/sheet_status.dart'; import 'navigation_sheet.dart'; diff --git a/package/lib/src/navigation/navigation_sheet.dart b/package/lib/src/navigation/navigation_sheet.dart index 4985a4d7..a2d6c2f9 100644 --- a/package/lib/src/navigation/navigation_sheet.dart +++ b/package/lib/src/navigation/navigation_sheet.dart @@ -3,10 +3,10 @@ import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; +import '../foundation/activities.dart'; import '../foundation/framework.dart'; import '../foundation/keyboard_dismissible.dart'; import '../foundation/physics.dart'; -import '../foundation/activities.dart'; import '../foundation/sheet_controller.dart'; import '../foundation/sheet_extent.dart'; import '../foundation/sheet_status.dart'; diff --git a/package/lib/src/scrollable/scrollable_sheet_extent.dart b/package/lib/src/scrollable/scrollable_sheet_extent.dart index 0a6c859b..8dd49902 100644 --- a/package/lib/src/scrollable/scrollable_sheet_extent.dart +++ b/package/lib/src/scrollable/scrollable_sheet_extent.dart @@ -3,8 +3,8 @@ import 'dart:math'; import 'package:flutter/material.dart'; import 'package:meta/meta.dart'; -import '../foundation/physics.dart'; import '../foundation/activities.dart'; +import '../foundation/physics.dart'; import '../foundation/sheet_extent.dart'; import '../foundation/sheet_status.dart'; import '../internal/double_utils.dart';