2022-08-03 07:04:34 +02:00
|
|
|
import 'package:auto_route/auto_route.dart';
|
2022-08-08 15:11:56 +02:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
2022-08-03 07:04:34 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
|
|
import 'package:immich_mobile/modules/album/providers/album.provider.dart';
|
|
|
|
import 'package:immich_mobile/modules/album/ui/album_thumbnail_card.dart';
|
|
|
|
import 'package:immich_mobile/routing/router.dart';
|
|
|
|
|
|
|
|
class LibraryPage extends HookConsumerWidget {
|
|
|
|
const LibraryPage({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
|
|
final albums = ref.watch(albumProvider);
|
|
|
|
|
|
|
|
useEffect(
|
|
|
|
() {
|
|
|
|
ref.read(albumProvider.notifier).getAllAlbums();
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
[],
|
|
|
|
);
|
|
|
|
|
2023-01-26 16:40:19 +02:00
|
|
|
Widget buildAppBar() {
|
2022-08-16 01:53:30 +02:00
|
|
|
return const SliverAppBar(
|
2022-08-03 07:04:34 +02:00
|
|
|
centerTitle: true,
|
|
|
|
floating: true,
|
|
|
|
pinned: false,
|
|
|
|
snap: false,
|
|
|
|
automaticallyImplyLeading: false,
|
|
|
|
title: Text(
|
|
|
|
'IMMICH',
|
|
|
|
style: TextStyle(
|
|
|
|
fontFamily: 'SnowburstOne',
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: 22,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-01-26 16:40:19 +02:00
|
|
|
Widget buildCreateAlbumButton() {
|
2022-08-03 07:04:34 +02:00
|
|
|
return GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
AutoRouter.of(context).push(CreateAlbumRoute(isSharedAlbum: false));
|
|
|
|
},
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
width: MediaQuery.of(context).size.width / 2 - 18,
|
|
|
|
height: MediaQuery.of(context).size.width / 2 - 18,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border.all(
|
|
|
|
color: Colors.grey,
|
|
|
|
),
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
),
|
|
|
|
child: Center(
|
|
|
|
child: Icon(
|
|
|
|
Icons.add_rounded,
|
|
|
|
size: 28,
|
|
|
|
color: Theme.of(context).primaryColor,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2022-08-08 15:11:56 +02:00
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(top: 8.0),
|
|
|
|
child: const Text(
|
|
|
|
'library_page_new_album',
|
2022-08-03 07:04:34 +02:00
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
),
|
2022-08-08 15:11:56 +02:00
|
|
|
).tr(),
|
2022-08-03 07:04:34 +02:00
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
body: CustomScrollView(
|
|
|
|
slivers: [
|
2023-01-26 16:40:19 +02:00
|
|
|
buildAppBar(),
|
2022-08-08 15:11:56 +02:00
|
|
|
SliverToBoxAdapter(
|
2022-08-03 07:04:34 +02:00
|
|
|
child: Padding(
|
2022-08-08 15:11:56 +02:00
|
|
|
padding: const EdgeInsets.all(12.0),
|
|
|
|
child: const Text(
|
|
|
|
'library_page_albums',
|
2022-08-03 07:04:34 +02:00
|
|
|
style: TextStyle(fontWeight: FontWeight.bold),
|
2022-08-08 15:11:56 +02:00
|
|
|
).tr(),
|
2022-08-03 07:04:34 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
SliverPadding(
|
|
|
|
padding: const EdgeInsets.only(left: 12.0, right: 12, bottom: 50),
|
|
|
|
sliver: SliverToBoxAdapter(
|
|
|
|
child: Wrap(
|
|
|
|
spacing: 12,
|
|
|
|
children: [
|
2023-01-26 16:40:19 +02:00
|
|
|
buildCreateAlbumButton(),
|
2022-08-03 07:04:34 +02:00
|
|
|
for (var album in albums)
|
|
|
|
AlbumThumbnailCard(
|
|
|
|
album: album,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|