file_icons_widget.dart 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. import 'package:flutter/material.dart';
  2. import 'package:photos/ente_theme_data.dart';
  3. import 'package:photos/models/collection.dart';
  4. import 'package:photos/models/trash_file.dart';
  5. import 'package:photos/theme/colors.dart';
  6. import 'package:photos/ui/sharing/user_avator_widget.dart';
  7. import 'package:photos/utils/date_time_util.dart';
  8. class ThumbnailPlaceHolder extends StatelessWidget {
  9. const ThumbnailPlaceHolder({Key? key}) : super(key: key);
  10. @override
  11. Widget build(BuildContext context) {
  12. return Container(
  13. alignment: Alignment.center,
  14. color: Theme.of(context).colorScheme.galleryThumbBackgroundColor,
  15. );
  16. }
  17. }
  18. class UnSyncedIcon extends StatelessWidget {
  19. const UnSyncedIcon({Key? key}) : super(key: key);
  20. @override
  21. Widget build(BuildContext context) {
  22. return Container(
  23. decoration: const BoxDecoration(
  24. gradient: LinearGradient(
  25. begin: Alignment.centerLeft,
  26. end: Alignment.centerRight,
  27. // background: linear-gradient(73.58deg, rgba(0, 0, 0, 0.3) -6.66%, rgba(255, 255, 255, 0) 44.44%);
  28. colors: [
  29. Color.fromRGBO(255, 255, 255, 0),
  30. Colors.transparent,
  31. // Color.fromRGBO(0, 0, 0, 0.3),
  32. ],
  33. stops: [-0.067, 0.445],
  34. ),
  35. ),
  36. child: const Align(
  37. alignment: Alignment.bottomLeft,
  38. child: Padding(
  39. padding: EdgeInsets.only(left: 4, bottom: 4),
  40. child: Icon(
  41. Icons.cloud_off_outlined,
  42. size: 18,
  43. color: fixedStrokeMutedWhite,
  44. ),
  45. ),
  46. ),
  47. );
  48. }
  49. }
  50. class VideoOverlayIcon extends StatelessWidget {
  51. const VideoOverlayIcon({Key? key}) : super(key: key);
  52. @override
  53. Widget build(BuildContext context) {
  54. return const SizedBox(
  55. height: 64,
  56. child: Icon(
  57. Icons.play_circle_outline,
  58. size: 40,
  59. color: Colors.white70,
  60. ),
  61. );
  62. }
  63. }
  64. class LivePhotoOverlayIcon extends StatelessWidget {
  65. const LivePhotoOverlayIcon({Key? key}) : super(key: key);
  66. @override
  67. Widget build(BuildContext context) {
  68. return const Align(
  69. alignment: Alignment.bottomRight,
  70. child: Padding(
  71. padding: EdgeInsets.only(right: 4, bottom: 4),
  72. child: Icon(
  73. Icons.album_outlined,
  74. size: 14,
  75. color: Colors.white, // fixed
  76. ),
  77. ),
  78. );
  79. }
  80. }
  81. class OwnerAvatarOverlayIcon extends StatelessWidget {
  82. final User user;
  83. const OwnerAvatarOverlayIcon(this.user, {Key? key}) : super(key: key);
  84. @override
  85. Widget build(BuildContext context) {
  86. return Align(
  87. alignment: Alignment.topRight,
  88. child: Padding(
  89. padding: const EdgeInsets.only(right: 4, top: 4),
  90. child: UserAvatarWidget(
  91. user,
  92. type: AvatarType.tiny,
  93. thumbnailView: true,
  94. ),
  95. ),
  96. );
  97. }
  98. }
  99. class FavoriteOverlayIcon extends StatelessWidget {
  100. const FavoriteOverlayIcon({Key? key}) : super(key: key);
  101. @override
  102. Widget build(BuildContext context) {
  103. return const BottomLeftOverlayIcon(Icons.favorite_rounded);
  104. }
  105. }
  106. class TrashedFileOverlayText extends StatelessWidget {
  107. final TrashFile file;
  108. const TrashedFileOverlayText(this.file, {Key? key}) : super(key: key);
  109. @override
  110. Widget build(BuildContext context) {
  111. return Container(
  112. decoration: BoxDecoration(
  113. gradient: LinearGradient(
  114. begin: Alignment.bottomCenter,
  115. end: Alignment.topCenter,
  116. colors: [Colors.black.withOpacity(0.33), Colors.transparent],
  117. ),
  118. ),
  119. alignment: Alignment.bottomCenter,
  120. padding: const EdgeInsets.only(bottom: 5),
  121. child: Text(
  122. daysLeft(file.deleteBy),
  123. style: Theme.of(context)
  124. .textTheme
  125. .subtitle2!
  126. .copyWith(color: Colors.white), //same for both themes
  127. ),
  128. );
  129. }
  130. }
  131. class ArchiveOverlayIcon extends StatelessWidget {
  132. const ArchiveOverlayIcon({Key? key}) : super(key: key);
  133. @override
  134. Widget build(BuildContext context) {
  135. return const Align(
  136. alignment: Alignment.bottomLeft,
  137. child: Padding(
  138. padding: EdgeInsets.only(left: 4, bottom: 4),
  139. child: Icon(
  140. Icons.archive_outlined,
  141. size: 20,
  142. color: fixedStrokeMutedWhite,
  143. ),
  144. ),
  145. );
  146. }
  147. }
  148. // Base variations
  149. /// Icon overlay in the bottom left.
  150. ///
  151. /// This usually indicates ente specific state of a file, e.g. if it is
  152. /// favorited/archived.
  153. class BottomLeftOverlayIcon extends StatelessWidget {
  154. final IconData icon;
  155. /// Overriddable color. Default is a fixed white.
  156. final Color color;
  157. const BottomLeftOverlayIcon(
  158. this.icon, {
  159. Key? key,
  160. this.color = Colors.white, // fixed
  161. }) : super(key: key);
  162. @override
  163. Widget build(BuildContext context) {
  164. return Container(
  165. decoration: const BoxDecoration(
  166. gradient: LinearGradient(
  167. begin: Alignment.bottomLeft,
  168. end: Alignment.center,
  169. colors: [
  170. Color.fromRGBO(0, 0, 0, 0.14),
  171. Color.fromRGBO(0, 0, 0, 0.05),
  172. Color.fromRGBO(0, 0, 0, 0.0),
  173. ],
  174. stops: [0, 0.6, 1],
  175. ),
  176. ),
  177. child: Align(
  178. alignment: Alignment.bottomLeft,
  179. child: Padding(
  180. padding: const EdgeInsets.only(left: 4, bottom: 4),
  181. child: Icon(
  182. icon,
  183. size: 22,
  184. color: color,
  185. ),
  186. ),
  187. ),
  188. );
  189. }
  190. }