control_bottom_app_bar.dart 5.1 KB

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