exif_info_dialog.dart 2.4 KB

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