mirror of
https://github.com/immich-app/immich.git
synced 2025-12-21 01:11:16 +03:00
Compare commits
2 Commits
feature/sh
...
renovate/f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c87f3d7eb | ||
|
|
de1b448639 |
@@ -10,7 +10,6 @@
|
|||||||
"active_count": "Active: {count}",
|
"active_count": "Active: {count}",
|
||||||
"activity": "Activity",
|
"activity": "Activity",
|
||||||
"activity_changed": "Activity is {enabled, select, true {enabled} other {disabled}}",
|
"activity_changed": "Activity is {enabled, select, true {enabled} other {disabled}}",
|
||||||
"activity_count": "{count, plural, =0 {Activity} =1 {1 activity} other {{count} activities}}",
|
|
||||||
"add": "Add",
|
"add": "Add",
|
||||||
"add_a_description": "Add a description",
|
"add_a_description": "Add a description",
|
||||||
"add_a_location": "Add a location",
|
"add_a_location": "Add a location",
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
"active": "アクティブ",
|
"active": "アクティブ",
|
||||||
"activity": "アクティビティ",
|
"activity": "アクティビティ",
|
||||||
"activity_changed": "アクティビティは{enabled, select, true {有効} other {無効}}になりました",
|
"activity_changed": "アクティビティは{enabled, select, true {有効} other {無効}}になりました",
|
||||||
"activity_count": "{count, plural, =0 {コメント} other {コメント\n{count}件}}",
|
|
||||||
"add": "追加",
|
"add": "追加",
|
||||||
"add_a_description": "説明を追加",
|
"add_a_description": "説明を追加",
|
||||||
"add_a_location": "場所を追加",
|
"add_a_location": "場所を追加",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ experimental_monorepo_root = true
|
|||||||
|
|
||||||
[tools]
|
[tools]
|
||||||
node = "24.11.1"
|
node = "24.11.1"
|
||||||
flutter = "3.35.7"
|
flutter = "3.38.5"
|
||||||
pnpm = "10.24.0"
|
pnpm = "10.24.0"
|
||||||
terragrunt = "0.93.10"
|
terragrunt = "0.93.10"
|
||||||
opentofu = "1.10.7"
|
opentofu = "1.10.7"
|
||||||
|
|||||||
@@ -7,5 +7,3 @@ enum AssetVisibilityEnum { timeline, hidden, archive, locked }
|
|||||||
enum SortUserBy { id }
|
enum SortUserBy { id }
|
||||||
|
|
||||||
enum ActionSource { timeline, viewer }
|
enum ActionSource { timeline, viewer }
|
||||||
|
|
||||||
enum ButtonPosition { bottomBar, kebabMenu, other }
|
|
||||||
|
|||||||
@@ -62,9 +62,6 @@ class Activity {
|
|||||||
|
|
||||||
class ActivityStats {
|
class ActivityStats {
|
||||||
final int comments;
|
final int comments;
|
||||||
final int likes;
|
|
||||||
|
|
||||||
const ActivityStats({required this.comments, required this.likes});
|
const ActivityStats({required this.comments});
|
||||||
|
|
||||||
int get total => comments + likes;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:auto_route/auto_route.dart';
|
import 'package:auto_route/auto_route.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
@@ -242,8 +241,7 @@ class _DriftBackupAlbumSelectionPageState extends ConsumerState<DriftBackupAlbum
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
if (Platform.isAndroid)
|
_SelectAllButton(filteredAlbums: filteredAlbums, selectedBackupAlbums: selectedBackupAlbums),
|
||||||
_SelectAllButton(filteredAlbums: filteredAlbums, selectedBackupAlbums: selectedBackupAlbums),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -8,10 +8,7 @@ import 'package:immich_mobile/providers/infrastructure/asset_viewer/current_asse
|
|||||||
import 'package:immich_mobile/routing/router.dart';
|
import 'package:immich_mobile/routing/router.dart';
|
||||||
|
|
||||||
class EditImageActionButton extends ConsumerWidget {
|
class EditImageActionButton extends ConsumerWidget {
|
||||||
final bool iconOnly;
|
const EditImageActionButton({super.key});
|
||||||
final bool menuItem;
|
|
||||||
|
|
||||||
const EditImageActionButton({super.key, this.iconOnly = false, this.menuItem = false});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
@@ -30,8 +27,6 @@ class EditImageActionButton extends ConsumerWidget {
|
|||||||
iconData: Icons.tune,
|
iconData: Icons.tune,
|
||||||
label: "edit".t(context: context),
|
label: "edit".t(context: context),
|
||||||
onPressed: onPress,
|
onPressed: onPress,
|
||||||
iconOnly: iconOnly,
|
|
||||||
menuItem: menuItem,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
||||||
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
|
||||||
import 'package:immich_mobile/domain/models/events.model.dart';
|
|
||||||
import 'package:immich_mobile/domain/utils/event_stream.dart';
|
|
||||||
import 'package:immich_mobile/extensions/translate_extensions.dart';
|
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/base_action_button.widget.dart';
|
|
||||||
import 'package:immich_mobile/providers/activity_statistics.provider.dart';
|
|
||||||
import 'package:immich_mobile/providers/infrastructure/asset_viewer/current_asset.provider.dart';
|
|
||||||
import 'package:immich_mobile/providers/infrastructure/current_album.provider.dart';
|
|
||||||
|
|
||||||
class OpenActivityActionButton extends ConsumerWidget {
|
|
||||||
const OpenActivityActionButton({super.key, this.iconOnly = false, this.menuItem = false});
|
|
||||||
|
|
||||||
final bool iconOnly;
|
|
||||||
final bool menuItem;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
|
||||||
final album = ref.watch(currentRemoteAlbumProvider);
|
|
||||||
final asset = ref.watch(currentAssetNotifier) as RemoteAsset?;
|
|
||||||
final count = album != null && album.id.isNotEmpty ? ref.watch(activityStatisticsProvider(album.id, asset?.id)) : 0;
|
|
||||||
|
|
||||||
return BaseActionButton(
|
|
||||||
iconData: Icons.chat_outlined,
|
|
||||||
label: "activity_count".t(args: {"count": count}),
|
|
||||||
onPressed: () => EventStream.shared.emit(const ViewerOpenBottomSheetEvent(activitiesMode: true)),
|
|
||||||
iconOnly: iconOnly,
|
|
||||||
menuItem: menuItem,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,18 +2,18 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:immich_mobile/constants/enums.dart';
|
import 'package:immich_mobile/constants/enums.dart';
|
||||||
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
||||||
import 'package:immich_mobile/domain/models/setting.model.dart';
|
|
||||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||||
|
import 'package:immich_mobile/presentation/widgets/action_buttons/delete_action_button.widget.dart';
|
||||||
|
import 'package:immich_mobile/presentation/widgets/action_buttons/delete_local_action_button.widget.dart';
|
||||||
|
import 'package:immich_mobile/presentation/widgets/action_buttons/edit_image_action_button.widget.dart';
|
||||||
|
import 'package:immich_mobile/presentation/widgets/action_buttons/share_action_button.widget.dart';
|
||||||
|
import 'package:immich_mobile/presentation/widgets/action_buttons/upload_action_button.widget.dart';
|
||||||
|
import 'package:immich_mobile/presentation/widgets/action_buttons/add_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/asset_viewer/asset_viewer.state.dart';
|
import 'package:immich_mobile/presentation/widgets/asset_viewer/asset_viewer.state.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/asset_viewer/current_asset.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/asset_viewer/current_asset.provider.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/current_album.provider.dart';
|
|
||||||
import 'package:immich_mobile/providers/infrastructure/readonly_mode.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/readonly_mode.provider.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/setting.provider.dart';
|
|
||||||
import 'package:immich_mobile/providers/infrastructure/timeline.provider.dart';
|
|
||||||
import 'package:immich_mobile/providers/routes.provider.dart';
|
import 'package:immich_mobile/providers/routes.provider.dart';
|
||||||
import 'package:immich_mobile/providers/server_info.provider.dart';
|
|
||||||
import 'package:immich_mobile/providers/user.provider.dart';
|
import 'package:immich_mobile/providers/user.provider.dart';
|
||||||
import 'package:immich_mobile/utils/action_button.utils.dart';
|
|
||||||
import 'package:immich_mobile/widgets/asset_viewer/video_controls.dart';
|
import 'package:immich_mobile/widgets/asset_viewer/video_controls.dart';
|
||||||
|
|
||||||
class ViewerBottomBar extends ConsumerWidget {
|
class ViewerBottomBar extends ConsumerWidget {
|
||||||
@@ -33,11 +33,6 @@ class ViewerBottomBar extends ConsumerWidget {
|
|||||||
int opacity = ref.watch(assetViewerProvider.select((state) => state.backgroundOpacity));
|
int opacity = ref.watch(assetViewerProvider.select((state) => state.backgroundOpacity));
|
||||||
final showControls = ref.watch(assetViewerProvider.select((s) => s.showingControls));
|
final showControls = ref.watch(assetViewerProvider.select((s) => s.showingControls));
|
||||||
final isInLockedView = ref.watch(inLockedViewProvider);
|
final isInLockedView = ref.watch(inLockedViewProvider);
|
||||||
final album = ref.watch(currentRemoteAlbumProvider);
|
|
||||||
final isArchived = asset is RemoteAsset && asset.visibility == AssetVisibility.archive;
|
|
||||||
final advancedTroubleshooting = ref.watch(settingsProvider.notifier).get(Setting.advancedTroubleshooting);
|
|
||||||
final timelineOrigin = ref.read(timelineServiceProvider).origin;
|
|
||||||
final isTrashEnable = ref.watch(serverInfoProvider.select((state) => state.serverFeatures.trash));
|
|
||||||
|
|
||||||
if (!showControls) {
|
if (!showControls) {
|
||||||
opacity = 0;
|
opacity = 0;
|
||||||
@@ -45,22 +40,21 @@ class ViewerBottomBar extends ConsumerWidget {
|
|||||||
|
|
||||||
final originalTheme = context.themeData;
|
final originalTheme = context.themeData;
|
||||||
|
|
||||||
final buttonContext = ActionButtonContext(
|
final actions = <Widget>[
|
||||||
asset: asset,
|
const ShareActionButton(source: ActionSource.viewer),
|
||||||
isOwner: isOwner,
|
|
||||||
isArchived: isArchived,
|
|
||||||
isTrashEnabled: isTrashEnable,
|
|
||||||
isStacked: asset is RemoteAsset && asset.stackId != null,
|
|
||||||
isInLockedView: isInLockedView,
|
|
||||||
currentAlbum: album,
|
|
||||||
advancedTroubleshooting: advancedTroubleshooting,
|
|
||||||
source: ActionSource.viewer,
|
|
||||||
timelineOrigin: timelineOrigin,
|
|
||||||
originalTheme: originalTheme,
|
|
||||||
buttonPosition: ButtonPosition.bottomBar,
|
|
||||||
);
|
|
||||||
|
|
||||||
final actions = ActionButtonBuilder.buildViewerBottomBar(buttonContext, context, ref);
|
if (!isInLockedView) ...[
|
||||||
|
if (asset.isLocalOnly) const UploadActionButton(source: ActionSource.viewer),
|
||||||
|
if (asset.type == AssetType.image) const EditImageActionButton(),
|
||||||
|
if (asset.hasRemote) AddActionButton(originalTheme: originalTheme),
|
||||||
|
|
||||||
|
if (isOwner) ...[
|
||||||
|
asset.isLocalOnly
|
||||||
|
? const DeleteLocalActionButton(source: ActionSource.viewer)
|
||||||
|
: const DeleteActionButton(source: ActionSource.viewer, showConfirmation: true),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
return IgnorePointer(
|
return IgnorePointer(
|
||||||
ignoring: opacity < 255,
|
ignoring: opacity < 255,
|
||||||
@@ -86,11 +80,7 @@ class ViewerBottomBar extends ConsumerWidget {
|
|||||||
children: [
|
children: [
|
||||||
if (asset.isVideo) const VideoControls(),
|
if (asset.isVideo) const VideoControls(),
|
||||||
if (!isReadonlyModeEnabled)
|
if (!isReadonlyModeEnabled)
|
||||||
Row(
|
Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: actions),
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: actions.map((action) => Expanded(child: action)).toList(),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:immich_mobile/constants/enums.dart';
|
import 'package:immich_mobile/constants/enums.dart';
|
||||||
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
||||||
|
import 'package:immich_mobile/domain/models/events.model.dart';
|
||||||
|
import 'package:immich_mobile/domain/utils/event_stream.dart';
|
||||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/favorite_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/favorite_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/motion_photo_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/motion_photo_action_button.widget.dart';
|
||||||
@@ -49,6 +51,13 @@ class ViewerTopAppBar extends ConsumerWidget implements PreferredSizeWidget {
|
|||||||
|
|
||||||
final actions = <Widget>[
|
final actions = <Widget>[
|
||||||
if (asset.isMotionPhoto) const MotionPhotoActionButton(iconOnly: true),
|
if (asset.isMotionPhoto) const MotionPhotoActionButton(iconOnly: true),
|
||||||
|
if (album != null && album.isActivityEnabled && album.isShared)
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.chat_outlined),
|
||||||
|
onPressed: () {
|
||||||
|
EventStream.shared.emit(const ViewerOpenBottomSheetEvent(activitiesMode: true));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
if (asset.hasRemote && isOwner && !asset.isFavorite)
|
if (asset.hasRemote && isOwner && !asset.isFavorite)
|
||||||
const FavoriteActionButton(source: ActionSource.viewer, iconOnly: true),
|
const FavoriteActionButton(source: ActionSource.viewer, iconOnly: true),
|
||||||
|
|||||||
@@ -26,10 +26,11 @@ class AlbumActivity extends _$AlbumActivity {
|
|||||||
ref.read(albumActivityProvider(albumId).notifier)._removeFromState(id);
|
ref.read(albumActivityProvider(albumId).notifier)._removeFromState(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update statistics for both comments and likes
|
if (removedActivity.type == ActivityType.comment) {
|
||||||
ref.watch(activityStatisticsProvider(albumId, assetId).notifier).removeActivity();
|
ref.watch(activityStatisticsProvider(albumId, assetId).notifier).removeActivity();
|
||||||
if (assetId != null) {
|
if (assetId != null) {
|
||||||
ref.watch(activityStatisticsProvider(albumId).notifier).removeActivity();
|
ref.watch(activityStatisticsProvider(albumId).notifier).removeActivity();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -41,11 +42,6 @@ class AlbumActivity extends _$AlbumActivity {
|
|||||||
if (assetId != null) {
|
if (assetId != null) {
|
||||||
ref.read(albumActivityProvider(albumId).notifier)._addToState(activity.requireValue);
|
ref.read(albumActivityProvider(albumId).notifier)._addToState(activity.requireValue);
|
||||||
}
|
}
|
||||||
// Update statistics when adding a like
|
|
||||||
ref.watch(activityStatisticsProvider(albumId, assetId).notifier).addActivity();
|
|
||||||
if (assetId != null) {
|
|
||||||
ref.watch(activityStatisticsProvider(albumId).notifier).addActivity();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
mobile/lib/providers/activity.provider.g.dart
generated
2
mobile/lib/providers/activity.provider.g.dart
generated
@@ -6,7 +6,7 @@ part of 'activity.provider.dart';
|
|||||||
// RiverpodGenerator
|
// RiverpodGenerator
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
String _$albumActivityHash() => r'fe472b87b56ce4e3802833799bf707779ccc02e3';
|
String _$albumActivityHash() => r'154e8ae98da3efc142369eae46d4005468fd67da';
|
||||||
|
|
||||||
/// Copied from Dart SDK
|
/// Copied from Dart SDK
|
||||||
class _SystemHash {
|
class _SystemHash {
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ import 'package:riverpod_annotation/riverpod_annotation.dart';
|
|||||||
part 'activity_statistics.provider.g.dart';
|
part 'activity_statistics.provider.g.dart';
|
||||||
|
|
||||||
// ignore: unintended_html_in_doc_comment
|
// ignore: unintended_html_in_doc_comment
|
||||||
/// Maintains the current number of activities (comments + likes) by <shared-album, asset>
|
/// Maintains the current number of comments by <shared-album, asset>
|
||||||
@riverpod
|
@riverpod
|
||||||
class ActivityStatistics extends _$ActivityStatistics {
|
class ActivityStatistics extends _$ActivityStatistics {
|
||||||
@override
|
@override
|
||||||
int build(String albumId, [String? assetId]) {
|
int build(String albumId, [String? assetId]) {
|
||||||
ref.watch(activityServiceProvider).getStatistics(albumId, assetId: assetId).then((stats) => state = stats.total);
|
ref.watch(activityServiceProvider).getStatistics(albumId, assetId: assetId).then((stats) => state = stats.comments);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ part of 'activity_statistics.provider.dart';
|
|||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
String _$activityStatisticsHash() =>
|
String _$activityStatisticsHash() =>
|
||||||
r'ae0123a6ce129988e21f7327273af4d9acbae0f6';
|
r'1f43f0bcb11c754ca3cb586a13570db25023b9a8';
|
||||||
|
|
||||||
/// Copied from Dart SDK
|
/// Copied from Dart SDK
|
||||||
class _SystemHash {
|
class _SystemHash {
|
||||||
@@ -37,22 +37,22 @@ abstract class _$ActivityStatistics extends BuildlessAutoDisposeNotifier<int> {
|
|||||||
int build(String albumId, [String? assetId]);
|
int build(String albumId, [String? assetId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Maintains the current number of activities (comments + likes) by <shared-album, asset>
|
/// Maintains the current number of comments by <shared-album, asset>
|
||||||
///
|
///
|
||||||
/// Copied from [ActivityStatistics].
|
/// Copied from [ActivityStatistics].
|
||||||
@ProviderFor(ActivityStatistics)
|
@ProviderFor(ActivityStatistics)
|
||||||
const activityStatisticsProvider = ActivityStatisticsFamily();
|
const activityStatisticsProvider = ActivityStatisticsFamily();
|
||||||
|
|
||||||
/// Maintains the current number of activities (comments + likes) by <shared-album, asset>
|
/// Maintains the current number of comments by <shared-album, asset>
|
||||||
///
|
///
|
||||||
/// Copied from [ActivityStatistics].
|
/// Copied from [ActivityStatistics].
|
||||||
class ActivityStatisticsFamily extends Family<int> {
|
class ActivityStatisticsFamily extends Family<int> {
|
||||||
/// Maintains the current number of activities (comments + likes) by <shared-album, asset>
|
/// Maintains the current number of comments by <shared-album, asset>
|
||||||
///
|
///
|
||||||
/// Copied from [ActivityStatistics].
|
/// Copied from [ActivityStatistics].
|
||||||
const ActivityStatisticsFamily();
|
const ActivityStatisticsFamily();
|
||||||
|
|
||||||
/// Maintains the current number of activities (comments + likes) by <shared-album, asset>
|
/// Maintains the current number of comments by <shared-album, asset>
|
||||||
///
|
///
|
||||||
/// Copied from [ActivityStatistics].
|
/// Copied from [ActivityStatistics].
|
||||||
ActivityStatisticsProvider call(String albumId, [String? assetId]) {
|
ActivityStatisticsProvider call(String albumId, [String? assetId]) {
|
||||||
@@ -81,12 +81,12 @@ class ActivityStatisticsFamily extends Family<int> {
|
|||||||
String? get name => r'activityStatisticsProvider';
|
String? get name => r'activityStatisticsProvider';
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Maintains the current number of activities (comments + likes) by <shared-album, asset>
|
/// Maintains the current number of comments by <shared-album, asset>
|
||||||
///
|
///
|
||||||
/// Copied from [ActivityStatistics].
|
/// Copied from [ActivityStatistics].
|
||||||
class ActivityStatisticsProvider
|
class ActivityStatisticsProvider
|
||||||
extends AutoDisposeNotifierProviderImpl<ActivityStatistics, int> {
|
extends AutoDisposeNotifierProviderImpl<ActivityStatistics, int> {
|
||||||
/// Maintains the current number of activities (comments + likes) by <shared-album, asset>
|
/// Maintains the current number of comments by <shared-album, asset>
|
||||||
///
|
///
|
||||||
/// Copied from [ActivityStatistics].
|
/// Copied from [ActivityStatistics].
|
||||||
ActivityStatisticsProvider(String albumId, [String? assetId])
|
ActivityStatisticsProvider(String albumId, [String? assetId])
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class ActivityApiRepository extends ApiRepository {
|
|||||||
|
|
||||||
Future<ActivityStats> getStats(String albumId, {String? assetId}) async {
|
Future<ActivityStats> getStats(String albumId, {String? assetId}) async {
|
||||||
final response = await checkNull(_api.getActivityStatistics(albumId, assetId: assetId));
|
final response = await checkNull(_api.getActivityStatistics(albumId, assetId: assetId));
|
||||||
return ActivityStats(comments: response.comments, likes: response.likes);
|
return ActivityStats(comments: response.comments);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Activity _toActivity(ActivityResponseDto dto) => Activity(
|
static Activity _toActivity(ActivityResponseDto dto) => Activity(
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class ActivityService with ErrorLoggerMixin {
|
|||||||
Future<ActivityStats> getStatistics(String albumId, {String? assetId}) async {
|
Future<ActivityStats> getStatistics(String albumId, {String? assetId}) async {
|
||||||
return logError(
|
return logError(
|
||||||
() => _activityApiRepository.getStats(albumId, assetId: assetId),
|
() => _activityApiRepository.getStats(albumId, assetId: assetId),
|
||||||
defaultValue: const ActivityStats(comments: 0, likes: 0),
|
defaultValue: const ActivityStats(comments: 0),
|
||||||
errorMessage: "Failed to statistics for album $albumId",
|
errorMessage: "Failed to statistics for album $albumId",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import 'package:immich_mobile/presentation/widgets/action_buttons/delete_local_a
|
|||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/delete_permanent_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/delete_permanent_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/download_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/download_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/like_activity_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/like_activity_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/open_activity_action_button.widget.dart';
|
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/move_to_lock_folder_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/move_to_lock_folder_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/remove_from_album_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/remove_from_album_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/remove_from_lock_folder_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/remove_from_lock_folder_action_button.widget.dart';
|
||||||
@@ -28,8 +27,6 @@ import 'package:immich_mobile/presentation/widgets/action_buttons/trash_action_b
|
|||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/unarchive_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/unarchive_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/unstack_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/unstack_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/upload_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/upload_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/edit_image_action_button.widget.dart';
|
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/add_action_button.widget.dart';
|
|
||||||
import 'package:immich_mobile/routing/router.dart';
|
import 'package:immich_mobile/routing/router.dart';
|
||||||
|
|
||||||
class ActionButtonContext {
|
class ActionButtonContext {
|
||||||
@@ -45,7 +42,6 @@ class ActionButtonContext {
|
|||||||
final bool isCasting;
|
final bool isCasting;
|
||||||
final TimelineOrigin timelineOrigin;
|
final TimelineOrigin timelineOrigin;
|
||||||
final ThemeData? originalTheme;
|
final ThemeData? originalTheme;
|
||||||
final ButtonPosition buttonPosition;
|
|
||||||
|
|
||||||
const ActionButtonContext({
|
const ActionButtonContext({
|
||||||
required this.asset,
|
required this.asset,
|
||||||
@@ -60,34 +56,13 @@ class ActionButtonContext {
|
|||||||
this.isCasting = false,
|
this.isCasting = false,
|
||||||
this.timelineOrigin = TimelineOrigin.main,
|
this.timelineOrigin = TimelineOrigin.main,
|
||||||
this.originalTheme,
|
this.originalTheme,
|
||||||
this.buttonPosition = ButtonPosition.other,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
ActionButtonContext withButtonPosition(ButtonPosition position) {
|
|
||||||
return ActionButtonContext(
|
|
||||||
asset: asset,
|
|
||||||
isOwner: isOwner,
|
|
||||||
isArchived: isArchived,
|
|
||||||
isTrashEnabled: isTrashEnabled,
|
|
||||||
isStacked: isStacked,
|
|
||||||
isInLockedView: isInLockedView,
|
|
||||||
currentAlbum: currentAlbum,
|
|
||||||
advancedTroubleshooting: advancedTroubleshooting,
|
|
||||||
source: source,
|
|
||||||
isCasting: isCasting,
|
|
||||||
timelineOrigin: timelineOrigin,
|
|
||||||
originalTheme: originalTheme,
|
|
||||||
buttonPosition: position,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ActionButtonType {
|
enum ActionButtonType {
|
||||||
openInfo,
|
openInfo,
|
||||||
openActivity,
|
|
||||||
likeActivity,
|
likeActivity,
|
||||||
share,
|
share,
|
||||||
editImage,
|
|
||||||
shareLink,
|
shareLink,
|
||||||
cast,
|
cast,
|
||||||
similarPhotos,
|
similarPhotos,
|
||||||
@@ -104,7 +79,6 @@ enum ActionButtonType {
|
|||||||
deleteLocal,
|
deleteLocal,
|
||||||
deletePermanent,
|
deletePermanent,
|
||||||
delete,
|
delete,
|
||||||
addTo,
|
|
||||||
advancedInfo;
|
advancedInfo;
|
||||||
|
|
||||||
bool shouldShow(ActionButtonContext context) {
|
bool shouldShow(ActionButtonContext context) {
|
||||||
@@ -182,22 +156,10 @@ enum ActionButtonType {
|
|||||||
context.timelineOrigin != TimelineOrigin.localAlbum &&
|
context.timelineOrigin != TimelineOrigin.localAlbum &&
|
||||||
context.isOwner,
|
context.isOwner,
|
||||||
ActionButtonType.cast => context.isCasting || context.asset.hasRemote,
|
ActionButtonType.cast => context.isCasting || context.asset.hasRemote,
|
||||||
ActionButtonType.editImage =>
|
|
||||||
!context.isInLockedView && //
|
|
||||||
context.asset.type == AssetType.image &&
|
|
||||||
!(context.buttonPosition == ButtonPosition.bottomBar && context.currentAlbum?.isShared == true),
|
|
||||||
ActionButtonType.addTo =>
|
|
||||||
!context.isInLockedView && //
|
|
||||||
context.asset.hasRemote,
|
|
||||||
ActionButtonType.openActivity =>
|
|
||||||
!context.isInLockedView &&
|
|
||||||
context.currentAlbum != null &&
|
|
||||||
context.currentAlbum!.isActivityEnabled &&
|
|
||||||
context.currentAlbum!.isShared,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildButton(
|
ConsumerWidget buildButton(
|
||||||
ActionButtonContext context, [
|
ActionButtonContext context, [
|
||||||
BuildContext? buildContext,
|
BuildContext? buildContext,
|
||||||
bool iconOnly = false,
|
bool iconOnly = false,
|
||||||
@@ -280,9 +242,6 @@ enum ActionButtonType {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
ActionButtonType.cast => CastActionButton(iconOnly: iconOnly, menuItem: menuItem),
|
ActionButtonType.cast => CastActionButton(iconOnly: iconOnly, menuItem: menuItem),
|
||||||
ActionButtonType.editImage => EditImageActionButton(iconOnly: iconOnly, menuItem: menuItem),
|
|
||||||
ActionButtonType.addTo => AddActionButton(originalTheme: context.originalTheme),
|
|
||||||
ActionButtonType.openActivity => OpenActivityActionButton(iconOnly: iconOnly, menuItem: menuItem),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,77 +272,39 @@ enum ActionButtonType {
|
|||||||
class ActionButtonBuilder {
|
class ActionButtonBuilder {
|
||||||
static const List<ActionButtonType> _actionTypes = ActionButtonType.values;
|
static const List<ActionButtonType> _actionTypes = ActionButtonType.values;
|
||||||
static const List<ActionButtonType> defaultViewerKebabMenuOrder = _actionTypes;
|
static const List<ActionButtonType> defaultViewerKebabMenuOrder = _actionTypes;
|
||||||
static const List<ActionButtonType> _defaultViewerBottomBarOrder = [
|
static const Set<ActionButtonType> defaultViewerBottomBarButtons = {
|
||||||
ActionButtonType.share,
|
ActionButtonType.share,
|
||||||
|
ActionButtonType.moveToLockFolder,
|
||||||
ActionButtonType.upload,
|
ActionButtonType.upload,
|
||||||
ActionButtonType.editImage,
|
|
||||||
ActionButtonType.addTo,
|
|
||||||
ActionButtonType.openActivity,
|
|
||||||
ActionButtonType.likeActivity,
|
|
||||||
ActionButtonType.deleteLocal,
|
|
||||||
ActionButtonType.delete,
|
ActionButtonType.delete,
|
||||||
ActionButtonType.removeFromLockFolder,
|
ActionButtonType.archive,
|
||||||
ActionButtonType.deletePermanent,
|
ActionButtonType.unarchive,
|
||||||
];
|
};
|
||||||
|
|
||||||
static List<Widget> build(ActionButtonContext context) {
|
static List<Widget> build(ActionButtonContext context) {
|
||||||
return _actionTypes.where((type) => type.shouldShow(context)).map((type) => type.buildButton(context)).toList();
|
return _actionTypes.where((type) => type.shouldShow(context)).map((type) => type.buildButton(context)).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<ActionButtonType> getViewerKebabMenuTypes(ActionButtonContext context) {
|
|
||||||
final visibleBottomBarButtons = getViewerBottomBarTypes(context);
|
|
||||||
final excludedTypes = <ActionButtonType>{...visibleBottomBarButtons, ActionButtonType.addTo};
|
|
||||||
|
|
||||||
if (visibleBottomBarButtons.contains(ActionButtonType.addTo)) {
|
|
||||||
excludedTypes.addAll([ActionButtonType.moveToLockFolder, ActionButtonType.archive, ActionButtonType.unarchive]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return defaultViewerKebabMenuOrder
|
|
||||||
.where((type) => !excludedTypes.contains(type) && type.shouldShow(context))
|
|
||||||
.toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
static List<ActionButtonType> getViewerBottomBarTypes(ActionButtonContext context) {
|
|
||||||
final bottomBarContext = context.withButtonPosition(ButtonPosition.bottomBar);
|
|
||||||
return _defaultViewerBottomBarOrder.where((type) => type.shouldShow(bottomBarContext)).take(4).toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
static List<Widget> buildViewerKebabMenu(ActionButtonContext context, BuildContext buildContext, WidgetRef ref) {
|
static List<Widget> buildViewerKebabMenu(ActionButtonContext context, BuildContext buildContext, WidgetRef ref) {
|
||||||
final visibleButtons = getViewerKebabMenuTypes(context);
|
final visibleButtons = defaultViewerKebabMenuOrder
|
||||||
return visibleButtons.toKebabMenuWidgets(context, buildContext, ref);
|
.where((type) => !defaultViewerBottomBarButtons.contains(type) && type.shouldShow(context))
|
||||||
}
|
.toList();
|
||||||
|
|
||||||
static List<Widget> buildViewerBottomBar(ActionButtonContext context, BuildContext buildContext, WidgetRef ref) {
|
if (visibleButtons.isEmpty) {
|
||||||
final visibleButtons = getViewerBottomBarTypes(context);
|
|
||||||
return visibleButtons.toBottomBarWidgets(context, buildContext, ref);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extension ActionButtonTypeListExtension on List<ActionButtonType> {
|
|
||||||
List<Widget> toKebabMenuWidgets(ActionButtonContext context, BuildContext buildContext, WidgetRef ref) {
|
|
||||||
if (isEmpty) {
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Widget> result = [];
|
final List<Widget> result = [];
|
||||||
int? lastGroup;
|
int? lastGroup;
|
||||||
|
|
||||||
for (final type in this) {
|
for (final type in visibleButtons) {
|
||||||
if (lastGroup != null && type.kebabMenuGroup != lastGroup) {
|
if (lastGroup != null && type.kebabMenuGroup != lastGroup) {
|
||||||
result.add(const Divider(height: 1));
|
result.add(const Divider(height: 1));
|
||||||
}
|
}
|
||||||
final widget = type.buildButton(context, buildContext, false, true);
|
result.add(type.buildButton(context, buildContext, false, true).build(buildContext, ref));
|
||||||
result.add(widget is ConsumerWidget ? widget.build(buildContext, ref) : widget);
|
|
||||||
lastGroup = type.kebabMenuGroup;
|
lastGroup = type.kebabMenuGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> toBottomBarWidgets(ActionButtonContext context, BuildContext buildContext, WidgetRef ref) {
|
|
||||||
return map((type) {
|
|
||||||
final widget = type.buildButton(context, buildContext, false, false);
|
|
||||||
return widget is ConsumerWidget ? widget.build(buildContext, ref) : widget;
|
|
||||||
}).toList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,9 +108,9 @@ void main() {
|
|||||||
expect(activities, hasLength(5));
|
expect(activities, hasLength(5));
|
||||||
expect(activities, contains(like));
|
expect(activities, contains(like));
|
||||||
|
|
||||||
// Verify activity count is bumped for new likes
|
// Never bump activity count for new likes
|
||||||
verify(() => activityStatisticsMock.addActivity()).called(1);
|
verifyNever(() => activityStatisticsMock.addActivity());
|
||||||
verify(() => albumActivityStatisticsMock.addActivity()).called(1);
|
verifyNever(() => albumActivityStatisticsMock.addActivity());
|
||||||
|
|
||||||
final albumActivities = container.read(albumProvider).requireValue;
|
final albumActivities = container.read(albumProvider).requireValue;
|
||||||
expect(albumActivities, hasLength(5));
|
expect(albumActivities, hasLength(5));
|
||||||
@@ -155,9 +155,8 @@ void main() {
|
|||||||
expect(activities, hasLength(3));
|
expect(activities, hasLength(3));
|
||||||
expect(activities, isNot(anyElement(predicate((Activity a) => a.id == '3'))));
|
expect(activities, isNot(anyElement(predicate((Activity a) => a.id == '3'))));
|
||||||
|
|
||||||
// Verify activity count is decreased for removed likes
|
verifyNever(() => activityStatisticsMock.removeActivity());
|
||||||
verify(() => activityStatisticsMock.removeActivity()).called(1);
|
verifyNever(() => albumActivityStatisticsMock.removeActivity());
|
||||||
verify(() => albumActivityStatisticsMock.removeActivity()).called(1);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Remove Like failed', () async {
|
test('Remove Like failed', () async {
|
||||||
@@ -205,9 +204,8 @@ void main() {
|
|||||||
expect(albumActivities, isNot(anyElement(predicate((Activity a) => a.id == '3'))));
|
expect(albumActivities, isNot(anyElement(predicate((Activity a) => a.id == '3'))));
|
||||||
|
|
||||||
verify(() => activityMock.removeActivity('3'));
|
verify(() => activityMock.removeActivity('3'));
|
||||||
// Verify activity count is decreased when removing from asset-scoped provider
|
verifyNever(() => activityStatisticsMock.removeActivity());
|
||||||
verify(() => activityStatisticsMock.removeActivity()).called(1);
|
verifyNever(() => albumActivityStatisticsMock.removeActivity());
|
||||||
verify(() => albumActivityStatisticsMock.removeActivity()).called(1);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ void main() {
|
|||||||
test('Returns the proper count family', () async {
|
test('Returns the proper count family', () async {
|
||||||
when(
|
when(
|
||||||
() => activityMock.getStatistics('test-album', assetId: 'test-asset'),
|
() => activityMock.getStatistics('test-album', assetId: 'test-asset'),
|
||||||
).thenAnswer((_) async => const ActivityStats(comments: 5, likes: 0));
|
).thenAnswer((_) async => const ActivityStats(comments: 5));
|
||||||
|
|
||||||
// Read here to make the getStatistics call
|
// Read here to make the getStatistics call
|
||||||
container.read(activityStatisticsProvider('test-album', 'test-asset'));
|
container.read(activityStatisticsProvider('test-album', 'test-asset'));
|
||||||
@@ -38,9 +38,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Adds activity', () async {
|
test('Adds activity', () async {
|
||||||
when(
|
when(() => activityMock.getStatistics('test-album')).thenAnswer((_) async => const ActivityStats(comments: 10));
|
||||||
() => activityMock.getStatistics('test-album'),
|
|
||||||
).thenAnswer((_) async => const ActivityStats(comments: 10, likes: 0));
|
|
||||||
|
|
||||||
final provider = activityStatisticsProvider('test-album');
|
final provider = activityStatisticsProvider('test-album');
|
||||||
container.listen(provider, listener.call, fireImmediately: true);
|
container.listen(provider, listener.call, fireImmediately: true);
|
||||||
@@ -57,7 +55,7 @@ void main() {
|
|||||||
test('Removes activity', () async {
|
test('Removes activity', () async {
|
||||||
when(
|
when(
|
||||||
() => activityMock.getStatistics('new-album', assetId: 'test-asset'),
|
() => activityMock.getStatistics('new-album', assetId: 'test-asset'),
|
||||||
).thenAnswer((_) async => const ActivityStats(comments: 10, likes: 0));
|
).thenAnswer((_) async => const ActivityStats(comments: 10));
|
||||||
|
|
||||||
final provider = activityStatisticsProvider('new-album', 'test-asset');
|
final provider = activityStatisticsProvider('new-album', 'test-asset');
|
||||||
container.listen(provider, listener.call, fireImmediately: true);
|
container.listen(provider, listener.call, fireImmediately: true);
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:collection/collection.dart';
|
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:immich_mobile/constants/enums.dart';
|
import 'package:immich_mobile/constants/enums.dart';
|
||||||
@@ -963,128 +962,4 @@ void main() {
|
|||||||
expect(nonArchivedWidgets, isNotEmpty);
|
expect(nonArchivedWidgets, isNotEmpty);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
group('ActionButtonBuilder.getViewerBottomBarTypes', () {
|
|
||||||
test('should return correct button types for shared album with activity', () {
|
|
||||||
final remoteAsset = createRemoteAsset();
|
|
||||||
final album = createRemoteAlbum(isActivityEnabled: true, isShared: true);
|
|
||||||
final context = ActionButtonContext(
|
|
||||||
asset: remoteAsset,
|
|
||||||
isOwner: true,
|
|
||||||
isArchived: false,
|
|
||||||
isTrashEnabled: true,
|
|
||||||
isInLockedView: false,
|
|
||||||
currentAlbum: album,
|
|
||||||
advancedTroubleshooting: false,
|
|
||||||
isStacked: false,
|
|
||||||
source: ActionSource.viewer,
|
|
||||||
buttonPosition: ButtonPosition.bottomBar,
|
|
||||||
);
|
|
||||||
|
|
||||||
const expectedTypes = [
|
|
||||||
ActionButtonType.share,
|
|
||||||
ActionButtonType.addTo,
|
|
||||||
ActionButtonType.openActivity,
|
|
||||||
ActionButtonType.likeActivity,
|
|
||||||
];
|
|
||||||
|
|
||||||
final bottomBarTypes = ActionButtonBuilder.getViewerBottomBarTypes(context);
|
|
||||||
final kebabTypes = ActionButtonBuilder.getViewerKebabMenuTypes(context);
|
|
||||||
|
|
||||||
expect(const ListEquality().equals(bottomBarTypes, expectedTypes), isTrue);
|
|
||||||
expect(bottomBarTypes.any(kebabTypes.contains), isFalse);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return correct button types for local only asset', () {
|
|
||||||
final localAsset = createLocalAsset();
|
|
||||||
final context = ActionButtonContext(
|
|
||||||
asset: localAsset,
|
|
||||||
isOwner: true,
|
|
||||||
isArchived: false,
|
|
||||||
isTrashEnabled: true,
|
|
||||||
isInLockedView: false,
|
|
||||||
currentAlbum: null,
|
|
||||||
advancedTroubleshooting: false,
|
|
||||||
isStacked: false,
|
|
||||||
source: ActionSource.viewer,
|
|
||||||
buttonPosition: ButtonPosition.bottomBar,
|
|
||||||
);
|
|
||||||
|
|
||||||
const expectedTypes = [
|
|
||||||
ActionButtonType.share,
|
|
||||||
ActionButtonType.upload,
|
|
||||||
ActionButtonType.editImage,
|
|
||||||
ActionButtonType.deleteLocal,
|
|
||||||
];
|
|
||||||
|
|
||||||
final bottomBarTypes = ActionButtonBuilder.getViewerBottomBarTypes(context);
|
|
||||||
final kebabTypes = ActionButtonBuilder.getViewerKebabMenuTypes(
|
|
||||||
context.withButtonPosition(ButtonPosition.kebabMenu),
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(const ListEquality().equals(bottomBarTypes, expectedTypes), isTrue);
|
|
||||||
expect(bottomBarTypes.any(kebabTypes.contains), isFalse);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return correct button types for locked view', () {
|
|
||||||
final remoteAsset = createRemoteAsset();
|
|
||||||
final context = ActionButtonContext(
|
|
||||||
asset: remoteAsset,
|
|
||||||
isOwner: true,
|
|
||||||
isArchived: false,
|
|
||||||
isTrashEnabled: false,
|
|
||||||
isInLockedView: true,
|
|
||||||
currentAlbum: null,
|
|
||||||
advancedTroubleshooting: false,
|
|
||||||
isStacked: false,
|
|
||||||
source: ActionSource.viewer,
|
|
||||||
buttonPosition: ButtonPosition.bottomBar,
|
|
||||||
);
|
|
||||||
|
|
||||||
const expectedTypes = [
|
|
||||||
ActionButtonType.share,
|
|
||||||
ActionButtonType.removeFromLockFolder,
|
|
||||||
ActionButtonType.deletePermanent,
|
|
||||||
];
|
|
||||||
|
|
||||||
final bottomBarTypes = ActionButtonBuilder.getViewerBottomBarTypes(context);
|
|
||||||
final kebabTypes = ActionButtonBuilder.getViewerKebabMenuTypes(
|
|
||||||
context.withButtonPosition(ButtonPosition.kebabMenu),
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(const ListEquality().equals(bottomBarTypes, expectedTypes), isTrue);
|
|
||||||
expect(bottomBarTypes.any(kebabTypes.contains), isFalse);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return correct button types for remote only asset', () {
|
|
||||||
final remoteAsset = createRemoteAsset();
|
|
||||||
final context = ActionButtonContext(
|
|
||||||
asset: remoteAsset,
|
|
||||||
isOwner: true,
|
|
||||||
isArchived: false,
|
|
||||||
isTrashEnabled: true,
|
|
||||||
isInLockedView: false,
|
|
||||||
currentAlbum: null,
|
|
||||||
advancedTroubleshooting: false,
|
|
||||||
isStacked: false,
|
|
||||||
source: ActionSource.viewer,
|
|
||||||
buttonPosition: ButtonPosition.bottomBar,
|
|
||||||
);
|
|
||||||
|
|
||||||
const expectedTypes = [
|
|
||||||
ActionButtonType.share,
|
|
||||||
ActionButtonType.editImage,
|
|
||||||
ActionButtonType.addTo,
|
|
||||||
ActionButtonType.delete,
|
|
||||||
];
|
|
||||||
|
|
||||||
final bottomBarTypes = ActionButtonBuilder.getViewerBottomBarTypes(context);
|
|
||||||
final kebabTypes = ActionButtonBuilder.getViewerKebabMenuTypes(
|
|
||||||
context.withButtonPosition(ButtonPosition.kebabMenu),
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(const ListEquality().equals(bottomBarTypes, expectedTypes), isTrue);
|
|
||||||
expect(bottomBarTypes.any(kebabTypes.contains), isFalse);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user