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 'package:stackwallet/models/paynym/paynym_account.dart';
|
2022-12-21 17:14:50 +00:00
|
|
|
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
2022-12-21 17:18:00 +00:00
|
|
|
import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart';
|
2022-12-21 17:14:50 +00:00
|
|
|
import 'package:stackwallet/utilities/assets.dart';
|
2022-12-21 17:06:53 +00:00
|
|
|
import 'package:stackwallet/utilities/text_styles.dart';
|
|
|
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
2023-01-04 17:20:25 +00:00
|
|
|
import 'package:stackwallet/utilities/util.dart';
|
2022-12-21 17:06:53 +00:00
|
|
|
import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart';
|
|
|
|
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
|
2023-01-04 17:20:25 +00:00
|
|
|
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
|
2022-12-21 17:06:53 +00:00
|
|
|
|
|
|
|
class PaynymQrPopup extends StatelessWidget {
|
|
|
|
const PaynymQrPopup({
|
|
|
|
Key? key,
|
|
|
|
required this.paynymAccount,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
final PaynymAccount paynymAccount;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-01-04 17:20:25 +00:00
|
|
|
final isDesktop = Util.isDesktop;
|
|
|
|
|
2022-12-21 17:06:53 +00:00
|
|
|
return DesktopDialog(
|
2023-01-04 17:20:25 +00:00
|
|
|
maxWidth: isDesktop ? 580 : MediaQuery.of(context).size.width - 32,
|
2022-12-21 17:06:53 +00:00
|
|
|
maxHeight: double.infinity,
|
|
|
|
child: Column(
|
|
|
|
children: [
|
2023-01-04 17:20:25 +00:00
|
|
|
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(
|
2023-01-04 17:20:25 +00:00
|
|
|
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.codes.first.code,
|
2023-01-04 17:20:25 +00:00
|
|
|
size: isDesktop ? 56 : 32,
|
2022-12-21 17:06:53 +00:00
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
width: 12,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
paynymAccount.nymName,
|
2023-01-04 17:20:25 +00:00
|
|
|
style: isDesktop
|
|
|
|
? STextStyles.w500_24(context)
|
|
|
|
: STextStyles.w600_12(context),
|
2022-12-21 17:06:53 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2023-01-04 17:20:25 +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(
|
|
|
|
constraints: const BoxConstraints(minHeight: 107),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text(
|
2023-01-04 17:20:25 +00:00
|
|
|
isDesktop ? "PayNym address" : "Your PayNym address",
|
|
|
|
style: isDesktop
|
|
|
|
? STextStyles.desktopTextSmall(context).copyWith(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textSubtitle1,
|
|
|
|
)
|
|
|
|
: STextStyles.infoSmall(context),
|
2022-12-21 17:06:53 +00:00
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 6,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
paynymAccount.codes.first.code,
|
2023-01-04 17:20:25 +00:00
|
|
|
style: isDesktop
|
|
|
|
? STextStyles.desktopTextSmall(context)
|
|
|
|
: STextStyles.infoSmall(context).copyWith(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.extension<StackColors>()!
|
|
|
|
.textDark,
|
|
|
|
),
|
2022-12-21 17:06:53 +00:00
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 6,
|
|
|
|
),
|
|
|
|
BlueTextButton(
|
|
|
|
text: "Copy",
|
2023-01-04 17:20:25 +00:00
|
|
|
textSize: isDesktop ? 18 : 10,
|
2022-12-21 17:06:53 +00:00
|
|
|
onTap: () async {
|
|
|
|
await Clipboard.setData(
|
|
|
|
ClipboardData(
|
|
|
|
text: paynymAccount.codes.first.code,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
unawaited(
|
|
|
|
showFloatingFlushBar(
|
|
|
|
type: FlushBarType.info,
|
|
|
|
message: "Copied to clipboard",
|
|
|
|
iconAsset: Assets.svg.copy,
|
|
|
|
context: context,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
width: 20,
|
|
|
|
),
|
|
|
|
QrImage(
|
|
|
|
padding: const EdgeInsets.all(0),
|
|
|
|
size: 107,
|
|
|
|
data: paynymAccount.codes.first.code,
|
|
|
|
foregroundColor:
|
|
|
|
Theme.of(context).extension<StackColors>()!.textDark,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|