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.
* Add currency modal bottom sheet * Refactor currency converter and consuming pages * Refactor modal bottom sheet list
- Loading branch information
1 parent
140c9ee
commit ceedceb
Showing
7 changed files
with
269 additions
and
90 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,50 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_starter/shared/grid.dart'; | ||
|
||
class CurrencyModal { | ||
static Future<dynamic> showCurrencyModal( | ||
BuildContext context, | ||
Function(String) onPressed, | ||
List<Map<String, Object>> supportedCurrencyList, | ||
String selectedCurrency) { | ||
return showModalBottomSheet( | ||
useSafeArea: true, | ||
isScrollControlled: true, | ||
context: context, | ||
builder: (BuildContext context) { | ||
return SafeArea( | ||
child: SizedBox( | ||
height: supportedCurrencyList.length * 80, | ||
child: Column(children: [ | ||
Padding( | ||
padding: const EdgeInsets.symmetric(vertical: Grid.xs), | ||
child: Text( | ||
'Select currency', | ||
style: Theme.of(context).textTheme.titleMedium, | ||
textAlign: TextAlign.center, | ||
)), | ||
Expanded( | ||
child: ListView( | ||
children: | ||
supportedCurrencyList.map((Map<String, Object> map) { | ||
IconData icon = map['icon'] as IconData; | ||
String label = map['label'].toString(); | ||
return (ListTile( | ||
onTap: () { | ||
onPressed(label); | ||
Navigator.pop(context); | ||
}, | ||
leading: Icon(icon), | ||
title: Text(label, | ||
style: Theme.of(context).textTheme.titleMedium), | ||
trailing: (selectedCurrency == label) | ||
? const Icon(Icons.check) | ||
: null, | ||
)); | ||
}).toList()), | ||
) | ||
]), | ||
)); | ||
}); | ||
} | ||
} |
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
Oops, something went wrong.