From 28c299377cfbac8645d89dd6bc7c785cea669f9c Mon Sep 17 00:00:00 2001 From: Niels Rijnberg Date: Wed, 24 Sep 2025 13:43:53 +0200 Subject: [PATCH 1/5] Add native dialog textstyle --- example/lib/main.dart | 22 ++++++++++++++++++++++ lib/ui/native_dialog.dart | 9 ++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 70a0daa..be00332 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -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'; @@ -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'), + ), ], ), ), diff --git a/lib/ui/native_dialog.dart b/lib/ui/native_dialog.dart index c678ee8..8796183 100644 --- a/lib/ui/native_dialog.dart +++ b/lib/ui/native_dialog.dart @@ -39,7 +39,7 @@ Future showNativeDialog( if (dialogContext.mounted) Navigator.of(dialogContext).pop(result); }, isDestructiveAction: action.isDestructiveAction, - child: Text(action.text), + child: Text(action.text, style: action.textStyle), ), ) .toList(), @@ -60,7 +60,7 @@ Future showNativeDialog( 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(), @@ -72,7 +72,7 @@ Future showNativeDialog( /// A dialog action which is used to show the actions of a native dialog. Tapping a action will also close the dialog. class DialogAction { /// 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; @@ -82,4 +82,7 @@ class DialogAction { /// 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; } From fd8150b32a22f22625626161b155606bc7398ff3 Mon Sep 17 00:00:00 2001 From: Niels Rijnberg Date: Wed, 24 Sep 2025 14:14:14 +0200 Subject: [PATCH 2/5] There is no build runner in deps --- .github/workflows/flutter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/flutter.yml b/.github/workflows/flutter.yml index 2b1d421..226bf1c 100644 --- a/.github/workflows/flutter.yml +++ b/.github/workflows/flutter.yml @@ -26,7 +26,7 @@ jobs: run: dart format . -o none --set-exit-if-changed - name: Run code generation - run: cd example && flutter pub get && flutter pub run build_runner build && cd .. + run: cd example && flutter pub get && cd .. - name: Analyze project source run: flutter analyze --fatal-infos From 40444b4614a796b120765f8c3342869db9cf7215 Mon Sep 17 00:00:00 2001 From: Niels Rijnberg Date: Wed, 24 Sep 2025 14:17:33 +0200 Subject: [PATCH 3/5] Re-enable build runner for example project --- .github/workflows/flutter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/flutter.yml b/.github/workflows/flutter.yml index 226bf1c..2b1d421 100644 --- a/.github/workflows/flutter.yml +++ b/.github/workflows/flutter.yml @@ -26,7 +26,7 @@ jobs: run: dart format . -o none --set-exit-if-changed - name: Run code generation - run: cd example && flutter pub get && cd .. + run: cd example && flutter pub get && flutter pub run build_runner build && cd .. - name: Analyze project source run: flutter analyze --fatal-infos From ae18745e21e1c1a37bfb6ad6e6d28c5a7c5fab3b Mon Sep 17 00:00:00 2001 From: Niels Rijnberg Date: Wed, 24 Sep 2025 14:23:49 +0200 Subject: [PATCH 4/5] Update json serializable --- example/pubspec.lock | 4 ++-- example/pubspec.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 3a3df14..7b50b2c 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -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: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index b871b5b..162d1c6 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -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 From 1b42de1777b2ffecebfc8b06164061c4c41c0158 Mon Sep 17 00:00:00 2001 From: Niels Rijnberg Date: Wed, 24 Sep 2025 14:27:03 +0200 Subject: [PATCH 5/5] Fix lint --- lib/common/result/result.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/common/result/result.dart b/lib/common/result/result.dart index 889a1a8..e055ca8 100644 --- a/lib/common/result/result.dart +++ b/lib/common/result/result.dart @@ -46,7 +46,7 @@ sealed class Result { required TResult Function(T response) success, required TResult Function(Object? error) error, }) { - if (this.isSuccess) { + if (isSuccess) { return success((this as Success).value); } else { return error((this as Failure).error);