stack_wallet/lib/widgets/dialogs/basic_dialog.dart

126 lines
3.2 KiB
Dart
Raw Normal View History

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
*
*/
2023-05-01 17:18:11 +00:00
import 'package:flutter/material.dart';
import '../../utilities/text_styles.dart';
import '../../utilities/util.dart';
import '../desktop/desktop_dialog.dart';
import '../desktop/desktop_dialog_close_button.dart';
import '../stack_dialog.dart';
2023-05-01 17:18:11 +00:00
class BasicDialog extends StatelessWidget {
const BasicDialog({
2024-05-27 23:56:22 +00:00
super.key,
2023-05-01 17:18:11 +00:00
this.leftButton,
this.rightButton,
this.icon,
required this.title,
this.message,
this.desktopHeight = 474,
this.desktopWidth = 641,
this.canPopWithBackButton = false,
this.flex = false,
2024-05-27 23:56:22 +00:00
});
2023-05-01 17:18:11 +00:00
final Widget? leftButton;
final Widget? rightButton;
final Widget? icon;
final String title;
final String? message;
final double? desktopHeight;
final double desktopWidth;
final bool canPopWithBackButton;
final bool flex;
2023-05-01 17:18:11 +00:00
@override
Widget build(BuildContext context) {
final isDesktop = Util.isDesktop;
if (isDesktop) {
return DesktopDialog(
maxHeight: desktopHeight,
maxWidth: desktopWidth,
child: Column(
children: [
Padding(
padding: const EdgeInsets.only(left: 32),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
title,
style: STextStyles.desktopH3(context),
),
const DesktopDialogCloseButton(),
],
),
),
if (flex)
const Spacer(
flex: 2,
),
2023-05-01 17:18:11 +00:00
if (message != null)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 32),
child: Text(
message!,
style: STextStyles.desktopTextSmall(context),
),
),
if (flex)
const Spacer(
flex: 3,
),
2023-05-01 17:18:11 +00:00
if (leftButton != null || rightButton != null)
const SizedBox(
height: 32,
),
if (leftButton != null || rightButton != null)
Padding(
padding: const EdgeInsets.all(32),
child: Row(
children: [
leftButton != null
? Expanded(child: leftButton!)
: const Spacer(),
const SizedBox(
width: 16,
),
rightButton != null
? Expanded(child: rightButton!)
: const Spacer(),
],
),
2024-05-27 23:56:22 +00:00
),
2023-05-01 17:18:11 +00:00
],
),
);
} else {
return WillPopScope(
onWillPop: () async {
return canPopWithBackButton;
},
child: StackDialog(
title: title,
leftButton: leftButton,
rightButton: rightButton,
icon: icon,
message: message,
),
);
}
}
}