Skip to content

Commit

Permalink
feat: dap send page (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethan-tbd committed Jun 24, 2024
1 parent f7a5e60 commit c1906a6
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 309 deletions.
59 changes: 31 additions & 28 deletions lib/features/account/account_balance_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AccountBalanceCard extends HookConsumerWidget {
final pfis = ref.watch(pfisProvider);
final accountBalance = ref.watch(accountBalanceProvider);

final accountTotal = accountBalance.asData?.value?.total ?? '';
final accountTotal = accountBalance.asData?.value?.total ?? '0';
final accountCurrency = accountBalance.asData?.value?.currencyCode ?? '';

AccountBalanceNotifier getAccountBalanceNotifier() =>
Expand Down Expand Up @@ -70,35 +70,36 @@ class AccountBalanceCard extends HookConsumerWidget {
BuildContext context,
String accountTotal,
String accountCurrency,
) =>
Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
children: [
Flexible(
child: AutoSizeText(
accountTotal,
style: Theme.of(context).textTheme.displayMedium?.copyWith(
fontWeight: FontWeight.bold,
),
maxLines: 1,
),
) {
return Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
children: [
Flexible(
child: AutoSizeText(
accountTotal,
style: Theme.of(context).textTheme.displayMedium?.copyWith(
fontWeight: FontWeight.bold,
),
maxLines: 1,
),
const SizedBox(width: Grid.half),
Padding(
padding: const EdgeInsets.symmetric(horizontal: Grid.xxs),
child: Text(
accountCurrency,
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
fontWeight: FontWeight.bold,
),
),
),
const SizedBox(width: Grid.half),
Padding(
padding: const EdgeInsets.symmetric(horizontal: Grid.xxs),
child: Text(
accountCurrency,
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
fontWeight: FontWeight.bold,
),
),
],
),
);
),
],
),
);
}

Widget _buildDepositWithdrawButtons(BuildContext context) => Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
Expand All @@ -112,6 +113,7 @@ class AccountBalanceCard extends HookConsumerWidget {
transactionType: TransactionType.deposit,
),
),
fullscreenDialog: true,
),
),
child: Text(Loc.of(context).deposit),
Expand All @@ -127,6 +129,7 @@ class AccountBalanceCard extends HookConsumerWidget {
transactionType: TransactionType.withdraw,
),
),
fullscreenDialog: true,
),
),
child: Text(Loc.of(context).withdraw),
Expand Down
14 changes: 6 additions & 8 deletions lib/features/account/account_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,12 @@ class AccountPage extends HookConsumerWidget {
),
child: IconButton(
icon: const Icon(Icons.qr_code, size: Grid.sm),
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => DidQrTabs(dap: dap),
fullscreenDialog: true,
),
);
},
onPressed: () => Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => DidQrTabs(dap: dap),
fullscreenDialog: true,
),
),
),
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/features/did/did_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class DidForm extends HookConsumerWidget {
),
),
DidQrTile(
title: Loc.of(context).dontKnowTheirDid,
title: Loc.of(context).dontKnowTheirDap,
didTextController: textController,
errorText: errorText,
),
Expand Down
5 changes: 5 additions & 0 deletions lib/features/feature_flags/feature_flag.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ const lucidMode = FeatureFlag(
name: 'Lucid mode',
description: 'Access all your PFI offerings',
);

const remittance = FeatureFlag(
name: 'Remittance',
description: 'Experience a tranditional remittance flow',
);
58 changes: 0 additions & 58 deletions lib/features/send/send_details_page.dart

This file was deleted.

106 changes: 32 additions & 74 deletions lib/features/send/send_page.dart
Original file line number Diff line number Diff line change
@@ -1,82 +1,49 @@
import 'package:didpay/features/account/account_balance_notifier.dart';
import 'package:didpay/features/countries/countries_page.dart';
import 'package:didpay/features/did/did_form.dart';
import 'package:didpay/features/feature_flags/feature_flag.dart';
import 'package:didpay/features/feature_flags/feature_flags_notifier.dart';
import 'package:didpay/features/feature_flags/lucid/lucid_offerings_page.dart';
import 'package:didpay/features/send/send_details_page.dart';
import 'package:didpay/features/payment/payment_amount_page.dart';
import 'package:didpay/features/payment/payment_state.dart';
import 'package:didpay/features/transaction/transaction.dart';
import 'package:didpay/l10n/app_localizations.dart';
import 'package:didpay/shared/next_button.dart';
import 'package:didpay/shared/number/number_display.dart';
import 'package:didpay/shared/number/number_key_press.dart';
import 'package:didpay/shared/number/number_pad.dart';
import 'package:didpay/shared/header.dart';
import 'package:didpay/shared/theme/grid.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';

