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
|
## 0.0.1
|
||||||
|
|
||||||
- Initial port
|
- 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
|
# Possible to overwrite the rules from the package
|
||||||
# https://dart.dev/guides/language/analysis-options
|
|
||||||
|
analyzer:
|
||||||
|
exclude:
|
||||||
|
|
||||||
|
linter:
|
||||||
|
rules:
|
|
@ -1,10 +1,10 @@
|
||||||
// SPDX-FileCopyrightText: 2022 Iconica
|
// SPDX-FileCopyrightText: 2022 Iconica
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
///
|
||||||
library flutter_dialogs;
|
library flutter_dialogs;
|
||||||
|
|
||||||
export './src/dialogs.dart';
|
|
||||||
export './src/popup_service.dart';
|
|
||||||
export './src/popup_parent.dart';
|
|
||||||
export './src/alert_dialogs.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';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class AlertDialogAction {
|
class AlertDialogAction {
|
||||||
final String text;
|
|
||||||
final bool primary;
|
|
||||||
final bool secondary;
|
|
||||||
final VoidCallback onPressed;
|
|
||||||
|
|
||||||
AlertDialogAction({
|
AlertDialogAction({
|
||||||
required this.text,
|
required this.text,
|
||||||
|
required this.onPressed,
|
||||||
this.primary = false,
|
this.primary = false,
|
||||||
this.secondary = false,
|
this.secondary = false,
|
||||||
required this.onPressed,
|
|
||||||
}) : assert(
|
}) : assert(
|
||||||
!(primary && secondary),
|
!(primary && secondary),
|
||||||
"AlertDialogAction can't be primary and secondary at the same time",
|
"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(
|
typedef ButtonCallback = Widget Function(
|
||||||
|
@ -33,13 +32,6 @@ typedef IconButtonCallback = Widget Function(
|
||||||
);
|
);
|
||||||
|
|
||||||
class IconicaAlertDialog extends StatelessWidget {
|
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._({
|
const IconicaAlertDialog._({
|
||||||
required this.buttons,
|
required this.buttons,
|
||||||
required this.body,
|
required this.body,
|
||||||
|
@ -59,23 +51,22 @@ class IconicaAlertDialog extends StatelessWidget {
|
||||||
ButtonCallback? primaryButton,
|
ButtonCallback? primaryButton,
|
||||||
ButtonCallback? secondaryButton,
|
ButtonCallback? secondaryButton,
|
||||||
IconButtonCallback? iconButton,
|
IconButtonCallback? iconButton,
|
||||||
}) {
|
}) =>
|
||||||
return IconicaAlertDialog.multiButton(
|
IconicaAlertDialog.multiButton(
|
||||||
primaryButton: primaryButton,
|
primaryButton: primaryButton,
|
||||||
secondaryButton: secondaryButton,
|
secondaryButton: secondaryButton,
|
||||||
iconButton: iconButton,
|
iconButton: iconButton,
|
||||||
closeButton: closeButton,
|
closeButton: closeButton,
|
||||||
title: title,
|
title: title,
|
||||||
body: body,
|
body: body,
|
||||||
buttons: [
|
buttons: [
|
||||||
AlertDialogAction(
|
AlertDialogAction(
|
||||||
text: buttonText,
|
text: buttonText,
|
||||||
onPressed: onPressed,
|
onPressed: onPressed,
|
||||||
primary: primary,
|
primary: primary,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
factory IconicaAlertDialog.multiButton({
|
factory IconicaAlertDialog.multiButton({
|
||||||
required String title,
|
required String title,
|
||||||
|
@ -85,40 +76,39 @@ class IconicaAlertDialog extends StatelessWidget {
|
||||||
ButtonCallback? primaryButton,
|
ButtonCallback? primaryButton,
|
||||||
ButtonCallback? secondaryButton,
|
ButtonCallback? secondaryButton,
|
||||||
IconButtonCallback? iconButton,
|
IconButtonCallback? iconButton,
|
||||||
}) {
|
}) =>
|
||||||
return IconicaAlertDialog._(
|
IconicaAlertDialog._(
|
||||||
primaryButton: primaryButton,
|
primaryButton: primaryButton,
|
||||||
secondaryButton: secondaryButton,
|
secondaryButton: secondaryButton,
|
||||||
iconButton: iconButton,
|
iconButton: iconButton,
|
||||||
closeButton: closeButton,
|
closeButton: closeButton,
|
||||||
buttons: buttons,
|
buttons: buttons,
|
||||||
body: (context) => Column(
|
body: (context) => Column(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 20,
|
horizontal: 20,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
title,
|
||||||
|
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Theme.of(context).textTheme.bodyMedium?.color,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
child: Text(
|
Padding(
|
||||||
title,
|
padding: const EdgeInsets.only(top: 20, left: 20, right: 20),
|
||||||
style: Theme.of(context).textTheme.headline6?.copyWith(
|
child: Text(
|
||||||
fontWeight: FontWeight.bold,
|
body,
|
||||||
color: Theme.of(context).textTheme.bodyText2?.color,
|
style: Theme.of(context).textTheme.bodyMedium,
|
||||||
),
|
textAlign: TextAlign.center,
|
||||||
textAlign: TextAlign.center,
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
Padding(
|
),
|
||||||
padding: const EdgeInsets.only(top: 20, left: 20, right: 20),
|
);
|
||||||
child: Text(
|
|
||||||
body,
|
|
||||||
style: Theme.of(context).textTheme.bodyText2,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
factory IconicaAlertDialog.icon({
|
factory IconicaAlertDialog.icon({
|
||||||
required String title,
|
required String title,
|
||||||
|
@ -129,38 +119,37 @@ class IconicaAlertDialog extends StatelessWidget {
|
||||||
ButtonCallback? primaryButton,
|
ButtonCallback? primaryButton,
|
||||||
ButtonCallback? secondaryButton,
|
ButtonCallback? secondaryButton,
|
||||||
IconButtonCallback? iconButton,
|
IconButtonCallback? iconButton,
|
||||||
}) {
|
}) =>
|
||||||
return IconicaAlertDialog._(
|
IconicaAlertDialog._(
|
||||||
primaryButton: primaryButton,
|
primaryButton: primaryButton,
|
||||||
secondaryButton: secondaryButton,
|
secondaryButton: secondaryButton,
|
||||||
iconButton: iconButton,
|
iconButton: iconButton,
|
||||||
closeButton: closeButton,
|
closeButton: closeButton,
|
||||||
buttons: buttons,
|
buttons: buttons,
|
||||||
body: (context) => Column(
|
body: (context) => Column(
|
||||||
children: [
|
children: [
|
||||||
icon,
|
icon,
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||||
child: Text(
|
child: Text(
|
||||||
title,
|
title,
|
||||||
style: Theme.of(context).textTheme.headline6?.copyWith(
|
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
Padding(
|
||||||
Padding(
|
padding: const EdgeInsets.only(top: 20, left: 20, right: 20),
|
||||||
padding: const EdgeInsets.only(top: 20, left: 20, right: 20),
|
child: Text(
|
||||||
child: Text(
|
body,
|
||||||
body,
|
style: Theme.of(context).textTheme.bodyMedium,
|
||||||
style: Theme.of(context).textTheme.bodyText2,
|
textAlign: TextAlign.center,
|
||||||
textAlign: TextAlign.center,
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
factory IconicaAlertDialog.yesOrNo({
|
factory IconicaAlertDialog.yesOrNo({
|
||||||
required String title,
|
required String title,
|
||||||
|
@ -173,17 +162,16 @@ class IconicaAlertDialog extends StatelessWidget {
|
||||||
ButtonCallback? primaryButton,
|
ButtonCallback? primaryButton,
|
||||||
ButtonCallback? secondaryButton,
|
ButtonCallback? secondaryButton,
|
||||||
IconButtonCallback? iconButton,
|
IconButtonCallback? iconButton,
|
||||||
}) {
|
}) =>
|
||||||
return IconicaAlertDialog.multiButton(
|
IconicaAlertDialog.multiButton(
|
||||||
primaryButton: primaryButton,
|
primaryButton: primaryButton,
|
||||||
secondaryButton: secondaryButton,
|
secondaryButton: secondaryButton,
|
||||||
iconButton: iconButton,
|
iconButton: iconButton,
|
||||||
closeButton: closeButton,
|
closeButton: closeButton,
|
||||||
title: title,
|
title: title,
|
||||||
body: body,
|
body: body,
|
||||||
buttons: _getYesNoDialogButtons(focusYes, otherSecondary, onYes, onNo),
|
buttons: _getYesNoDialogButtons(focusYes, otherSecondary, onYes, onNo),
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
factory IconicaAlertDialog.yesOrNoIcon({
|
factory IconicaAlertDialog.yesOrNoIcon({
|
||||||
required String title,
|
required String title,
|
||||||
|
@ -197,18 +185,17 @@ class IconicaAlertDialog extends StatelessWidget {
|
||||||
ButtonCallback? primaryButton,
|
ButtonCallback? primaryButton,
|
||||||
ButtonCallback? secondaryButton,
|
ButtonCallback? secondaryButton,
|
||||||
IconButtonCallback? iconButton,
|
IconButtonCallback? iconButton,
|
||||||
}) {
|
}) =>
|
||||||
return IconicaAlertDialog.icon(
|
IconicaAlertDialog.icon(
|
||||||
primaryButton: primaryButton,
|
primaryButton: primaryButton,
|
||||||
secondaryButton: secondaryButton,
|
secondaryButton: secondaryButton,
|
||||||
iconButton: iconButton,
|
iconButton: iconButton,
|
||||||
closeButton: closeButton,
|
closeButton: closeButton,
|
||||||
title: title,
|
title: title,
|
||||||
body: body,
|
body: body,
|
||||||
icon: icon,
|
icon: icon,
|
||||||
buttons: _getYesNoDialogButtons(focusYes, otherSecondary, onYes, onNo),
|
buttons: _getYesNoDialogButtons(focusYes, otherSecondary, onYes, onNo),
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
factory IconicaAlertDialog.singleButtonIcon({
|
factory IconicaAlertDialog.singleButtonIcon({
|
||||||
required String title,
|
required String title,
|
||||||
|
@ -222,25 +209,24 @@ class IconicaAlertDialog extends StatelessWidget {
|
||||||
ButtonCallback? primaryButton,
|
ButtonCallback? primaryButton,
|
||||||
ButtonCallback? secondaryButton,
|
ButtonCallback? secondaryButton,
|
||||||
IconButtonCallback? iconButton,
|
IconButtonCallback? iconButton,
|
||||||
}) {
|
}) =>
|
||||||
return IconicaAlertDialog.icon(
|
IconicaAlertDialog.icon(
|
||||||
primaryButton: primaryButton,
|
primaryButton: primaryButton,
|
||||||
secondaryButton: secondaryButton,
|
secondaryButton: secondaryButton,
|
||||||
iconButton: iconButton,
|
iconButton: iconButton,
|
||||||
closeButton: closeButton,
|
closeButton: closeButton,
|
||||||
title: title,
|
title: title,
|
||||||
icon: icon,
|
icon: icon,
|
||||||
body: body,
|
body: body,
|
||||||
buttons: [
|
buttons: [
|
||||||
AlertDialogAction(
|
AlertDialogAction(
|
||||||
text: buttonText,
|
text: buttonText,
|
||||||
primary: primary,
|
primary: primary,
|
||||||
secondary: secondary,
|
secondary: secondary,
|
||||||
onPressed: onPressed,
|
onPressed: onPressed,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
factory IconicaAlertDialog.custom({
|
factory IconicaAlertDialog.custom({
|
||||||
required Widget body,
|
required Widget body,
|
||||||
|
@ -249,16 +235,21 @@ class IconicaAlertDialog extends StatelessWidget {
|
||||||
ButtonCallback? primaryButton,
|
ButtonCallback? primaryButton,
|
||||||
ButtonCallback? secondaryButton,
|
ButtonCallback? secondaryButton,
|
||||||
IconButtonCallback? iconButton,
|
IconButtonCallback? iconButton,
|
||||||
}) {
|
}) =>
|
||||||
return IconicaAlertDialog._(
|
IconicaAlertDialog._(
|
||||||
closeButton: closeButton,
|
closeButton: closeButton,
|
||||||
buttons: buttons,
|
buttons: buttons,
|
||||||
body: (_) => body,
|
body: (_) => body,
|
||||||
primaryButton: primaryButton,
|
primaryButton: primaryButton,
|
||||||
secondaryButton: secondaryButton,
|
secondaryButton: secondaryButton,
|
||||||
iconButton: iconButton,
|
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(
|
static List<AlertDialogAction> _getYesNoDialogButtons(
|
||||||
bool focusYes,
|
bool focusYes,
|
||||||
|
@ -267,49 +258,47 @@ class IconicaAlertDialog extends StatelessWidget {
|
||||||
VoidCallback onNo, {
|
VoidCallback onNo, {
|
||||||
String no = 'No',
|
String no = 'No',
|
||||||
String yes = 'Yes',
|
String yes = 'Yes',
|
||||||
}) {
|
}) =>
|
||||||
return <AlertDialogAction>[
|
<AlertDialogAction>[
|
||||||
if (focusYes) ...[
|
if (focusYes) ...[
|
||||||
|
AlertDialogAction(
|
||||||
|
text: no,
|
||||||
|
primary: !focusYes,
|
||||||
|
secondary: !focusYes && otherSecondary,
|
||||||
|
onPressed: onNo,
|
||||||
|
),
|
||||||
|
],
|
||||||
AlertDialogAction(
|
AlertDialogAction(
|
||||||
text: no,
|
text: yes,
|
||||||
primary: !focusYes,
|
primary: focusYes,
|
||||||
secondary: !focusYes && otherSecondary,
|
secondary: !focusYes && otherSecondary,
|
||||||
onPressed: onNo,
|
onPressed: onYes,
|
||||||
),
|
),
|
||||||
],
|
if (!focusYes) ...[
|
||||||
AlertDialogAction(
|
AlertDialogAction(
|
||||||
text: yes,
|
text: no,
|
||||||
primary: focusYes,
|
primary: !focusYes,
|
||||||
secondary: !focusYes && otherSecondary,
|
secondary: focusYes && otherSecondary,
|
||||||
onPressed: onYes,
|
onPressed: onNo,
|
||||||
),
|
),
|
||||||
if (!focusYes) ...[
|
],
|
||||||
AlertDialogAction(
|
];
|
||||||
text: no,
|
|
||||||
primary: !focusYes,
|
|
||||||
secondary: focusYes && otherSecondary,
|
|
||||||
onPressed: onNo,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) => Column(
|
||||||
return Column(
|
children: [
|
||||||
children: [
|
const Spacer(),
|
||||||
const Spacer(),
|
AlertDialog(
|
||||||
AlertDialog(
|
insetPadding: EdgeInsets.zero,
|
||||||
insetPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
contentPadding: EdgeInsets.zero,
|
backgroundColor: Theme.of(context).cardColor,
|
||||||
backgroundColor: Theme.of(context).cardColor,
|
shape: const RoundedRectangleBorder(
|
||||||
shape: const RoundedRectangleBorder(
|
borderRadius: BorderRadius.only(
|
||||||
borderRadius: BorderRadius.only(
|
topLeft: Radius.circular(10),
|
||||||
topLeft: Radius.circular(10),
|
topRight: Radius.circular(10),
|
||||||
topRight: Radius.circular(10),
|
),
|
||||||
),
|
),
|
||||||
),
|
content: SizedBox(
|
||||||
content: SizedBox(
|
|
||||||
width: MediaQuery.of(context).size.width,
|
width: MediaQuery.of(context).size.width,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
|
@ -322,10 +311,11 @@ class IconicaAlertDialog extends StatelessWidget {
|
||||||
body.call(context),
|
body.call(context),
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
top: buttons.isNotEmpty ? 40 : 0,
|
top: buttons.isNotEmpty ? 40 : 0,
|
||||||
bottom: 20,
|
bottom: 20,
|
||||||
left: 20,
|
left: 20,
|
||||||
right: 20),
|
right: 20,
|
||||||
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: buttons.map(
|
children: buttons.map(
|
||||||
|
@ -377,9 +367,9 @@ class IconicaAlertDialog extends StatelessWidget {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
)),
|
),
|
||||||
)
|
),
|
||||||
],
|
),
|
||||||
);
|
],
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import 'package:flutter/material.dart' as m;
|
||||||
|
|
||||||
class DialogService {
|
class DialogService {
|
||||||
static DialogService? _instance;
|
static DialogService? _instance;
|
||||||
static DialogService get instance => _instance ??= DialogService();
|
static final DialogService instance = _instance ??= DialogService();
|
||||||
|
|
||||||
Future<T?> showDialog<T>({
|
Future<T?> showDialog<T>({
|
||||||
required m.BuildContext context,
|
required m.BuildContext context,
|
||||||
|
@ -17,16 +17,14 @@ class DialogService {
|
||||||
bool useSafeArea = false,
|
bool useSafeArea = false,
|
||||||
bool useRootNavigator = true,
|
bool useRootNavigator = true,
|
||||||
m.RouteSettings? routeSettings,
|
m.RouteSettings? routeSettings,
|
||||||
}) {
|
}) =>
|
||||||
return m.showDialog(
|
m.showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: barrierDismissible,
|
barrierDismissible: barrierDismissible,
|
||||||
barrierColor: barrierColor,
|
barrierColor: barrierColor,
|
||||||
barrierLabel: barrierLabel,
|
barrierLabel: barrierLabel,
|
||||||
useSafeArea: useSafeArea,
|
useSafeArea: useSafeArea,
|
||||||
useRootNavigator: useRootNavigator,
|
useRootNavigator: useRootNavigator,
|
||||||
builder: (ctx) {
|
builder: (ctx) => m.Builder(builder: builder),
|
||||||
return m.Builder(builder: builder);
|
);
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,16 +9,17 @@ class PopUp extends StatelessWidget {
|
||||||
const PopUp({
|
const PopUp({
|
||||||
required this.popUpData,
|
required this.popUpData,
|
||||||
this.onTap,
|
this.onTap,
|
||||||
Key? key,
|
super.key,
|
||||||
}) : super(key: key);
|
});
|
||||||
|
|
||||||
final void Function()? onTap;
|
final void Function()? onTap;
|
||||||
final PopUpData popUpData;
|
final PopUpData popUpData;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var style = Theme.of(context).textTheme.bodyText1?.copyWith(
|
var style = Theme.of(context).textTheme.bodyLarge?.copyWith(
|
||||||
color: popUpData.textColor ?? Theme.of(context).backgroundColor,
|
color:
|
||||||
|
popUpData.textColor ?? Theme.of(context).colorScheme.background,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
height: 1.571,
|
height: 1.571,
|
||||||
|
|
|
@ -10,7 +10,7 @@ import 'package:flutter_dialogs/src/popup_data.dart';
|
||||||
import 'package:flutter_dialogs/src/popup_service.dart';
|
import 'package:flutter_dialogs/src/popup_service.dart';
|
||||||
|
|
||||||
class PopUpParent extends StatefulWidget {
|
class PopUpParent extends StatefulWidget {
|
||||||
const PopUpParent({required this.child, Key? key}) : super(key: key);
|
const PopUpParent({required this.child, super.key});
|
||||||
|
|
||||||
final Widget child;
|
final Widget child;
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ class PopUpParentState extends State<PopUpParent> {
|
||||||
final Queue<PopUpData> _popUpQueue = Queue();
|
final Queue<PopUpData> _popUpQueue = Queue();
|
||||||
|
|
||||||
void displayPopUp(PopUpData popUp) {
|
void displayPopUp(PopUpData popUp) {
|
||||||
if (_showPopUp == true) {
|
if (_showPopUp) {
|
||||||
_popUpQueue.add(popUp);
|
_popUpQueue.add(popUp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -62,33 +62,31 @@ class PopUpParentState extends State<PopUpParent> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) => Stack(
|
||||||
return Stack(
|
children: [
|
||||||
children: [
|
widget.child,
|
||||||
widget.child,
|
Container(
|
||||||
Container(
|
width: MediaQuery.of(context).size.width,
|
||||||
width: MediaQuery.of(context).size.width,
|
height: MediaQuery.of(context).size.height -
|
||||||
height: MediaQuery.of(context).size.height -
|
MediaQuery.of(context).viewInsets.bottom,
|
||||||
MediaQuery.of(context).viewInsets.bottom,
|
alignment: Alignment.bottomCenter,
|
||||||
alignment: Alignment.bottomCenter,
|
child: AnimatedCrossFade(
|
||||||
child: AnimatedCrossFade(
|
firstChild: SizedBox(
|
||||||
firstChild: SizedBox(
|
width: MediaQuery.of(context).size.width,
|
||||||
width: MediaQuery.of(context).size.width,
|
),
|
||||||
|
secondChild: _popUp?.custom ??
|
||||||
|
PopUp(
|
||||||
|
popUpData: _popUp ?? PopUpData(const Duration(seconds: 3)),
|
||||||
|
onTap: () {
|
||||||
|
_closePopUp(_popUpId);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
crossFadeState: _showPopUp
|
||||||
|
? CrossFadeState.showSecond
|
||||||
|
: CrossFadeState.showFirst,
|
||||||
|
duration: const Duration(milliseconds: 250),
|
||||||
),
|
),
|
||||||
secondChild: _popUp?.custom ??
|
|
||||||
PopUp(
|
|
||||||
popUpData: _popUp ?? PopUpData(const Duration(seconds: 3)),
|
|
||||||
onTap: () {
|
|
||||||
_closePopUp(_popUpId);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
crossFadeState: _showPopUp
|
|
||||||
? CrossFadeState.showSecond
|
|
||||||
: CrossFadeState.showFirst,
|
|
||||||
duration: const Duration(milliseconds: 250),
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import 'package:flutter_dialogs/src/popup_parent.dart';
|
||||||
|
|
||||||
class PopUpService {
|
class PopUpService {
|
||||||
static PopUpService? _instance;
|
static PopUpService? _instance;
|
||||||
static PopUpService get instance => _instance ??= PopUpService();
|
static final PopUpService instance = _instance ??= PopUpService();
|
||||||
|
|
||||||
late PopUpParentState currentState;
|
late PopUpParentState currentState;
|
||||||
|
|
||||||
|
@ -19,22 +19,26 @@ class PopUpService {
|
||||||
Color? backgroundColor,
|
Color? backgroundColor,
|
||||||
Color? textColor,
|
Color? textColor,
|
||||||
}) {
|
}) {
|
||||||
currentState.displayPopUp(PopUpData(
|
currentState.displayPopUp(
|
||||||
duration,
|
PopUpData(
|
||||||
text: text,
|
duration,
|
||||||
icon: icon,
|
text: text,
|
||||||
backgroundColor: backgroundColor,
|
icon: icon,
|
||||||
textColor: textColor,
|
backgroundColor: backgroundColor,
|
||||||
));
|
textColor: textColor,
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showCustom(
|
void showCustom(
|
||||||
Widget custom, {
|
Widget custom, {
|
||||||
Duration duration = const Duration(seconds: 3),
|
Duration duration = const Duration(seconds: 3),
|
||||||
}) {
|
}) {
|
||||||
currentState.displayPopUp(PopUpData(
|
currentState.displayPopUp(
|
||||||
duration,
|
PopUpData(
|
||||||
custom: custom,
|
duration,
|
||||||
));
|
custom: custom,
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
name: flutter_dialogs
|
name: flutter_dialogs
|
||||||
description: A new Flutter package project.
|
description: A new Flutter package project.
|
||||||
version: 0.0.1
|
version: 0.0.2
|
||||||
homepage: https://github.com/Iconica-Development/flutter_dialogs
|
homepage: https://github.com/Iconica-Development/flutter_dialogs
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=2.18.2 <3.0.0'
|
sdk: ">=2.18.2 <3.0.0"
|
||||||
flutter: ">=1.17.0"
|
flutter: ">=1.17.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -14,6 +14,9 @@ dependencies:
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
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:
|
flutter:
|
||||||
|
|
Loading…
Reference in a new issue