chore: apply newest iconica linter version

This commit is contained in:
Freek van de Ven 2024-06-06 09:19:19 +02:00 committed by Freek van de Ven
parent 586174c264
commit be6784a3db
15 changed files with 497 additions and 643 deletions

View file

@ -1,29 +1,9 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.
include: package:flutter_iconica_analysis/analysis_options.yaml
# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml
# Possible to overwrite the rules from the package
analyzer:
exclude:
linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
rules:

View file

@ -2,8 +2,8 @@
//
// SPDX-License-Identifier: BSD-3-Clause
import 'package:flutter/material.dart';
import 'package:flutter_dialogs/flutter_dialogs.dart';
import "package:flutter/material.dart";
import "package:flutter_dialogs/flutter_dialogs.dart";
void main() {
runApp(const DialogDemoApp());
@ -13,24 +13,20 @@ class DialogDemoApp extends StatelessWidget {
const DialogDemoApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Dialogs demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const DialogDemoPage(title: 'Flutter Dialogs demo'),
builder: (context, child) {
return BottomAlertDialogConfig(
Widget build(BuildContext context) => MaterialApp(
title: "Flutter Dialogs demo",
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const DialogDemoPage(title: "Flutter Dialogs demo"),
builder: (context, child) => BottomAlertDialogConfig(
child: child ?? const SizedBox.shrink(),
);
},
);
}
),
);
}
class DialogDemoPage extends StatefulWidget {
const DialogDemoPage({super.key, required this.title});
const DialogDemoPage({required this.title, super.key});
final String title;
@ -45,34 +41,32 @@ class _DialogDemoPageState extends State<DialogDemoPage> {
}
@override
Widget build(BuildContext context) {
return PopUpParent(
child: Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Spacer(
flex: 3,
),
ElevatedButton(
onPressed: () {
PopUpService.instance.showIconText('test');
},
child: const Text('Show popup'),
),
const Spacer(),
ElevatedButton(
onPressed: () {
DialogService.instance.showDialog(
Widget build(BuildContext context) => PopUpParent(
child: Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Spacer(
flex: 3,
),
ElevatedButton(
onPressed: () {
PopUpService.instance.showIconText("test");
},
child: const Text("Show popup"),
),
const Spacer(),
ElevatedButton(
onPressed: () async => DialogService.instance.showDialog(
context: context,
builder: (_) => IconicaAlertDialog.multiButton(
closeButton: true,
title: 'title',
body: 'body',
title: "title",
body: "body",
iconButton: (context, onPressed) => IconButton(
onPressed: onPressed,
icon: const Icon(Icons.dangerous),
@ -80,7 +74,7 @@ class _DialogDemoPageState extends State<DialogDemoPage> {
primaryButton: (onPressed, child, context) =>
ElevatedButton(
onPressed: () {
debugPrint('custom button');
debugPrint("custom button");
onPressed.call();
},
child: child,
@ -88,355 +82,315 @@ class _DialogDemoPageState extends State<DialogDemoPage> {
buttons: [
AlertDialogAction(
primary: true,
text: 'test',
text: "test",
onPressed: () {
debugPrint('test');
debugPrint("test");
},
),
AlertDialogAction(
secondary: true,
text: 'test',
text: "test",
onPressed: () {
debugPrint('test');
debugPrint("test");
},
),
],
),
);
},
child: const Text('Show dialog'),
),
const Spacer(
flex: 3,
),
ElevatedButton(
onPressed: () {
showDialog(
),
child: const Text("Show dialog"),
),
const Spacer(
flex: 3,
),
ElevatedButton(
onPressed: () async => showDialog(
context: context,
builder: (context) {
return BottomAlertDialog.singleButton(
closeButton: true,
title: const Text('Confirm'),
body: const Text(
'Click the button to dismiss',
),
buttonText: 'Ok',
onPressed: () {
Navigator.pop(context);
},
);
},
);
},
child: const Text('BottomAlertDialog.singleButton'),
),
Container(
height: 10,
),
ElevatedButton(
onPressed: () {
showDialog(
builder: (context) => BottomAlertDialog.singleButton(
closeButton: true,
title: const Text("Confirm"),
body: const Text(
"Click the button to dismiss",
),
buttonText: "Ok",
onPressed: () {
Navigator.pop(context);
},
),
),
child: const Text("BottomAlertDialog.singleButton"),
),
Container(
height: 10,
),
ElevatedButton(
onPressed: () async => showDialog(
context: context,
builder: (context) {
return BottomAlertDialog.multiButton(
title: const Text('Favorite Color'),
body: const Text(
'Choose your favorite color',
builder: (context) => BottomAlertDialog.multiButton(
title: const Text("Favorite Color"),
body: const Text(
"Choose your favorite color",
),
buttons: [
BottomAlertDialogAction(
text: "Red",
onPressed: () {
Navigator.pop(context);
},
buttonType: ButtonType.primary,
),
buttons: [
BottomAlertDialogAction(
text: 'Red',
onPressed: () {
Navigator.pop(context);
},
buttonType: ButtonType.primary,
),
BottomAlertDialogAction(
text: 'Green',
onPressed: () {
Navigator.pop(context);
},
buttonType: ButtonType.primary,
),
BottomAlertDialogAction(
text: 'Blue',
onPressed: () {
Navigator.pop(context);
},
buttonType: ButtonType.primary,
),
BottomAlertDialogAction(
text: 'Yellow',
onPressed: () {
Navigator.pop(context);
},
buttonType: ButtonType.primary,
),
],
);
},
);
},
child: const Text('BottomAlertDialog.multiButton'),
),
Container(
height: 10,
),
ElevatedButton(
onPressed: () {
showDialog(
BottomAlertDialogAction(
text: "Green",
onPressed: () {
Navigator.pop(context);
},
buttonType: ButtonType.primary,
),
BottomAlertDialogAction(
text: "Blue",
onPressed: () {
Navigator.pop(context);
},
buttonType: ButtonType.primary,
),
BottomAlertDialogAction(
text: "Yellow",
onPressed: () {
Navigator.pop(context);
},
buttonType: ButtonType.primary,
),
],
),
),
child: const Text("BottomAlertDialog.multiButton"),
),
Container(
height: 10,
),
ElevatedButton(
onPressed: () async => showDialog(
context: context,
builder: (context) {
return BottomAlertDialog.singleButtonIcon(
closeButton: true,
title: const Text('Confirm'),
body: const Text(
'Click the button to dismiss',
),
icon: const Icon(
Icons.info,
color: Colors.blue,
),
buttonText: 'Ok',
onPressed: () {
Navigator.pop(context);
},
);
},
);
},
child: const Text('BottomAlertDialog.singleButtonIcon'),
),
Container(
height: 10,
),
ElevatedButton(
onPressed: () {
showDialog(
builder: (context) => BottomAlertDialog.singleButtonIcon(
closeButton: true,
title: const Text("Confirm"),
body: const Text(
"Click the button to dismiss",
),
icon: const Icon(
Icons.info,
color: Colors.blue,
),
buttonText: "Ok",
onPressed: () {
Navigator.pop(context);
},
),
),
child: const Text("BottomAlertDialog.singleButtonIcon"),
),
Container(
height: 10,
),
ElevatedButton(
onPressed: () async => showDialog(
context: context,
builder: (context) {
return BottomAlertDialog.icon(
closeButton: true,
title: const Text('Favorite Car'),
body: const Text(
'Choose your favorite car brand',
builder: (context) => BottomAlertDialog.icon(
closeButton: true,
title: const Text("Favorite Car"),
body: const Text(
"Choose your favorite car brand",
),
icon: const Icon(
Icons.car_rental_sharp,
),
buttons: [
ElevatedButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text("BMW"),
),
icon: const Icon(
Icons.car_rental_sharp,
ElevatedButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text("Opel"),
),
buttons: [
ElevatedButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text('BMW'),
),
ElevatedButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text('Opel'),
),
ElevatedButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text('Mercedes'),
),
ElevatedButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text('Kia'),
),
ElevatedButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text('Skoda'),
),
],
);
},
);
},
child: const Text('BottomAlertDialog.icon'),
),
Container(
height: 10,
),
ElevatedButton(
onPressed: () {
showDialog(
ElevatedButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text("Mercedes"),
),
ElevatedButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text("Kia"),
),
ElevatedButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text("Skoda"),
),
],
),
),
child: const Text("BottomAlertDialog.icon"),
),
Container(
height: 10,
),
ElevatedButton(
onPressed: () async => showDialog(
context: context,
builder: (context) {
return BottomAlertDialog.yesOrNo(
title: const Text('Question'),
body: const Text(
'Do you really wanna do this?',
),
onYes: () {
Navigator.of(context).pop();
},
onNo: () {
Navigator.of(context).pop();
},
);
},
);
},
child: const Text('BottomAlertDialog.yesOrNo'),
),
Container(
height: 10,
),
ElevatedButton(
onPressed: () {
showDialog(
builder: (context) => BottomAlertDialog.yesOrNo(
title: const Text("Question"),
body: const Text(
"Do you really wanna do this?",
),
onYes: () {
Navigator.of(context).pop();
},
onNo: () {
Navigator.of(context).pop();
},
),
),
child: const Text("BottomAlertDialog.yesOrNo"),
),
Container(
height: 10,
),
ElevatedButton(
onPressed: () async => showDialog(
context: context,
builder: (context) {
return BottomAlertDialog.yesOrNoIcon(
title: const Text('Question'),
body: const Text(
'Do you really wanna do this?',
),
onYes: () {
Navigator.of(context).pop();
},
onNo: () {
Navigator.of(context).pop();
},
icon: const Icon(
Icons.question_mark_sharp,
color: Colors.red,
),
);
},
);
},
child: const Text('BottomAlertDialog.yesOrNoIcon'),
),
Container(
height: 10,
),
ElevatedButton(
onPressed: () {
showDialog(
builder: (context) => BottomAlertDialog.yesOrNoIcon(
title: const Text("Question"),
body: const Text(
"Do you really wanna do this?",
),
onYes: () {
Navigator.of(context).pop();
},
onNo: () {
Navigator.of(context).pop();
},
icon: const Icon(
Icons.question_mark_sharp,
color: Colors.red,
),
),
),
child: const Text("BottomAlertDialog.yesOrNoIcon"),
),
Container(
height: 10,
),
ElevatedButton(
onPressed: () async => showDialog(
context: context,
builder: (context) {
return BottomAlertDialog.custom(
closeButton: true,
body: SizedBox(
height: 100,
child: Column(
children: [
const Text('Custom Dialog with PageView'),
Flexible(
child: PageView(
children: [
Container(
child:
const Center(child: Text('Page 1')),
),
Container(
child:
const Center(child: Text('Page 2')),
),
Container(
child:
const Center(child: Text('Page 3')),
),
],
),
builder: (context) => BottomAlertDialog.custom(
closeButton: true,
body: SizedBox(
height: 100,
child: Column(
children: [
const Text("Custom Dialog with PageView"),
Flexible(
child: PageView(
children: const [
Center(child: Text("Page 1")),
Center(child: Text("Page 2")),
Center(child: Text("Page 3")),
],
),
),
],
),
),
buttons: [
ElevatedButton(
onPressed: () {
Navigator.of(context).pop();
},
child: const Text("Ok"),
),
],
),
),
child: const Text("BottomAlertDialog.custom"),
),
Container(
height: 10,
),
ElevatedButton(
child: const Text("Multiple chained dialogs"),
onPressed: () async => showDialog(
context: context,
builder: (context) => BottomAlertDialog.yesOrNo(
closeButton: true,
title: const Text("Pokémon"),
body: const Text(
"Do you want to choose your starter Pokémon?",
),
onYes: () {
Navigator.pop(context);
showDialog(
context: context,
builder: (context) => BottomAlertDialog.multiButton(
title: const Text("Starter Pokémon"),
body: const Text("Choose a starter Pokémon"),
buttons: [
BottomAlertDialogAction(
text: "Turtwig",
buttonType: ButtonType.secondary,
onPressed: () =>
_showDoneDialog(context, "Turtwig"),
),
BottomAlertDialogAction(
text: "Chimchar",
buttonType: ButtonType.secondary,
onPressed: () =>
_showDoneDialog(context, "Chimchar"),
),
BottomAlertDialogAction(
text: "Piplup",
buttonType: ButtonType.secondary,
onPressed: () =>
_showDoneDialog(context, "Piplup"),
),
],
),
),
buttons: [
ElevatedButton(
onPressed: () {
Navigator.of(context).pop();
},
child: const Text('Ok'),
),
],
);
},
);
},
child: const Text('BottomAlertDialog.custom'),
),
Container(
height: 10,
),
ElevatedButton(
child: const Text('Multiple chained dialogs'),
onPressed: () {
showDialog(
context: context,
builder: (context) {
return BottomAlertDialog.yesOrNo(
closeButton: true,
title: const Text('Pokémon'),
body: const Text(
'Do you want to choose your starter Pokémon?',
),
onYes: () {
Navigator.pop(context);
showDialog(
context: context,
builder: (context) => BottomAlertDialog.multiButton(
title: const Text('Starter Pokémon'),
body: const Text('Choose a starter Pokémon'),
buttons: [
BottomAlertDialogAction(
text: 'Turtwig',
buttonType: ButtonType.secondary,
onPressed: () =>
_showDoneDialog(context, 'Turtwig'),
),
BottomAlertDialogAction(
text: 'Chimchar',
buttonType: ButtonType.secondary,
onPressed: () =>
_showDoneDialog(context, 'Chimchar'),
),
BottomAlertDialogAction(
text: 'Piplup',
buttonType: ButtonType.secondary,
onPressed: () =>
_showDoneDialog(context, 'Piplup'),
),
],
),
);
},
onNo: () => Navigator.pop(context),
);
},
);
},
),
],
);
},
onNo: () => Navigator.pop(context),
),
),
),
const Spacer(
flex: 3,
),
],
),
),
),
),
);
}
);
void _showDoneDialog(BuildContext context, String name) {
Future<void> _showDoneDialog(BuildContext context, String name) async {
Navigator.pop(context);
showDialog(
await showDialog(
context: context,
builder: (context) => BottomAlertDialog.icon(
title: const Text('Good choice!'),
title: const Text("Good choice!"),
icon: Icon(
Icons.catching_pokemon,
color: Color(name.hashCode).withAlpha(255),
),
body: Text('You chose $name to be your starter Pokémon.'),
buttons: [
const CloseButton(
body: Text("You chose $name to be your starter Pokémon."),
buttons: const [
CloseButton(
color: Colors.green,
),
],

View file

@ -1,93 +1,25 @@
name: example
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+1
environment:
sdk: '>=2.18.2 <3.0.0'
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
flutter_dialogs:
path: ../
dev_dependencies:
flutter_test:
sdk: flutter
flutter_iconica_analysis:
git:
url: https://github.com/Iconica-Development/flutter_iconica_analysis
ref: 7.0.0
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^2.0.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter packages.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages

View file

@ -9,26 +9,25 @@
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:example/main.dart';
import "package:example/main.dart";
import "package:flutter/material.dart";
import "package:flutter_test/flutter_test.dart";
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
testWidgets("Counter increments smoke test", (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const DialogDemoApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
expect(find.text("0"), findsOneWidget);
expect(find.text("1"), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
expect(find.text("0"), findsNothing);
expect(find.text("1"), findsOneWidget);
});
}

View file

@ -4,9 +4,9 @@
///
library flutter_dialogs;
export './src/alert_dialogs.dart';
export './src/dialogs.dart';
export './src/popup_parent.dart';
export './src/popup_service.dart';
export './src/bottom_alert_dialog_config.dart';
export './src/bottom_alert_dialog.dart';
export "./src/alert_dialogs.dart";
export "./src/bottom_alert_dialog.dart";
export "./src/bottom_alert_dialog_config.dart";
export "./src/dialogs.dart";
export "./src/popup_parent.dart";
export "./src/popup_service.dart";

View file

@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: BSD-3-Clause
import 'package:flutter/material.dart';
import "package:flutter/material.dart";
class AlertDialogAction {
AlertDialogAction({
@ -256,8 +256,8 @@ class IconicaAlertDialog extends StatelessWidget {
bool otherSecondary,
VoidCallback onYes,
VoidCallback onNo, {
String no = 'No',
String yes = 'Yes',
String no = "No",
String yes = "Yes",
}) =>
<AlertDialogAction>[
if (focusYes) ...[

View file

@ -2,16 +2,16 @@
//
// SPDX-License-Identifier: BSD-3-Clause
import 'package:flutter/material.dart';
import 'package:flutter_dialogs/src/bottom_alert_dialog_config.dart';
import "package:flutter/material.dart";
import "package:flutter_dialogs/src/bottom_alert_dialog_config.dart";
class BottomAlertDialogAction extends StatelessWidget {
const BottomAlertDialogAction({
required this.text,
required this.onPressed,
this.buttonType = ButtonType.tertiary,
Key? key,
}) : super(key: key);
super.key,
});
final String text;
final ButtonType buttonType;
final VoidCallback onPressed;
@ -21,9 +21,9 @@ class BottomAlertDialogAction extends StatelessWidget {
var config = BottomAlertDialogConfig.of(context);
var buttonBuilder = config.buttonBuilder;
var translatedText = text;
if (text == 'shell.alertdialog.button.yes') {
if (text == "shell.alertdialog.button.yes") {
translatedText = config.yesText;
} else if (text == 'shell.alertdialog.button.no') {
} else if (text == "shell.alertdialog.button.no") {
translatedText = config.noText;
}
return buttonBuilder.call(
@ -41,14 +41,13 @@ class BottomAlertDialog extends StatelessWidget {
required List<Widget> buttons,
List<BottomAlertDialogAction>? actions,
bool? closeButton,
}) {
return BottomAlertDialog._(
closeButton: closeButton,
buttons: buttons,
actions: actions,
body: (_) => body,
);
}
}) =>
BottomAlertDialog._(
closeButton: closeButton,
buttons: buttons,
actions: actions,
body: (_) => body,
);
factory BottomAlertDialog.singleButtonIcon({
required Widget title,
@ -58,21 +57,20 @@ class BottomAlertDialog extends StatelessWidget {
required VoidCallback onPressed,
ButtonType buttonType = ButtonType.tertiary,
bool? closeButton,
}) {
return BottomAlertDialog.icon(
closeButton: closeButton,
title: title,
icon: icon,
body: body,
buttons: [
BottomAlertDialogAction(
text: buttonText,
buttonType: buttonType,
onPressed: onPressed,
),
],
);
}
}) =>
BottomAlertDialog.icon(
closeButton: closeButton,
title: title,
icon: icon,
body: body,
buttons: [
BottomAlertDialogAction(
text: buttonText,
buttonType: buttonType,
onPressed: onPressed,
),
],
);
factory BottomAlertDialog.yesOrNoIcon({
required Widget title,
@ -83,15 +81,14 @@ class BottomAlertDialog extends StatelessWidget {
bool focusYes = true,
bool otherSecondary = false,
bool? closeButton,
}) {
return BottomAlertDialog.icon(
closeButton: closeButton,
title: title,
body: body,
icon: icon,
buttons: _getYesNoDialogButtons(focusYes, otherSecondary, onYes, onNo),
);
}
}) =>
BottomAlertDialog.icon(
closeButton: closeButton,
title: title,
body: body,
icon: icon,
buttons: _getYesNoDialogButtons(focusYes, otherSecondary, onYes, onNo),
);
factory BottomAlertDialog.yesOrNo({
required Widget title,
@ -101,15 +98,14 @@ class BottomAlertDialog extends StatelessWidget {
bool focusYes = true,
bool otherSecondary = false,
bool? closeButton,
}) {
return BottomAlertDialog.multiButton(
closeButton: closeButton,
title: title,
body: body,
buttons: const [],
actions: _getYesNoDialogButtons(focusYes, otherSecondary, onYes, onNo),
);
}
}) =>
BottomAlertDialog.multiButton(
closeButton: closeButton,
title: title,
body: body,
buttons: const [],
actions: _getYesNoDialogButtons(focusYes, otherSecondary, onYes, onNo),
);
factory BottomAlertDialog.icon({
required Widget title,
@ -118,26 +114,25 @@ class BottomAlertDialog extends StatelessWidget {
required List<Widget> buttons,
List<BottomAlertDialogAction>? actions,
bool? closeButton,
}) {
return BottomAlertDialog._(
closeButton: closeButton,
buttons: buttons,
actions: actions,
body: (context) => Column(
children: [
icon,
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: title,
),
Padding(
padding: const EdgeInsets.only(top: 20, left: 20, right: 20),
child: body,
),
],
),
);
}
}) =>
BottomAlertDialog._(
closeButton: closeButton,
buttons: buttons,
actions: actions,
body: (context) => Column(
children: [
icon,
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: title,
),
Padding(
padding: const EdgeInsets.only(top: 20, left: 20, right: 20),
child: body,
),
],
),
);
factory BottomAlertDialog.multiButton({
required Widget title,
@ -145,27 +140,26 @@ class BottomAlertDialog extends StatelessWidget {
required List<BottomAlertDialogAction> buttons,
List<BottomAlertDialogAction>? actions,
bool? closeButton,
}) {
return BottomAlertDialog._(
closeButton: closeButton,
buttons: buttons,
actions: actions,
body: (context) => Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20,
}) =>
BottomAlertDialog._(
closeButton: closeButton,
buttons: buttons,
actions: actions,
body: (context) => Column(
children: [
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20,
),
child: title,
),
child: title,
),
Padding(
padding: const EdgeInsets.only(top: 20, left: 20, right: 20),
child: body,
),
],
),
);
}
Padding(
padding: const EdgeInsets.only(top: 20, left: 20, right: 20),
child: body,
),
],
),
);
factory BottomAlertDialog.singleButton({
required Widget title,
required Widget body,
@ -173,20 +167,19 @@ class BottomAlertDialog extends StatelessWidget {
required VoidCallback onPressed,
ButtonType buttonType = ButtonType.tertiary,
bool? closeButton,
}) {
return BottomAlertDialog.multiButton(
closeButton: closeButton,
title: title,
body: body,
buttons: [
BottomAlertDialogAction(
text: buttonText,
onPressed: onPressed,
buttonType: buttonType,
),
],
);
}
}) =>
BottomAlertDialog.multiButton(
closeButton: closeButton,
title: title,
body: body,
buttons: [
BottomAlertDialogAction(
text: buttonText,
onPressed: onPressed,
buttonType: buttonType,
),
],
);
const BottomAlertDialog._({
required this.buttons,
required this.body,
@ -203,34 +196,33 @@ class BottomAlertDialog extends StatelessWidget {
bool otherSecondary,
VoidCallback onYes,
VoidCallback onNo,
) {
return <BottomAlertDialogAction>[
if (focusYes) ...[
) =>
<BottomAlertDialogAction>[
if (focusYes) ...[
BottomAlertDialogAction(
text: "shell.alertdialog.button.no",
buttonType:
otherSecondary ? ButtonType.secondary : ButtonType.tertiary,
onPressed: onNo,
),
],
BottomAlertDialogAction(
text: 'shell.alertdialog.button.no',
buttonType:
otherSecondary ? ButtonType.secondary : ButtonType.tertiary,
onPressed: onNo,
text: "shell.alertdialog.button.yes",
buttonType: focusYes
? ButtonType.primary
: otherSecondary
? ButtonType.secondary
: ButtonType.tertiary,
onPressed: onYes,
),
],
BottomAlertDialogAction(
text: 'shell.alertdialog.button.yes',
buttonType: focusYes
? ButtonType.primary
: otherSecondary
? ButtonType.secondary
: ButtonType.tertiary,
onPressed: onYes,
),
if (!focusYes) ...[
BottomAlertDialogAction(
text: 'shell.alertdialog.button.no',
buttonType: ButtonType.primary,
onPressed: onNo,
),
],
];
}
if (!focusYes) ...[
BottomAlertDialogAction(
text: "shell.alertdialog.button.no",
buttonType: ButtonType.primary,
onPressed: onNo,
),
],
];
@override
Widget build(BuildContext context) {

View file

@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: BSD-3-Clause
import 'package:flutter/material.dart';
import "package:flutter/material.dart";
enum ButtonType {
primary,
@ -27,8 +27,8 @@ class BottomAlertDialogConfig extends InheritedWidget {
required super.child,
ButtonBuilder? buttonBuilder,
CloseButtonBuilder? closeButtonBuilder,
this.yesText = 'Yes',
this.noText = 'No',
this.yesText = "Yes",
this.noText = "No",
this.backgroundColor,
super.key,
}) : _buttonBuilder = buttonBuilder,
@ -54,9 +54,9 @@ class BottomAlertDialogConfig extends InheritedWidget {
return ElevatedButton(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all(theme.colorScheme.primary),
foregroundColor: MaterialStateProperty.all(Colors.black),
shape: MaterialStateProperty.all(
WidgetStateProperty.all(theme.colorScheme.primary),
foregroundColor: WidgetStateProperty.all(Colors.black),
shape: WidgetStateProperty.all(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15),
side: BorderSide(color: theme.colorScheme.primary),
@ -69,9 +69,9 @@ class BottomAlertDialogConfig extends InheritedWidget {
case ButtonType.secondary:
return ElevatedButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.white),
foregroundColor: MaterialStateProperty.all(Colors.black),
shape: MaterialStateProperty.all(
backgroundColor: WidgetStateProperty.all(Colors.white),
foregroundColor: WidgetStateProperty.all(Colors.black),
shape: WidgetStateProperty.all(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15),
side: BorderSide(color: theme.colorScheme.primary),
@ -84,10 +84,10 @@ class BottomAlertDialogConfig extends InheritedWidget {
case ButtonType.tertiary:
return ElevatedButton(
style: ButtonStyle(
shadowColor: MaterialStateProperty.all(Colors.transparent),
backgroundColor: MaterialStateProperty.all(Colors.white),
foregroundColor: MaterialStateProperty.all(Colors.black),
shape: MaterialStateProperty.all(
shadowColor: WidgetStateProperty.all(Colors.transparent),
backgroundColor: WidgetStateProperty.all(Colors.white),
foregroundColor: WidgetStateProperty.all(Colors.black),
shape: WidgetStateProperty.all(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15),
side: const BorderSide(color: Colors.white),
@ -102,21 +102,19 @@ class BottomAlertDialogConfig extends InheritedWidget {
CloseButtonBuilder get closeButtonBuilder =>
_closeButtonBuilder ??
(context, {required onPressed}) {
return IconButton(
onPressed: onPressed,
icon: const Icon(
Icons.close,
size: 25,
color: Colors.black,
),
);
};
(context, {required onPressed}) => IconButton(
onPressed: onPressed,
icon: const Icon(
Icons.close,
size: 25,
color: Colors.black,
),
);
static BottomAlertDialogConfig of(BuildContext context) {
var result =
context.dependOnInheritedWidgetOfExactType<BottomAlertDialogConfig>();
assert(result != null, 'No BottomAlertDialogConfig found in context');
assert(result != null, "No BottomAlertDialogConfig found in context");
return result!;
}

View file

@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: BSD-3-Clause
import 'package:flutter/material.dart' as m;
import "package:flutter/material.dart" as m;
class DialogService {
static DialogService? _instance;

View file

@ -2,8 +2,8 @@
//
// SPDX-License-Identifier: BSD-3-Clause
import 'package:flutter/material.dart';
import 'package:flutter_dialogs/src/popup_data.dart';
import "package:flutter/material.dart";
import "package:flutter_dialogs/src/popup_data.dart";
class PopUp extends StatelessWidget {
const PopUp({
@ -18,8 +18,7 @@ class PopUp extends StatelessWidget {
@override
Widget build(BuildContext context) {
var style = Theme.of(context).textTheme.bodyLarge?.copyWith(
color:
popUpData.textColor ?? Theme.of(context).colorScheme.background,
color: popUpData.textColor ?? Theme.of(context).colorScheme.surface,
fontWeight: FontWeight.w500,
fontSize: 14,
height: 1.571,
@ -48,7 +47,7 @@ class PopUp extends StatelessWidget {
child: Padding(
padding: const EdgeInsets.only(left: 20, bottom: 5),
child: Text(
popUpData.text ?? '',
popUpData.text ?? "",
style: style,
),
),

View file

@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: BSD-3-Clause
import 'package:flutter/material.dart';
import "package:flutter/material.dart";
class PopUpData {
PopUpData(

View file

@ -2,12 +2,12 @@
//
// SPDX-License-Identifier: BSD-3-Clause
import 'dart:collection';
import "dart:collection";
import 'package:flutter/material.dart';
import 'package:flutter_dialogs/src/popup.dart';
import 'package:flutter_dialogs/src/popup_data.dart';
import 'package:flutter_dialogs/src/popup_service.dart';
import "package:flutter/material.dart";
import "package:flutter_dialogs/src/popup.dart";
import "package:flutter_dialogs/src/popup_data.dart";
import "package:flutter_dialogs/src/popup_service.dart";
class PopUpParent extends StatefulWidget {
const PopUpParent({required this.child, super.key});

View file

@ -2,9 +2,9 @@
//
// SPDX-License-Identifier: BSD-3-Clause
import 'package:flutter/material.dart';
import 'package:flutter_dialogs/src/popup_data.dart';
import 'package:flutter_dialogs/src/popup_parent.dart';
import "package:flutter/material.dart";
import "package:flutter_dialogs/src/popup_data.dart";
import "package:flutter_dialogs/src/popup_parent.dart";
class PopUpService {
static PopUpService? _instance;

View file

@ -17,6 +17,6 @@ dev_dependencies:
flutter_iconica_analysis:
git:
url: https://github.com/Iconica-Development/flutter_iconica_analysis
ref: 6.0.0
ref: 7.0.0
flutter:

View file

@ -2,10 +2,10 @@
//
// SPDX-License-Identifier: BSD-3-Clause
import 'package:flutter_test/flutter_test.dart';
import "package:flutter_test/flutter_test.dart";
void main() {
test('', () {
test("", () {
expect(true, true);
});
}