file_icons_widget.dart 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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 const BottomLeftOverlayIcon(Icons.cloud_off_outlined);
  23. }
  24. }
  25. class FavoriteOverlayIcon extends StatelessWidget {
  26. const FavoriteOverlayIcon({Key? key}) : super(key: key);
  27. @override
  28. Widget build(BuildContext context) {
  29. return const BottomLeftOverlayIcon(Icons.favorite_rounded);
  30. }
  31. }
  32. class ArchiveOverlayIcon extends StatelessWidget {
  33. const ArchiveOverlayIcon({Key? key}) : super(key: key);
  34. @override
  35. Widget build(BuildContext context) {
  36. return const BottomLeftOverlayIcon(
  37. Icons.archive_outlined,
  38. color: fixedStrokeMutedWhite,
  39. );
  40. }
  41. }
  42. class VideoOverlayIcon extends StatelessWidget {
  43. const VideoOverlayIcon({Key? key}) : super(key: key);
  44. @override
  45. Widget build(BuildContext context) {
  46. return const SizedBox(
  47. height: 64,
  48. child: Icon(
  49. Icons.play_circle_outline,
  50. size: 40,
  51. color: Colors.white70,
  52. ),
  53. );
  54. }
  55. }
  56. class LivePhotoOverlayIcon extends StatelessWidget {
  57. const LivePhotoOverlayIcon({Key? key}) : super(key: key);
  58. @override
  59. Widget build(BuildContext context) {
  60. return const Align(
  61. alignment: Alignment.bottomRight,
  62. child: Padding(
  63. padding: EdgeInsets.only(right: 4, bottom: 4),
  64. child: Icon(
  65. Icons.album_outlined,
  66. size: 14,
  67. color: Colors.white, // fixed
  68. ),
  69. ),
  70. );
  71. }
  72. }
  73. class OwnerAvatarOverlayIcon extends StatelessWidget {
  74. final User user;
  75. const OwnerAvatarOverlayIcon(this.user, {Key? key}) : super(key: key);
  76. @override
  77. Widget build(BuildContext context) {
  78. return Align(
  79. alignment: Alignment.topRight,
  80. child: Padding(
  81. padding: const EdgeInsets.only(right: 4, top: 4),
  82. child: UserAvatarWidget(
  83. user,
  84. type: AvatarType.tiny,
  85. thumbnailView: true,
  86. ),
  87. ),
  88. );
  89. }
  90. }
  91. class TrashedFileOverlayText extends StatelessWidget {
  92. final TrashFile file;
  93. const TrashedFileOverlayText(this.file, {Key? key}) : super(key: key);
  94. @override
  95. Widget build(BuildContext context) {
  96. return Container(
  97. decoration: BoxDecoration(
  98. gradient: LinearGradient(
  99. begin: Alignment.bottomCenter,
  100. end: Alignment.topCenter,
  101. colors: [Colors.black.withOpacity(0.33), Colors.transparent],
  102. ),
  103. ),
  104. alignment: Alignment.bottomCenter,
  105. padding: const EdgeInsets.only(bottom: 5),
  106. child: Text(
  107. daysLeft(file.deleteBy),
  108. style: Theme.of(context)
  109. .textTheme
  110. .subtitle2!
  111. .copyWith(color: Colors.white), //same for both themes
  112. ),
  113. );
  114. }
  115. }
  116. // Base variations
  117. /// Icon overlay in the bottom left.
  118. ///
  119. /// This usually indicates ente specific state of a file, e.g. if it is
  120. /// favorited/archived.
  121. class BottomLeftOverlayIcon extends StatelessWidget {
  122. final IconData icon;
  123. /// Overriddable color. Default is a fixed white.
  124. final Color color;
  125. const BottomLeftOverlayIcon(
  126. this.icon, {
  127. Key? key,
  128. this.color = Colors.white, // fixed
  129. }) : super(key: key);
  130. @override
  131. Widget build(BuildContext context) {
  132. return Container(
  133. decoration: const BoxDecoration(
  134. gradient: LinearGradient(
  135. begin: Alignment.bottomLeft,
  136. end: Alignment.center,
  137. colors: [
  138. Color.fromRGBO(0, 0, 0, 0.14),
  139. Color.fromRGBO(0, 0, 0, 0.05),
  140. Color.fromRGBO(0, 0, 0, 0.0),
  141. ],
  142. stops: [0, 0.6, 1],
  143. ),
  144. ),
  145. child: Align(
  146. alignment: Alignment.bottomLeft,
  147. child: Padding(
  148. padding: const EdgeInsets.only(left: 4, bottom: 4),
  149. child: Icon(
  150. icon,
  151. size: 22,
  152. color: color,
  153. ),
  154. ),
  155. ),
  156. );
  157. }
  158. }