Skip to content

Commit

Permalink
fix: golden test and flexible parent error
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaxiii committed Jun 3, 2024
1 parent 780be75 commit 0662490
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 126 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,65 +59,69 @@ class _Buttons extends StatelessWidget {
final VoidCallback onSendMoneyPressed;

@override
Widget build(BuildContext context) => DecoratedBox(
decoration: const BoxDecoration(
color: CpColors.dashboardBackgroundColor,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(31),
topRight: Radius.circular(31),
),
Widget build(BuildContext context) {
final MediaQueryData mediaQueryData = MediaQuery.of(context);

return DecoratedBox(
decoration: const BoxDecoration(
color: CpColors.dashboardBackgroundColor,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(31),
topRight: Radius.circular(31),
),
child: ValueStreamBuilder<bool>(
create: () =>
sl<WatchUserCashBalance>().call().map((it) => it.isZero),
builder: (context, isZeroAmount) => Padding(
padding:
const EdgeInsets.only(left: 18, top: 20, right: 18, bottom: 8),
child: Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
FittedBox(
child: Text(
isZeroAmount
? context.l10n.fundYourAccount
: context.l10n.investmentHeaderButtonsTitle,
textAlign: TextAlign.center,
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.w500,
fontSize: 17,
letterSpacing: 0.23,
),
),
child: ValueStreamBuilder<bool>(
create: () => sl<WatchUserCashBalance>().call().map((it) => it.isZero),
builder: (context, isZeroAmount) => Padding(
padding:
const EdgeInsets.only(left: 18, top: 20, right: 18, bottom: 8),
child: Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
FittedBox(
child: Text(
isZeroAmount
? context.l10n.fundYourAccount
: context.l10n.investmentHeaderButtonsTitle,
textAlign: TextAlign.center,
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.w500,
fontSize: 17,
letterSpacing: 0.23,
),
),
const SizedBox(height: 8),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (!isZeroAmount) ...[
Flexible(
child: CpButton(
minWidth: 250,
size: CpButtonSize.wide,
text: context.l10n.sendMoney,
onPressed: onSendMoneyPressed,
),
),
const SizedBox(width: 8),
],
const AddCashButton(size: CpButtonSize.wide),
if (!isZeroAmount) ...[
const SizedBox(width: 8),
const CashOutButton(size: CpButtonSize.wide),
],
),
const SizedBox(height: 8),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
if (!isZeroAmount) ...[
SizedBox(
width: mediaQueryData.size.width * 0.3,
child:
PayOrRequestButton(voidCallback: onSendMoneyPressed),
),
],
),
],
),
SizedBox(
width: mediaQueryData.size.width * 0.3,
child: const AddCashButton(size: CpButtonSize.wide),
),
if (!isZeroAmount) ...[
SizedBox(
width: mediaQueryData.size.width * 0.3,
child: const CashOutButton(size: CpButtonSize.wide),
),
],
],
),
],
),
),
);
),
);
}
}

class _Info extends StatelessWidget {
Expand Down
140 changes: 67 additions & 73 deletions packages/espressocash_app/lib/features/ramp/widgets/ramp_buttons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,23 @@ class PayOrRequestButton extends StatelessWidget {
final CpButtonSize size;
final VoidCallback voidCallback;
@override
Widget build(BuildContext context) => Flexible(
child: Column(
children: [
CpIconButton(
icon: Assets.icons.dolar.svg(color: Colors.black),
variant: CpIconButtonVariant.dark,
size: CpIconButtonSize.large,
onPressed: voidCallback,
),
const SizedBox(height: 8),
Text(
context.l10n.sendMoney,
style: Theme.of(context)
.textTheme
.bodyLarge
?.copyWith(fontWeight: FontWeight.w500),
),
],
),
Widget build(BuildContext context) => Column(
children: [
CpIconButton(
icon: Assets.icons.dolar.svg(color: Colors.black),
variant: CpIconButtonVariant.dark,
size: CpIconButtonSize.large,
onPressed: voidCallback,
),
const SizedBox(height: 8),
Text(
context.l10n.sendMoney,
style: Theme.of(context)
.textTheme
.bodyLarge
?.copyWith(fontWeight: FontWeight.w500),
),
],
);
}

Expand All @@ -65,33 +63,31 @@ class AddCashButton extends StatelessWidget {
final CpButtonSize size;

@override
Widget build(BuildContext context) => Flexible(
child: Column(
children: [
CpIconButton(
icon: Assets.icons.addAlternative.svg(color: Colors.black),
variant: CpIconButtonVariant.dark,
size: CpIconButtonSize.large,
onPressed: () async {
final data = await context.ensureProfileData(RampType.onRamp);
if (context.mounted && data != null) {
context.launchOnRampFlow(
profile: data,
address: sl<MyAccount>().wallet.publicKey.toBase58(),
);
}
},
),
const SizedBox(height: 8),
Text(
context.l10n.ramp_btnAddCash,
style: Theme.of(context)
.textTheme
.bodyLarge
?.copyWith(fontWeight: FontWeight.w500),
),
],
),
Widget build(BuildContext context) => Column(
children: [
CpIconButton(
icon: Assets.icons.addAlternative.svg(color: Colors.black),
variant: CpIconButtonVariant.dark,
size: CpIconButtonSize.large,
onPressed: () async {
final data = await context.ensureProfileData(RampType.onRamp);
if (context.mounted && data != null) {
context.launchOnRampFlow(
profile: data,
address: sl<MyAccount>().wallet.publicKey.toBase58(),
);
}
},
),
const SizedBox(height: 8),
Text(
context.l10n.ramp_btnAddCash,
style: Theme.of(context)
.textTheme
.bodyLarge
?.copyWith(fontWeight: FontWeight.w500),
),
],
);
}

Expand All @@ -104,33 +100,31 @@ class CashOutButton extends StatelessWidget {
final CpButtonSize size;

@override
Widget build(BuildContext context) => Flexible(
child: Column(
children: [
CpIconButton(
icon: Assets.icons.withdrawn.svg(color: Colors.black),
variant: CpIconButtonVariant.dark,
size: CpIconButtonSize.large,
onPressed: () async {
final data = await context.ensureProfileData(RampType.offRamp);
if (context.mounted && data != null) {
context.launchOffRampFlow(
profile: data,
address: sl<MyAccount>().wallet.publicKey.toBase58(),
);
}
},
),
const SizedBox(height: 8),
Text(
context.l10n.ramp_btnCashOut,
style: Theme.of(context)
.textTheme
.bodyLarge
?.copyWith(fontWeight: FontWeight.w500),
),
],
),
Widget build(BuildContext context) => Column(
children: [
CpIconButton(
icon: Assets.icons.withdrawn.svg(color: Colors.black),
variant: CpIconButtonVariant.dark,
size: CpIconButtonSize.large,
onPressed: () async {
final data = await context.ensureProfileData(RampType.offRamp);
if (context.mounted && data != null) {
context.launchOffRampFlow(
profile: data,
address: sl<MyAccount>().wallet.publicKey.toBase58(),
);
}
},
),
const SizedBox(height: 8),
Text(
context.l10n.ramp_btnCashOut,
style: Theme.of(context)
.textTheme
.bodyLarge
?.copyWith(fontWeight: FontWeight.w500),
),
],
);
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0662490

Please sign in to comment.