1
0
mirror of https://github.com/immich-app/immich.git synced 2025-06-22 04:28:11 +02:00

feat(mobile): Add selected assets to album (#901)

* First implementation that uses new API

* Various UI improvements

* Create new album from home screen

* Fix padding when in multiselect mode

* Alex Suggestions

* Change to album after creation
This commit is contained in:
Matthias Rupp
2022-11-06 02:21:55 +01:00
committed by GitHub
parent 02bc84062e
commit b5751a3fa8
6 changed files with 252 additions and 60 deletions

View File

@ -1,62 +1,161 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:hive/hive.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/constants/hive_box.dart';
import 'package:immich_mobile/modules/home/ui/delete_diaglog.dart';
import 'package:immich_mobile/utils/image_url_builder.dart';
import 'package:openapi/api.dart';
class ControlBottomAppBar extends ConsumerWidget {
final Function onShare;
final Function onDelete;
final Function(AlbumResponseDto album) onAddToAlbum;
final void Function() onCreateNewAlbum;
const ControlBottomAppBar(
{Key? key, required this.onShare, required this.onDelete})
: super(key: key);
final List<AlbumResponseDto> albums;
const ControlBottomAppBar({
Key? key,
required this.onShare,
required this.onDelete,
required this.albums,
required this.onAddToAlbum,
required this.onCreateNewAlbum,
}) : super(key: key);
@override
Widget build(BuildContext context, WidgetRef ref) {
Widget renderActionButtons() {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ControlBoxButton(
iconData: Icons.delete_forever_rounded,
label: "control_bottom_app_bar_delete".tr(),
onPressed: () {
showDialog(
context: context,
builder: (BuildContext context) {
return DeleteDialog(
onDelete: onDelete,
);
},
);
},
),
ControlBoxButton(
iconData: Icons.share,
label: "control_bottom_app_bar_share".tr(),
onPressed: () {
onShare();
},
),
],
),
);
}
Widget renderAlbums() {
Widget renderAlbum(AlbumResponseDto album) {
final box = Hive.box(userInfoBox);
return GestureDetector(
onTap: () => onAddToAlbum(album),
child: Container(
width: 112,
padding: const EdgeInsets.all(6),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ClipRRect(
borderRadius: BorderRadius.circular(8),
child: CachedNetworkImage(
width: 100,
height: 100,
fit: BoxFit.cover,
imageUrl:
getAlbumThumbnailUrl(album, type: ThumbnailFormat.JPEG),
httpHeaders: {
"Authorization": "Bearer ${box.get(accessTokenKey)}"
},
cacheKey: "${album.albumThumbnailAssetId}",
),
),
Padding(
padding: const EdgeInsets.only(top: 12),
child: Text(
album.albumName,
style: TextStyle(fontWeight: FontWeight.bold),
),
),
Text(album.shared
? "control_bottom_app_bar_album_info_shared"
: "control_bottom_app_bar_album_info")
.tr(args: [album.assetCount.toString()]),
],
),
),
);
}
return SizedBox(
height: 200,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemBuilder: (buildContext, i) => renderAlbum(albums[i]),
itemCount: albums.length,
),
);
}
return Positioned(
bottom: 0,
left: 0,
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height * 0.15,
decoration: BoxDecoration(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(8),
topRight: Radius.circular(8),
topLeft: Radius.circular(10),
topRight: Radius.circular(10),
),
color: Theme.of(context).scaffoldBackgroundColor.withOpacity(0.95),
color: Theme.of(context).scaffoldBackgroundColor,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
renderActionButtons(),
const Divider(
thickness: 2,
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ControlBoxButton(
iconData: Icons.delete_forever_rounded,
label: "control_bottom_app_bar_delete".tr(),
onPressed: () {
showDialog(
context: context,
builder: (BuildContext context) {
return DeleteDialog(
onDelete: onDelete,
);
},
);
},
),
ControlBoxButton(
iconData: Icons.share,
label: "control_bottom_app_bar_share".tr(),
onPressed: () {
onShare();
},
),
],
),
)
padding: const EdgeInsets.all(12),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
"control_bottom_app_bar_add_to_album",
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
).tr(),
TextButton(
onPressed: onCreateNewAlbum,
child: Text(
"control_bottom_app_bar_create_new_album",
style: TextStyle(
color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold,
),
).tr(),
),
],
)),
renderAlbums(),
],
),
),