Skip to content
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
22 changes: 22 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:dcc_toolkit/ui/annotated_text/annotated_text.dart';
import 'package:dcc_toolkit/ui/native_dialog.dart';
import 'package:example/core/injectable/injectable.dart';
import 'package:example/profile/presentation/cubit/user_cubit.dart';
import 'package:example/profile/presentation/user_page.dart';
Expand Down Expand Up @@ -87,6 +88,27 @@ class MyHomePage extends StatelessWidget {
),
child: const Text('Get user fails'),
),
ElevatedButton(
onPressed:
() => showNativeDialog(
context,
title: 'Title',
content: 'Content',
actions: [
DialogAction(
text: 'Action',
onTap: () {},
textStyle: const TextStyle(color: Colors.green),
),
DialogAction(
text: 'Action',
onTap: () {},
textStyle: const TextStyle(color: Colors.red),
),
],
),
child: const Text('Show native dialog'),
),
],
),
),
Expand Down
4 changes: 2 additions & 2 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,10 @@ packages:
dependency: "direct dev"
description:
name: json_serializable
sha256: "81f04dee10969f89f604e1249382d46b97a1ccad53872875369622b5bfc9e58a"
sha256: c50ef5fc083d5b5e12eef489503ba3bf5ccc899e487d691584699b4bdefeea8c
url: "https://pub.dev"
source: hosted
version: "6.9.4"
version: "6.9.5"
leak_tracker:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dev_dependencies:
flutter_lints: ^5.0.0
freezed: ^3.0.4
injectable_generator: ^2.7.0
json_serializable: ^6.9.4
json_serializable: ^6.9.5

flutter:
uses-material-design: true
2 changes: 1 addition & 1 deletion lib/common/result/result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ sealed class Result<T> {
required TResult Function(T response) success,
required TResult Function(Object? error) error,
}) {
if (this.isSuccess) {
if (isSuccess) {
return success((this as Success<T>).value);
} else {
return error((this as Failure<T>).error);
Expand Down
9 changes: 6 additions & 3 deletions lib/ui/native_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Future<T?> showNativeDialog<T>(
if (dialogContext.mounted) Navigator.of(dialogContext).pop(result);
},
isDestructiveAction: action.isDestructiveAction,
child: Text(action.text),
child: Text(action.text, style: action.textStyle),
),
)
.toList(),
Expand All @@ -60,7 +60,7 @@ Future<T?> showNativeDialog<T>(
final result = await action.onTap();
if (dialogContext.mounted) Navigator.of(dialogContext).pop(result);
},
child: Text(action.text),
child: Text(action.text, style: action.textStyle),
),
)
.toList(),
Expand All @@ -72,7 +72,7 @@ Future<T?> showNativeDialog<T>(
/// A dialog action which is used to show the actions of a native dialog. Tapping a action will also close the dialog.
class DialogAction<T> {
/// Creates a [DialogAction].
const DialogAction({required this.text, required this.onTap, this.isDestructiveAction = false});
const DialogAction({required this.text, required this.onTap, this.isDestructiveAction = false, this.textStyle});

/// The text of the action.
final String text;
Expand All @@ -82,4 +82,7 @@ class DialogAction<T> {

/// Whether the action is a destructive action. This is only used on iOS.
final bool isDestructiveAction;

/// The style of the action text.
final TextStyle? textStyle;
}