-
-
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.
Merge pull request #175 from flow-mn/sadespresso/feat-search-txns-160
Beta v0.6.0
- Loading branch information
Showing
78 changed files
with
2,958 additions
and
703 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
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,24 @@ | ||
import 'package:flow/data/money.dart'; | ||
import 'package:flow/services/exchange_rates.dart'; | ||
|
||
class ChartData<T> implements Comparable<ChartData<T>> { | ||
final String key; | ||
final Money money; | ||
final T? associatedData; | ||
|
||
double get displayTotal => money.amount.abs(); | ||
|
||
ChartData({ | ||
required this.key, | ||
required this.money, | ||
required this.associatedData, | ||
}); | ||
|
||
@override | ||
int compareTo(ChartData<T> other) { | ||
return money.tryCompareToWithExchange( | ||
other.money, | ||
ExchangeRatesService().getPrimaryCurrencyRates(), | ||
); | ||
} | ||
} |
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,35 @@ | ||
import 'package:moment_dart/moment_dart.dart'; | ||
|
||
/// Uses endpoints from here: | ||
class ExchangeRates { | ||
final DateTime date; | ||
final String baseCurrency; | ||
final Map<String, num> rates; | ||
|
||
const ExchangeRates({ | ||
required this.date, | ||
required this.baseCurrency, | ||
required this.rates, | ||
}); | ||
|
||
factory ExchangeRates.fromJson(Map<String, dynamic> json) { | ||
final String baseCurrency = json.keys.firstWhere((key) => key != "date"); | ||
|
||
return ExchangeRates( | ||
date: DateTime.parse(json['date']), | ||
baseCurrency: baseCurrency, | ||
rates: Map<String, num>.from(json[baseCurrency.toLowerCase()]), | ||
); | ||
} | ||
|
||
Map<String, dynamic> toJson() { | ||
return { | ||
"date": date.format(payload: "YYYY-MM-DD"), | ||
baseCurrency: rates, | ||
}; | ||
} | ||
|
||
double? getRate(String currency) { | ||
return rates[currency.toLowerCase()]?.toDouble(); | ||
} | ||
} |
Oops, something went wrong.