mirror of
https://github.com/immich-app/immich.git
synced 2024-12-24 10:37:28 +02:00
9b4a770b9d
* Adds image provider * uses image provider * wip load preview * wip everything but activity asset thumbnail needs some help with a remote id * Immich provider used in gallery * First draft of the immich image provider, working nicely! * Removed OriginalImageProvider * Fixes for thumbnails * feat(mobile): thumbhash support (#7028) * feat(mobile): thumbhash support * perf(mobile): store bmp thumbhash bytes in Isar --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> * Uses octoimage for fade in and placeholders * fixes thumbnails, removes unused values, adds better thumbnail size * removes thumbhash support for now * Forgot one thumbhash removal * Use big thumbnail for local image on ios * fix(mobile): Multipart image loading for iOS double swipe (#7064) * uses local thumb first * Multipart thumbnail * Clean up file delete * await file delete * Fynn's comments, made thumbnail smaller and doesn't crash on erroring out on thumbnail * lint --------- Co-authored-by: Marty Fuhry <marty@fuhry.farm> Co-authored-by: Alex <alex.tran1502@gmail.com> * Moves http client to global private place for reuse * Got rid of usePreview for local image providers since we always show a thumbnail anyway first * linter --------- Co-authored-by: shenlong <139912620+shenlong-tanwen@users.noreply.github.com> Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Co-authored-by: Alex <alex.tran1502@gmail.com> Co-authored-by: Marty Fuhry <marty@fuhry.farm>
120 lines
3.6 KiB
Dart
120 lines
3.6 KiB
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/extensions/datetime_extensions.dart';
|
|
import 'package:immich_mobile/modules/activities/models/activity.model.dart';
|
|
import 'package:immich_mobile/modules/asset_viewer/image_providers/immich_remote_image_provider.dart';
|
|
import 'package:immich_mobile/modules/asset_viewer/providers/current_asset.provider.dart';
|
|
import 'package:immich_mobile/shared/ui/user_circle_avatar.dart';
|
|
|
|
class ActivityTile extends HookConsumerWidget {
|
|
final Activity activity;
|
|
|
|
const ActivityTile(this.activity, {super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final asset = ref.watch(currentAssetProvider);
|
|
final isLike = activity.type == ActivityType.like;
|
|
// Asset thumbnail is displayed when we are accessing activities from the album page
|
|
// currentAssetProvider will not be set until we open the gallery viewer
|
|
final showAssetThumbnail = asset == null && activity.assetId != null;
|
|
|
|
return ListTile(
|
|
minVerticalPadding: 15,
|
|
leading: isLike
|
|
? Container(
|
|
width: 44,
|
|
alignment: Alignment.center,
|
|
child: Icon(
|
|
Icons.favorite_rounded,
|
|
color: Colors.red[700],
|
|
),
|
|
)
|
|
: UserCircleAvatar(user: activity.user),
|
|
title: _ActivityTitle(
|
|
userName: activity.user.name,
|
|
createdAt: activity.createdAt.timeAgo(),
|
|
leftAlign: isLike || showAssetThumbnail,
|
|
),
|
|
// No subtitle for like, so center title
|
|
titleAlignment:
|
|
!isLike ? ListTileTitleAlignment.top : ListTileTitleAlignment.center,
|
|
trailing: showAssetThumbnail
|
|
? _ActivityAssetThumbnail(activity.assetId!)
|
|
: null,
|
|
subtitle: !isLike ? Text(activity.comment!) : null,
|
|
);
|
|
}
|
|
}
|
|
|
|
class _ActivityTitle extends StatelessWidget {
|
|
final String userName;
|
|
final String createdAt;
|
|
final bool leftAlign;
|
|
|
|
const _ActivityTitle({
|
|
required this.userName,
|
|
required this.createdAt,
|
|
required this.leftAlign,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final textColor = context.isDarkTheme ? Colors.white : Colors.black;
|
|
final textStyle = context.textTheme.bodyMedium
|
|
?.copyWith(color: textColor.withOpacity(0.6));
|
|
|
|
return Row(
|
|
mainAxisAlignment:
|
|
leftAlign ? MainAxisAlignment.start : MainAxisAlignment.spaceBetween,
|
|
mainAxisSize: leftAlign ? MainAxisSize.min : MainAxisSize.max,
|
|
children: [
|
|
Text(
|
|
userName,
|
|
style: textStyle,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
if (leftAlign)
|
|
Text(
|
|
" • ",
|
|
style: textStyle,
|
|
),
|
|
Expanded(
|
|
child: Text(
|
|
createdAt,
|
|
style: textStyle,
|
|
overflow: TextOverflow.ellipsis,
|
|
textAlign: leftAlign ? TextAlign.left : TextAlign.right,
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
class _ActivityAssetThumbnail extends StatelessWidget {
|
|
final String assetId;
|
|
|
|
const _ActivityAssetThumbnail(this.assetId);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
width: 40,
|
|
height: 30,
|
|
decoration: BoxDecoration(
|
|
borderRadius: const BorderRadius.all(Radius.circular(4)),
|
|
image: DecorationImage(
|
|
image: ImmichRemoteImageProvider(
|
|
assetId: assetId,
|
|
isThumbnail: true,
|
|
),
|
|
fit: BoxFit.cover,
|
|
),
|
|
),
|
|
child: const SizedBox.shrink(),
|
|
);
|
|
}
|
|
}
|