image_url_builder.dart 911 B

1234567891011121314151617181920212223242526272829303132333435
  1. import 'package:hive/hive.dart';
  2. import 'package:openapi/api.dart';
  3. import '../constants/hive_box.dart';
  4. String getThumbnailUrl(
  5. final AssetResponseDto asset, {
  6. ThumbnailFormat type = ThumbnailFormat.WEBP,
  7. }) {
  8. return _getThumbnailUrl(asset.id, type: type);
  9. }
  10. String getAlbumThumbnailUrl(
  11. final AlbumResponseDto album, {
  12. ThumbnailFormat type = ThumbnailFormat.WEBP,
  13. }) {
  14. if (album.albumThumbnailAssetId == null) {
  15. return '';
  16. }
  17. return _getThumbnailUrl(album.albumThumbnailAssetId!, type: type);
  18. }
  19. String getImageUrl(final AssetResponseDto asset) {
  20. final box = Hive.box(userInfoBox);
  21. return '${box.get(serverEndpointKey)}/asset/file/${asset.id}?isThumb=false';
  22. }
  23. String _getThumbnailUrl(
  24. final String id, {
  25. ThumbnailFormat type = ThumbnailFormat.WEBP,
  26. }) {
  27. final box = Hive.box(userInfoBox);
  28. return '${box.get(serverEndpointKey)}/asset/thumbnail/$id?format=${type.value}';
  29. }