2022-08-08 02:43:09 +02:00
|
|
|
import 'package:hive/hive.dart';
|
|
|
|
import 'package:openapi/api.dart';
|
|
|
|
|
|
|
|
import '../constants/hive_box.dart';
|
|
|
|
|
2022-08-21 18:41:36 +02:00
|
|
|
String getThumbnailUrl(
|
|
|
|
final AssetResponseDto asset, {
|
|
|
|
ThumbnailFormat type = ThumbnailFormat.WEBP,
|
|
|
|
}) {
|
|
|
|
return _getThumbnailUrl(asset.id, type: type);
|
|
|
|
}
|
2022-08-08 02:43:09 +02:00
|
|
|
|
2022-08-21 18:41:36 +02:00
|
|
|
String getAlbumThumbnailUrl(
|
|
|
|
final AlbumResponseDto album, {
|
|
|
|
ThumbnailFormat type = ThumbnailFormat.WEBP,
|
|
|
|
}) {
|
|
|
|
if (album.albumThumbnailAssetId == null) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
return _getThumbnailUrl(album.albumThumbnailAssetId!, type: type);
|
2022-08-08 02:43:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
String getImageUrl(final AssetResponseDto asset) {
|
|
|
|
final box = Hive.box(userInfoBox);
|
|
|
|
return '${box.get(serverEndpointKey)}/asset/file?aid=${asset.deviceAssetId}&did=${asset.deviceId}&isThumb=false';
|
|
|
|
}
|
2022-08-21 18:41:36 +02:00
|
|
|
|
2022-10-14 18:15:19 +02:00
|
|
|
String _getThumbnailUrl(
|
|
|
|
final String id, {
|
|
|
|
ThumbnailFormat type = ThumbnailFormat.WEBP,
|
|
|
|
}) {
|
2022-08-21 18:41:36 +02:00
|
|
|
final box = Hive.box(userInfoBox);
|
|
|
|
|
2022-10-14 18:15:19 +02:00
|
|
|
return '${box.get(serverEndpointKey)}/asset/thumbnail/$id?format=${type.value}';
|
2022-08-21 18:41:36 +02:00
|
|
|
}
|