2022-04-23 19:08:45 -07:00
|
|
|
import 'package:auto_route/auto_route.dart';
|
2022-07-07 11:40:54 -07:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
2022-04-23 19:08:45 -07:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
|
|
import 'package:hive/hive.dart';
|
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
|
|
import 'package:immich_mobile/constants/hive_box.dart';
|
2022-08-02 22:04:34 -07:00
|
|
|
import 'package:immich_mobile/modules/album/providers/shared_album.provider.dart';
|
|
|
|
import 'package:immich_mobile/modules/album/ui/sharing_sliver_appbar.dart';
|
2022-04-23 19:08:45 -07:00
|
|
|
import 'package:immich_mobile/routing/router.dart';
|
2022-07-13 05:23:48 -07:00
|
|
|
import 'package:openapi/api.dart';
|
2022-04-23 19:08:45 -07:00
|
|
|
import 'package:transparent_image/transparent_image.dart';
|
|
|
|
|
|
|
|
class SharingPage extends HookConsumerWidget {
|
|
|
|
const SharingPage({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
|
|
var box = Hive.box(userInfoBox);
|
|
|
|
var thumbnailRequestUrl = '${box.get(serverEndpointKey)}/asset/thumbnail';
|
2022-07-13 05:23:48 -07:00
|
|
|
final List<AlbumResponseDto> sharedAlbums = ref.watch(sharedAlbumProvider);
|
2022-04-23 19:08:45 -07:00
|
|
|
|
2022-07-13 05:23:48 -07:00
|
|
|
useEffect(
|
|
|
|
() {
|
|
|
|
ref.read(sharedAlbumProvider.notifier).getAllSharedAlbums();
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
[],
|
|
|
|
);
|
2022-04-23 19:08:45 -07:00
|
|
|
|
|
|
|
_buildAlbumList() {
|
|
|
|
return SliverList(
|
|
|
|
delegate: SliverChildBuilderDelegate(
|
|
|
|
(BuildContext context, int index) {
|
2022-06-25 13:12:47 -07:00
|
|
|
String thumbnailUrl = sharedAlbums[index].albumThumbnailAssetId !=
|
|
|
|
null
|
2022-04-23 19:08:45 -07:00
|
|
|
? "$thumbnailRequestUrl/${sharedAlbums[index].albumThumbnailAssetId}"
|
|
|
|
: "https://images.unsplash.com/photo-1612178537253-bccd437b730e?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8NXx8Ymxhbmt8ZW58MHx8MHx8&auto=format&fit=crop&w=700&q=60";
|
|
|
|
|
|
|
|
return ListTile(
|
2022-06-25 13:12:47 -07:00
|
|
|
contentPadding:
|
|
|
|
const EdgeInsets.symmetric(vertical: 12, horizontal: 12),
|
2022-04-23 19:08:45 -07:00
|
|
|
leading: ClipRRect(
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
child: FadeInImage(
|
|
|
|
width: 60,
|
|
|
|
height: 60,
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
placeholder: MemoryImage(kTransparentImage),
|
|
|
|
image: NetworkImage(
|
|
|
|
thumbnailUrl,
|
2022-06-25 13:12:47 -07:00
|
|
|
headers: {
|
|
|
|
"Authorization": "Bearer ${box.get(accessTokenKey)}"
|
|
|
|
},
|
2022-04-23 19:08:45 -07:00
|
|
|
),
|
|
|
|
fadeInDuration: const Duration(milliseconds: 200),
|
|
|
|
fadeOutDuration: const Duration(milliseconds: 200),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
title: Text(
|
|
|
|
sharedAlbums[index].albumName,
|
|
|
|
maxLines: 1,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
2022-06-25 13:12:47 -07:00
|
|
|
style: TextStyle(
|
2022-07-13 05:23:48 -07:00
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: Colors.grey.shade800,
|
|
|
|
),
|
2022-04-23 19:08:45 -07:00
|
|
|
),
|
|
|
|
onTap: () {
|
2022-06-25 13:12:47 -07:00
|
|
|
AutoRouter.of(context)
|
|
|
|
.push(AlbumViewerRoute(albumId: sharedAlbums[index].id));
|
2022-04-23 19:08:45 -07:00
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
childCount: sharedAlbums.length,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
_buildEmptyListIndication() {
|
|
|
|
return SliverToBoxAdapter(
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
child: Card(
|
|
|
|
elevation: 0,
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(10), // if you need this
|
|
|
|
side: const BorderSide(
|
|
|
|
color: Colors.black12,
|
|
|
|
width: 1,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
color: Colors.transparent,
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(18.0),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(left: 5.0, bottom: 5),
|
|
|
|
child: Icon(
|
|
|
|
Icons.offline_share_outlined,
|
|
|
|
size: 50,
|
|
|
|
color: Theme.of(context).primaryColor.withAlpha(200),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
child: Text(
|
2022-07-07 11:40:54 -07:00
|
|
|
'sharing_page_empty_list',
|
2022-04-23 19:08:45 -07:00
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
color: Theme.of(context).primaryColor,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
2022-07-07 11:40:54 -07:00
|
|
|
).tr(),
|
2022-04-23 19:08:45 -07:00
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
child: Text(
|
2022-07-07 11:40:54 -07:00
|
|
|
'sharing_page_description',
|
2022-04-23 19:08:45 -07:00
|
|
|
style: TextStyle(fontSize: 12, color: Colors.grey[700]),
|
2022-07-07 11:40:54 -07:00
|
|
|
).tr(),
|
2022-04-23 19:08:45 -07:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
body: CustomScrollView(
|
|
|
|
slivers: [
|
|
|
|
const SharingSliverAppBar(),
|
2022-07-07 11:40:54 -07:00
|
|
|
SliverPadding(
|
2022-07-13 05:23:48 -07:00
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12),
|
2022-04-23 19:08:45 -07:00
|
|
|
sliver: SliverToBoxAdapter(
|
2022-07-13 05:23:48 -07:00
|
|
|
child: const Text(
|
2022-07-07 11:40:54 -07:00
|
|
|
"sharing_page_album",
|
2022-04-23 19:08:45 -07:00
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
2022-07-07 11:40:54 -07:00
|
|
|
).tr(),
|
2022-04-23 19:08:45 -07:00
|
|
|
),
|
|
|
|
),
|
2022-06-25 13:12:47 -07:00
|
|
|
sharedAlbums.isNotEmpty
|
|
|
|
? _buildAlbumList()
|
|
|
|
: _buildEmptyListIndication()
|
2022-04-23 19:08:45 -07:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|