Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: fujidaiti/smooth_sheets
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.4.1
Choose a base ref
...
head repository: fujidaiti/smooth_sheets
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.4.2
Choose a head ref
  • 8 commits
  • 32 files changed
  • 1 contributor

Commits on Mar 20, 2024

  1. Add tutorial of BottomBarVisibility widgets (#70)

    fujidaiti authored Mar 20, 2024
    Copy the full SHA
    7e7cdf9 View commit details

Commits on Apr 13, 2024

  1. Refactor scrollable module to prepare for upcoming features (#86)

    This PR reworks some of the guts of the ScrollableSheet in preparation for #87.
    fujidaiti authored Apr 13, 2024
    Copy the full SHA
    036bcd1 View commit details

Commits on Apr 14, 2024

  1. Add new SheetNotifications for drag events (#92)

    This PR adds new `SheetNotification`s for drag start/end/cancel events
    of a sheet (as mentioned in #88).
    
    - SheetDragStartNotification
    - SheetDragEndNotification
    - SheetDragCancelNotification
    fujidaiti authored Apr 14, 2024
    Copy the full SHA
    021489c View commit details

Commits on Apr 15, 2024

  1. Add SheetTheme (#93)

    Closes #91.
    fujidaiti authored Apr 15, 2024
    Copy the full SHA
    1170461 View commit details

Commits on Apr 18, 2024

  1. Refactor (#95)

    To prepare for #89.
    fujidaiti authored Apr 18, 2024
    Copy the full SHA
    57dde8b View commit details

Commits on Apr 20, 2024

  1. Add a way to specify default physics and default ancestor physics (#96)

    The following APIs are added in this PR to enable specifying the default
    physics and the default ancestor physics that is used by sheets.
    - `SheetPhysics.applyTo`
    - `SheetPhysics.copyWith`
    - `SheetTheme.physics`
    - `SheetTheme.basePhysics`
    fujidaiti authored Apr 20, 2024
    Copy the full SHA
    dfdf390 View commit details
  2. Copy the full SHA
    4963e57 View commit details

Commits on Apr 21, 2024

  1. Bump to 0.4.2 (#99)

    The last update before the upcoming breaking changes.
    fujidaiti authored Apr 21, 2024
    Copy the full SHA
    e79cbc5 View commit details
Showing with 1,576 additions and 952 deletions.
  1. +7 −0 .vscode/launch.json
  2. +183 −0 cookbook/lib/tutorial/bottom_bar_visibility.dart
  3. +6 −0 package/CHANGELOG.md
  4. +2 −1 package/README.md
  5. +1 −0 package/analysis_options.yaml
  6. +9 −6 package/lib/smooth_sheets.dart
  7. +115 −41 package/lib/src/draggable/draggable_sheet.dart
  8. +31 −55 package/lib/src/draggable/sheet_draggable.dart
  9. +92 −4 package/lib/src/foundation/{sheet_activity.dart → activities.dart}
  10. +2 −2 package/lib/src/foundation/{animation.dart → animations.dart}
  11. +5 −5 package/lib/src/foundation/framework.dart
  12. +2 −2 package/lib/src/foundation/keyboard_dismissible.dart
  13. +62 −7 package/lib/src/foundation/{notification.dart → notifications.dart}
  14. +105 −78 package/lib/src/foundation/{sheet_physics.dart → physics.dart}
  15. +4 −1 package/lib/src/foundation/sheet_content_scaffold.dart
  16. +1 −1 package/lib/src/foundation/sheet_controller.dart
  17. +42 −28 package/lib/src/foundation/sheet_extent.dart
  18. +0 −145 package/lib/src/foundation/sized_content_sheet.dart
  19. +99 −0 package/lib/src/foundation/theme.dart
  20. +0 −3 package/lib/src/internal/into.dart
  21. +3 −3 package/lib/src/modal/cupertino.dart
  22. +4 −4 package/lib/src/modal/modal_sheet.dart
  23. +8 −7 package/lib/src/navigation/navigation_route.dart
  24. +176 −157 package/lib/src/navigation/navigation_routes.dart
  25. +26 −15 package/lib/src/navigation/navigation_sheet.dart
  26. +0 −209 package/lib/src/scrollable/content_scroll_position.dart
  27. +191 −0 package/lib/src/scrollable/delegatable_scroll_position.dart
  28. +82 −45 package/lib/src/scrollable/scrollable_sheet.dart
  29. +257 −123 package/lib/src/scrollable/scrollable_sheet_extent.dart
  30. +22 −8 package/lib/src/scrollable/scrollable_sheet_physics.dart
  31. +1 −1 package/pubspec.yaml
  32. +38 −1 package/test/foundation/{sheet_physics_test.dart → physics_test.dart}
7 changes: 7 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -74,6 +74,13 @@
"program": "lib/tutorial/sheet_content_scaffold.dart",
"cwd": "./cookbook"
},
{
"name": "Bottom Bar Visibility",
"request": "launch",
"type": "dart",
"program": "lib/tutorial/bottom_bar_visibility.dart",
"cwd": "./cookbook"
},
{
"name": "Sheet Controller",
"request": "launch",
183 changes: 183 additions & 0 deletions cookbook/lib/tutorial/bottom_bar_visibility.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
import 'package:flutter/material.dart';
import 'package:smooth_sheets/smooth_sheets.dart';

void main() {
runApp(const _BottomBarVisibilityExample());
}

class _BottomBarVisibilityExample extends StatelessWidget {
const _BottomBarVisibilityExample();

@override
Widget build(BuildContext context) {
return const MaterialApp(
home: _ExampleHome(),
);
}
}

enum _BottomBarVisibilityType {
fixed(
name: 'FixedBottomBarVisibility',
description: 'The bottom bar is fixed at the bottommost of the sheet.',
),
sticky(
name: 'StickyBottomBarVisibility',
description:
'The bottom bar is always visible regardless of the sheet position.',
),
conditionalSticky(
name: 'ConditionalStickyBottomBarVisibility',
description:
'The bottom bar is visible only when a certain condition is met.',
);

final String name;
final String description;

const _BottomBarVisibilityType({
required this.name,
required this.description,
});
}

class _ExampleHome extends StatefulWidget {
const _ExampleHome();

@override
State<_ExampleHome> createState() => _ExampleHomeState();
}

class _ExampleHomeState extends State<_ExampleHome> {
_BottomBarVisibilityType selectedVisibilityType =
_BottomBarVisibilityType.sticky;

@override
Widget build(BuildContext context) {
final options = [
for (final type in _BottomBarVisibilityType.values)
RadioListTile(
title: Text(type.name),
subtitle: Text(type.description),
value: type,
groupValue: selectedVisibilityType,
contentPadding: const EdgeInsets.only(left: 24, right: 16),
controlAffinity: ListTileControlAffinity.trailing,
onChanged: (value) => setState(() {
selectedVisibilityType = value!;
}),
),
];

return Scaffold(
body: SafeArea(
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const ListTile(
title: Text('BottomBarVisibility'),
subtitle: Text(
'Controls the visibility of the bottom bar based on the sheet position. '
"Intended to be used as the 'SheetContentScaffold.bottomBar'.",
),
),
...options,
const SizedBox(height: 100),
],
),
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton: FloatingActionButton.extended(
label: const Text('Show sheet'),
onPressed: () => showExampleSheet(context),
),
);
}

void showExampleSheet(BuildContext context) {
Navigator.push(
context,
ModalSheetRoute(
builder: (context) => _ExampleSheet(
visibilityType: selectedVisibilityType,
),
),
);
}
}

class _ExampleSheet extends StatelessWidget {
const _ExampleSheet({
required this.visibilityType,
});

final _BottomBarVisibilityType visibilityType;

@override
Widget build(BuildContext context) {
final bottomBar = BottomAppBar(
child: Row(
children: [
IconButton(
onPressed: () {},
icon: const Icon(Icons.menu),
),
const Spacer(),
IconButton(
onPressed: () {},
icon: const Icon(Icons.more_vert),
),
],
),
);

const minSize = Extent.proportional(0.3);
const halfSize = Extent.proportional(0.5);
const fullSize = Extent.proportional(1);

final multiStopPhysics = StretchingSheetPhysics(
parent: SnappingSheetPhysics(
snappingBehavior: SnapToNearest(
snapTo: const [minSize, halfSize, fullSize],
),
),
);

return SafeArea(
bottom: false,
child: DraggableSheet(
minExtent: minSize,
initialExtent: halfSize,
physics: multiStopPhysics,
child: SheetContentScaffold(
appBar: AppBar(),
body: const SizedBox.expand(),
bottomBar: switch (visibilityType) {
_BottomBarVisibilityType.fixed =>
FixedBottomBarVisibility(child: bottomBar),
_BottomBarVisibilityType.sticky =>
StickyBottomBarVisibility(child: bottomBar),
_BottomBarVisibilityType.conditionalSticky =>
ConditionalStickyBottomBarVisibility(
// This callback is called whenever the sheet metrics changes,
// and returning true keeps the bottom bar visible.
getIsVisible: (metrics) {
// The bottom bar is visible when at least 50% of the sheet is visible.
return metrics.pixels >=
const Extent.proportional(0.5)
.resolve(metrics.contentDimensions);
},
child: bottomBar,
),
},
// Add the following 3 lines to keep the bottom bar visible when the keyboard is open.
// resizeBehavior: const ResizeScaffoldBehavior.avoidBottomInset(
// maintainBottomBar: true,
// ),
),
),
);
}
}
6 changes: 6 additions & 0 deletions package/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.4.2 Apr 21, 2024

- Add new SheetNotifications for drag events (#92)
- Add SheetTheme (#93)
- Add a way to specify default physics and default ancestor physics (#96)

## 0.4.1 Mar 20, 2024

- Fix mistakes in the documentation of `BottomBarVisibility` and `ConditionalStickyBottomBarVisibility` which may mislead readers.
3 changes: 2 additions & 1 deletion package/README.md
Original file line number Diff line number Diff line change
@@ -265,9 +265,10 @@ A special kind of [Scaffold](https://api.flutter.dev/flutter/material/Scaffold-c

See also:

- [tutorial/sheet_content_scaffold.dart](https://github.com/fujidaiti/smooth_sheets/blob/main/cookbook/lib/tutorial/sheet_content_scaffold.dart), which shows the basic usage of this widget.
- [SheetContentScaffold](https://pub.dev/documentation/smooth_sheets/latest/smooth_sheets/SheetContentScaffold-class.html), the API documentation.
- [BottomBarVisibility](https://pub.dev/documentation/smooth_sheets/latest/smooth_sheets/BottomBarVisibility-class.html), which can be used to control the visibility of the bottom bar based on the sheet position.
- [tutorial/sheet_content_scaffold.dart](https://github.com/fujidaiti/smooth_sheets/blob/main/cookbook/lib/tutorial/sheet_content_scaffold.dart), which shows the basic usage of SheetContentScaffold.
- [tutorial/bottom_bar_visibility.dart](https://github.com/fujidaiti/smooth_sheets/blob/main/cookbook/lib/tutorial/bottom_bar_visibility.dart), which shows the basic usage of BottomBarVisibility widgets.

<br/>

1 change: 1 addition & 0 deletions package/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -11,3 +11,4 @@ linter:
flutter_style_todos: false
cascade_invocations: false
join_return_with_assignment: false
prefer_relative_imports: true
15 changes: 9 additions & 6 deletions package/lib/smooth_sheets.dart
Original file line number Diff line number Diff line change
@@ -5,19 +5,22 @@ library smooth_sheets;

export 'src/draggable/draggable_sheet.dart';
export 'src/draggable/sheet_draggable.dart';
export 'src/foundation/animation.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/notification.dart';
export 'src/foundation/sheet_activity.dart';
export 'src/foundation/notifications.dart';
export 'src/foundation/physics.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/theme.dart';
export 'src/modal/cupertino.dart';
export 'src/modal/modal_sheet.dart';
export 'src/navigation/navigation_route.dart';
export 'src/navigation/navigation_routes.dart';
export 'src/navigation/navigation_sheet.dart';
export 'src/scrollable/scrollable_sheet.dart';
export 'src/scrollable/scrollable_sheet_extent.dart';
export 'src/scrollable/scrollable_sheet.dart'
hide PrimarySheetContentScrollController;
export 'src/scrollable/scrollable_sheet_extent.dart'
hide SheetContentScrollController;
Loading