feat(mobile): Add selected assets to album (#901)

* First implementation that uses new API

* Various UI improvements

* Create new album from home screen

* Fix padding when in multiselect mode

* Alex Suggestions

* Change to album after creation
This commit is contained in:
Matthias Rupp
2022-11-06 02:21:55 +01:00
committed by GitHub
parent 02bc84062e
commit b5751a3fa8
6 changed files with 252 additions and 60 deletions

View File

@@ -46,6 +46,31 @@ class AlbumService {
}
}
/*
* Creates names like Untitled, Untitled (1), Untitled (2), ...
*/
String _getNextAlbumName(List<AlbumResponseDto>? albums) {
const baseName = "Untitled";
if (albums != null) {
for (int round = 0; round < albums.length; round++) {
final proposedName = "$baseName${round == 0 ? "" : " ($round)"}";
if (albums.where((a) => a.albumName == proposedName).isEmpty) {
return proposedName;
}
}
}
return baseName;
}
Future<AlbumResponseDto?> createAlbumWithGeneratedName(
Set<AssetResponseDto> assets,
) async {
return createAlbum(
_getNextAlbumName(await getAlbums(isShared: false)), assets, []);
}
Future<AlbumResponseDto?> getAlbumDetail(String albumId) async {
try {
return await _apiService.albumApi.getAlbumInfo(albumId);
@@ -55,7 +80,7 @@ class AlbumService {
}
}
Future<bool> addAdditionalAssetToAlbum(
Future<AddAssetsResponseDto?> addAdditionalAssetToAlbum(
Set<AssetResponseDto> assets,
String albumId,
) async {
@@ -64,10 +89,10 @@ class AlbumService {
albumId,
AddAssetsDto(assetIds: assets.map((asset) => asset.id).toList()),
);
return result != null;
return result;
} catch (e) {
debugPrint("Error addAdditionalAssetToAlbum ${e.toString()}");
return false;
return null;
}
}