exif_info_dialog.dart 2.4 KB

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