stack_wallet/lib/pages/paynym/subwidgets/paynym_card_button.dart

135 lines
4.5 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
*
*/
import 'package:flutter/material.dart';
2023-01-09 19:15:15 +00:00
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../models/paynym/paynym_account_lite.dart';
import '../dialogs/paynym_details_popup.dart';
import 'paynym_bot.dart';
import '../../../providers/ui/selected_paynym_details_item_Provider.dart';
import '../../../themes/stack_colors.dart';
import '../../../utilities/constants.dart';
import '../../../utilities/format.dart';
import '../../../utilities/text_styles.dart';
import '../../../utilities/util.dart';
import '../../../widgets/rounded_container.dart';
2023-01-09 19:15:15 +00:00
class PaynymCardButton extends ConsumerStatefulWidget {
const PaynymCardButton({
2024-05-27 23:56:22 +00:00
super.key,
required this.walletId,
required this.accountLite,
2024-05-27 23:56:22 +00:00
});
final String walletId;
final PaynymAccountLite accountLite;
@override
2023-01-09 19:15:15 +00:00
ConsumerState<PaynymCardButton> createState() => _PaynymCardButtonState();
}
2023-01-09 19:15:15 +00:00
class _PaynymCardButtonState extends ConsumerState<PaynymCardButton> {
final isDesktop = Util.isDesktop;
@override
Widget build(BuildContext context) {
return Padding(
2023-01-09 19:15:15 +00:00
padding: const EdgeInsets.all(4),
child: RoundedContainer(
padding: const EdgeInsets.all(0),
2023-01-09 19:15:15 +00:00
color: isDesktop &&
ref
.watch(selectedPaynymDetailsItemProvider.state)
.state
?.nymId ==
widget.accountLite.nymId
? Theme.of(context)
.extension<StackColors>()!
.accentColorDark
.withOpacity(0.08)
: Colors.transparent,
child: RawMaterialButton(
padding: const EdgeInsets.all(0),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
2023-01-09 19:15:15 +00:00
),
onPressed: () {
if (isDesktop) {
ref.read(selectedPaynymDetailsItemProvider.state).state =
widget.accountLite;
} else {
showDialog<void>(
context: context,
builder: (context) => PaynymDetailsPopup(
accountLite: widget.accountLite,
walletId: widget.walletId,
),
);
}
},
child: Padding(
padding: isDesktop
? const EdgeInsets.symmetric(
vertical: 8,
horizontal: 12,
)
: const EdgeInsets.all(8.0),
child: Row(
children: [
PayNymBot(
2023-02-01 21:02:41 +00:00
size: 36,
2023-01-09 19:15:15 +00:00
paymentCodeString: widget.accountLite.code,
),
2023-01-09 19:15:15 +00:00
const SizedBox(
width: 12,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.accountLite.nymName,
style: isDesktop
? STextStyles.desktopTextExtraExtraSmall(context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textFieldActiveText,
)
2023-02-01 21:02:41 +00:00
: STextStyles.w500_14(context),
2023-01-09 19:15:15 +00:00
),
const SizedBox(
height: 2,
),
Text(
Format.shorten(widget.accountLite.code, 12, 5),
style: isDesktop
? STextStyles.desktopTextExtraExtraSmall(context)
2023-02-01 21:02:41 +00:00
: STextStyles.w500_14(context).copyWith(
2023-01-09 19:15:15 +00:00
color: Theme.of(context)
.extension<StackColors>()!
.textSubtitle1,
),
),
],
),
),
],
),
),
),
),
);
}
}