control_bottom_app_bar.dart 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. import 'package:easy_localization/easy_localization.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:hooks_riverpod/hooks_riverpod.dart';
  4. import 'package:immich_mobile/modules/album/ui/add_to_album_sliverlist.dart';
  5. import 'package:immich_mobile/modules/home/ui/delete_dialog.dart';
  6. import 'package:immich_mobile/shared/ui/drag_sheet.dart';
  7. import 'package:immich_mobile/shared/models/album.dart';
  8. class ControlBottomAppBar extends ConsumerWidget {
  9. final Function onShare;
  10. final Function onFavorite;
  11. final Function onArchive;
  12. final Function onDelete;
  13. final Function(Album album) onAddToAlbum;
  14. final void Function() onCreateNewAlbum;
  15. final List<Album> albums;
  16. final List<Album> sharedAlbums;
  17. const ControlBottomAppBar({
  18. Key? key,
  19. required this.onShare,
  20. required this.onFavorite,
  21. required this.onArchive,
  22. required this.onDelete,
  23. required this.sharedAlbums,
  24. required this.albums,
  25. required this.onAddToAlbum,
  26. required this.onCreateNewAlbum,
  27. }) : super(key: key);
  28. @override
  29. Widget build(BuildContext context, WidgetRef ref) {
  30. var isDarkMode = Theme.of(context).brightness == Brightness.dark;
  31. Widget renderActionButtons() {
  32. return Row(
  33. children: [
  34. ControlBoxButton(
  35. iconData: Icons.ios_share_rounded,
  36. label: "control_bottom_app_bar_share".tr(),
  37. onPressed: () {
  38. onShare();
  39. },
  40. ),
  41. ControlBoxButton(
  42. iconData: Icons.star_rounded,
  43. label: "control_bottom_app_bar_favorite".tr(),
  44. onPressed: () {
  45. onFavorite();
  46. },
  47. ),
  48. ControlBoxButton(
  49. iconData: Icons.delete_outline_rounded,
  50. label: "control_bottom_app_bar_delete".tr(),
  51. onPressed: () {
  52. showDialog(
  53. context: context,
  54. builder: (BuildContext context) {
  55. return DeleteDialog(
  56. onDelete: onDelete,
  57. );
  58. },
  59. );
  60. },
  61. ),
  62. ControlBoxButton(
  63. iconData: Icons.archive,
  64. label: "control_bottom_app_bar_archive".tr(),
  65. onPressed: () => onArchive(),
  66. ),
  67. ],
  68. );
  69. }
  70. return DraggableScrollableSheet(
  71. initialChildSize: 0.30,
  72. minChildSize: 0.15,
  73. maxChildSize: 0.57,
  74. snap: true,
  75. builder: (
  76. BuildContext context,
  77. ScrollController scrollController,
  78. ) {
  79. return Card(
  80. color: isDarkMode ? Colors.grey[900] : Colors.grey[100],
  81. surfaceTintColor: Colors.transparent,
  82. elevation: 18.0,
  83. shape: const RoundedRectangleBorder(
  84. borderRadius: BorderRadius.only(
  85. topLeft: Radius.circular(12),
  86. topRight: Radius.circular(12),
  87. ),
  88. ),
  89. margin: const EdgeInsets.all(0),
  90. child: CustomScrollView(
  91. controller: scrollController,
  92. slivers: [
  93. SliverToBoxAdapter(
  94. child: Column(
  95. children: <Widget>[
  96. const SizedBox(height: 12),
  97. const CustomDraggingHandle(),
  98. const SizedBox(height: 12),
  99. renderActionButtons(),
  100. const Divider(
  101. indent: 16,
  102. endIndent: 16,
  103. thickness: 1,
  104. ),
  105. AddToAlbumTitleRow(onCreateNewAlbum: onCreateNewAlbum),
  106. ],
  107. ),
  108. ),
  109. SliverPadding(
  110. padding: const EdgeInsets.symmetric(horizontal: 16),
  111. sliver: AddToAlbumSliverList(
  112. albums: albums,
  113. sharedAlbums: sharedAlbums,
  114. onAddToAlbum: onAddToAlbum,
  115. ),
  116. ),
  117. const SliverToBoxAdapter(
  118. child: SizedBox(height: 200),
  119. )
  120. ],
  121. ),
  122. );
  123. },
  124. );
  125. }
  126. }
  127. class AddToAlbumTitleRow extends StatelessWidget {
  128. const AddToAlbumTitleRow({
  129. super.key,
  130. required this.onCreateNewAlbum,
  131. });
  132. final VoidCallback onCreateNewAlbum;
  133. @override
  134. Widget build(BuildContext context) {
  135. return Padding(
  136. padding: const EdgeInsets.symmetric(horizontal: 16),
  137. child: Row(
  138. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  139. children: [
  140. const Text(
  141. "common_add_to_album",
  142. style: TextStyle(
  143. fontSize: 14,
  144. fontWeight: FontWeight.bold,
  145. ),
  146. ).tr(),
  147. TextButton.icon(
  148. onPressed: onCreateNewAlbum,
  149. icon: const Icon(Icons.add),
  150. label: Text(
  151. "common_create_new_album",
  152. style: TextStyle(
  153. color: Theme.of(context).primaryColor,
  154. fontWeight: FontWeight.bold,
  155. fontSize: 14,
  156. ),
  157. ).tr(),
  158. ),
  159. ],
  160. ),
  161. );
  162. }
  163. }