Skip to content

Commit

Permalink
Merge pull request #60 from mono0926/57-add-builder-parameter
Browse files Browse the repository at this point in the history
Add builder parameter
  • Loading branch information
mono0926 authored Mar 28, 2022
2 parents c644518 + 1534d3b commit 3da2d54
Show file tree
Hide file tree
Showing 19 changed files with 246 additions and 142 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.5.0

- Add `builder` parameter
- This resolved #28, #42 and #56

## 1.4.0

- Change `isCupertinoStyle` to return `true` if TargetPlatform is macOS
Expand Down
3 changes: 3 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# https://pub.dev/packages/pedantic_mono
include: package:pedantic_mono/analysis_options.yaml
analyzer:
exclude:
- '**/generated_plugin_registrant.dart'
22 changes: 21 additions & 1 deletion example/lib/pages/alert_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,25 @@ class AlertPage extends StatelessWidget {
logger.info(result);
},
),
ListTile(
title: const Text('OK Dialog (Theme builder)'),
onTap: () async {
final result = await showOkAlertDialog(
context: context,
title: 'Title',
message: 'This is message.',
builder: (context, child) => Theme(
data: ThemeData(
textButtonTheme: TextButtonThemeData(
style: TextButton.styleFrom(primary: Colors.orange),
),
),
child: child,
),
);
logger.info(result);
},
),
ListTile(
title: const Text('OK/Cancel Dialog'),
onTap: () async {
Expand Down Expand Up @@ -199,7 +218,8 @@ class AlertPage extends StatelessWidget {
),
ListTile(
title: const Text(
'Confirmation Dialog (few selections / default selection)'),
'Confirmation Dialog (few selections / default selection)',
),
onTap: () async {
final result = await showConfirmationDialog<int>(
context: context,
Expand Down
8 changes: 5 additions & 3 deletions example/lib/pages/nested_navigator_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ class _RootPage extends StatelessWidget {
ElevatedButton(
child: const Text('Next Page'),
onPressed: () {
Navigator.of(context).push<void>(MaterialPageRoute(
builder: (context) => const _RootPage(),
));
Navigator.of(context).push<void>(
MaterialPageRoute(
builder: (context) => const _RootPage(),
),
);
},
),
],
Expand Down
29 changes: 29 additions & 0 deletions example/lib/pages/sheet_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:adaptive_dialog/adaptive_dialog.dart';
import 'package:example/router.dart';
import 'package:example/util/util.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class SheetPage extends StatelessWidget {
Expand Down Expand Up @@ -84,6 +85,34 @@ class SheetPage extends StatelessWidget {
logger.info(result);
},
),
ListTile(
title: const Text('Theme builder'),
onTap: () async {
final result = await showModalActionSheet<String>(
context: context,
actions: [
const SheetAction(
icon: Icons.info,
label: 'Hello',
key: 'helloKey',
),
],
builder: (context, child) => Theme(
data: ThemeData(
cupertinoOverrideTheme: const CupertinoThemeData(
primaryColor: Colors.orange,
),
listTileTheme: const ListTileThemeData(
textColor: Colors.orange,
iconColor: Colors.orange,
),
),
child: child,
),
);
logger.info(result);
},
),
ListTile(
title: const Text('Default action'),
onTap: () async {
Expand Down
39 changes: 16 additions & 23 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.4.0"
version: "1.5.0"
animations:
dependency: transitive
description:
Expand Down Expand Up @@ -89,7 +89,7 @@ packages:
name: flutter_hooks
url: "https://pub.dartlang.org"
source: hosted
version: "0.18.2"
version: "0.18.2+1"
flutter_lints:
dependency: transitive
description:
Expand Down Expand Up @@ -167,21 +167,21 @@ packages:
name: image_picker
url: "https://pub.dartlang.org"
source: hosted
version: "0.8.4+6"
version: "0.8.4+11"
image_picker_for_web:
dependency: transitive
description:
name: image_picker_for_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.5"
version: "2.1.6"
image_picker_platform_interface:
dependency: transitive
description:
name: image_picker_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.3"
version: "2.4.4"
intl:
dependency: transitive
description:
Expand Down Expand Up @@ -251,7 +251,7 @@ packages:
name: mono_kit
url: "https://pub.dartlang.org"
source: hosted
version: "0.24.0"
version: "0.25.0"
nested:
dependency: transitive
description:
Expand Down Expand Up @@ -280,20 +280,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.11.1"
pedantic_mono:
dependency: "direct dev"
description:
name: pedantic_mono
url: "https://pub.dartlang.org"
source: hosted
version: "1.16.0"
version: "1.17.0"
petitparser:
dependency: transitive
description:
Expand Down Expand Up @@ -431,7 +424,7 @@ packages:
name: tinycolor2
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.0.1"
typed_data:
dependency: transitive
description:
Expand All @@ -445,35 +438,35 @@ packages:
name: url_launcher
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.18"
version: "6.0.20"
url_launcher_android:
dependency: transitive
description:
name: url_launcher_android
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.14"
version: "6.0.15"
url_launcher_ios:
dependency: transitive
description:
name: url_launcher_ios
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.14"
version: "6.0.15"
url_launcher_linux:
dependency: transitive
description:
name: url_launcher_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
version: "3.0.0"
url_launcher_macos:
dependency: transitive
description:
name: url_launcher_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
version: "3.0.0"
url_launcher_platform_interface:
dependency: transitive
description:
Expand All @@ -487,14 +480,14 @@ packages:
name: url_launcher_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.7"
version: "2.0.9"
url_launcher_windows:
dependency: transitive
description:
name: url_launcher_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
version: "3.0.0"
vector_math:
dependency: transitive
description:
Expand All @@ -511,4 +504,4 @@ packages:
version: "5.3.1"
sdks:
dart: ">=2.16.0 <3.0.0"
flutter: ">=2.8.0"
flutter: ">=2.10.0"
5 changes: 3 additions & 2 deletions lib/adaptive_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export 'src/adaptive_style.dart';
export 'src/alert_dialog/alert_dialog.dart';
export 'src/modal_action_sheet/modal_action_sheet.dart';
export 'src/text_input_dialog/text_answer_dialog.dart';
export 'src/text_input_dialog/text_input_dialog.dart';
export 'src/text_input_dialog/show_text_answer_dialog.dart';
export 'src/text_input_dialog/show_text_input_dialog.dart';
export 'src/typedefs.dart';
34 changes: 20 additions & 14 deletions lib/src/alert_dialog/alert_dialog_action.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,35 @@ extension AlertDialogActionListEx<T> on List<AlertDialogAction<T>> {
List<Widget> convertToCupertinoDialogActions({
required ActionCallback<T> onPressed,
}) =>
map((a) => a.convertToCupertinoDialogAction(
onPressed: onPressed,
)).toList();
map(
(a) => a.convertToCupertinoDialogAction(
onPressed: onPressed,
),
).toList();

List<Widget> convertToMaterialDialogActions({
required ActionCallback<T> onPressed,
required Color destructiveColor,
required bool fullyCapitalized,
}) =>
map((a) => a.convertToMaterialDialogAction(
onPressed: onPressed,
destructiveColor: destructiveColor,
fullyCapitalized: fullyCapitalized,
)).toList();
map(
(a) => a.convertToMaterialDialogAction(
onPressed: onPressed,
destructiveColor: destructiveColor,
fullyCapitalized: fullyCapitalized,
),
).toList();

List<SheetAction<T>> convertToSheetActions() =>
where((a) => a.key != OkCancelResult.cancel)
.map((a) => SheetAction(
key: a.key,
label: a.label,
isDefaultAction: a.isDefaultAction,
isDestructiveAction: a.isDestructiveAction,
))
.map(
(a) => SheetAction(
key: a.key,
label: a.label,
isDefaultAction: a.isDefaultAction,
isDestructiveAction: a.isDestructiveAction,
),
)
.toList();

String? findCancelLabel() {
Expand Down
Loading

0 comments on commit 3da2d54

Please sign in to comment.