Skip to content

Commit

Permalink
fix: Added contentdxOffset (#80)
Browse files Browse the repository at this point in the history
* added contentdxOffset

* updated code by new flutter version

* Update lib/src/popover.dart

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* refactoring

* up flutter ver

---------

Co-authored-by: Dzmitry Kasianiuk <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 29, 2023
1 parent d86ef98 commit e66db75
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
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

0 comments on commit e66db75

Please sign in to comment.