mirror of
https://github.com/immich-app/immich.git
synced 2025-11-28 20:09:53 +09:00
feat(mobile): shared album activities (#20714)
* feat(mobile): shared album activities * add like buttons and fix behavior of unliking * fix: conditionally show activity button and fix title truncations * fix(mobile): newest/oldest album sort (#20743) * fix(mobile): newest/oldest album sort * chore: use sqlite to determine album asset timestamps * Fix missing future Co-authored-by: Alex <alex.tran1502@gmail.com> * fix: async handling of sort * chore: tests * chore: code review changes * fix: use created at for newest asset * fix: use localDateTime for sorting * chore: cleanup * chore: use final * feat: loading indicator --------- Co-authored-by: Alex <alex.tran1502@gmail.com> --------- Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
@@ -1195,6 +1195,7 @@
|
|||||||
"library_page_sort_title": "Album title",
|
"library_page_sort_title": "Album title",
|
||||||
"licenses": "Licenses",
|
"licenses": "Licenses",
|
||||||
"light": "Light",
|
"light": "Light",
|
||||||
|
"like": "Like",
|
||||||
"like_deleted": "Like deleted",
|
"like_deleted": "Like deleted",
|
||||||
"link_motion_video": "Link motion video",
|
"link_motion_video": "Link motion video",
|
||||||
"link_to_oauth": "Link to OAuth",
|
"link_to_oauth": "Link to OAuth",
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ class RemoteAlbum {
|
|||||||
final AlbumAssetOrder order;
|
final AlbumAssetOrder order;
|
||||||
final int assetCount;
|
final int assetCount;
|
||||||
final String ownerName;
|
final String ownerName;
|
||||||
|
final bool isShared;
|
||||||
|
|
||||||
const RemoteAlbum({
|
const RemoteAlbum({
|
||||||
required this.id,
|
required this.id,
|
||||||
@@ -36,6 +37,7 @@ class RemoteAlbum {
|
|||||||
required this.order,
|
required this.order,
|
||||||
required this.assetCount,
|
required this.assetCount,
|
||||||
required this.ownerName,
|
required this.ownerName,
|
||||||
|
required this.isShared,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -52,6 +54,7 @@ class RemoteAlbum {
|
|||||||
thumbnailAssetId: ${thumbnailAssetId ?? "<NA>"}
|
thumbnailAssetId: ${thumbnailAssetId ?? "<NA>"}
|
||||||
assetCount: $assetCount
|
assetCount: $assetCount
|
||||||
ownerName: $ownerName
|
ownerName: $ownerName
|
||||||
|
isShared: $isShared
|
||||||
}''';
|
}''';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +72,8 @@ class RemoteAlbum {
|
|||||||
isActivityEnabled == other.isActivityEnabled &&
|
isActivityEnabled == other.isActivityEnabled &&
|
||||||
order == other.order &&
|
order == other.order &&
|
||||||
assetCount == other.assetCount &&
|
assetCount == other.assetCount &&
|
||||||
ownerName == other.ownerName;
|
ownerName == other.ownerName &&
|
||||||
|
isShared == other.isShared;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -84,7 +88,8 @@ class RemoteAlbum {
|
|||||||
isActivityEnabled.hashCode ^
|
isActivityEnabled.hashCode ^
|
||||||
order.hashCode ^
|
order.hashCode ^
|
||||||
assetCount.hashCode ^
|
assetCount.hashCode ^
|
||||||
ownerName.hashCode;
|
ownerName.hashCode ^
|
||||||
|
isShared.hashCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoteAlbum copyWith({
|
RemoteAlbum copyWith({
|
||||||
@@ -99,6 +104,7 @@ class RemoteAlbum {
|
|||||||
AlbumAssetOrder? order,
|
AlbumAssetOrder? order,
|
||||||
int? assetCount,
|
int? assetCount,
|
||||||
String? ownerName,
|
String? ownerName,
|
||||||
|
bool? isShared,
|
||||||
}) {
|
}) {
|
||||||
return RemoteAlbum(
|
return RemoteAlbum(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
@@ -112,6 +118,7 @@ class RemoteAlbum {
|
|||||||
order: order ?? this.order,
|
order: order ?? this.order,
|
||||||
assetCount: assetCount ?? this.assetCount,
|
assetCount: assetCount ?? this.assetCount,
|
||||||
ownerName: ownerName ?? this.ownerName,
|
ownerName: ownerName ?? this.ownerName,
|
||||||
|
isShared: isShared ?? this.isShared,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,11 +31,17 @@ class DriftRemoteAlbumRepository extends DriftDatabaseRepository {
|
|||||||
useColumns: false,
|
useColumns: false,
|
||||||
),
|
),
|
||||||
leftOuterJoin(_db.userEntity, _db.userEntity.id.equalsExp(_db.remoteAlbumEntity.ownerId), useColumns: false),
|
leftOuterJoin(_db.userEntity, _db.userEntity.id.equalsExp(_db.remoteAlbumEntity.ownerId), useColumns: false),
|
||||||
|
leftOuterJoin(
|
||||||
|
_db.remoteAlbumUserEntity,
|
||||||
|
_db.remoteAlbumUserEntity.albumId.equalsExp(_db.remoteAlbumEntity.id),
|
||||||
|
useColumns: false,
|
||||||
|
),
|
||||||
]);
|
]);
|
||||||
query
|
query
|
||||||
..where(_db.remoteAssetEntity.deletedAt.isNull())
|
..where(_db.remoteAssetEntity.deletedAt.isNull())
|
||||||
..addColumns([assetCount])
|
..addColumns([assetCount])
|
||||||
..addColumns([_db.userEntity.name])
|
..addColumns([_db.userEntity.name])
|
||||||
|
..addColumns([_db.remoteAlbumUserEntity.userId.count()])
|
||||||
..groupBy([_db.remoteAlbumEntity.id]);
|
..groupBy([_db.remoteAlbumEntity.id]);
|
||||||
|
|
||||||
if (sortBy.isNotEmpty) {
|
if (sortBy.isNotEmpty) {
|
||||||
@@ -53,7 +59,11 @@ class DriftRemoteAlbumRepository extends DriftDatabaseRepository {
|
|||||||
.map(
|
.map(
|
||||||
(row) => row
|
(row) => row
|
||||||
.readTable(_db.remoteAlbumEntity)
|
.readTable(_db.remoteAlbumEntity)
|
||||||
.toDto(assetCount: row.read(assetCount) ?? 0, ownerName: row.read(_db.userEntity.name)!),
|
.toDto(
|
||||||
|
assetCount: row.read(assetCount) ?? 0,
|
||||||
|
ownerName: row.read(_db.userEntity.name)!,
|
||||||
|
isShared: row.read(_db.remoteAlbumUserEntity.userId.count())! > 2,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.get();
|
.get();
|
||||||
}
|
}
|
||||||
@@ -78,17 +88,27 @@ class DriftRemoteAlbumRepository extends DriftDatabaseRepository {
|
|||||||
_db.userEntity.id.equalsExp(_db.remoteAlbumEntity.ownerId),
|
_db.userEntity.id.equalsExp(_db.remoteAlbumEntity.ownerId),
|
||||||
useColumns: false,
|
useColumns: false,
|
||||||
),
|
),
|
||||||
|
leftOuterJoin(
|
||||||
|
_db.remoteAlbumUserEntity,
|
||||||
|
_db.remoteAlbumUserEntity.albumId.equalsExp(_db.remoteAlbumEntity.id),
|
||||||
|
useColumns: false,
|
||||||
|
),
|
||||||
])
|
])
|
||||||
..where(_db.remoteAlbumEntity.id.equals(albumId) & _db.remoteAssetEntity.deletedAt.isNull())
|
..where(_db.remoteAlbumEntity.id.equals(albumId) & _db.remoteAssetEntity.deletedAt.isNull())
|
||||||
..addColumns([assetCount])
|
..addColumns([assetCount])
|
||||||
..addColumns([_db.userEntity.name])
|
..addColumns([_db.userEntity.name])
|
||||||
|
..addColumns([_db.remoteAlbumUserEntity.userId.count()])
|
||||||
..groupBy([_db.remoteAlbumEntity.id]);
|
..groupBy([_db.remoteAlbumEntity.id]);
|
||||||
|
|
||||||
return query
|
return query
|
||||||
.map(
|
.map(
|
||||||
(row) => row
|
(row) => row
|
||||||
.readTable(_db.remoteAlbumEntity)
|
.readTable(_db.remoteAlbumEntity)
|
||||||
.toDto(assetCount: row.read(assetCount) ?? 0, ownerName: row.read(_db.userEntity.name)!),
|
.toDto(
|
||||||
|
assetCount: row.read(assetCount) ?? 0,
|
||||||
|
ownerName: row.read(_db.userEntity.name)!,
|
||||||
|
isShared: row.read(_db.remoteAlbumUserEntity.userId.count())! > 2,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.getSingleOrNull();
|
.getSingleOrNull();
|
||||||
}
|
}
|
||||||
@@ -254,13 +274,24 @@ class DriftRemoteAlbumRepository extends DriftDatabaseRepository {
|
|||||||
_db.userEntity.id.equalsExp(_db.remoteAlbumEntity.ownerId),
|
_db.userEntity.id.equalsExp(_db.remoteAlbumEntity.ownerId),
|
||||||
useColumns: false,
|
useColumns: false,
|
||||||
),
|
),
|
||||||
|
leftOuterJoin(
|
||||||
|
_db.remoteAlbumUserEntity,
|
||||||
|
_db.remoteAlbumUserEntity.albumId.equalsExp(_db.remoteAlbumEntity.id),
|
||||||
|
useColumns: false,
|
||||||
|
),
|
||||||
])
|
])
|
||||||
..where(_db.remoteAlbumEntity.id.equals(albumId))
|
..where(_db.remoteAlbumEntity.id.equals(albumId))
|
||||||
..addColumns([_db.userEntity.name])
|
..addColumns([_db.userEntity.name])
|
||||||
|
..addColumns([_db.remoteAlbumUserEntity.userId.count()])
|
||||||
..groupBy([_db.remoteAlbumEntity.id]);
|
..groupBy([_db.remoteAlbumEntity.id]);
|
||||||
|
|
||||||
return query.map((row) {
|
return query.map((row) {
|
||||||
final album = row.readTable(_db.remoteAlbumEntity).toDto(ownerName: row.read(_db.userEntity.name)!);
|
final album = row
|
||||||
|
.readTable(_db.remoteAlbumEntity)
|
||||||
|
.toDto(
|
||||||
|
ownerName: row.read(_db.userEntity.name)!,
|
||||||
|
isShared: row.read(_db.remoteAlbumUserEntity.userId.count())! > 2,
|
||||||
|
);
|
||||||
return album;
|
return album;
|
||||||
}).watchSingleOrNull();
|
}).watchSingleOrNull();
|
||||||
}
|
}
|
||||||
@@ -293,7 +324,7 @@ class DriftRemoteAlbumRepository extends DriftDatabaseRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension on RemoteAlbumEntityData {
|
extension on RemoteAlbumEntityData {
|
||||||
RemoteAlbum toDto({int assetCount = 0, required String ownerName}) {
|
RemoteAlbum toDto({int assetCount = 0, required String ownerName, required bool isShared}) {
|
||||||
return RemoteAlbum(
|
return RemoteAlbum(
|
||||||
id: id,
|
id: id,
|
||||||
name: name,
|
name: name,
|
||||||
@@ -306,6 +337,7 @@ extension on RemoteAlbumEntityData {
|
|||||||
order: order,
|
order: order,
|
||||||
assetCount: assetCount,
|
assetCount: assetCount,
|
||||||
ownerName: ownerName,
|
ownerName: ownerName,
|
||||||
|
isShared: isShared,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
104
mobile/lib/presentation/pages/drift_activities.page.dart
Normal file
104
mobile/lib/presentation/pages/drift_activities.page.dart
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
import 'package:auto_route/auto_route.dart';
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_hooks/flutter_hooks.dart' hide Store;
|
||||||
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
||||||
|
import 'package:immich_mobile/extensions/asyncvalue_extensions.dart';
|
||||||
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||||
|
import 'package:immich_mobile/models/activities/activity.model.dart';
|
||||||
|
import 'package:immich_mobile/presentation/widgets/action_buttons/like_activity_action_button.widget.dart';
|
||||||
|
import 'package:immich_mobile/presentation/widgets/album/drift_activity_text_field.dart';
|
||||||
|
import 'package:immich_mobile/providers/activity.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/user.provider.dart';
|
||||||
|
import 'package:immich_mobile/widgets/activities/activity_tile.dart';
|
||||||
|
import 'package:immich_mobile/widgets/activities/dismissible_activity.dart';
|
||||||
|
|
||||||
|
@RoutePage()
|
||||||
|
class DriftActivitiesPage extends HookConsumerWidget {
|
||||||
|
const DriftActivitiesPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final album = ref.watch(currentRemoteAlbumProvider)!;
|
||||||
|
final asset = ref.watch(currentAssetNotifier) as RemoteAsset?;
|
||||||
|
final user = ref.watch(currentUserProvider);
|
||||||
|
|
||||||
|
final activityNotifier = ref.read(albumActivityProvider(album.id, asset?.id).notifier);
|
||||||
|
final activities = ref.watch(albumActivityProvider(album.id, asset?.id));
|
||||||
|
final listViewScrollController = useScrollController();
|
||||||
|
|
||||||
|
void scrollToBottom() {
|
||||||
|
listViewScrollController.animateTo(
|
||||||
|
listViewScrollController.position.maxScrollExtent + 80,
|
||||||
|
duration: const Duration(milliseconds: 600),
|
||||||
|
curve: Curves.fastOutSlowIn,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> onAddComment(String comment) async {
|
||||||
|
await activityNotifier.addComment(comment);
|
||||||
|
scrollToBottom();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: asset == null ? Text(album.name) : null,
|
||||||
|
actions: [const LikeActivityActionButton(menuItem: true)],
|
||||||
|
actionsPadding: const EdgeInsets.only(right: 8),
|
||||||
|
),
|
||||||
|
body: activities.widgetWhen(
|
||||||
|
onData: (data) {
|
||||||
|
final liked = data.firstWhereOrNull(
|
||||||
|
(a) => a.type == ActivityType.like && a.user.id == user?.id && a.assetId == asset?.id,
|
||||||
|
);
|
||||||
|
|
||||||
|
return SafeArea(
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
ListView.builder(
|
||||||
|
controller: listViewScrollController,
|
||||||
|
itemCount: data.length + 1,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
if (index == data.length) {
|
||||||
|
return const SizedBox(height: 80);
|
||||||
|
}
|
||||||
|
final activity = data[index];
|
||||||
|
final canDelete = activity.user.id == user?.id || album.ownerId == user?.id;
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(5),
|
||||||
|
child: DismissibleActivity(
|
||||||
|
activity.id,
|
||||||
|
ActivityTile(activity),
|
||||||
|
onDismiss: canDelete
|
||||||
|
? (activityId) async => await activityNotifier.removeActivity(activity.id)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.bottomCenter,
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: context.scaffoldBackgroundColor,
|
||||||
|
border: Border(top: BorderSide(color: context.colorScheme.secondaryContainer, width: 1)),
|
||||||
|
),
|
||||||
|
child: DriftActivityTextField(
|
||||||
|
isEnabled: album.isActivityEnabled,
|
||||||
|
likeId: liked?.id,
|
||||||
|
onSubmit: onAddComment,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
resizeToAvoidBottomInset: true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -165,6 +165,10 @@ class _RemoteAlbumPageState extends ConsumerState<RemoteAlbumPage> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> showActivity(BuildContext context) async {
|
||||||
|
context.pushRoute(const DriftActivitiesRoute());
|
||||||
|
}
|
||||||
|
|
||||||
void showOptionSheet(BuildContext context) {
|
void showOptionSheet(BuildContext context) {
|
||||||
final user = ref.watch(currentUserProvider);
|
final user = ref.watch(currentUserProvider);
|
||||||
final isOwner = user != null ? user.id == _album.ownerId : false;
|
final isOwner = user != null ? user.id == _album.ownerId : false;
|
||||||
@@ -241,6 +245,7 @@ class _RemoteAlbumPageState extends ConsumerState<RemoteAlbumPage> {
|
|||||||
onShowOptions: () => showOptionSheet(context),
|
onShowOptions: () => showOptionSheet(context),
|
||||||
onToggleAlbumOrder: () => toggleAlbumOrder(),
|
onToggleAlbumOrder: () => toggleAlbumOrder(),
|
||||||
onEditTitle: () => showEditTitleAndDescription(context),
|
onEditTitle: () => showEditTitleAndDescription(context),
|
||||||
|
onActivity: () => showActivity(context),
|
||||||
),
|
),
|
||||||
bottomSheet: RemoteAlbumBottomSheet(album: _album),
|
bottomSheet: RemoteAlbumBottomSheet(album: _album),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
import 'package:collection/collection.dart';
|
||||||
|
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/extensions/translate_extensions.dart';
|
||||||
|
import 'package:immich_mobile/models/activities/activity.model.dart';
|
||||||
|
import 'package:immich_mobile/presentation/widgets/action_buttons/base_action_button.widget.dart';
|
||||||
|
import 'package:immich_mobile/providers/activity.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/user.provider.dart';
|
||||||
|
|
||||||
|
class LikeActivityActionButton extends ConsumerWidget {
|
||||||
|
const LikeActivityActionButton({super.key, this.menuItem = false});
|
||||||
|
|
||||||
|
final bool menuItem;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final album = ref.watch(currentRemoteAlbumProvider);
|
||||||
|
final asset = ref.watch(currentAssetNotifier) as RemoteAsset?;
|
||||||
|
final user = ref.watch(currentUserProvider);
|
||||||
|
|
||||||
|
final activities = ref.watch(albumActivityProvider(album?.id ?? "", asset?.id));
|
||||||
|
|
||||||
|
onTap(Activity? liked) async {
|
||||||
|
if (user == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (liked != null) {
|
||||||
|
await ref.read(albumActivityProvider(album?.id ?? "", asset?.id).notifier).removeActivity(liked.id);
|
||||||
|
} else {
|
||||||
|
await ref.read(albumActivityProvider(album?.id ?? "", asset?.id).notifier).addLike();
|
||||||
|
}
|
||||||
|
|
||||||
|
ref.invalidate(albumActivityProvider(album?.id ?? "", asset?.id));
|
||||||
|
}
|
||||||
|
|
||||||
|
return activities.when(
|
||||||
|
data: (data) {
|
||||||
|
final liked = data.firstWhereOrNull(
|
||||||
|
(a) => a.type == ActivityType.like && a.user.id == user?.id && a.assetId == asset?.id,
|
||||||
|
);
|
||||||
|
|
||||||
|
return BaseActionButton(
|
||||||
|
iconData: liked != null ? Icons.favorite : Icons.favorite_border,
|
||||||
|
label: "like".t(context: context),
|
||||||
|
onPressed: () => onTap(liked),
|
||||||
|
menuItem: menuItem,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
// default to empty heart during loading
|
||||||
|
loading: () => BaseActionButton(
|
||||||
|
iconData: Icons.favorite_border,
|
||||||
|
label: "like".t(context: context),
|
||||||
|
menuItem: menuItem,
|
||||||
|
),
|
||||||
|
error: (error, stack) => Text("Error: $error"),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||||
|
import 'package:immich_mobile/providers/user.provider.dart';
|
||||||
|
import 'package:immich_mobile/widgets/common/user_circle_avatar.dart';
|
||||||
|
|
||||||
|
class DriftActivityTextField extends ConsumerStatefulWidget {
|
||||||
|
final bool isEnabled;
|
||||||
|
final String? likeId;
|
||||||
|
final Function(String) onSubmit;
|
||||||
|
final Function()? onKeyboardFocus;
|
||||||
|
|
||||||
|
const DriftActivityTextField({
|
||||||
|
required this.onSubmit,
|
||||||
|
this.isEnabled = true,
|
||||||
|
this.likeId,
|
||||||
|
this.onKeyboardFocus,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
ConsumerState<DriftActivityTextField> createState() => _DriftActivityTextFieldState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DriftActivityTextFieldState extends ConsumerState<DriftActivityTextField> {
|
||||||
|
late FocusNode inputFocusNode;
|
||||||
|
late TextEditingController inputController;
|
||||||
|
bool sendEnabled = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
inputController = TextEditingController();
|
||||||
|
inputFocusNode = FocusNode();
|
||||||
|
|
||||||
|
inputFocusNode.requestFocus();
|
||||||
|
|
||||||
|
inputFocusNode.addListener(() {
|
||||||
|
if (inputFocusNode.hasFocus) {
|
||||||
|
widget.onKeyboardFocus?.call();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
inputController.addListener(() {
|
||||||
|
setState(() {
|
||||||
|
sendEnabled = inputController.text.trim().isNotEmpty;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
inputController.dispose();
|
||||||
|
inputFocusNode.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final user = ref.watch(currentUserProvider);
|
||||||
|
|
||||||
|
// Pass text to callback and reset controller
|
||||||
|
void onEditingComplete() {
|
||||||
|
if (inputController.text.trim().isEmpty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
widget.onSubmit(inputController.text);
|
||||||
|
inputController.clear();
|
||||||
|
inputFocusNode.unfocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||||
|
child: TextField(
|
||||||
|
controller: inputController,
|
||||||
|
enabled: widget.isEnabled,
|
||||||
|
focusNode: inputFocusNode,
|
||||||
|
textInputAction: TextInputAction.send,
|
||||||
|
autofocus: false,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
isDense: true,
|
||||||
|
contentPadding: const EdgeInsets.symmetric(vertical: 12), // Adjust as needed
|
||||||
|
border: InputBorder.none,
|
||||||
|
focusedBorder: InputBorder.none,
|
||||||
|
enabledBorder: InputBorder.none,
|
||||||
|
prefixIcon: user != null
|
||||||
|
? Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||||
|
child: UserCircleAvatar(user: user, size: 30, radius: 15),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
suffixIcon: IconButton(
|
||||||
|
onPressed: sendEnabled ? onEditingComplete : null,
|
||||||
|
icon: const Icon(Icons.send),
|
||||||
|
iconSize: 24,
|
||||||
|
color: context.primaryColor,
|
||||||
|
disabledColor: context.colorScheme.secondaryContainer,
|
||||||
|
),
|
||||||
|
hintText: !widget.isEnabled ? 'shared_album_activities_input_disable'.tr() : 'say_something'.tr(),
|
||||||
|
hintStyle: TextStyle(fontWeight: FontWeight.normal, fontSize: 14, color: Colors.grey[600]),
|
||||||
|
),
|
||||||
|
onEditingComplete: onEditingComplete,
|
||||||
|
onTapOutside: (_) => inputFocusNode.unfocus(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,9 +8,10 @@ import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
|||||||
import 'package:immich_mobile/extensions/translate_extensions.dart';
|
import 'package:immich_mobile/extensions/translate_extensions.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/archive_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/archive_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/delete_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/delete_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/delete_local_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/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/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/share_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/share_action_button.widget.dart';
|
||||||
@@ -49,6 +50,8 @@ class AssetDetailBottomSheet extends ConsumerWidget {
|
|||||||
|
|
||||||
final actions = <Widget>[
|
final actions = <Widget>[
|
||||||
const ShareActionButton(source: ActionSource.viewer),
|
const ShareActionButton(source: ActionSource.viewer),
|
||||||
|
if (currentAlbum != null && currentAlbum.isActivityEnabled && currentAlbum.isShared)
|
||||||
|
const LikeActivityActionButton(),
|
||||||
if (asset.hasRemote) ...[
|
if (asset.hasRemote) ...[
|
||||||
const ShareLinkActionButton(source: ActionSource.viewer),
|
const ShareLinkActionButton(source: ActionSource.viewer),
|
||||||
const ArchiveActionButton(source: ActionSource.viewer),
|
const ArchiveActionButton(source: ActionSource.viewer),
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import 'package:immich_mobile/presentation/widgets/action_buttons/unfavorite_act
|
|||||||
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/cast.provider.dart';
|
import 'package:immich_mobile/providers/cast.provider.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/routes.provider.dart';
|
import 'package:immich_mobile/providers/routes.provider.dart';
|
||||||
import 'package:immich_mobile/providers/user.provider.dart';
|
import 'package:immich_mobile/providers/user.provider.dart';
|
||||||
import 'package:immich_mobile/routing/router.dart';
|
import 'package:immich_mobile/routing/router.dart';
|
||||||
@@ -27,6 +28,8 @@ class ViewerTopAppBar extends ConsumerWidget implements PreferredSizeWidget {
|
|||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final album = ref.watch(currentRemoteAlbumProvider);
|
||||||
|
|
||||||
final user = ref.watch(currentUserProvider);
|
final user = ref.watch(currentUserProvider);
|
||||||
final isOwner = asset is RemoteAsset && asset.ownerId == user?.id;
|
final isOwner = asset is RemoteAsset && asset.ownerId == user?.id;
|
||||||
final isInLockedView = ref.watch(inLockedViewProvider);
|
final isInLockedView = ref.watch(inLockedViewProvider);
|
||||||
@@ -49,6 +52,13 @@ class ViewerTopAppBar extends ConsumerWidget implements PreferredSizeWidget {
|
|||||||
|
|
||||||
final actions = <Widget>[
|
final actions = <Widget>[
|
||||||
if (isCasting || (asset.hasRemote)) const CastActionButton(menuItem: true),
|
if (isCasting || (asset.hasRemote)) const CastActionButton(menuItem: true),
|
||||||
|
if (album != null && album.isActivityEnabled && album.isShared)
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.chat_outlined),
|
||||||
|
onPressed: () {
|
||||||
|
context.navigateTo(const DriftActivitiesRoute());
|
||||||
|
},
|
||||||
|
),
|
||||||
if (showViewInTimelineButton)
|
if (showViewInTimelineButton)
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
|
|||||||
@@ -165,6 +165,7 @@ class AlbumApiRepository extends ApiRepository {
|
|||||||
order: dto.order == AssetOrder.asc ? AlbumAssetOrder.asc : AlbumAssetOrder.desc,
|
order: dto.order == AssetOrder.asc ? AlbumAssetOrder.asc : AlbumAssetOrder.desc,
|
||||||
assetCount: dto.assetCount,
|
assetCount: dto.assetCount,
|
||||||
ownerName: dto.owner.name,
|
ownerName: dto.owner.name,
|
||||||
|
isShared: dto.albumUsers.length > 2,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ extension on AlbumResponseDto {
|
|||||||
order: order == AssetOrder.asc ? AlbumAssetOrder.asc : AlbumAssetOrder.desc,
|
order: order == AssetOrder.asc ? AlbumAssetOrder.asc : AlbumAssetOrder.desc,
|
||||||
assetCount: assetCount,
|
assetCount: assetCount,
|
||||||
ownerName: owner.name,
|
ownerName: owner.name,
|
||||||
|
isShared: albumUsers.length > 2,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ import 'package:immich_mobile/pages/share_intent/share_intent.page.dart';
|
|||||||
import 'package:immich_mobile/presentation/pages/dev/feat_in_development.page.dart';
|
import 'package:immich_mobile/presentation/pages/dev/feat_in_development.page.dart';
|
||||||
import 'package:immich_mobile/presentation/pages/dev/main_timeline.page.dart';
|
import 'package:immich_mobile/presentation/pages/dev/main_timeline.page.dart';
|
||||||
import 'package:immich_mobile/presentation/pages/dev/media_stat.page.dart';
|
import 'package:immich_mobile/presentation/pages/dev/media_stat.page.dart';
|
||||||
|
import 'package:immich_mobile/presentation/pages/drift_activities.page.dart';
|
||||||
import 'package:immich_mobile/presentation/pages/drift_album.page.dart';
|
import 'package:immich_mobile/presentation/pages/drift_album.page.dart';
|
||||||
import 'package:immich_mobile/presentation/pages/drift_album_options.page.dart';
|
import 'package:immich_mobile/presentation/pages/drift_album_options.page.dart';
|
||||||
import 'package:immich_mobile/presentation/pages/drift_archive.page.dart';
|
import 'package:immich_mobile/presentation/pages/drift_archive.page.dart';
|
||||||
@@ -339,6 +340,7 @@ class AppRouter extends RootStackRouter {
|
|||||||
AutoRoute(page: DriftEditImageRoute.page),
|
AutoRoute(page: DriftEditImageRoute.page),
|
||||||
AutoRoute(page: DriftCropImageRoute.page),
|
AutoRoute(page: DriftCropImageRoute.page),
|
||||||
AutoRoute(page: DriftFilterImageRoute.page),
|
AutoRoute(page: DriftFilterImageRoute.page),
|
||||||
|
AutoRoute(page: DriftActivitiesRoute.page, guards: [_authGuard, _duplicateGuard]),
|
||||||
// required to handle all deeplinks in deep_link.service.dart
|
// required to handle all deeplinks in deep_link.service.dart
|
||||||
// auto_route_library#1722
|
// auto_route_library#1722
|
||||||
RedirectRoute(path: '*', redirectTo: '/'),
|
RedirectRoute(path: '*', redirectTo: '/'),
|
||||||
|
|||||||
@@ -667,6 +667,22 @@ class CropImageRouteArgs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// generated route for
|
||||||
|
/// [DriftActivitiesPage]
|
||||||
|
class DriftActivitiesRoute extends PageRouteInfo<void> {
|
||||||
|
const DriftActivitiesRoute({List<PageRouteInfo>? children})
|
||||||
|
: super(DriftActivitiesRoute.name, initialChildren: children);
|
||||||
|
|
||||||
|
static const String name = 'DriftActivitiesRoute';
|
||||||
|
|
||||||
|
static PageInfo page = PageInfo(
|
||||||
|
name,
|
||||||
|
builder: (data) {
|
||||||
|
return const DriftActivitiesPage();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// generated route for
|
/// generated route for
|
||||||
/// [DriftAlbumOptionsPage]
|
/// [DriftAlbumOptionsPage]
|
||||||
class DriftAlbumOptionsRoute extends PageRouteInfo<void> {
|
class DriftAlbumOptionsRoute extends PageRouteInfo<void> {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:immich_mobile/constants/errors.dart';
|
||||||
import 'package:immich_mobile/mixins/error_logger.mixin.dart';
|
import 'package:immich_mobile/mixins/error_logger.mixin.dart';
|
||||||
import 'package:immich_mobile/models/activities/activity.model.dart';
|
import 'package:immich_mobile/models/activities/activity.model.dart';
|
||||||
import 'package:immich_mobile/repositories/activity_api.repository.dart';
|
import 'package:immich_mobile/repositories/activity_api.repository.dart';
|
||||||
@@ -30,7 +31,11 @@ class ActivityService with ErrorLoggerMixin {
|
|||||||
Future<bool> removeActivity(String id) async {
|
Future<bool> removeActivity(String id) async {
|
||||||
return logError(
|
return logError(
|
||||||
() async {
|
() async {
|
||||||
|
try {
|
||||||
await _activityApiRepository.delete(id);
|
await _activityApiRepository.delete(id);
|
||||||
|
} on NoResponseDtoError {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
|
|||||||
@@ -28,12 +28,14 @@ class RemoteAlbumSliverAppBar extends ConsumerStatefulWidget {
|
|||||||
this.onShowOptions,
|
this.onShowOptions,
|
||||||
this.onToggleAlbumOrder,
|
this.onToggleAlbumOrder,
|
||||||
this.onEditTitle,
|
this.onEditTitle,
|
||||||
|
this.onActivity,
|
||||||
});
|
});
|
||||||
|
|
||||||
final IconData icon;
|
final IconData icon;
|
||||||
final void Function()? onShowOptions;
|
final void Function()? onShowOptions;
|
||||||
final void Function()? onToggleAlbumOrder;
|
final void Function()? onToggleAlbumOrder;
|
||||||
final void Function()? onEditTitle;
|
final void Function()? onEditTitle;
|
||||||
|
final void Function()? onActivity;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ConsumerState<RemoteAlbumSliverAppBar> createState() => _MesmerizingSliverAppBarState();
|
ConsumerState<RemoteAlbumSliverAppBar> createState() => _MesmerizingSliverAppBarState();
|
||||||
@@ -101,12 +103,33 @@ class _MesmerizingSliverAppBarState extends ConsumerState<RemoteAlbumSliverAppBa
|
|||||||
icon: Icon(Icons.swap_vert_rounded, color: actionIconColor, shadows: actionIconShadows),
|
icon: Icon(Icons.swap_vert_rounded, color: actionIconColor, shadows: actionIconShadows),
|
||||||
onPressed: widget.onToggleAlbumOrder,
|
onPressed: widget.onToggleAlbumOrder,
|
||||||
),
|
),
|
||||||
|
if (currentAlbum.isActivityEnabled && currentAlbum.isShared)
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.chat_outlined, color: actionIconColor, shadows: actionIconShadows),
|
||||||
|
onPressed: widget.onActivity,
|
||||||
|
),
|
||||||
if (widget.onShowOptions != null)
|
if (widget.onShowOptions != null)
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.more_vert, color: actionIconColor, shadows: actionIconShadows),
|
icon: Icon(Icons.more_vert, color: actionIconColor, shadows: actionIconShadows),
|
||||||
onPressed: widget.onShowOptions,
|
onPressed: widget.onShowOptions,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
title: Builder(
|
||||||
|
builder: (context) {
|
||||||
|
final settings = context.dependOnInheritedWidgetOfExactType<FlexibleSpaceBarSettings>();
|
||||||
|
final scrollProgress = _calculateScrollProgress(settings);
|
||||||
|
|
||||||
|
return AnimatedSwitcher(
|
||||||
|
duration: const Duration(milliseconds: 200),
|
||||||
|
child: scrollProgress > 0.95
|
||||||
|
? Text(
|
||||||
|
currentAlbum.name,
|
||||||
|
style: TextStyle(color: context.primaryColor, fontWeight: FontWeight.w600, fontSize: 18),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
flexibleSpace: Builder(
|
flexibleSpace: Builder(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
final settings = context.dependOnInheritedWidgetOfExactType<FlexibleSpaceBarSettings>();
|
final settings = context.dependOnInheritedWidgetOfExactType<FlexibleSpaceBarSettings>();
|
||||||
@@ -122,16 +145,6 @@ class _MesmerizingSliverAppBarState extends ConsumerState<RemoteAlbumSliverAppBa
|
|||||||
});
|
});
|
||||||
|
|
||||||
return FlexibleSpaceBar(
|
return FlexibleSpaceBar(
|
||||||
centerTitle: true,
|
|
||||||
title: AnimatedSwitcher(
|
|
||||||
duration: const Duration(milliseconds: 200),
|
|
||||||
child: scrollProgress > 0.95
|
|
||||||
? Text(
|
|
||||||
currentAlbum.name,
|
|
||||||
style: TextStyle(color: context.primaryColor, fontWeight: FontWeight.w600, fontSize: 18),
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
background: _ExpandedBackground(
|
background: _ExpandedBackground(
|
||||||
scrollProgress: scrollProgress,
|
scrollProgress: scrollProgress,
|
||||||
icon: widget.icon,
|
icon: widget.icon,
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ void main() {
|
|||||||
updatedAt: DateTime(2023, 1, 2),
|
updatedAt: DateTime(2023, 1, 2),
|
||||||
ownerId: 'owner1',
|
ownerId: 'owner1',
|
||||||
ownerName: "Test User",
|
ownerName: "Test User",
|
||||||
|
isShared: false,
|
||||||
);
|
);
|
||||||
|
|
||||||
final albumB = RemoteAlbum(
|
final albumB = RemoteAlbum(
|
||||||
@@ -68,6 +69,7 @@ void main() {
|
|||||||
updatedAt: DateTime(2023, 2, 2),
|
updatedAt: DateTime(2023, 2, 2),
|
||||||
ownerId: 'owner2',
|
ownerId: 'owner2',
|
||||||
ownerName: "Test User",
|
ownerName: "Test User",
|
||||||
|
isShared: false,
|
||||||
);
|
);
|
||||||
|
|
||||||
group('sortAlbums', () {
|
group('sortAlbums', () {
|
||||||
|
|||||||
Reference in New Issue
Block a user