2026-07-30 12:39:24 -07:00
|
|
|
import 'dart:async';
|
|
|
|
|
|
2025-08-14 17:50:56 -05:00
|
|
|
import 'package:auto_route/auto_route.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_hooks/flutter_hooks.dart' hide Store;
|
|
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2025-10-28 11:52:01 -05:00
|
|
|
import 'package:immich_mobile/domain/models/album/album.model.dart';
|
2025-08-14 17:50:56 -05:00
|
|
|
import 'package:immich_mobile/extensions/asyncvalue_extensions.dart';
|
|
|
|
|
import 'package:immich_mobile/extensions/build_context_extensions.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/current_album.provider.dart';
|
2026-04-17 20:01:44 +05:30
|
|
|
import 'package:immich_mobile/widgets/activities/comment_bubble.dart';
|
2025-08-14 17:50:56 -05:00
|
|
|
|
|
|
|
|
@RoutePage()
|
|
|
|
|
class DriftActivitiesPage extends HookConsumerWidget {
|
2025-10-28 11:52:01 -05:00
|
|
|
final RemoteAlbum album;
|
2026-02-17 15:24:34 +00:00
|
|
|
final String? assetId;
|
|
|
|
|
final String? assetName;
|
2025-10-28 11:52:01 -05:00
|
|
|
|
2026-02-17 15:24:34 +00:00
|
|
|
const DriftActivitiesPage({super.key, required this.album, this.assetId, this.assetName});
|
2025-08-14 17:50:56 -05:00
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
2026-08-05 01:26:49 +05:30
|
|
|
final activityNotifier = ref.watch(albumActivityProvider((album.id, assetId)).notifier);
|
2026-04-17 20:01:44 +05:30
|
|
|
final activities = ref.watch(albumActivityProvider((album.id, assetId)));
|
2025-08-14 17:50:56 -05:00
|
|
|
final listViewScrollController = useScrollController();
|
|
|
|
|
|
2026-07-30 12:39:24 -07:00
|
|
|
Future<void> scrollToBottom() {
|
|
|
|
|
return listViewScrollController.animateTo(
|
|
|
|
|
0,
|
|
|
|
|
duration: const Duration(milliseconds: 300),
|
|
|
|
|
curve: Curves.fastOutSlowIn,
|
|
|
|
|
);
|
2025-08-14 17:50:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> onAddComment(String comment) async {
|
|
|
|
|
await activityNotifier.addComment(comment);
|
2026-07-30 12:39:24 -07:00
|
|
|
unawaited(scrollToBottom());
|
2025-08-14 17:50:56 -05:00
|
|
|
}
|
|
|
|
|
|
2025-10-28 11:52:01 -05:00
|
|
|
return ProviderScope(
|
|
|
|
|
overrides: [currentRemoteAlbumScopedProvider.overrideWithValue(album)],
|
|
|
|
|
child: Scaffold(
|
|
|
|
|
appBar: AppBar(
|
2026-02-17 15:24:34 +00:00
|
|
|
title: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(album.name),
|
|
|
|
|
if (assetName != null) Text(assetName!, style: context.textTheme.bodySmall),
|
|
|
|
|
],
|
|
|
|
|
),
|
2026-07-30 01:56:46 -07:00
|
|
|
actions: const [LikeActivityActionButton(iconOnly: true)],
|
2025-10-28 11:52:01 -05:00
|
|
|
actionsPadding: const EdgeInsets.only(right: 8),
|
|
|
|
|
),
|
|
|
|
|
body: activities.widgetWhen(
|
|
|
|
|
onData: (data) {
|
2025-10-29 22:45:28 +09:00
|
|
|
final List<Widget> activityWidgets = [];
|
|
|
|
|
for (final activity in data.reversed) {
|
|
|
|
|
activityWidgets.add(
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
|
2026-02-17 15:24:34 +00:00
|
|
|
child: CommentBubble(activity: activity, isAssetActivity: assetId != null),
|
2025-10-29 22:45:28 +09:00
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
2025-08-14 17:50:56 -05:00
|
|
|
|
2025-10-28 11:52:01 -05:00
|
|
|
return SafeArea(
|
|
|
|
|
child: Stack(
|
|
|
|
|
children: [
|
2025-10-29 22:45:28 +09:00
|
|
|
ListView(
|
2025-10-28 11:52:01 -05:00
|
|
|
controller: listViewScrollController,
|
2025-10-29 22:45:28 +09:00
|
|
|
padding: const EdgeInsets.only(top: 8, bottom: 80),
|
|
|
|
|
reverse: true,
|
|
|
|
|
children: activityWidgets,
|
2025-10-28 11:52:01 -05:00
|
|
|
),
|
|
|
|
|
Align(
|
|
|
|
|
alignment: Alignment.bottomCenter,
|
2026-07-30 12:15:35 -07:00
|
|
|
child: DecoratedBox(
|
2025-10-28 11:52:01 -05:00
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: context.scaffoldBackgroundColor,
|
|
|
|
|
border: Border(top: BorderSide(color: context.colorScheme.secondaryContainer, width: 1)),
|
|
|
|
|
),
|
2025-10-29 22:45:28 +09:00
|
|
|
child: DriftActivityTextField(isEnabled: album.isActivityEnabled, onSubmit: onAddComment),
|
2025-08-14 17:50:56 -05:00
|
|
|
),
|
|
|
|
|
),
|
2025-10-28 11:52:01 -05:00
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
resizeToAvoidBottomInset: true,
|
2025-08-14 17:50:56 -05:00
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|