This commit is contained in:
Thibault Deckers 2022-09-30 16:42:17 +02:00
parent 034934c8d0
commit 47a2364f5a
3 changed files with 15 additions and 5 deletions

View file

@ -122,7 +122,7 @@ class XmpNamespace extends Equatable {
if (matches.isEmpty) return false;
final match = matches.first;
final field = XmpProp.formatKey(match.group(1)!);
final field = match.group(1)!;
store[field] = formatValue(prop);
return true;
}
@ -133,7 +133,7 @@ class XmpNamespace extends Equatable {
final match = matches.first;
final index = int.parse(match.group(1)!);
final field = XmpProp.formatKey(match.group(2)!);
final field = match.group(2)!;
final fields = store.putIfAbsent(index, () => <String, String>{});
fields[field] = formatValue(prop);
return true;

View file

@ -5,19 +5,28 @@ import 'package:flutter/widgets.dart';
// cf https://github.com/adobe/xmp-docs/blob/master/XMPNamespaces/photoshop.md
class XmpPhotoshopNamespace extends XmpNamespace {
late final cameraProfilesPattern = RegExp(nsPrefix + r'CameraProfiles\[(\d+)\]/(.*)');
late final textLayersPattern = RegExp(nsPrefix + r'TextLayers\[(\d+)\]/(.*)');
final cameraProfiles = <int, Map<String, String>>{};
final textLayers = <int, Map<String, String>>{};
XmpPhotoshopNamespace(String nsPrefix, Map<String, String> rawProps) : super(Namespaces.photoshop, nsPrefix, rawProps);
@override
bool extractData(XmpProp prop) {
return extractIndexedStruct(prop, textLayersPattern, textLayers);
var hasIndexedStructs = extractIndexedStruct(prop, cameraProfilesPattern, cameraProfiles);
hasIndexedStructs |= extractIndexedStruct(prop, textLayersPattern, textLayers);
return hasIndexedStructs;
}
@override
List<Widget> buildFromExtractedData() => [
if (cameraProfiles.isNotEmpty)
XmpStructArrayCard(
title: 'Camera Profiles',
structByIndex: cameraProfiles,
),
if (textLayers.isNotEmpty)
XmpStructArrayCard(
title: 'Text Layers',

View file

@ -8,6 +8,7 @@ import 'package:aves/widgets/common/basic/multi_cross_fader.dart';
import 'package:aves/widgets/common/extensions/build_context.dart';
import 'package:aves/widgets/common/identity/highlight_title.dart';
import 'package:aves/widgets/viewer/info/common.dart';
import 'package:aves/widgets/viewer/info/metadata/xmp_namespaces.dart';
import 'package:flutter/material.dart';
class XmpStructArrayCard extends StatefulWidget {
@ -93,7 +94,7 @@ class _XmpStructArrayCardState extends State<XmpStructArrayCard> {
// without clipping the text
padding: const EdgeInsets.only(left: 8, right: 8, bottom: 8),
child: InfoRowGroup(
info: structs[_index],
info: structs[_index].map((key, value) => MapEntry(XmpProp.formatKey(key), value)),
maxValueLength: Constants.infoGroupMaxValueLength,
spanBuilders: widget.linkifier?.call(_index + 1),
),
@ -135,7 +136,7 @@ class XmpStructCard extends StatelessWidget {
showHighlight: false,
),
InfoRowGroup(
info: struct,
info: struct.map((key, value) => MapEntry(XmpProp.formatKey(key), value)),
maxValueLength: Constants.infoGroupMaxValueLength,
spanBuilders: linkifier?.call(),
),