feat(App): update Finlytic Flutter app UI and blocs
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import 'package:finlytic_app/core/network/api_client.dart';
|
||||
import 'package:finlytic_app/features/favorites/models/favorite_asset_model.dart';
|
||||
import 'package:finlytic_app/core/utils/asset_utils.dart';
|
||||
|
||||
class FavoritesRepository {
|
||||
final ApiClient apiClient;
|
||||
|
||||
FavoritesRepository({required this.apiClient});
|
||||
|
||||
Future<List<FavoriteAssetModel>> fetchFavoritesDetails(List<String> symbols) async {
|
||||
if (symbols.isEmpty) return [];
|
||||
|
||||
try {
|
||||
final res = await apiClient.post('/api/v1/assets/batch', data: {'symbols': symbols});
|
||||
if (res.statusCode == 200 && res.data != null) {
|
||||
final List<dynamic> data = res.data;
|
||||
return data.map((json) => FavoriteAssetModel.fromJson(json)).toList();
|
||||
}
|
||||
return symbols.map((s) => FavoriteAssetModel(
|
||||
symbol: s,
|
||||
name: AssetUtils.getAssetName(s),
|
||||
currentPrice: 0.0,
|
||||
change24h: 0.0,
|
||||
)).toList();
|
||||
} catch (e) {
|
||||
print('Error fetching favorites details: $e');
|
||||
return symbols.map((s) => FavoriteAssetModel(
|
||||
symbol: s,
|
||||
name: AssetUtils.getAssetName(s),
|
||||
currentPrice: 0.0,
|
||||
change24h: 0.0,
|
||||
)).toList();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user