Skip to content

Commit

Permalink
chore: Follow up new dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
krille-chan committed Dec 10, 2024
1 parent a169484 commit 21be49c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
1 change: 0 additions & 1 deletion lib/utils/adaptive_bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ Future<T?> showAdaptiveBottomSheet<T>({
maxWidth: FluffyThemes.columnWidth * 1.25,
),
backgroundColor: Colors.transparent,
showDragHandle: !dialogMode,
clipBehavior: Clip.hardEdge,
);
}
14 changes: 12 additions & 2 deletions lib/widgets/adaptive_dialogs/adaptive_dialog_action.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import 'package:flutter/material.dart';

class AdaptiveDialogAction extends StatelessWidget {
final VoidCallback? onPressed;
final bool autofocus;
final Widget child;

const AdaptiveDialogAction({
super.key,
required this.onPressed,
required this.child,
this.autofocus = false,
});

@override
Expand All @@ -19,10 +21,18 @@ class AdaptiveDialogAction extends StatelessWidget {
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
return TextButton(onPressed: onPressed, child: child);
return TextButton(
onPressed: onPressed,
autofocus: autofocus,
child: child,
);
case TargetPlatform.iOS:
case TargetPlatform.macOS:
return CupertinoDialogAction(onPressed: onPressed, child: child);
return CupertinoDialogAction(
onPressed: onPressed,
isDefaultAction: autofocus,
child: child,
);
}
}
}
2 changes: 2 additions & 0 deletions lib/widgets/adaptive_dialogs/show_ok_cancel_alert_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Future<OkCancelResult?> showOkCancelAlertDialog({
AdaptiveDialogAction(
onPressed: () =>
Navigator.of(context).pop<OkCancelResult>(OkCancelResult.ok),
autofocus: true,
child: Text(
okLabel ?? L10n.of(context).ok,
style: isDestructive
Expand Down Expand Up @@ -70,6 +71,7 @@ Future<OkCancelResult?> showOkAlertDialog({
AdaptiveDialogAction(
onPressed: () =>
Navigator.of(context).pop<OkCancelResult>(OkCancelResult.ok),
autofocus: true,
child: Text(okLabel ?? L10n.of(context).close),
),
],
Expand Down
1 change: 1 addition & 0 deletions lib/widgets/adaptive_dialogs/show_text_input_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Future<String?> showTextInputDialog({
}
Navigator.of(context).pop<String>(input);
},
autofocus: true,
child: Text(
okLabel ?? L10n.of(context).ok,
style: isDestructive
Expand Down

0 comments on commit 21be49c

Please sign in to comment.