2023-01-05 22:19:02 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2023-01-09 19:15:15 +00:00
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
2023-01-05 22:19:02 +00:00
|
|
|
import 'package:stackwallet/models/paynym/paynym_account_lite.dart';
|
|
|
|
import 'package:stackwallet/pages/paynym/dialogs/paynym_details_popup.dart';
|
|
|
|
import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart';
|
2023-01-09 19:15:15 +00:00
|
|
|
import 'package:stackwallet/providers/ui/selected_paynym_details_item_Provider.dart';
|
2023-05-09 21:57:40 +00:00
|
|
|
import 'package:stackwallet/themes/stack_colors.dart';
|
2023-01-05 22:19:02 +00:00
|
|
|
import 'package:stackwallet/utilities/constants.dart';
|
|
|
|
import 'package:stackwallet/utilities/format.dart';
|
|
|
|
import 'package:stackwallet/utilities/text_styles.dart';
|
|
|
|
import 'package:stackwallet/utilities/util.dart';
|
2023-01-09 19:15:15 +00:00
|
|
|
import 'package:stackwallet/widgets/rounded_container.dart';
|
2023-01-05 22:19:02 +00:00
|
|
|
|
2023-01-09 19:15:15 +00:00
|
|
|
class PaynymCardButton extends ConsumerStatefulWidget {
|
2023-01-05 22:19:02 +00:00
|
|
|
const PaynymCardButton({
|
|
|
|
Key? key,
|
|
|
|
required this.walletId,
|
|
|
|
required this.accountLite,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
final String walletId;
|
|
|
|
final PaynymAccountLite accountLite;
|
|
|
|
|
|
|
|
@override
|
2023-01-09 19:15:15 +00:00
|
|
|
ConsumerState<PaynymCardButton> createState() => _PaynymCardButtonState();
|
2023-01-05 22:19:02 +00:00
|
|
|
}
|
|
|
|
|
2023-01-09 19:15:15 +00:00
|
|
|
class _PaynymCardButtonState extends ConsumerState<PaynymCardButton> {
|
2023-01-05 22:19:02 +00:00
|
|
|
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(
|
2023-01-05 22:19:02 +00:00
|
|
|
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-05 22:19:02 +00:00
|
|
|
),
|
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-05 22:19:02 +00:00
|
|
|
),
|
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,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2023-01-05 22:19:02 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|