mirror of
https://github.com/Iconica-Development/flutter_dialogs.git
synced 2025-05-18 10:53:45 +02:00
fix: add CI and linter
This commit is contained in:
parent
d9f7b51336
commit
fcd23e78b6
10 changed files with 269 additions and 252 deletions
14
.github/workflows/component-ci.yml
vendored
Normal file
14
.github/workflows/component-ci.yml
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
name: Iconica Standard Component CI Workflow
|
||||
# Workflow Caller version: 2.0.0
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
call-global-iconica-workflow:
|
||||
uses: Iconica-Development/.github/.github/workflows/component-ci.yml@master
|
||||
secrets: inherit
|
||||
permissions: write-all
|
||||
with:
|
||||
subfolder: "." # add optional subfolder to run workflow in
|
|
@ -1,3 +1,7 @@
|
|||
## 0.0.2
|
||||
|
||||
- Added CI and linter
|
||||
|
||||
## 0.0.1
|
||||
|
||||
- Initial port
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
include: package:flutter_lints/flutter.yaml
|
||||
include: package:flutter_iconica_analysis/analysis_options.yaml
|
||||
|
||||
# Additional information about this file can be found at
|
||||
# https://dart.dev/guides/language/analysis-options
|
||||
# Possible to overwrite the rules from the package
|
||||
|
||||
analyzer:
|
||||
exclude:
|
||||
|
||||
linter:
|
||||
rules:
|
|
@ -1,10 +1,10 @@
|
|||
// SPDX-FileCopyrightText: 2022 Iconica
|
||||
//
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
///
|
||||
library flutter_dialogs;
|
||||
|
||||
export './src/dialogs.dart';
|
||||
export './src/popup_service.dart';
|
||||
export './src/popup_parent.dart';
|
||||
export './src/alert_dialogs.dart';
|
||||
export './src/dialogs.dart';
|
||||
export './src/popup_parent.dart';
|
||||
export './src/popup_service.dart';
|
||||
|
|
|
@ -5,20 +5,19 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class AlertDialogAction {
|
||||
final String text;
|
||||
final bool primary;
|
||||
final bool secondary;
|
||||
final VoidCallback onPressed;
|
||||
|
||||
AlertDialogAction({
|
||||
required this.text,
|
||||
required this.onPressed,
|
||||
this.primary = false,
|
||||
this.secondary = false,
|
||||
required this.onPressed,
|
||||
}) : assert(
|
||||
!(primary && secondary),
|
||||
"AlertDialogAction can't be primary and secondary at the same time",
|
||||
);
|
||||
final String text;
|
||||
final bool primary;
|
||||
final bool secondary;
|
||||
final VoidCallback onPressed;
|
||||
}
|
||||
|
||||
typedef ButtonCallback = Widget Function(
|
||||
|
@ -33,13 +32,6 @@ typedef IconButtonCallback = Widget Function(
|
|||
);
|
||||
|
||||
class IconicaAlertDialog extends StatelessWidget {
|
||||
final List<AlertDialogAction> buttons;
|
||||
final WidgetBuilder body;
|
||||
final bool? closeButton;
|
||||
final ButtonCallback? primaryButton;
|
||||
final ButtonCallback? secondaryButton;
|
||||
final IconButtonCallback? iconButton;
|
||||
|
||||
const IconicaAlertDialog._({
|
||||
required this.buttons,
|
||||
required this.body,
|
||||
|
@ -59,8 +51,8 @@ class IconicaAlertDialog extends StatelessWidget {
|
|||
ButtonCallback? primaryButton,
|
||||
ButtonCallback? secondaryButton,
|
||||
IconButtonCallback? iconButton,
|
||||
}) {
|
||||
return IconicaAlertDialog.multiButton(
|
||||
}) =>
|
||||
IconicaAlertDialog.multiButton(
|
||||
primaryButton: primaryButton,
|
||||
secondaryButton: secondaryButton,
|
||||
iconButton: iconButton,
|
||||
|
@ -75,7 +67,6 @@ class IconicaAlertDialog extends StatelessWidget {
|
|||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
factory IconicaAlertDialog.multiButton({
|
||||
required String title,
|
||||
|
@ -85,8 +76,8 @@ class IconicaAlertDialog extends StatelessWidget {
|
|||
ButtonCallback? primaryButton,
|
||||
ButtonCallback? secondaryButton,
|
||||
IconButtonCallback? iconButton,
|
||||
}) {
|
||||
return IconicaAlertDialog._(
|
||||
}) =>
|
||||
IconicaAlertDialog._(
|
||||
primaryButton: primaryButton,
|
||||
secondaryButton: secondaryButton,
|
||||
iconButton: iconButton,
|
||||
|
@ -100,9 +91,9 @@ class IconicaAlertDialog extends StatelessWidget {
|
|||
),
|
||||
child: Text(
|
||||
title,
|
||||
style: Theme.of(context).textTheme.headline6?.copyWith(
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).textTheme.bodyText2?.color,
|
||||
color: Theme.of(context).textTheme.bodyMedium?.color,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
|
@ -111,14 +102,13 @@ class IconicaAlertDialog extends StatelessWidget {
|
|||
padding: const EdgeInsets.only(top: 20, left: 20, right: 20),
|
||||
child: Text(
|
||||
body,
|
||||
style: Theme.of(context).textTheme.bodyText2,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
factory IconicaAlertDialog.icon({
|
||||
required String title,
|
||||
|
@ -129,8 +119,8 @@ class IconicaAlertDialog extends StatelessWidget {
|
|||
ButtonCallback? primaryButton,
|
||||
ButtonCallback? secondaryButton,
|
||||
IconButtonCallback? iconButton,
|
||||
}) {
|
||||
return IconicaAlertDialog._(
|
||||
}) =>
|
||||
IconicaAlertDialog._(
|
||||
primaryButton: primaryButton,
|
||||
secondaryButton: secondaryButton,
|
||||
iconButton: iconButton,
|
||||
|
@ -143,7 +133,7 @@ class IconicaAlertDialog extends StatelessWidget {
|
|||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
child: Text(
|
||||
title,
|
||||
style: Theme.of(context).textTheme.headline6?.copyWith(
|
||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
|
@ -153,14 +143,13 @@ class IconicaAlertDialog extends StatelessWidget {
|
|||
padding: const EdgeInsets.only(top: 20, left: 20, right: 20),
|
||||
child: Text(
|
||||
body,
|
||||
style: Theme.of(context).textTheme.bodyText2,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
factory IconicaAlertDialog.yesOrNo({
|
||||
required String title,
|
||||
|
@ -173,8 +162,8 @@ class IconicaAlertDialog extends StatelessWidget {
|
|||
ButtonCallback? primaryButton,
|
||||
ButtonCallback? secondaryButton,
|
||||
IconButtonCallback? iconButton,
|
||||
}) {
|
||||
return IconicaAlertDialog.multiButton(
|
||||
}) =>
|
||||
IconicaAlertDialog.multiButton(
|
||||
primaryButton: primaryButton,
|
||||
secondaryButton: secondaryButton,
|
||||
iconButton: iconButton,
|
||||
|
@ -183,7 +172,6 @@ class IconicaAlertDialog extends StatelessWidget {
|
|||
body: body,
|
||||
buttons: _getYesNoDialogButtons(focusYes, otherSecondary, onYes, onNo),
|
||||
);
|
||||
}
|
||||
|
||||
factory IconicaAlertDialog.yesOrNoIcon({
|
||||
required String title,
|
||||
|
@ -197,8 +185,8 @@ class IconicaAlertDialog extends StatelessWidget {
|
|||
ButtonCallback? primaryButton,
|
||||
ButtonCallback? secondaryButton,
|
||||
IconButtonCallback? iconButton,
|
||||
}) {
|
||||
return IconicaAlertDialog.icon(
|
||||
}) =>
|
||||
IconicaAlertDialog.icon(
|
||||
primaryButton: primaryButton,
|
||||
secondaryButton: secondaryButton,
|
||||
iconButton: iconButton,
|
||||
|
@ -208,7 +196,6 @@ class IconicaAlertDialog extends StatelessWidget {
|
|||
icon: icon,
|
||||
buttons: _getYesNoDialogButtons(focusYes, otherSecondary, onYes, onNo),
|
||||
);
|
||||
}
|
||||
|
||||
factory IconicaAlertDialog.singleButtonIcon({
|
||||
required String title,
|
||||
|
@ -222,8 +209,8 @@ class IconicaAlertDialog extends StatelessWidget {
|
|||
ButtonCallback? primaryButton,
|
||||
ButtonCallback? secondaryButton,
|
||||
IconButtonCallback? iconButton,
|
||||
}) {
|
||||
return IconicaAlertDialog.icon(
|
||||
}) =>
|
||||
IconicaAlertDialog.icon(
|
||||
primaryButton: primaryButton,
|
||||
secondaryButton: secondaryButton,
|
||||
iconButton: iconButton,
|
||||
|
@ -240,7 +227,6 @@ class IconicaAlertDialog extends StatelessWidget {
|
|||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
factory IconicaAlertDialog.custom({
|
||||
required Widget body,
|
||||
|
@ -249,8 +235,8 @@ class IconicaAlertDialog extends StatelessWidget {
|
|||
ButtonCallback? primaryButton,
|
||||
ButtonCallback? secondaryButton,
|
||||
IconButtonCallback? iconButton,
|
||||
}) {
|
||||
return IconicaAlertDialog._(
|
||||
}) =>
|
||||
IconicaAlertDialog._(
|
||||
closeButton: closeButton,
|
||||
buttons: buttons,
|
||||
body: (_) => body,
|
||||
|
@ -258,7 +244,12 @@ class IconicaAlertDialog extends StatelessWidget {
|
|||
secondaryButton: secondaryButton,
|
||||
iconButton: iconButton,
|
||||
);
|
||||
}
|
||||
final List<AlertDialogAction> buttons;
|
||||
final WidgetBuilder body;
|
||||
final bool? closeButton;
|
||||
final ButtonCallback? primaryButton;
|
||||
final ButtonCallback? secondaryButton;
|
||||
final IconButtonCallback? iconButton;
|
||||
|
||||
static List<AlertDialogAction> _getYesNoDialogButtons(
|
||||
bool focusYes,
|
||||
|
@ -267,8 +258,8 @@ class IconicaAlertDialog extends StatelessWidget {
|
|||
VoidCallback onNo, {
|
||||
String no = 'No',
|
||||
String yes = 'Yes',
|
||||
}) {
|
||||
return <AlertDialogAction>[
|
||||
}) =>
|
||||
<AlertDialogAction>[
|
||||
if (focusYes) ...[
|
||||
AlertDialogAction(
|
||||
text: no,
|
||||
|
@ -292,11 +283,9 @@ class IconicaAlertDialog extends StatelessWidget {
|
|||
),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
Widget build(BuildContext context) => Column(
|
||||
children: [
|
||||
const Spacer(),
|
||||
AlertDialog(
|
||||
|
@ -325,7 +314,8 @@ class IconicaAlertDialog extends StatelessWidget {
|
|||
top: buttons.isNotEmpty ? 40 : 0,
|
||||
bottom: 20,
|
||||
left: 20,
|
||||
right: 20),
|
||||
right: 20,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: buttons.map(
|
||||
|
@ -377,9 +367,9 @@ class IconicaAlertDialog extends StatelessWidget {
|
|||
),
|
||||
],
|
||||
],
|
||||
)),
|
||||
)
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import 'package:flutter/material.dart' as m;
|
|||
|
||||
class DialogService {
|
||||
static DialogService? _instance;
|
||||
static DialogService get instance => _instance ??= DialogService();
|
||||
static final DialogService instance = _instance ??= DialogService();
|
||||
|
||||
Future<T?> showDialog<T>({
|
||||
required m.BuildContext context,
|
||||
|
@ -17,16 +17,14 @@ class DialogService {
|
|||
bool useSafeArea = false,
|
||||
bool useRootNavigator = true,
|
||||
m.RouteSettings? routeSettings,
|
||||
}) {
|
||||
return m.showDialog(
|
||||
}) =>
|
||||
m.showDialog(
|
||||
context: context,
|
||||
barrierDismissible: barrierDismissible,
|
||||
barrierColor: barrierColor,
|
||||
barrierLabel: barrierLabel,
|
||||
useSafeArea: useSafeArea,
|
||||
useRootNavigator: useRootNavigator,
|
||||
builder: (ctx) {
|
||||
return m.Builder(builder: builder);
|
||||
});
|
||||
}
|
||||
builder: (ctx) => m.Builder(builder: builder),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -9,16 +9,17 @@ class PopUp extends StatelessWidget {
|
|||
const PopUp({
|
||||
required this.popUpData,
|
||||
this.onTap,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
super.key,
|
||||
});
|
||||
|
||||
final void Function()? onTap;
|
||||
final PopUpData popUpData;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var style = Theme.of(context).textTheme.bodyText1?.copyWith(
|
||||
color: popUpData.textColor ?? Theme.of(context).backgroundColor,
|
||||
var style = Theme.of(context).textTheme.bodyLarge?.copyWith(
|
||||
color:
|
||||
popUpData.textColor ?? Theme.of(context).colorScheme.background,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 14,
|
||||
height: 1.571,
|
||||
|
|
|
@ -10,7 +10,7 @@ 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, Key? key}) : super(key: key);
|
||||
const PopUpParent({required this.child, super.key});
|
||||
|
||||
final Widget child;
|
||||
|
||||
|
@ -26,7 +26,7 @@ class PopUpParentState extends State<PopUpParent> {
|
|||
final Queue<PopUpData> _popUpQueue = Queue();
|
||||
|
||||
void displayPopUp(PopUpData popUp) {
|
||||
if (_showPopUp == true) {
|
||||
if (_showPopUp) {
|
||||
_popUpQueue.add(popUp);
|
||||
return;
|
||||
}
|
||||
|
@ -62,8 +62,7 @@ class PopUpParentState extends State<PopUpParent> {
|
|||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Stack(
|
||||
Widget build(BuildContext context) => Stack(
|
||||
children: [
|
||||
widget.child,
|
||||
Container(
|
||||
|
@ -90,5 +89,4 @@ class PopUpParentState extends State<PopUpParent> {
|
|||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import 'package:flutter_dialogs/src/popup_parent.dart';
|
|||
|
||||
class PopUpService {
|
||||
static PopUpService? _instance;
|
||||
static PopUpService get instance => _instance ??= PopUpService();
|
||||
static final PopUpService instance = _instance ??= PopUpService();
|
||||
|
||||
late PopUpParentState currentState;
|
||||
|
||||
|
@ -19,22 +19,26 @@ class PopUpService {
|
|||
Color? backgroundColor,
|
||||
Color? textColor,
|
||||
}) {
|
||||
currentState.displayPopUp(PopUpData(
|
||||
currentState.displayPopUp(
|
||||
PopUpData(
|
||||
duration,
|
||||
text: text,
|
||||
icon: icon,
|
||||
backgroundColor: backgroundColor,
|
||||
textColor: textColor,
|
||||
));
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showCustom(
|
||||
Widget custom, {
|
||||
Duration duration = const Duration(seconds: 3),
|
||||
}) {
|
||||
currentState.displayPopUp(PopUpData(
|
||||
currentState.displayPopUp(
|
||||
PopUpData(
|
||||
duration,
|
||||
custom: custom,
|
||||
));
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
name: flutter_dialogs
|
||||
description: A new Flutter package project.
|
||||
version: 0.0.1
|
||||
version: 0.0.2
|
||||
homepage: https://github.com/Iconica-Development/flutter_dialogs
|
||||
|
||||
environment:
|
||||
sdk: '>=2.18.2 <3.0.0'
|
||||
sdk: ">=2.18.2 <3.0.0"
|
||||
flutter: ">=1.17.0"
|
||||
|
||||
dependencies:
|
||||
|
@ -14,6 +14,9 @@ dependencies:
|
|||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
flutter_lints: ^2.0.0
|
||||
flutter_iconica_analysis:
|
||||
git:
|
||||
url: https://github.com/Iconica-Development/flutter_iconica_analysis
|
||||
ref: 6.0.0
|
||||
|
||||
flutter:
|
||||
|
|
Loading…
Reference in a new issue