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.
- Loading branch information
Showing
9 changed files
with
308 additions
and
93 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,120 @@ | ||
import 'package:didpay/features/account/account_did_page.dart'; | ||
import 'package:didpay/features/account/account_vc_page.dart'; | ||
import 'package:didpay/features/pfis/pfis_page.dart'; | ||
import 'package:didpay/l10n/app_localizations.dart'; | ||
import 'package:didpay/shared/theme/grid.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_hooks/flutter_hooks.dart'; | ||
|
||
// TODO(ethan-tbd): redesign AccountPage, https://github.com/TBD54566975/didpay/issues/130 | ||
class AccountPage extends StatelessWidget { | ||
class AccountPage extends HookWidget { | ||
const AccountPage({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
body: SafeArea( | ||
child: _buildAccountNavigation(context), | ||
), | ||
); | ||
} | ||
Widget build(BuildContext context) => Scaffold( | ||
body: SafeArea( | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Padding( | ||
padding: const EdgeInsets.symmetric( | ||
horizontal: Grid.side, | ||
vertical: Grid.xs, | ||
), | ||
child: Text( | ||
Loc.of(context).account, | ||
style: Theme.of(context).textTheme.bodyLarge, | ||
), | ||
), | ||
Expanded( | ||
child: ListView( | ||
children: [ | ||
_buildMyPfisTile(context), | ||
_buildMyDidTile(context), | ||
_buildMyVcTile(context), | ||
], | ||
), | ||
), | ||
], | ||
), | ||
), | ||
); | ||
|
||
Widget _buildAccountNavigation(BuildContext context) => Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
Padding( | ||
padding: const EdgeInsets.symmetric( | ||
horizontal: Grid.side, | ||
vertical: Grid.xs, | ||
), | ||
child: Text( | ||
Loc.of(context).account, | ||
style: Theme.of(context).textTheme.bodyLarge, | ||
Widget _buildMyPfisTile(BuildContext context) => ListTile( | ||
title: Text( | ||
Loc.of(context).myPfis, | ||
style: Theme.of(context).textTheme.bodyLarge, | ||
), | ||
trailing: const Icon(Icons.chevron_right), | ||
leading: Container( | ||
width: Grid.md, | ||
height: Grid.md, | ||
decoration: BoxDecoration( | ||
color: Theme.of(context).colorScheme.surface, | ||
borderRadius: BorderRadius.circular(Grid.xxs), | ||
), | ||
child: const Center( | ||
child: Icon(Icons.currency_exchange), | ||
), | ||
), | ||
onTap: () { | ||
Navigator.of(context).push( | ||
MaterialPageRoute( | ||
builder: (context) => const PfisPage(), | ||
), | ||
); | ||
}, | ||
); | ||
|
||
Widget _buildMyDidTile(BuildContext context) => ListTile( | ||
title: Text( | ||
Loc.of(context).myDid, | ||
style: Theme.of(context).textTheme.bodyLarge, | ||
), | ||
trailing: const Icon(Icons.chevron_right), | ||
leading: Container( | ||
width: Grid.md, | ||
height: Grid.md, | ||
decoration: BoxDecoration( | ||
color: Theme.of(context).colorScheme.surface, | ||
borderRadius: BorderRadius.circular(Grid.xxs), | ||
), | ||
Expanded( | ||
child: ListView( | ||
children: [ | ||
ListTile( | ||
title: Text( | ||
Loc.of(context).myDid, | ||
style: Theme.of(context).textTheme.bodyLarge, | ||
), | ||
trailing: const Icon(Icons.chevron_right), | ||
leading: const Icon(Icons.text_snippet, size: Grid.md), | ||
onTap: () { | ||
Navigator.of(context).push( | ||
MaterialPageRoute( | ||
builder: (context) => const AccountDidPage(), | ||
), | ||
); | ||
}, | ||
), | ||
ListTile( | ||
title: Text( | ||
Loc.of(context).myVc, | ||
style: Theme.of(context).textTheme.bodyLarge, | ||
), | ||
trailing: const Icon(Icons.chevron_right), | ||
leading: const Icon(Icons.person, size: Grid.md), | ||
onTap: () { | ||
Navigator.of(context).push( | ||
MaterialPageRoute( | ||
builder: (context) => const AccountVCPage(), | ||
), | ||
); | ||
}, | ||
), | ||
], | ||
child: const Center( | ||
child: Icon(Icons.text_snippet), | ||
), | ||
), | ||
onTap: () { | ||
Navigator.of(context).push( | ||
MaterialPageRoute( | ||
builder: (context) => const AccountDidPage(), | ||
), | ||
); | ||
}, | ||
); | ||
|
||
Widget _buildMyVcTile(BuildContext context) => ListTile( | ||
title: Text( | ||
Loc.of(context).myVc, | ||
style: Theme.of(context).textTheme.bodyLarge, | ||
), | ||
trailing: const Icon(Icons.chevron_right), | ||
leading: Container( | ||
width: Grid.md, | ||
height: Grid.md, | ||
decoration: BoxDecoration( | ||
color: Theme.of(context).colorScheme.surface, | ||
borderRadius: BorderRadius.circular(Grid.xxs), | ||
), | ||
], | ||
child: const Center( | ||
child: Icon(Icons.person), | ||
), | ||
), | ||
onTap: () { | ||
Navigator.of(context).push( | ||
MaterialPageRoute( | ||
builder: (context) => const AccountVCPage(), | ||
), | ||
); | ||
}, | ||
); | ||
} |
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,69 @@ | ||
import 'package:didpay/features/pfis/pfi.dart'; | ||
import 'package:didpay/features/pfis/pfis_notifier.dart'; | ||
import 'package:didpay/l10n/app_localizations.dart'; | ||
import 'package:didpay/shared/theme/grid.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:hooks_riverpod/hooks_riverpod.dart'; | ||
|
||
class PfiModal { | ||
static Future<dynamic> show( | ||
BuildContext context, | ||
WidgetRef ref, | ||
Pfi pfi, | ||
) => | ||
showModalBottomSheet( | ||
useSafeArea: true, | ||
isScrollControlled: true, | ||
context: context, | ||
builder: (context) => SafeArea( | ||
child: Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
Padding( | ||
padding: const EdgeInsets.symmetric(vertical: Grid.sm), | ||
child: Text( | ||
pfi.did, | ||
style: Theme.of(context).textTheme.titleMedium?.copyWith( | ||
fontWeight: FontWeight.bold, | ||
), | ||
textAlign: TextAlign.center, | ||
), | ||
), | ||
Divider( | ||
color: Theme.of(context).colorScheme.outlineVariant, | ||
thickness: 0.25, | ||
), | ||
ListTile( | ||
title: Center( | ||
child: Text( | ||
Loc.of(context).removePfi, | ||
style: | ||
TextStyle(color: Theme.of(context).colorScheme.error), | ||
), | ||
), | ||
onTap: () async { | ||
await ref.read(pfisProvider.notifier).remove(pfi); | ||
// ignore: use_build_context_synchronously | ||
Navigator.pop(context); | ||
}, | ||
), | ||
Divider( | ||
color: Theme.of(context).colorScheme.outlineVariant, | ||
thickness: 0.25, | ||
), | ||
ListTile( | ||
title: Center( | ||
child: Text( | ||
Loc.of(context).cancel, | ||
style: Theme.of(context).textTheme.bodyLarge, | ||
), | ||
), | ||
onTap: () { | ||
Navigator.pop(context); | ||
}, | ||
), | ||
], | ||
), | ||
), | ||
); | ||
} |
Oops, something went wrong.