control_bottom_app_bar.dart 5.0 KB

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