|
@@ -7,7 +7,6 @@ import 'package:immich_mobile/constants/immich_colors.dart';
|
|
import 'package:immich_mobile/modules/home/ui/draggable_scrollbar.dart';
|
|
import 'package:immich_mobile/modules/home/ui/draggable_scrollbar.dart';
|
|
import 'package:immich_mobile/modules/login/providers/authentication.provider.dart';
|
|
import 'package:immich_mobile/modules/login/providers/authentication.provider.dart';
|
|
import 'package:immich_mobile/modules/sharing/models/asset_selection_page_result.model.dart';
|
|
import 'package:immich_mobile/modules/sharing/models/asset_selection_page_result.model.dart';
|
|
-import 'package:immich_mobile/modules/sharing/models/shared_album.model.dart';
|
|
|
|
import 'package:immich_mobile/modules/sharing/providers/asset_selection.provider.dart';
|
|
import 'package:immich_mobile/modules/sharing/providers/asset_selection.provider.dart';
|
|
import 'package:immich_mobile/modules/sharing/providers/shared_album.provider.dart';
|
|
import 'package:immich_mobile/modules/sharing/providers/shared_album.provider.dart';
|
|
import 'package:immich_mobile/modules/sharing/services/shared_album.service.dart';
|
|
import 'package:immich_mobile/modules/sharing/services/shared_album.service.dart';
|
|
@@ -19,7 +18,7 @@ import 'package:immich_mobile/routing/router.dart';
|
|
import 'package:immich_mobile/shared/ui/immich_loading_indicator.dart';
|
|
import 'package:immich_mobile/shared/ui/immich_loading_indicator.dart';
|
|
import 'package:immich_mobile/shared/ui/immich_sliver_persistent_app_bar_delegate.dart';
|
|
import 'package:immich_mobile/shared/ui/immich_sliver_persistent_app_bar_delegate.dart';
|
|
import 'package:immich_mobile/shared/views/immich_loading_overlay.dart';
|
|
import 'package:immich_mobile/shared/views/immich_loading_overlay.dart';
|
|
-import 'package:intl/intl.dart';
|
|
|
|
|
|
+import 'package:openapi/api.dart';
|
|
|
|
|
|
class AlbumViewerPage extends HookConsumerWidget {
|
|
class AlbumViewerPage extends HookConsumerWidget {
|
|
final String albumId;
|
|
final String albumId;
|
|
@@ -30,18 +29,18 @@ class AlbumViewerPage extends HookConsumerWidget {
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
FocusNode titleFocusNode = useFocusNode();
|
|
FocusNode titleFocusNode = useFocusNode();
|
|
ScrollController scrollController = useScrollController();
|
|
ScrollController scrollController = useScrollController();
|
|
- AsyncValue<SharedAlbum> albumInfo =
|
|
|
|
|
|
+ AsyncValue<AlbumResponseDto?> albumInfo =
|
|
ref.watch(sharedAlbumDetailProvider(albumId));
|
|
ref.watch(sharedAlbumDetailProvider(albumId));
|
|
|
|
|
|
final userId = ref.watch(authenticationProvider).userId;
|
|
final userId = ref.watch(authenticationProvider).userId;
|
|
|
|
|
|
/// Find out if the assets in album exist on the device
|
|
/// Find out if the assets in album exist on the device
|
|
/// If they exist, add to selected asset state to show they are already selected.
|
|
/// If they exist, add to selected asset state to show they are already selected.
|
|
- void _onAddPhotosPressed(SharedAlbum albumInfo) async {
|
|
|
|
- if (albumInfo.assets?.isNotEmpty == true) {
|
|
|
|
|
|
+ void _onAddPhotosPressed(AlbumResponseDto albumInfo) async {
|
|
|
|
+ if (albumInfo.assets.isNotEmpty == true) {
|
|
ref
|
|
ref
|
|
.watch(assetSelectionProvider.notifier)
|
|
.watch(assetSelectionProvider.notifier)
|
|
- .addNewAssets(albumInfo.assets!.toList());
|
|
|
|
|
|
+ .addNewAssets(albumInfo.assets.toList());
|
|
}
|
|
}
|
|
|
|
|
|
ref.watch(assetSelectionProvider.notifier).setIsAlbumExist(true);
|
|
ref.watch(assetSelectionProvider.notifier).setIsAlbumExist(true);
|
|
@@ -57,7 +56,9 @@ class AlbumViewerPage extends HookConsumerWidget {
|
|
var isSuccess = await ref
|
|
var isSuccess = await ref
|
|
.watch(sharedAlbumServiceProvider)
|
|
.watch(sharedAlbumServiceProvider)
|
|
.addAdditionalAssetToAlbum(
|
|
.addAdditionalAssetToAlbum(
|
|
- returnPayload.selectedAdditionalAsset, albumId);
|
|
|
|
|
|
+ returnPayload.selectedAdditionalAsset,
|
|
|
|
+ albumId,
|
|
|
|
+ );
|
|
|
|
|
|
if (isSuccess) {
|
|
if (isSuccess) {
|
|
ref.refresh(sharedAlbumDetailProvider(albumId));
|
|
ref.refresh(sharedAlbumDetailProvider(albumId));
|
|
@@ -72,10 +73,11 @@ class AlbumViewerPage extends HookConsumerWidget {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- void _onAddUsersPressed(SharedAlbum albumInfo) async {
|
|
|
|
- List<String>? sharedUserIds = await AutoRouter.of(context)
|
|
|
|
- .push<List<String>?>(
|
|
|
|
- SelectAdditionalUserForSharingRoute(albumInfo: albumInfo));
|
|
|
|
|
|
+ void _onAddUsersPressed(AlbumResponseDto albumInfo) async {
|
|
|
|
+ List<String>? sharedUserIds =
|
|
|
|
+ await AutoRouter.of(context).push<List<String>?>(
|
|
|
|
+ SelectAdditionalUserForSharingRoute(albumInfo: albumInfo),
|
|
|
|
+ );
|
|
|
|
|
|
if (sharedUserIds != null) {
|
|
if (sharedUserIds != null) {
|
|
ImmichLoadingOverlayController.appLoader.show();
|
|
ImmichLoadingOverlayController.appLoader.show();
|
|
@@ -92,7 +94,7 @@ class AlbumViewerPage extends HookConsumerWidget {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- Widget _buildTitle(SharedAlbum albumInfo) {
|
|
|
|
|
|
+ Widget _buildTitle(AlbumResponseDto albumInfo) {
|
|
return Padding(
|
|
return Padding(
|
|
padding: const EdgeInsets.only(left: 8, right: 8, top: 16),
|
|
padding: const EdgeInsets.only(left: 8, right: 8, top: 16),
|
|
child: userId == albumInfo.ownerId
|
|
child: userId == albumInfo.ownerId
|
|
@@ -102,19 +104,24 @@ class AlbumViewerPage extends HookConsumerWidget {
|
|
)
|
|
)
|
|
: Padding(
|
|
: Padding(
|
|
padding: const EdgeInsets.only(left: 8.0),
|
|
padding: const EdgeInsets.only(left: 8.0),
|
|
- child: Text(albumInfo.albumName,
|
|
|
|
- style: const TextStyle(
|
|
|
|
- fontSize: 24, fontWeight: FontWeight.bold)),
|
|
|
|
|
|
+ child: Text(
|
|
|
|
+ albumInfo.albumName,
|
|
|
|
+ style: const TextStyle(
|
|
|
|
+ fontSize: 24,
|
|
|
|
+ fontWeight: FontWeight.bold,
|
|
|
|
+ ),
|
|
|
|
+ ),
|
|
),
|
|
),
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
- Widget _buildAlbumDateRange(SharedAlbum albumInfo) {
|
|
|
|
|
|
+ Widget _buildAlbumDateRange(AlbumResponseDto albumInfo) {
|
|
String startDate = "";
|
|
String startDate = "";
|
|
DateTime parsedStartDate =
|
|
DateTime parsedStartDate =
|
|
- DateTime.parse(albumInfo.assets!.first.createdAt);
|
|
|
|
|
|
+ DateTime.parse(albumInfo.assets.first.createdAt);
|
|
DateTime parsedEndDate = DateTime.parse(
|
|
DateTime parsedEndDate = DateTime.parse(
|
|
- albumInfo.assets?.last.createdAt ?? '11111111'); //Need default.
|
|
|
|
|
|
+ albumInfo.assets.last.createdAt,
|
|
|
|
+ ); //Need default.
|
|
|
|
|
|
if (parsedStartDate.year == parsedEndDate.year) {
|
|
if (parsedStartDate.year == parsedEndDate.year) {
|
|
startDate = DateFormat('LLL d').format(parsedStartDate);
|
|
startDate = DateFormat('LLL d').format(parsedStartDate);
|
|
@@ -129,18 +136,21 @@ class AlbumViewerPage extends HookConsumerWidget {
|
|
child: Text(
|
|
child: Text(
|
|
"$startDate-$endDate",
|
|
"$startDate-$endDate",
|
|
style: const TextStyle(
|
|
style: const TextStyle(
|
|
- fontSize: 14, fontWeight: FontWeight.bold, color: Colors.grey),
|
|
|
|
|
|
+ fontSize: 14,
|
|
|
|
+ fontWeight: FontWeight.bold,
|
|
|
|
+ color: Colors.grey,
|
|
|
|
+ ),
|
|
),
|
|
),
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
- Widget _buildHeader(SharedAlbum albumInfo) {
|
|
|
|
|
|
+ Widget _buildHeader(AlbumResponseDto albumInfo) {
|
|
return SliverToBoxAdapter(
|
|
return SliverToBoxAdapter(
|
|
child: Column(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
children: [
|
|
_buildTitle(albumInfo),
|
|
_buildTitle(albumInfo),
|
|
- if (albumInfo.assets?.isNotEmpty == true)
|
|
|
|
|
|
+ if (albumInfo.assets.isNotEmpty == true)
|
|
_buildAlbumDateRange(albumInfo),
|
|
_buildAlbumDateRange(albumInfo),
|
|
SizedBox(
|
|
SizedBox(
|
|
height: 60,
|
|
height: 60,
|
|
@@ -172,8 +182,8 @@ class AlbumViewerPage extends HookConsumerWidget {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
- Widget _buildImageGrid(SharedAlbum albumInfo) {
|
|
|
|
- if (albumInfo.assets?.isNotEmpty == true) {
|
|
|
|
|
|
+ Widget _buildImageGrid(AlbumResponseDto albumInfo) {
|
|
|
|
+ if (albumInfo.assets.isNotEmpty) {
|
|
return SliverPadding(
|
|
return SliverPadding(
|
|
padding: const EdgeInsets.only(top: 10.0),
|
|
padding: const EdgeInsets.only(top: 10.0),
|
|
sliver: SliverGrid(
|
|
sliver: SliverGrid(
|
|
@@ -184,9 +194,9 @@ class AlbumViewerPage extends HookConsumerWidget {
|
|
),
|
|
),
|
|
delegate: SliverChildBuilderDelegate(
|
|
delegate: SliverChildBuilderDelegate(
|
|
(BuildContext context, int index) {
|
|
(BuildContext context, int index) {
|
|
- return AlbumViewerThumbnail(asset: albumInfo.assets![index]);
|
|
|
|
|
|
+ return AlbumViewerThumbnail(asset: albumInfo.assets[index]);
|
|
},
|
|
},
|
|
- childCount: albumInfo.assets?.length,
|
|
|
|
|
|
+ childCount: albumInfo.assets.length,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
);
|
|
@@ -194,7 +204,7 @@ class AlbumViewerPage extends HookConsumerWidget {
|
|
return const SliverToBoxAdapter();
|
|
return const SliverToBoxAdapter();
|
|
}
|
|
}
|
|
|
|
|
|
- Widget _buildControlButton(SharedAlbum albumInfo) {
|
|
|
|
|
|
+ Widget _buildControlButton(AlbumResponseDto albumInfo) {
|
|
return Padding(
|
|
return Padding(
|
|
padding: const EdgeInsets.only(left: 16.0, top: 8, bottom: 8),
|
|
padding: const EdgeInsets.only(left: 16.0, top: 8, bottom: 8),
|
|
child: SizedBox(
|
|
child: SizedBox(
|
|
@@ -219,7 +229,7 @@ class AlbumViewerPage extends HookConsumerWidget {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
- Widget _buildBody(SharedAlbum albumInfo) {
|
|
|
|
|
|
+ Widget _buildBody(AlbumResponseDto albumInfo) {
|
|
return GestureDetector(
|
|
return GestureDetector(
|
|
onTap: () {
|
|
onTap: () {
|
|
titleFocusNode.unfocus();
|
|
titleFocusNode.unfocus();
|
|
@@ -252,9 +262,16 @@ class AlbumViewerPage extends HookConsumerWidget {
|
|
|
|
|
|
return Scaffold(
|
|
return Scaffold(
|
|
appBar: AlbumViewerAppbar(
|
|
appBar: AlbumViewerAppbar(
|
|
- albumInfo: albumInfo, userId: userId, albumId: albumId),
|
|
|
|
|
|
+ albumInfo: albumInfo,
|
|
|
|
+ userId: userId,
|
|
|
|
+ albumId: albumId,
|
|
|
|
+ ),
|
|
body: albumInfo.when(
|
|
body: albumInfo.when(
|
|
- data: (albumInfo) => _buildBody(albumInfo),
|
|
|
|
|
|
+ data: (albumInfo) => albumInfo != null
|
|
|
|
+ ? _buildBody(albumInfo)
|
|
|
|
+ : const Center(
|
|
|
|
+ child: CircularProgressIndicator(),
|
|
|
|
+ ),
|
|
error: (e, _) => Center(child: Text("Error loading album info $e")),
|
|
error: (e, _) => Center(child: Text("Error loading album info $e")),
|
|
loading: () => const Center(
|
|
loading: () => const Center(
|
|
child: ImmichLoadingIndicator(),
|
|
child: ImmichLoadingIndicator(),
|