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

fix: Added contentdxOffset #80

Merged
merged 5 commits into from
Nov 29, 2023
Merged
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
4 changes: 2 additions & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ version: 0.1.0
publish_to: none

environment:
sdk: '>=2.19.0 <3.0.0'
flutter: '>=3.3.0'
sdk: '>=3.2.1 <4.0.0'
flutter: '>=3.16.1'

dependencies:
flutter:
Expand Down
20 changes: 13 additions & 7 deletions lib/src/popover.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ import 'utils/popover_utils.dart';
/// position on Y axis. It can be positive or negative number.
/// This argument defaults to 0.
///
/// The`contentDxOffset` offsets [Popover]s content
/// position on X axis. It can be positive or negative number.
/// This argument defaults to 0.
///
/// The `barrierDismissible` argument is used to determine whether this route
/// can be dismissed by tapping the modal barrier. This argument defaults
/// to true.
Expand Down Expand Up @@ -81,13 +85,17 @@ Future<T?> showPopover<T extends Object?>({
Duration transitionDuration = const Duration(milliseconds: 200),
double radius = 8,
List<BoxShadow> shadow = const [
BoxShadow(color: Color(0x1F000000), blurRadius: 5)
BoxShadow(
color: Color(0x1F000000),
blurRadius: 5,
)
],
double arrowWidth = 24,
double arrowHeight = 12,
double arrowDxOffset = 0,
double arrowDyOffset = 0,
double contentDyOffset = 0,
double contentDxOffset = 0,
bool barrierDismissible = true,
double? width,
double? height,
Expand All @@ -111,11 +119,8 @@ Future<T?> showPopover<T extends Object?>({
return Navigator.of(context, rootNavigator: true).push<T>(
RawDialogRoute<T>(
pageBuilder: (_, animation, __) {
return WillPopScope(
onWillPop: () {
onPop?.call();
return Future.value(true);
},
return PopScope(
onPopInvoked: (_) => onPop?.call(),
child: PopoverItem(
transition: transition,
child: Builder(builder: bodyBuilder),
Expand All @@ -131,12 +136,13 @@ Future<T?> showPopover<T extends Object?>({
arrowDxOffset: arrowDxOffset,
arrowDyOffset: arrowDyOffset,
contentDyOffset: contentDyOffset,
contentDxOffset: contentDxOffset,
key: key,
),
);
},
barrierDismissible: barrierDismissible,
barrierLabel: barrierLabel ??=
barrierLabel: barrierLabel ??
MaterialLocalizations.of(context).modalBarrierDismissLabel,
barrierColor: barrierColor,
transitionDuration: transitionDuration,
Expand Down
4 changes: 3 additions & 1 deletion lib/src/popover_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class PopoverItem extends StatefulWidget {
final double arrowDxOffset;
final double arrowDyOffset;
final double contentDyOffset;
final double contentDxOffset;
final PopoverTransition transition;

const PopoverItem({
Expand All @@ -36,6 +37,7 @@ class PopoverItem extends StatefulWidget {
this.arrowDxOffset = 0,
this.arrowDyOffset = 0,
this.contentDyOffset = 0,
this.contentDxOffset = 0,
super.key,
});

Expand Down Expand Up @@ -142,7 +144,7 @@ class _PopoverItemState extends State<PopoverItem> {
_attachRect = Rect.fromLTWH(
offset.dx + (widget.arrowDxOffset),
offset.dy + (widget.arrowDyOffset),
bounds.width,
bounds.width + (widget.contentDxOffset),
bounds.height + (widget.contentDyOffset),
);
}
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ version: 0.3.0
homepage: https://github.com/minikin/popover

environment:
sdk: '>=3.1.2 <4.0.0'
flutter: '>=3.13.5'
sdk: '>=3.2.1 <4.0.0'
flutter: '>=3.16.1'

dependencies:
flutter:
Expand Down
Loading