2023-05-26 21:21:16 +00:00
|
|
|
/*
|
|
|
|
* This file is part of Stack Wallet.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2023 Cypher Stack
|
|
|
|
* All Rights Reserved.
|
|
|
|
* The code is distributed under GPLv3 license, see LICENSE file for details.
|
|
|
|
* Generated by Cypher Stack on 2023-05-26
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2024-06-18 20:35:31 +00:00
|
|
|
|
2024-05-23 00:37:06 +00:00
|
|
|
import '../themes/stack_colors.dart';
|
|
|
|
import '../utilities/text_styles.dart';
|
|
|
|
import '../utilities/util.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
class StackDialogBase extends StatelessWidget {
|
|
|
|
const StackDialogBase({
|
2024-05-27 23:56:22 +00:00
|
|
|
super.key,
|
2022-08-26 08:11:35 +00:00
|
|
|
this.child,
|
|
|
|
this.padding = const EdgeInsets.all(24),
|
2023-08-22 23:06:30 +00:00
|
|
|
this.keyboardPaddingAmount = 0,
|
2024-05-27 23:56:22 +00:00
|
|
|
});
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
final EdgeInsets padding;
|
|
|
|
final Widget? child;
|
2023-08-22 23:06:30 +00:00
|
|
|
final double keyboardPaddingAmount;
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Padding(
|
2023-08-22 23:06:30 +00:00
|
|
|
padding: EdgeInsets.only(
|
|
|
|
top: 16,
|
|
|
|
left: 16,
|
|
|
|
right: 16,
|
|
|
|
bottom: 16 + keyboardPaddingAmount,
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
child: Column(
|
2022-11-09 22:32:39 +00:00
|
|
|
mainAxisAlignment:
|
|
|
|
!Util.isDesktop ? MainAxisAlignment.end : MainAxisAlignment.center,
|
2022-08-26 08:11:35 +00:00
|
|
|
children: [
|
2023-03-09 16:12:47 +00:00
|
|
|
Flexible(
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: Material(
|
2022-08-26 08:11:35 +00:00
|
|
|
borderRadius: BorderRadius.circular(
|
|
|
|
20,
|
|
|
|
),
|
2023-03-09 16:12:47 +00:00
|
|
|
child: Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Theme.of(context).extension<StackColors>()!.popupBG,
|
|
|
|
borderRadius: BorderRadius.circular(
|
|
|
|
20,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Padding(
|
|
|
|
padding: padding,
|
|
|
|
child: child,
|
|
|
|
),
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class StackDialog extends StatelessWidget {
|
|
|
|
const StackDialog({
|
2024-05-27 23:56:22 +00:00
|
|
|
super.key,
|
2022-08-26 08:11:35 +00:00
|
|
|
this.leftButton,
|
|
|
|
this.rightButton,
|
|
|
|
this.icon,
|
|
|
|
required this.title,
|
|
|
|
this.message,
|
2024-05-27 23:56:22 +00:00
|
|
|
});
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
final Widget? leftButton;
|
|
|
|
final Widget? rightButton;
|
|
|
|
|
|
|
|
final Widget? icon;
|
|
|
|
|
|
|
|
final String title;
|
|
|
|
final String? message;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return StackDialogBase(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Flexible(
|
|
|
|
child: Text(
|
|
|
|
title,
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.pageTitleH2(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
icon != null ? icon! : Container(),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
if (message != null)
|
|
|
|
const SizedBox(
|
|
|
|
height: 8,
|
|
|
|
),
|
|
|
|
if (message != null)
|
|
|
|
Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
message!,
|
2022-09-22 22:17:21 +00:00
|
|
|
style: STextStyles.smallMed14(context),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
if (leftButton != null || rightButton != null)
|
|
|
|
const SizedBox(
|
|
|
|
height: 20,
|
|
|
|
),
|
|
|
|
if (leftButton != null || rightButton != null)
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
leftButton == null
|
|
|
|
? const Spacer()
|
|
|
|
: Expanded(child: leftButton!),
|
|
|
|
const SizedBox(
|
|
|
|
width: 8,
|
|
|
|
),
|
|
|
|
rightButton == null
|
|
|
|
? const Spacer()
|
|
|
|
: Expanded(child: rightButton!),
|
|
|
|
],
|
2024-05-27 23:56:22 +00:00
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class StackOkDialog extends StatelessWidget {
|
|
|
|
const StackOkDialog({
|
2024-05-27 23:56:22 +00:00
|
|
|
super.key,
|
2022-08-26 08:11:35 +00:00
|
|
|
this.leftButton,
|
|
|
|
this.onOkPressed,
|
|
|
|
this.icon,
|
|
|
|
required this.title,
|
|
|
|
this.message,
|
2024-01-19 23:44:01 +00:00
|
|
|
this.desktopPopRootNavigator = false,
|
2024-06-18 20:35:31 +00:00
|
|
|
this.maxWidth,
|
2024-05-27 23:56:22 +00:00
|
|
|
});
|
2022-08-26 08:11:35 +00:00
|
|
|
|
2024-01-19 23:44:01 +00:00
|
|
|
final bool desktopPopRootNavigator;
|
2022-08-26 08:11:35 +00:00
|
|
|
final Widget? leftButton;
|
|
|
|
final void Function(String)? onOkPressed;
|
|
|
|
|
|
|
|
final Widget? icon;
|
|
|
|
|
|
|
|
final String title;
|
|
|
|
final String? message;
|
2024-06-18 20:35:31 +00:00
|
|
|
final double? maxWidth;
|
2022-08-26 08:11:35 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return StackDialogBase(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
2024-06-18 20:35:31 +00:00
|
|
|
ConstrainedBox(
|
|
|
|
constraints: BoxConstraints(maxWidth: maxWidth ?? double.infinity),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Flexible(
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
style: STextStyles.pageTitleH2(context),
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
2024-06-18 20:35:31 +00:00
|
|
|
icon != null ? icon! : Container(),
|
|
|
|
],
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
if (message != null)
|
|
|
|
const SizedBox(
|
|
|
|
height: 8,
|
|
|
|
),
|
|
|
|
if (message != null)
|
2024-06-25 19:38:32 +00:00
|
|
|
ConstrainedBox(
|
|
|
|
constraints:
|
|
|
|
BoxConstraints(maxWidth: maxWidth ?? double.infinity),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Flexible(
|
|
|
|
child: Text(
|
|
|
|
message!,
|
|
|
|
style: STextStyles.smallMed14(context),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 20,
|
|
|
|
),
|
2024-06-18 20:35:31 +00:00
|
|
|
ConstrainedBox(
|
|
|
|
constraints: BoxConstraints(maxWidth: maxWidth ?? double.infinity),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
leftButton == null
|
|
|
|
? const Spacer()
|
|
|
|
: Expanded(child: leftButton!),
|
|
|
|
const SizedBox(
|
|
|
|
width: 8,
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: TextButton(
|
|
|
|
onPressed: !Util.isDesktop
|
|
|
|
? () {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
onOkPressed?.call("OK");
|
2024-01-19 23:44:01 +00:00
|
|
|
}
|
2024-06-18 20:35:31 +00:00
|
|
|
: () {
|
|
|
|
if (desktopPopRootNavigator) {
|
|
|
|
Navigator.of(context, rootNavigator: true).pop();
|
|
|
|
} else {
|
|
|
|
int count = 0;
|
|
|
|
Navigator.of(context)
|
|
|
|
.popUntil((_) => count++ >= 2);
|
|
|
|
// onOkPressed?.call("OK");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
style: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.getPrimaryEnabledButtonStyle(context),
|
|
|
|
child: Text(
|
|
|
|
"Ok",
|
|
|
|
style: STextStyles.button(context),
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
2024-06-18 20:35:31 +00:00
|
|
|
],
|
|
|
|
),
|
2024-05-27 23:56:22 +00:00
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|