This repository has been archived by the owner on Dec 12, 2024. It is now read-only.
generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update readme * extract fee details to shared component * extract currency converter to shared component * update deposit page with shared components * add withdraw page * add navigation to withdraw page * Update account balance test * Add withdraw page test * Add fee details test * Update currency converter component * Add currency converter test * update readme, tests, component usage per comments
- Loading branch information
1 parent
bec57f4
commit ea7dfd8
Showing
14 changed files
with
494 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_hooks/flutter_hooks.dart'; | ||
import 'package:flutter_starter/l10n/app_localizations.dart'; | ||
import 'package:flutter_starter/shared/currency_converter.dart'; | ||
import 'package:flutter_starter/shared/fee_details.dart'; | ||
import 'package:flutter_starter/shared/grid.dart'; | ||
import 'package:flutter_starter/shared/number_pad.dart'; | ||
|
||
class WithdrawPage extends HookWidget { | ||
const WithdrawPage({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final withdrawAmount = useState<String>('0'); | ||
|
||
return Scaffold( | ||
appBar: AppBar(), | ||
body: SafeArea( | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.stretch, | ||
children: [ | ||
Expanded( | ||
child: SingleChildScrollView( | ||
physics: const BouncingScrollPhysics(), | ||
child: Padding( | ||
padding: const EdgeInsets.symmetric( | ||
horizontal: Grid.side, vertical: Grid.sm), | ||
child: Column( | ||
children: [ | ||
CurrencyConverter( | ||
originAmount: withdrawAmount.value, | ||
originCurrency: Loc.of(context).usd, | ||
originLabel: Loc.of(context).youWithdraw, | ||
destinationCurrency: 'MXN', | ||
exchangeRate: '17'), | ||
const SizedBox(height: Grid.xl), | ||
// these will come from PFI offerings later | ||
FeeDetails( | ||
originCurrency: Loc.of(context).usd, | ||
destinationCurrency: 'MXN', | ||
exchangeRate: '17', | ||
serviceFee: '0') | ||
], | ||
), | ||
), | ||
), | ||
), | ||
Center(child: buildNumberPad(withdrawAmount)), | ||
const SizedBox(height: Grid.sm), | ||
Padding( | ||
padding: const EdgeInsets.symmetric(horizontal: Grid.side), | ||
child: FilledButton( | ||
onPressed: () {}, | ||
child: Text(Loc.of(context).next), | ||
), | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
|
||
Widget buildNumberPad(ValueNotifier<String> withdrawAmount) { | ||
return NumberPad( | ||
onKeyPressed: (key) { | ||
withdrawAmount.value = | ||
(withdrawAmount.value == '0') ? key : '${withdrawAmount.value}$key'; | ||
}, | ||
onDeletePressed: () { | ||
withdrawAmount.value = (withdrawAmount.value.length > 1) | ||
? withdrawAmount.value.substring(0, withdrawAmount.value.length - 1) | ||
: '0'; | ||
}, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_hooks/flutter_hooks.dart'; | ||
import 'package:flutter_starter/l10n/app_localizations.dart'; | ||
import 'package:flutter_starter/shared/grid.dart'; | ||
import 'package:intl/intl.dart'; | ||
|
||
class CurrencyConverter extends HookWidget { | ||
final String originAmount; | ||
final String originCurrency; | ||
final String originLabel; | ||
final String destinationCurrency; | ||
final String exchangeRate; | ||
|
||
const CurrencyConverter({ | ||
required this.originAmount, | ||
required this.originCurrency, | ||
required this.originLabel, | ||
required this.destinationCurrency, | ||
required this.exchangeRate, | ||
super.key, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Row( | ||
crossAxisAlignment: CrossAxisAlignment.baseline, | ||
textBaseline: TextBaseline.alphabetic, | ||
children: [ | ||
Text( | ||
NumberFormat.simpleCurrency().format(double.parse(originAmount)), | ||
style: Theme.of(context).textTheme.displayMedium, | ||
), | ||
const SizedBox(width: Grid.xs), | ||
Baseline( | ||
baseline: 0, | ||
baselineType: TextBaseline.alphabetic, | ||
child: Text( | ||
originCurrency, | ||
style: Theme.of(context).textTheme.headlineMedium, | ||
), | ||
), | ||
], | ||
), | ||
const SizedBox(height: Grid.xxs), | ||
Text( | ||
originLabel, | ||
style: Theme.of(context).textTheme.bodyLarge, | ||
), | ||
const SizedBox(height: Grid.sm), | ||
Row( | ||
crossAxisAlignment: CrossAxisAlignment.baseline, | ||
textBaseline: TextBaseline.alphabetic, | ||
children: [ | ||
Text( | ||
NumberFormat.simpleCurrency().format( | ||
double.parse(originAmount) * double.parse(exchangeRate)), | ||
style: Theme.of(context).textTheme.displayMedium, | ||
), | ||
const SizedBox(width: Grid.xs), | ||
Text( | ||
destinationCurrency, | ||
style: Theme.of(context).textTheme.headlineMedium, | ||
), | ||
], | ||
), | ||
const SizedBox(height: Grid.xxs), | ||
Text( | ||
Loc.of(context).youGet, | ||
style: Theme.of(context).textTheme.bodyLarge, | ||
), | ||
], | ||
); | ||
} | ||
} |
Oops, something went wrong.