feat(App): update Finlytic Flutter app UI and blocs
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class FavoriteAssetModel extends Equatable {
|
||||
final String symbol;
|
||||
final String name;
|
||||
final String isin;
|
||||
final String image;
|
||||
final double currentPrice;
|
||||
final double change24h;
|
||||
|
||||
const FavoriteAssetModel({
|
||||
required this.symbol,
|
||||
required this.name,
|
||||
this.isin = '',
|
||||
this.image = '',
|
||||
required this.currentPrice,
|
||||
required this.change24h,
|
||||
});
|
||||
|
||||
factory FavoriteAssetModel.fromJson(Map<String, dynamic> json) {
|
||||
return FavoriteAssetModel(
|
||||
symbol: json['symbol']?.toString() ?? json['Symbol']?.toString() ?? '',
|
||||
name: json['name']?.toString() ?? json['Name']?.toString() ?? '',
|
||||
isin: json['isin']?.toString() ?? json['Isin']?.toString() ?? json['symbol']?.toString() ?? '',
|
||||
image: json['image']?.toString() ?? json['Image']?.toString() ?? '',
|
||||
currentPrice: (json['currentPrice'] ?? json['CurrentPrice'] ?? json['price'] ?? 0.0).toDouble(),
|
||||
change24h: (json['dailyChangePercent'] ?? json['DailyChangePercent'] ?? json['change24h'] ?? json['Change24h'] ?? 0.0).toDouble(),
|
||||
);
|
||||
}
|
||||
|
||||
FavoriteAssetModel copyWith({
|
||||
String? symbol,
|
||||
String? name,
|
||||
String? isin,
|
||||
String? image,
|
||||
double? currentPrice,
|
||||
double? change24h,
|
||||
}) {
|
||||
return FavoriteAssetModel(
|
||||
symbol: symbol ?? this.symbol,
|
||||
name: name ?? this.name,
|
||||
isin: isin ?? this.isin,
|
||||
image: image ?? this.image,
|
||||
currentPrice: currentPrice ?? this.currentPrice,
|
||||
change24h: change24h ?? this.change24h,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'symbol': symbol,
|
||||
'name': name,
|
||||
'isin': isin,
|
||||
'image': image,
|
||||
'currentPrice': currentPrice,
|
||||
'change24h': change24h,
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [symbol, name, isin, image, currentPrice, change24h];
|
||||
}
|
||||
Reference in New Issue
Block a user