Skip to content

Commit

Permalink
V2.0.10
Browse files Browse the repository at this point in the history
Merge pull request #52 from Daniel-Ioannou/v2.0.10
  • Loading branch information
Daniel-Ioannou committed Apr 30, 2022
2 parents e9b2e64 + cb3c89f commit e699d98
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 27 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [2.0.10] - 30 Apr 2022
* Add more currencies:
- Cambodian riel
- Central African CFA franc
* Remove duplicated currency BYN

## [2.0.9] - 06 Apr 2022
* Add more currencies:
- Seychellois rupee
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A flutter package to select a currency from a list of currencies.
Add the package to your pubspec.yaml:

```yaml
currency_picker: ^2.0.9
currency_picker: ^2.0.10
```

In your dart file, import the library:
Expand Down
2 changes: 1 addition & 1 deletion example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A flutter package to select a currency from a list of currencies.
Add the package to your pubspec.yaml:

```yaml
currency_picker: ^2.0.9
currency_picker: ^2.0.10
```

In your dart file, import the library:
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.0.9"
version: "2.0.10"
fake_async:
dependency: transitive
description:
Expand Down
39 changes: 26 additions & 13 deletions lib/src/currencies.dart
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,19 @@ List<Map<String, dynamic>> currencies = [
"space_between_amount_and_symbol": false,
"symbol_on_left": true,
},
{
"code": "XAF",
"name": "Central African CFA franc",
"symbol": "FCFA",
"flag": null,
"decimal_digits": 2,
"number": 950,
"name_plural": "Central African CFA franc",
"thousands_separator": ",",
"decimal_separator": ".",
"space_between_amount_and_symbol": false,
"symbol_on_left": true,
},
{
"code": "CRC",
"name": "Costa Rica Colon",
Expand Down Expand Up @@ -754,6 +767,19 @@ List<Map<String, dynamic>> currencies = [
"space_between_amount_and_symbol": false,
"symbol_on_left": true,
},
{
"code": "KHR",
"name": "Cambodian riel",
"symbol": "៛",
"flag": "KHM",
"decimal_digits": 2,
"number": 116,
"name_plural": "Cambodian riels",
"thousands_separator": ",",
"decimal_separator": ".",
"space_between_amount_and_symbol": false,
"symbol_on_left": false,
},
{
"code": "KWD",
"name": "Kuwaiti Dinar",
Expand Down Expand Up @@ -1274,19 +1300,6 @@ List<Map<String, dynamic>> currencies = [
"space_between_amount_and_symbol": true,
"symbol_on_left": true,
},
{
"code": "BYN",
"name": "Belarussian Ruble",
"symbol": "Br",
"flag": "BY",
"decimal_digits": 2,
"number": 933,
"name_plural": "Belarusian rubles",
"thousands_separator": ".",
"decimal_separator": ",",
"space_between_amount_and_symbol": true,
"symbol_on_left": true,
},
{
"code": "SYP",
"name": "Syrian Lira",
Expand Down
2 changes: 1 addition & 1 deletion lib/src/currency.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Currency {
///The currency flag code
///
/// To get flag unicode(Emoji) use [CurrencyUtils.currencyToEmoji]
final String flag;
final String? flag;

///The currency number
final int number;
Expand Down
25 changes: 19 additions & 6 deletions lib/src/currency_list_view.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:currency_picker/src/extensions.dart';
import 'package:flutter/material.dart';

import 'currency.dart';
Expand Down Expand Up @@ -178,12 +179,7 @@ class _CurrencyListViewState extends State<CurrencyListView> {
children: [
const SizedBox(width: 15),
if (widget.showFlag) ...[
Text(
CurrencyUtils.currencyToEmoji(currency),
style: TextStyle(
fontSize: widget.theme?.flagSize ?? 25,
),
),
_flagWidget(currency),
const SizedBox(width: 15),
],
Expanded(
Expand Down Expand Up @@ -224,6 +220,23 @@ class _CurrencyListViewState extends State<CurrencyListView> {
);
}

Widget _flagWidget(Currency currency) {
if (currency.flag == null) {
return Image.asset(
'no_flag.png'.imagePath,
package: 'currency_picker',
width: 27,
);
}

return Text(
CurrencyUtils.currencyToEmoji(currency),
style: TextStyle(
fontSize: widget.theme?.flagSize ?? 25,
),
);
}

void _filterSearchResults(String query) {
List<Currency> _searchResult = <Currency>[];

Expand Down
4 changes: 2 additions & 2 deletions lib/src/currency_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import 'currency.dart';

class CurrencyUtils {
/// Return Flag (Emoji Unicode) of a given currency
static String currencyToEmoji(Currency? currency) {
final String currencyFlag = currency!.flag;
static String currencyToEmoji(Currency currency) {
final String currencyFlag = currency.flag!;
// 0x41 is Letter A
// 0x1F1E6 is Regional Indicator Symbol Letter A
// Example :
Expand Down
3 changes: 3 additions & 0 deletions lib/src/extensions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
extension StringExtensions on String {
String get imagePath => 'lib/src/res/$this';
}
Binary file added lib/src/res/no_flag.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: A flutter package to select a currency from a list of currencies.
homepage: https://github.com/Daniel-Ioannou
repository: https://github.com/Daniel-Ioannou/flutter_currency_picker

version: 2.0.9
version: 2.0.10

environment:
sdk: '>=2.12.0 <3.0.0'
Expand All @@ -15,9 +15,13 @@ dependencies:
sdk: flutter
collection: ^1.15.0

flutter:
assets:
- lib/src/res/

dev_dependencies:
flutter_test:
sdk: flutter
lint: ^1.8.2

flutter:

0 comments on commit e699d98

Please sign in to comment.