generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add account balance widget (#11)
* move `SendPage` to app tabs * update tests for new send tab * update `outline` color in `lightColorScheme` * add `accountBalance` localization * add `AccountBalance` widget * add test for `AccountBalance` widget
- Loading branch information
Showing
9 changed files
with
133 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_hooks/flutter_hooks.dart'; | ||
import 'package:flutter_starter/l10n/app_localizations.dart'; | ||
|
||
class AccountBalance extends HookWidget { | ||
const AccountBalance({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Padding( | ||
padding: const EdgeInsets.symmetric(horizontal: 20.0), | ||
child: Container( | ||
decoration: BoxDecoration( | ||
border: Border.all( | ||
color: Theme.of(context).colorScheme.outline, width: 2.0), | ||
borderRadius: BorderRadius.circular(24.0), | ||
), | ||
padding: const EdgeInsets.symmetric(horizontal: 20.0, vertical: 16.0), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Text( | ||
Loc.of(context).accountBalance, | ||
style: Theme.of(context).textTheme.labelMedium, | ||
), | ||
const SizedBox(height: 10), | ||
Center( | ||
child: Text( | ||
'\$0.00', | ||
style: Theme.of(context).textTheme.displayMedium?.copyWith( | ||
fontWeight: FontWeight.bold, | ||
), | ||
), | ||
), | ||
const SizedBox(height: 20), | ||
Row( | ||
mainAxisAlignment: MainAxisAlignment.spaceEvenly, | ||
children: [ | ||
Expanded( | ||
child: FilledButton( | ||
onPressed: () {}, child: Text(Loc.of(context).deposit)), | ||
), | ||
const SizedBox( | ||
width: 20, | ||
), | ||
Expanded( | ||
child: FilledButton( | ||
onPressed: () {}, child: Text(Loc.of(context).withdraw)), | ||
), | ||
], | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
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
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,43 @@ | ||
import 'package:flutter_starter/features/home/account_balance.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
import '../../helpers/widget_helpers.dart'; | ||
|
||
void main() { | ||
group('AccountBalance', () { | ||
testWidgets('should show account balance', (widgetTester) async { | ||
await widgetTester.pumpWidget( | ||
WidgetHelpers.testableWidget(child: const AccountBalance()), | ||
); | ||
|
||
expect(find.text('Account balance'), findsOneWidget); | ||
}); | ||
|
||
testWidgets('should show valid account balance amount', | ||
(widgetTester) async { | ||
await widgetTester.pumpWidget( | ||
WidgetHelpers.testableWidget(child: const AccountBalance()), | ||
); | ||
|
||
final dollarAmountPattern = RegExp(r'\$[0-9]+\.[0-9]{2}$'); | ||
|
||
expect(find.textContaining(dollarAmountPattern), findsOneWidget); | ||
}); | ||
|
||
testWidgets('should show deposit button', (tester) async { | ||
await tester.pumpWidget( | ||
WidgetHelpers.testableWidget(child: const AccountBalance()), | ||
); | ||
|
||
expect(find.text('Deposit'), findsOneWidget); | ||
}); | ||
|
||
testWidgets('should show withdraw button', (tester) async { | ||
await tester.pumpWidget( | ||
WidgetHelpers.testableWidget(child: const AccountBalance()), | ||
); | ||
|
||
expect(find.text('Withdraw'), findsOneWidget); | ||
}); | ||
}); | ||
} |