ente/lib/ui/viewer/file/exif_info_dialog.dart

94 lines
2.5 KiB
Dart
Raw Normal View History

2021-07-06 16:03:39 +00:00
import 'dart:ui';
import 'package:flutter/material.dart';
2023-04-07 05:41:42 +00:00
import "package:photos/generated/l10n.dart";
2023-08-25 04:39:30 +00:00
import 'package:photos/models/file/file.dart';
2023-03-14 13:04:11 +00:00
import "package:photos/theme/ente_theme.dart";
import 'package:photos/ui/common/loading_widget.dart';
2021-08-24 07:14:33 +00:00
import 'package:photos/utils/exif_util.dart';
2021-07-06 16:03:39 +00:00
2023-03-14 13:04:11 +00:00
class ExifInfoDialog extends StatelessWidget {
2023-08-24 16:56:24 +00:00
final EnteFile file;
const ExifInfoDialog(this.file, {Key? key}) : super(key: key);
2021-07-06 16:03:39 +00:00
@override
Widget build(BuildContext context) {
2023-03-14 13:04:11 +00:00
final textTheme = getEnteTextTheme(context);
2021-07-06 16:03:39 +00:00
return AlertDialog(
2023-03-14 13:04:11 +00:00
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
2023-04-07 05:41:42 +00:00
S.of(context).exif,
2023-03-14 13:04:11 +00:00
style: textTheme.h3Bold,
),
Text(
file.title!,
style: textTheme.smallMuted,
),
],
2022-05-03 10:05:54 +00:00
),
2021-07-06 20:44:35 +00:00
content: Scrollbar(
2022-07-03 07:47:15 +00:00
thumbVisibility: true,
2021-07-06 20:44:35 +00:00
child: SingleChildScrollView(
child: _getInfo(),
),
2021-07-06 16:03:39 +00:00
),
actions: [
TextButton(
child: Text(
2023-04-07 05:41:42 +00:00
S.of(context).close,
2023-03-14 13:04:11 +00:00
style: textTheme.body,
2021-07-06 16:03:39 +00:00
),
onPressed: () {
Navigator.of(context, rootNavigator: true).pop('dialog');
},
),
],
);
}
Widget _getInfo() {
return FutureBuilder(
2023-03-14 13:04:11 +00:00
future: getExif(file),
2021-07-06 16:03:39 +00:00
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.hasData) {
final exif = snapshot.data;
String data = "";
for (String key in exif.keys) {
2021-07-07 00:25:57 +00:00
data += "$key: ${exif[key]}\n";
2021-07-06 16:03:39 +00:00
}
if (data.isEmpty) {
data = "no exif data found";
}
return Container(
2022-07-04 06:02:17 +00:00
padding: const EdgeInsets.all(2),
2021-07-06 20:44:35 +00:00
color: Colors.white.withOpacity(0.05),
2021-07-06 16:03:39 +00:00
child: Center(
2021-07-06 20:44:35 +00:00
child: Padding(
2022-05-03 10:05:54 +00:00
padding: const EdgeInsets.all(4),
2021-07-06 20:44:35 +00:00
child: Text(
data,
style: TextStyle(
fontSize: 14,
2021-07-23 10:15:54 +00:00
fontFeatures: const [
2021-07-06 20:44:35 +00:00
FontFeature.tabularFigures(),
],
height: 1.4,
2022-07-03 09:49:33 +00:00
color: Theme.of(context)
.colorScheme
.onSurface
.withOpacity(0.7),
2021-07-06 20:44:35 +00:00
),
2021-07-06 16:03:39 +00:00
),
),
),
);
} else {
return const EnteLoadingWidget();
2021-07-06 16:03:39 +00:00
}
},
);
}
}