Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
fujidaiti committed Dec 3, 2024
1 parent 144a74a commit a08a1dd
Show file tree
Hide file tree
Showing 5 changed files with 474 additions and 4 deletions.
7 changes: 4 additions & 3 deletions example/lib/tutorial/imperative_navigation_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class _ExampleSheet extends StatelessWidget {
onGenerateInitialRoutes: (navigator, initialRoute) {
return [
// Use ScrollableNavigationSheetRoute for a draggable page.
NavigationSheetRoute(
PagedSheetRoute(
builder: (context) {
return const _DraggablePage();
},
Expand All @@ -49,7 +49,7 @@ class _ExampleSheet extends StatelessWidget {
);

// Wrap the nested navigator in a NavigationSheet.
return NavigationSheet(
return PagedSheet(
transitionObserver: _transitionObserver,
child: Card(
clipBehavior: Clip.antiAlias,
Expand All @@ -69,7 +69,8 @@ class _DraggablePage extends StatelessWidget {

void navigateToScrollablePage(BuildContext context) {
// Use ScrollableNavigationSheetRoute for a scrollable page.
final route = NavigationSheetRoute(
final route = PagedSheetRoute(
scrollConfiguration: const SheetScrollConfiguration(),
builder: (context) {
return const _ScrollablePage();
},
Expand Down
1 change: 1 addition & 0 deletions lib/smooth_sheets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ library;
export 'src/foundation/foundation.dart';
export 'src/modal/modal.dart';
export 'src/navigation/navigation.dart';
export 'src/paged_sheet.dart';
export 'src/scrollable/scrollable.dart';
7 changes: 6 additions & 1 deletion lib/src/foundation/sheet_position.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ import 'sheet_status.dart';
/// proportionally to the sheet's content height.
/// - [FixedSheetAnchor], which defines the position
/// using a fixed value in pixels.
// TODO: Rename to SheetPosition.
// TODO: Rename to SheetOffset.
abstract interface class SheetAnchor {
/// {@macro FixedSheetAnchor}
// TODO: Rename to `absolute`.
const factory SheetAnchor.pixels(double pixels) = FixedSheetAnchor;

/// {@macro ProportionalSheetAnchor}
// TODO: Rename to `relative`.
const factory SheetAnchor.proportional(double size) = ProportionalSheetAnchor;

/// Resolves the position to an actual value in pixels.
Expand Down Expand Up @@ -392,6 +394,7 @@ abstract class SheetPosition extends ChangeNotifier
);
}

// TODO: Move this to DraggableScrollableSheetPosition.
Drag drag(DragStartDetails details, VoidCallback dragCancelCallback) {
assert(currentDrag == null);
final dragActivity = DragSheetActivity();
Expand Down Expand Up @@ -432,6 +435,7 @@ abstract class SheetPosition extends ChangeNotifier
super.dispose();
}

// TODO: Rename to `setOffset`.
void setPixels(double pixels) {
final oldPixels = maybePixels;
correctPixels(pixels);
Expand All @@ -440,6 +444,7 @@ abstract class SheetPosition extends ChangeNotifier
}
}

// TODO: Rename to `correctOffset`.
void correctPixels(double pixels) {
if (maybePixels != pixels) {
_updateMetrics(pixels: pixels);
Expand Down
3 changes: 3 additions & 0 deletions lib/src/foundation/sheet_position_scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ abstract class SheetPositionScope<E extends SheetPosition>
@internal
abstract class SheetPositionScopeState<E extends SheetPosition,
W extends SheetPositionScope> extends State<W> {
@protected
E get position => _position;
late E _position;

SheetController? _controller;

SheetPositionScopeKey? get _scopeKey {
Expand Down
Loading

0 comments on commit a08a1dd

Please sign in to comment.