class SendPage extends HookConsumerWidget {
const SendPage({super.key});

@override
Widget build(BuildContext context, WidgetRef ref) {
final accountBalance = ref.watch(accountBalanceProvider);
final featureFlags = ref.watch(featureFlagsProvider);

final amount = useState('0');
final keyPress = useState(NumberKeyPress(0, ''));

final sendCurrency = accountBalance.asData?.value?.currencyCode ?? '';

return Scaffold(
appBar: _buildAppBar(context, featureFlags),
body: SafeArea(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Header(
title: Loc.of(context).enterRecipientDap,
subtitle: Loc.of(context).makeSureInfoIsCorrect,
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding:
const EdgeInsets.symmetric(horizontal: Grid.side),
child: NumberDisplay(
currencyCode: sendCurrency,
currencyWidget: _buildCurrency(context, sendCurrency),
amount: amount,
keyPress: keyPress,
textStyle: const TextStyle(
fontSize: 80,
fontWeight: FontWeight.bold,
),
),
child: DidForm(
buttonTitle: Loc.of(context).next,
onSubmit: (did) => Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => const PaymentAmountPage(
paymentState: PaymentState(
transactionType: TransactionType.send,
),
],
),
fullscreenDialog: true,
),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: Grid.xs),
child: NumberPad(
onKeyPressed: (key) => keyPress.value =
NumberKeyPress(keyPress.value.count + 1, key),
),
),
),
NextButton(
onPressed: double.tryParse(amount.value) == 0
? null
: () => Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
SendDetailsPage(sendAmount: amount.value),
),
),
title: Loc.of(context).send,
),
],
),
),
Expand All @@ -85,19 +52,20 @@ class SendPage extends HookConsumerWidget {

AppBar _buildAppBar(BuildContext context, List<FeatureFlag> featureFlags) =>
AppBar(
leading: Padding(
padding: const EdgeInsets.only(left: Grid.xxs),
child: IconButton(
icon: const Icon(Icons.language, size: Grid.lg),
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => const CountriesPage(),
leading: featureFlags
.any((flag) => flag.name == 'Remittance' && flag.isEnabled)
? Padding(
padding: const EdgeInsets.only(left: Grid.xxs),
child: IconButton(
icon: const Icon(Icons.language, size: Grid.lg),
onPressed: () => Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => const CountriesPage(),
),
),
),
);
},
),
),
)
: null,
actions: featureFlags.any(
(flag) => flag.name == Loc.of(context).lucidMode && flag.isEnabled,
)
Expand All @@ -116,14 +84,4 @@ class SendPage extends HookConsumerWidget {
]
: null,
);

Widget _buildCurrency(BuildContext context, String sendCurrency) => Padding(
padding: const EdgeInsets.symmetric(horizontal: Grid.xxs),
child: Text(
sendCurrency,
style: Theme.of(context).textTheme.displayMedium?.copyWith(
fontWeight: FontWeight.bold,
),
),
);
}
4 changes: 2 additions & 2 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
"cancel": "Cancel",
"linkedPfis": "Linked PFIs",
"noTransactionsFound": "No transactions found",
"enterRecipientDid": "Enter the recipient's DID",
"enterRecipientDap": "Enter the recipient's DAP",
"fetchingOfferings": "Fetching offerings...",
"startingIdv": "Starting identity verification...",
"verifyingYourIdentity": "Verifying your identity...",
Expand All @@ -144,7 +144,7 @@
"fetchingTransactions": "Fetching transactions...",
"scan": "Scan",
"cameraUnavailable": "Camera unavailable",
"dontKnowTheirDid": "Don't know their DID? Scan their DID QR code instead",
"dontKnowTheirDap": "Don't know their DAP? Scan their QR code instead",
"featureFlags": "Feature flags",
"lucidMode": "Lucid mode",
"selectFromUnfilteredList": "Select from an unfiltered list of all your PFI offerings.",
Expand Down
12 changes: 6 additions & 6 deletions lib/l10n/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -697,11 +697,11 @@ abstract class Loc {
/// **'No transactions found'**
String get noTransactionsFound;

/// No description provided for @enterRecipientDid.
/// No description provided for @enterRecipientDap.
///
/// In en, this message translates to:
/// **'Enter the recipient\'s DID'**
String get enterRecipientDid;
/// **'Enter the recipient\'s DAP'**
String get enterRecipientDap;

/// No description provided for @fetchingOfferings.
///
Expand Down Expand Up @@ -769,11 +769,11 @@ abstract class Loc {
/// **'Camera unavailable'**
String get cameraUnavailable;

/// No description provided for @dontKnowTheirDid.
/// No description provided for @dontKnowTheirDap.
///
/// In en, this message translates to:
/// **'Don\'t know their DID? Scan their DID QR code instead'**
String get dontKnowTheirDid;
/// **'Don\'t know their DAP? Scan their QR code instead'**
String get dontKnowTheirDap;

/// No description provided for @featureFlags.
///
Expand Down
Loading

0 comments on commit c1906a6

Please sign in to comment.