us_image_thumbnail.dart 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import 'package:flyinsono/lab/color/lab_colors.dart';
  2. import 'package:flutter/material.dart';
  3. class USImageThumbnail extends StatelessWidget {
  4. const USImageThumbnail({
  5. super.key,
  6. required this.imageUrl,
  7. required this.description,
  8. this.labelBuilder,
  9. this.isVideo = false,
  10. });
  11. final String imageUrl;
  12. final String description;
  13. final Widget? labelBuilder;
  14. final bool isVideo;
  15. @override
  16. Widget build(BuildContext context) {
  17. return Container(
  18. decoration: BoxDecoration(
  19. color: Colors.black,
  20. borderRadius: BorderRadius.circular(5),
  21. ),
  22. clipBehavior: Clip.antiAlias,
  23. child: Stack(
  24. children: [
  25. Center(
  26. child: Image.network(
  27. imageUrl,
  28. fit: BoxFit.contain,
  29. errorBuilder:
  30. (BuildContext context, Object error, StackTrace? stackTrace) {
  31. return Center(
  32. child: Icon(
  33. Icons.image_outlined,
  34. size: 60,
  35. color: LabColors.text400,
  36. ),
  37. );
  38. },
  39. ),
  40. ),
  41. if (isVideo) ...[
  42. Center(
  43. child: Icon(
  44. Icons.play_circle_outline,
  45. color: Colors.white,
  46. size: 40,
  47. ),
  48. ),
  49. ],
  50. Align(
  51. alignment: Alignment.bottomLeft,
  52. child: Container(
  53. color: Colors.black,
  54. width: double.maxFinite,
  55. child: Padding(
  56. padding: const EdgeInsets.symmetric(horizontal: 5),
  57. child: Text(
  58. description,
  59. style: TextStyle(
  60. color: LabColors.text400,
  61. fontSize: 12,
  62. ),
  63. ),
  64. ),
  65. ),
  66. ),
  67. if (labelBuilder != null)
  68. Align(
  69. alignment: Alignment.bottomRight,
  70. child: Container(
  71. padding: EdgeInsets.symmetric(vertical: 2, horizontal: 5),
  72. margin: EdgeInsets.all(5),
  73. decoration: BoxDecoration(
  74. color: Colors.black,
  75. borderRadius: BorderRadius.circular(5),
  76. border: Border.all(
  77. color: LabColors.base800,
  78. width: 1,
  79. ),
  80. ),
  81. child: labelBuilder!,
  82. ),
  83. ),
  84. ],
  85. ),
  86. );
  87. }
  88. }