Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust the position of the drag handler gesture detector in wolt_moda… #181

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions lib/src/content/wolt_modal_sheet_layout.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:wolt_modal_sheet/src/content/components/paginating_group/paginating_widgets_group.dart';
import 'package:wolt_modal_sheet/src/theme/wolt_modal_sheet_default_theme_data.dart';
import 'package:wolt_modal_sheet/src/widgets/wolt_bottom_sheet_drag_handle.dart';
import 'package:wolt_modal_sheet/wolt_modal_sheet.dart';

const double _minInteractiveDimension = 48.0;

/// The layout for the Wolt Modal Sheet.
class WoltModalSheetLayout extends StatelessWidget {
const WoltModalSheetLayout({
Expand Down Expand Up @@ -31,9 +34,24 @@ class WoltModalSheetLayout extends StatelessWidget {
themeData?.navBarHeight ??
defaultThemeData.navBarHeight)
: 0.0;

return Stack(
children: [
paginatingWidgetsGroup.mainContentAnimatedBuilder,
if (showDragHandle)
Positioned(
child: GestureDetector(
// By setting behavior to HitTestBehavior.opaque, the GestureDetector will capture touch
// events even if its child (the drag handle) isn't the exact size of the gesture.
// Effectively allowing the handler to capture drag gestures.
behavior: HitTestBehavior.opaque,
child: const Row(
children: [
SizedBox(height: _minInteractiveDimension,),
],
),
),
),
if (hasTopBarLayer)
Positioned(
left: 0,
Expand Down
31 changes: 10 additions & 21 deletions lib/src/widgets/wolt_bottom_sheet_drag_handle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import 'package:flutter/material.dart';
import 'package:wolt_modal_sheet/src/theme/wolt_modal_sheet_default_theme_data.dart';
import 'package:wolt_modal_sheet/wolt_modal_sheet.dart';

const double _minInteractiveDimension = 48.0;

class WoltBottomSheetDragHandle extends StatelessWidget {
const WoltBottomSheetDragHandle({super.key});

Expand All @@ -16,28 +14,19 @@ class WoltBottomSheetDragHandle extends StatelessWidget {
themeData?.dragHandleSize ?? defaultThemeData.dragHandleSize;
final handleColor =
themeData?.dragHandleColor ?? defaultThemeData.dragHandleColor;

return Semantics(
label: semanticsLabel(context),
container: true,
child: SizedBox.square(
dimension: _minInteractiveDimension,
// By setting behavior to HitTestBehavior.opaque, the GestureDetector will capture touch
// events even if its child (the drag handle) isn't the exact size of the gesture.
// This will prevent the scrollable content below from receiving the touch events,
// effectively allowing the handler to capture drag gestures.
child: GestureDetector(
behavior: HitTestBehavior.opaque,
child: Align(
alignment: Alignment.topCenter,
child: Container(
margin: const EdgeInsets.only(top: 8.0),
height: handleSize.height,
width: handleSize.width,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(handleSize.height / 2),
color: handleColor,
),
),
child: Align(
alignment: Alignment.topCenter,
child: Container(
margin: const EdgeInsets.only(top: 8.0),
height: handleSize.height,
width: handleSize.width,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(handleSize.height / 2),
color: handleColor,
),
),
),
Expand Down
36 changes: 25 additions & 11 deletions playground/lib/home/pages/sheet_page_with_custom_top_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ class SheetPageWithCustomTopBar {
),
),
trailingNavBarWidget: WoltModalSheetCloseButton(onClosed: onClosed),
isTopBarLayerAlwaysVisible: false,
topBar: _CustomTopBar(onClosed: onClosed, onBackPressed: onBackPressed),
pageTitle: const ModalSheetTitle('Page with custom top bar'),
child: Column(
child: const Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
children: [
Padding(
padding: EdgeInsets.all(16.0),
child: Text(
Expand Down Expand Up @@ -71,16 +70,31 @@ class _CustomTopBar extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Center(child: ModalSheetTitle('Feeling lucky?')),
Expanded(
child: Padding(
padding: _searchBarPadding,
child: IconButton(
onPressed: () {},
tooltip: 'Search',
icon: const Icon(Icons.search),
),
const Spacer(),
Padding(
padding: _searchBarPadding,
child: IconButton(
onPressed: () {
WoltModalSheet.show(
context: context,
modalTypeBuilder: (context) => WoltModalType.dialog,
pageListBuilder: (sheetContext) => [
WoltModalSheetPage(
child: const SizedBox(),
topBarTitle: const ModalSheetTitle(
'Custom tab bar action!',
textAlign: TextAlign.center,
),
isTopBarLayerAlwaysVisible: true,
)
],
);
},
tooltip: 'Custom Action',
icon: const Icon(Icons.accessibility, color: Colors.white,),
),
),
const SizedBox(width: 70,),
],
),
);
Expand Down
Loading