stack_wallet/lib/pages/paynym/dialogs/paynym_qr_popup.dart

175 lines
6 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
*
*/
2022-12-21 17:06:53 +00:00
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:qr_flutter/qr_flutter.dart';
import '../../../models/paynym/paynym_account.dart';
import '../../../notifications/show_flush_bar.dart';
import '../subwidgets/paynym_bot.dart';
import '../../../themes/stack_colors.dart';
import '../../../utilities/assets.dart';
import '../../../utilities/text_styles.dart';
import '../../../utilities/util.dart';
import '../../../widgets/custom_buttons/blue_text_button.dart';
import '../../../widgets/desktop/desktop_dialog.dart';
import '../../../widgets/desktop/desktop_dialog_close_button.dart';
2022-12-21 17:06:53 +00:00
class PaynymQrPopup extends StatelessWidget {
const PaynymQrPopup({
2024-05-27 23:56:22 +00:00
super.key,
2022-12-21 17:06:53 +00:00
required this.paynymAccount,
2024-05-27 23:56:22 +00:00
});
2022-12-21 17:06:53 +00:00
final PaynymAccount paynymAccount;
@override
Widget build(BuildContext context) {
final isDesktop = Util.isDesktop;
2022-12-21 17:06:53 +00:00
return DesktopDialog(
maxWidth: isDesktop ? 580 : MediaQuery.of(context).size.width - 32,
2022-12-21 17:06:53 +00:00
maxHeight: double.infinity,
child: Column(
children: [
if (isDesktop)
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.only(left: 32),
child: Text(
"Address details",
style: STextStyles.desktopH3(context),
),
),
const DesktopDialogCloseButton(),
],
),
2022-12-21 17:06:53 +00:00
Padding(
padding: EdgeInsets.only(
left: isDesktop ? 32 : 24,
top: isDesktop ? 16 : 24,
2022-12-21 17:06:53 +00:00
right: 24,
bottom: 16,
),
child: Row(
children: [
PayNymBot(
paymentCodeString: paynymAccount.nonSegwitPaymentCode.code,
2023-02-01 21:02:41 +00:00
size: isDesktop ? 56 : 36,
2022-12-21 17:06:53 +00:00
),
const SizedBox(
width: 12,
),
Text(
paynymAccount.nymName,
style: isDesktop
? STextStyles.w500_24(context)
2023-02-01 21:02:41 +00:00
: STextStyles.w600_14(context),
2022-12-21 17:06:53 +00:00
),
],
),
),
if (!isDesktop)
Container(
color:
Theme.of(context).extension<StackColors>()!.backgroundAppBar,
height: 1,
),
2022-12-21 17:06:53 +00:00
Padding(
padding: const EdgeInsets.only(
left: 24,
top: 16,
right: 24,
bottom: 24,
),
child: Row(
children: [
Expanded(
child: ConstrainedBox(
2023-02-01 21:02:41 +00:00
constraints: const BoxConstraints(minHeight: 130),
2022-12-21 17:06:53 +00:00
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
isDesktop ? "PayNym address" : "Your PayNym address",
style: isDesktop
? STextStyles.desktopTextSmall(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textSubtitle1,
)
2023-02-01 21:02:41 +00:00
: STextStyles.infoSmall(context).copyWith(
fontSize: 12,
),
2022-12-21 17:06:53 +00:00
),
const SizedBox(
height: 6,
),
Text(
paynymAccount.nonSegwitPaymentCode.code,
style: isDesktop
? STextStyles.desktopTextSmall(context)
: STextStyles.infoSmall(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textDark,
2023-02-01 21:02:41 +00:00
fontSize: 12,
),
2022-12-21 17:06:53 +00:00
),
const SizedBox(
height: 6,
),
CustomTextButton(
2022-12-21 17:06:53 +00:00
text: "Copy",
2023-02-01 21:02:41 +00:00
textSize: isDesktop ? 18 : 14,
2022-12-21 17:06:53 +00:00
onTap: () async {
await Clipboard.setData(
ClipboardData(
text: paynymAccount.nonSegwitPaymentCode.code,
2022-12-21 17:06:53 +00:00
),
);
unawaited(
showFloatingFlushBar(
type: FlushBarType.info,
message: "Copied to clipboard",
iconAsset: Assets.svg.copy,
context: context,
),
);
},
),
],
),
),
),
const SizedBox(
width: 20,
),
2023-06-05 13:40:56 +00:00
QrImageView(
2022-12-21 17:06:53 +00:00
padding: const EdgeInsets.all(0),
2023-02-01 21:02:41 +00:00
size: 130,
data: paynymAccount.nonSegwitPaymentCode.code,
2022-12-21 17:06:53 +00:00
foregroundColor:
Theme.of(context).extension<StackColors>()!.textDark,
),
],
),
2024-05-27 23:56:22 +00:00
),
2022-12-21 17:06:53 +00:00
],
),
);
}
}