exif_info_dialog.dart 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import 'dart:ui';
  2. import 'package:flutter/material.dart';
  3. import "package:photos/generated/l10n.dart";
  4. import 'package:photos/models/file.dart';
  5. import "package:photos/theme/ente_theme.dart";
  6. import 'package:photos/ui/common/loading_widget.dart';
  7. import 'package:photos/utils/exif_util.dart';
  8. class ExifInfoDialog extends StatelessWidget {
  9. final File file;
  10. const ExifInfoDialog(this.file, {Key? key}) : super(key: key);
  11. @override
  12. Widget build(BuildContext context) {
  13. final textTheme = getEnteTextTheme(context);
  14. return AlertDialog(
  15. title: Column(
  16. crossAxisAlignment: CrossAxisAlignment.start,
  17. children: [
  18. Text(
  19. S.of(context).exif,
  20. style: textTheme.h3Bold,
  21. ),
  22. Text(
  23. file.title!,
  24. style: textTheme.smallMuted,
  25. ),
  26. ],
  27. ),
  28. content: Scrollbar(
  29. thumbVisibility: true,
  30. child: SingleChildScrollView(
  31. child: _getInfo(),
  32. ),
  33. ),
  34. actions: [
  35. TextButton(
  36. child: Text(
  37. S.of(context).close,
  38. style: textTheme.body,
  39. ),
  40. onPressed: () {
  41. Navigator.of(context, rootNavigator: true).pop('dialog');
  42. },
  43. ),
  44. ],
  45. );
  46. }
  47. Widget _getInfo() {
  48. return FutureBuilder(
  49. future: getExif(file),
  50. builder: (BuildContext context, AsyncSnapshot snapshot) {
  51. if (snapshot.hasData) {
  52. final exif = snapshot.data;
  53. String data = "";
  54. for (String key in exif.keys) {
  55. data += "$key: ${exif[key]}\n";
  56. }
  57. if (data.isEmpty) {
  58. data = "no exif data found";
  59. }
  60. return Container(
  61. padding: const EdgeInsets.all(2),
  62. color: Colors.white.withOpacity(0.05),
  63. child: Center(
  64. child: Padding(
  65. padding: const EdgeInsets.all(4),
  66. child: Text(
  67. data,
  68. style: TextStyle(
  69. fontSize: 14,
  70. fontFeatures: const [
  71. FontFeature.tabularFigures(),
  72. ],
  73. height: 1.4,
  74. color: Theme.of(context)
  75. .colorScheme
  76. .onSurface
  77. .withOpacity(0.7),
  78. ),
  79. ),
  80. ),
  81. ),
  82. );
  83. } else {
  84. return const EnteLoadingWidget();
  85. }
  86. },
  87. );
  88. }
  89. }