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

Add support for right to left locales #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
20 changes: 16 additions & 4 deletions lib/src/slider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class SliderButton extends StatefulWidget {

final bool disable;

/* Support for right-to-left locales */
final bool rightToLeftLocale;

SliderButton({
required this.action,
this.radius = 100,
Expand All @@ -64,6 +67,7 @@ class SliderButton extends StatefulWidget {
this.icon,
this.dismissThresholds = 0.75,
this.disable = false,
this.rightToLeftLocale = false,
}) : assert((buttonSize ?? 60) <= (height));

@override
Expand Down Expand Up @@ -140,10 +144,18 @@ class _SliderButtonState extends State<SliderButton> {
)
: Dismissible(
key: UniqueKey(),
direction: DismissDirection.startToEnd,
dismissThresholds: {
DismissDirection.startToEnd: widget.dismissThresholds
},
direction: widget.rightToLeftLocale
? DismissDirection.endToStart
: DismissDirection.startToEnd,
dismissThresholds: widget.rightToLeftLocale
? {
DismissDirection.endToStart:
widget.dismissThresholds
}
: {
DismissDirection.startToEnd:
widget.dismissThresholds
},
confirmDismiss: (_) async {
bool result;
try {
Expand Down