|
@@ -1,3 +1,4 @@
|
|
|
|
+import 'package:appflowy_popover/popover.dart';
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:flowy_infra/text_style.dart';
|
|
import 'package:flowy_infra/text_style.dart';
|
|
import 'package:flowy_infra/theme.dart';
|
|
import 'package:flowy_infra/theme.dart';
|
|
@@ -15,13 +16,13 @@ import 'package:textstyle_extensions/textstyle_extensions.dart';
|
|
export 'package:flowy_infra_ui/widget/dialog/styled_dialogs.dart';
|
|
export 'package:flowy_infra_ui/widget/dialog/styled_dialogs.dart';
|
|
import 'package:app_flowy/generated/locale_keys.g.dart';
|
|
import 'package:app_flowy/generated/locale_keys.g.dart';
|
|
|
|
|
|
-class TextFieldDialog extends StatefulWidget {
|
|
|
|
|
|
+class NavigatorTextFieldDialog extends StatefulWidget {
|
|
final String value;
|
|
final String value;
|
|
final String title;
|
|
final String title;
|
|
final void Function()? cancel;
|
|
final void Function()? cancel;
|
|
final void Function(String) confirm;
|
|
final void Function(String) confirm;
|
|
|
|
|
|
- const TextFieldDialog({
|
|
|
|
|
|
+ const NavigatorTextFieldDialog({
|
|
required this.title,
|
|
required this.title,
|
|
required this.value,
|
|
required this.value,
|
|
required this.confirm,
|
|
required this.confirm,
|
|
@@ -30,10 +31,10 @@ class TextFieldDialog extends StatefulWidget {
|
|
}) : super(key: key);
|
|
}) : super(key: key);
|
|
|
|
|
|
@override
|
|
@override
|
|
- State<TextFieldDialog> createState() => _CreateTextFieldDialog();
|
|
|
|
|
|
+ State<NavigatorTextFieldDialog> createState() => _CreateTextFieldDialog();
|
|
}
|
|
}
|
|
|
|
|
|
-class _CreateTextFieldDialog extends State<TextFieldDialog> {
|
|
|
|
|
|
+class _CreateTextFieldDialog extends State<NavigatorTextFieldDialog> {
|
|
String newValue = "";
|
|
String newValue = "";
|
|
|
|
|
|
@override
|
|
@override
|
|
@@ -56,7 +57,8 @@ class _CreateTextFieldDialog extends State<TextFieldDialog> {
|
|
FlowyFormTextInput(
|
|
FlowyFormTextInput(
|
|
hintText: LocaleKeys.dialogCreatePageNameHint.tr(),
|
|
hintText: LocaleKeys.dialogCreatePageNameHint.tr(),
|
|
initialValue: widget.value,
|
|
initialValue: widget.value,
|
|
- textStyle: const TextStyle(fontSize: 24, fontWeight: FontWeight.w400),
|
|
|
|
|
|
+ textStyle:
|
|
|
|
+ const TextStyle(fontSize: 24, fontWeight: FontWeight.w400),
|
|
autoFocus: true,
|
|
autoFocus: true,
|
|
onChanged: (text) {
|
|
onChanged: (text) {
|
|
newValue = text;
|
|
newValue = text;
|
|
@@ -70,11 +72,13 @@ class _CreateTextFieldDialog extends State<TextFieldDialog> {
|
|
OkCancelButton(
|
|
OkCancelButton(
|
|
onOkPressed: () {
|
|
onOkPressed: () {
|
|
widget.confirm(newValue);
|
|
widget.confirm(newValue);
|
|
|
|
+ Navigator.of(context).pop();
|
|
},
|
|
},
|
|
onCancelPressed: () {
|
|
onCancelPressed: () {
|
|
if (widget.cancel != null) {
|
|
if (widget.cancel != null) {
|
|
widget.cancel!();
|
|
widget.cancel!();
|
|
}
|
|
}
|
|
|
|
+ Navigator.of(context).pop();
|
|
},
|
|
},
|
|
)
|
|
)
|
|
],
|
|
],
|
|
@@ -83,12 +87,14 @@ class _CreateTextFieldDialog extends State<TextFieldDialog> {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-class FlowyAlertDialog extends StatefulWidget {
|
|
|
|
|
|
+class PopoverAlertView extends StatelessWidget {
|
|
|
|
+ final PopoverMutex popoverMutex;
|
|
final String title;
|
|
final String title;
|
|
final void Function()? cancel;
|
|
final void Function()? cancel;
|
|
final void Function()? confirm;
|
|
final void Function()? confirm;
|
|
|
|
|
|
- const FlowyAlertDialog({
|
|
|
|
|
|
+ const PopoverAlertView({
|
|
|
|
+ required this.popoverMutex,
|
|
required this.title,
|
|
required this.title,
|
|
this.confirm,
|
|
this.confirm,
|
|
this.cancel,
|
|
this.cancel,
|
|
@@ -96,10 +102,46 @@ class FlowyAlertDialog extends StatefulWidget {
|
|
}) : super(key: key);
|
|
}) : super(key: key);
|
|
|
|
|
|
@override
|
|
@override
|
|
- State<FlowyAlertDialog> createState() => _CreateFlowyAlertDialog();
|
|
|
|
|
|
+ Widget build(BuildContext context) {
|
|
|
|
+ final theme = context.watch<AppTheme>();
|
|
|
|
+ return StyledDialog(
|
|
|
|
+ child: Column(
|
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
+ children: <Widget>[
|
|
|
|
+ ...[
|
|
|
|
+ FlowyText.medium(title, color: theme.shader4),
|
|
|
|
+ ],
|
|
|
|
+ if (confirm != null) ...[
|
|
|
|
+ const VSpace(20),
|
|
|
|
+ OkCancelButton(
|
|
|
|
+ onOkPressed: confirm,
|
|
|
|
+ onCancelPressed: cancel,
|
|
|
|
+ )
|
|
|
|
+ ]
|
|
|
|
+ ],
|
|
|
|
+ ),
|
|
|
|
+ );
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
-class _CreateFlowyAlertDialog extends State<FlowyAlertDialog> {
|
|
|
|
|
|
+class NavigatorAlertDialog extends StatefulWidget {
|
|
|
|
+ final String title;
|
|
|
|
+ final void Function()? cancel;
|
|
|
|
+ final void Function()? confirm;
|
|
|
|
+
|
|
|
|
+ const NavigatorAlertDialog({
|
|
|
|
+ required this.title,
|
|
|
|
+ this.confirm,
|
|
|
|
+ this.cancel,
|
|
|
|
+ Key? key,
|
|
|
|
+ }) : super(key: key);
|
|
|
|
+
|
|
|
|
+ @override
|
|
|
|
+ State<NavigatorAlertDialog> createState() => _CreateFlowyAlertDialog();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+class _CreateFlowyAlertDialog extends State<NavigatorAlertDialog> {
|
|
@override
|
|
@override
|
|
void initState() {
|
|
void initState() {
|
|
super.initState();
|
|
super.initState();
|
|
@@ -118,10 +160,13 @@ class _CreateFlowyAlertDialog extends State<FlowyAlertDialog> {
|
|
],
|
|
],
|
|
if (widget.confirm != null) ...[
|
|
if (widget.confirm != null) ...[
|
|
const VSpace(20),
|
|
const VSpace(20),
|
|
- OkCancelButton(
|
|
|
|
- onOkPressed: widget.confirm!,
|
|
|
|
- onCancelPressed: widget.confirm,
|
|
|
|
- )
|
|
|
|
|
|
+ OkCancelButton(onOkPressed: () {
|
|
|
|
+ widget.confirm?.call();
|
|
|
|
+ Navigator.of(context).pop();
|
|
|
|
+ }, onCancelPressed: () {
|
|
|
|
+ widget.cancel?.call();
|
|
|
|
+ Navigator.of(context).pop();
|
|
|
|
+ })
|
|
]
|
|
]
|
|
],
|
|
],
|
|
),
|
|
),
|
|
@@ -129,7 +174,7 @@ class _CreateFlowyAlertDialog extends State<FlowyAlertDialog> {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-class OkCancelDialog extends StatelessWidget {
|
|
|
|
|
|
+class NavigatorOkCancelDialog extends StatelessWidget {
|
|
final VoidCallback? onOkPressed;
|
|
final VoidCallback? onOkPressed;
|
|
final VoidCallback? onCancelPressed;
|
|
final VoidCallback? onCancelPressed;
|
|
final String? okTitle;
|
|
final String? okTitle;
|
|
@@ -138,7 +183,7 @@ class OkCancelDialog extends StatelessWidget {
|
|
final String message;
|
|
final String message;
|
|
final double? maxWidth;
|
|
final double? maxWidth;
|
|
|
|
|
|
- const OkCancelDialog(
|
|
|
|
|
|
+ const NavigatorOkCancelDialog(
|
|
{Key? key,
|
|
{Key? key,
|
|
this.onOkPressed,
|
|
this.onOkPressed,
|
|
this.onCancelPressed,
|
|
this.onCancelPressed,
|
|
@@ -158,7 +203,7 @@ class OkCancelDialog extends StatelessWidget {
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: <Widget>[
|
|
children: <Widget>[
|
|
if (title != null) ...[
|
|
if (title != null) ...[
|
|
- Text(title!.toUpperCase(), style: TextStyles.T1.textColor(theme.shader1)),
|
|
|
|
|
|
+ FlowyText.medium(title!.toUpperCase(), color: theme.shader1),
|
|
VSpace(Insets.sm * 1.5),
|
|
VSpace(Insets.sm * 1.5),
|
|
Container(color: theme.bg1, height: 1),
|
|
Container(color: theme.bg1, height: 1),
|
|
VSpace(Insets.m * 1.5),
|
|
VSpace(Insets.m * 1.5),
|
|
@@ -166,8 +211,14 @@ class OkCancelDialog extends StatelessWidget {
|
|
Text(message, style: TextStyles.Body1.textHeight(1.5)),
|
|
Text(message, style: TextStyles.Body1.textHeight(1.5)),
|
|
SizedBox(height: Insets.l),
|
|
SizedBox(height: Insets.l),
|
|
OkCancelButton(
|
|
OkCancelButton(
|
|
- onOkPressed: onOkPressed,
|
|
|
|
- onCancelPressed: onCancelPressed,
|
|
|
|
|
|
+ onOkPressed: () {
|
|
|
|
+ onOkPressed?.call();
|
|
|
|
+ Navigator.of(context).pop();
|
|
|
|
+ },
|
|
|
|
+ onCancelPressed: () {
|
|
|
|
+ onCancelPressed?.call();
|
|
|
|
+ Navigator.of(context).pop();
|
|
|
|
+ },
|
|
okTitle: okTitle?.toUpperCase(),
|
|
okTitle: okTitle?.toUpperCase(),
|
|
cancelTitle: cancelTitle?.toUpperCase(),
|
|
cancelTitle: cancelTitle?.toUpperCase(),
|
|
)
|
|
)
|
|
@@ -185,7 +236,12 @@ class OkCancelButton extends StatelessWidget {
|
|
final double? minHeight;
|
|
final double? minHeight;
|
|
|
|
|
|
const OkCancelButton(
|
|
const OkCancelButton(
|
|
- {Key? key, this.onOkPressed, this.onCancelPressed, this.okTitle, this.cancelTitle, this.minHeight})
|
|
|
|
|
|
+ {Key? key,
|
|
|
|
+ this.onOkPressed,
|
|
|
|
+ this.onCancelPressed,
|
|
|
|
+ this.okTitle,
|
|
|
|
+ this.cancelTitle,
|
|
|
|
+ this.minHeight})
|
|
: super(key: key);
|
|
: super(key: key);
|
|
|
|
|
|
@override
|
|
@override
|
|
@@ -198,20 +254,14 @@ class OkCancelButton extends StatelessWidget {
|
|
if (onCancelPressed != null)
|
|
if (onCancelPressed != null)
|
|
SecondaryTextButton(
|
|
SecondaryTextButton(
|
|
cancelTitle ?? LocaleKeys.button_Cancel.tr(),
|
|
cancelTitle ?? LocaleKeys.button_Cancel.tr(),
|
|
- onPressed: () {
|
|
|
|
- onCancelPressed!();
|
|
|
|
- AppGlobals.nav.pop();
|
|
|
|
- },
|
|
|
|
|
|
+ onPressed: onCancelPressed,
|
|
bigMode: true,
|
|
bigMode: true,
|
|
),
|
|
),
|
|
HSpace(Insets.m),
|
|
HSpace(Insets.m),
|
|
if (onOkPressed != null)
|
|
if (onOkPressed != null)
|
|
PrimaryTextButton(
|
|
PrimaryTextButton(
|
|
okTitle ?? LocaleKeys.button_OK.tr(),
|
|
okTitle ?? LocaleKeys.button_OK.tr(),
|
|
- onPressed: () {
|
|
|
|
- onOkPressed!();
|
|
|
|
- AppGlobals.nav.pop();
|
|
|
|
- },
|
|
|
|
|
|
+ onPressed: onOkPressed,
|
|
bigMode: true,
|
|
bigMode: true,
|
|
),
|
|
),
|
|
],
|
|
],
|