file_icons_widget.dart 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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 ArchiveOverlayIcon extends StatelessWidget {
  107. const ArchiveOverlayIcon({Key? key}) : super(key: key);
  108. @override
  109. Widget build(BuildContext context) {
  110. return const BottomLeftOverlayIcon(
  111. Icons.archive_outlined,
  112. color: fixedStrokeMutedWhite,
  113. );
  114. }
  115. }
  116. class TrashedFileOverlayText extends StatelessWidget {
  117. final TrashFile file;
  118. const TrashedFileOverlayText(this.file, {Key? key}) : super(key: key);
  119. @override
  120. Widget build(BuildContext context) {
  121. return Container(
  122. decoration: BoxDecoration(
  123. gradient: LinearGradient(
  124. begin: Alignment.bottomCenter,
  125. end: Alignment.topCenter,
  126. colors: [Colors.black.withOpacity(0.33), Colors.transparent],
  127. ),
  128. ),
  129. alignment: Alignment.bottomCenter,
  130. padding: const EdgeInsets.only(bottom: 5),
  131. child: Text(
  132. daysLeft(file.deleteBy),
  133. style: Theme.of(context)
  134. .textTheme
  135. .subtitle2!
  136. .copyWith(color: Colors.white), //same for both themes
  137. ),
  138. );
  139. }
  140. }
  141. // Base variations
  142. /// Icon overlay in the bottom left.
  143. ///
  144. /// This usually indicates ente specific state of a file, e.g. if it is
  145. /// favorited/archived.
  146. class BottomLeftOverlayIcon extends StatelessWidget {
  147. final IconData icon;
  148. /// Overriddable color. Default is a fixed white.
  149. final Color color;
  150. const BottomLeftOverlayIcon(
  151. this.icon, {
  152. Key? key,
  153. this.color = Colors.white, // fixed
  154. }) : super(key: key);
  155. @override
  156. Widget build(BuildContext context) {
  157. return Container(
  158. decoration: const BoxDecoration(
  159. gradient: LinearGradient(
  160. begin: Alignment.bottomLeft,
  161. end: Alignment.center,
  162. colors: [
  163. Color.fromRGBO(0, 0, 0, 0.14),
  164. Color.fromRGBO(0, 0, 0, 0.05),
  165. Color.fromRGBO(0, 0, 0, 0.0),
  166. ],
  167. stops: [0, 0.6, 1],
  168. ),
  169. ),
  170. child: Align(
  171. alignment: Alignment.bottomLeft,
  172. child: Padding(
  173. padding: const EdgeInsets.only(left: 4, bottom: 4),
  174. child: Icon(
  175. icon,
  176. size: 22,
  177. color: color,
  178. ),
  179. ),
  180. ),
  181. );
  182. }
  183. }