Prove embedded surface slots across Eve runtimes
This commit is contained in:
parent
614844ee2b
commit
dabb3e692f
8 changed files with 255 additions and 85 deletions
|
|
@ -9,6 +9,8 @@ Current smoke target:
|
|||
|
||||
- `CultUiInspectorSurface`
|
||||
- custom-painted slider track/fill/thumb
|
||||
- `EmbeddedSurfaceDemo`, which verifies `surface.slot` /
|
||||
`embeddedDocuments` parsing and rendering from the shared fixture
|
||||
- golden PNG output through `flutter test --update-goldens`
|
||||
|
||||
Run from the repository root:
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ class EveNode {
|
|||
required this.props,
|
||||
required this.layout,
|
||||
required this.children,
|
||||
required this.embeddedDocuments,
|
||||
});
|
||||
|
||||
final String id;
|
||||
|
|
@ -111,6 +112,7 @@ class EveNode {
|
|||
final Map<String, dynamic> props;
|
||||
final Map<String, dynamic> layout;
|
||||
final List<EveNode> children;
|
||||
final List<EveEmbeddedDocumentSlot> embeddedDocuments;
|
||||
|
||||
factory EveNode.fromJson(Map<String, dynamic> json) {
|
||||
return EveNode(
|
||||
|
|
@ -121,6 +123,32 @@ class EveNode {
|
|||
children: ((json['children'] as List<dynamic>?) ?? const [])
|
||||
.map((child) => EveNode.fromJson(child as Map<String, dynamic>))
|
||||
.toList(),
|
||||
embeddedDocuments: ((json['embeddedDocuments'] as List<dynamic>?) ?? const [])
|
||||
.map((slot) => EveEmbeddedDocumentSlot.fromJson(slot as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class EveEmbeddedDocumentSlot {
|
||||
EveEmbeddedDocumentSlot({
|
||||
required this.slotId,
|
||||
required this.documentId,
|
||||
required this.schemaId,
|
||||
required this.presentationKind,
|
||||
});
|
||||
|
||||
final String slotId;
|
||||
final String documentId;
|
||||
final String schemaId;
|
||||
final String presentationKind;
|
||||
|
||||
factory EveEmbeddedDocumentSlot.fromJson(Map<String, dynamic> json) {
|
||||
return EveEmbeddedDocumentSlot(
|
||||
slotId: (json['slotId'] ?? '').toString(),
|
||||
documentId: (json['documentId'] ?? '').toString(),
|
||||
schemaId: (json['schemaId'] ?? '').toString(),
|
||||
presentationKind: (json['presentationKind'] ?? '').toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -250,11 +278,36 @@ class EveNodeView extends StatelessWidget {
|
|||
return _dialogue();
|
||||
case 'rail.actions':
|
||||
return _actions();
|
||||
case 'surface.slot':
|
||||
return _surfaceSlot();
|
||||
default:
|
||||
return _fallback();
|
||||
}
|
||||
}
|
||||
|
||||
Widget _surfaceSlot() {
|
||||
final slot = node.embeddedDocuments.firstOrNull;
|
||||
final label = node.props['presentationKind']?.toString() ??
|
||||
slot?.presentationKind ??
|
||||
node.props['slotId']?.toString() ??
|
||||
slot?.slotId ??
|
||||
'embedded surface';
|
||||
return DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: state.tokens.panelAlt.withValues(alpha: 0.65),
|
||||
border: Border.all(color: state.tokens.accent.withValues(alpha: 0.45)),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(color: state.tokens.muted, fontFamily: 'EveParity', fontSize: 12),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _vnStage() {
|
||||
final background = node.children.where((child) => child.kind == 'image.background').firstOrNull;
|
||||
final sceneChildren = node.children.where((child) {
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 27 KiB |
|
|
@ -1,3 +1,6 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:eve_parity/main.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
|
@ -39,6 +42,40 @@ void main() {
|
|||
);
|
||||
});
|
||||
}
|
||||
|
||||
test('parses embedded document slots for CultUI nested surfaces', () {
|
||||
final node = EveNode.fromJson(const {
|
||||
'id': 'test.slot',
|
||||
'kind': 'surface.slot',
|
||||
'props': {'presentationKind': 'inventory.dropdown'},
|
||||
'embeddedDocuments': [
|
||||
{
|
||||
'slotId': 'inventory.dropdown',
|
||||
'documentId': 'cultmesh://test/dropdown',
|
||||
'schemaId': 'gamecult.eve.surface.v1',
|
||||
'presentationKind': 'inventory.dropdown',
|
||||
}
|
||||
],
|
||||
});
|
||||
|
||||
expect(node.embeddedDocuments, hasLength(1));
|
||||
expect(node.embeddedDocuments.single.slotId, 'inventory.dropdown');
|
||||
expect(node.embeddedDocuments.single.documentId, 'cultmesh://test/dropdown');
|
||||
});
|
||||
|
||||
test('embedded_surface_fixture_contract', () {
|
||||
final raw = File('../../web/fixtures/cultui-embedded-surface.json').readAsStringSync();
|
||||
final json = jsonDecode(raw) as Map<String, dynamic>;
|
||||
final surface = json['surface'] as Map<String, dynamic>;
|
||||
final root = EveNode.fromJson(surface['root'] as Map<String, dynamic>);
|
||||
final slot = root.children.singleWhere((node) => node.kind == 'surface.slot');
|
||||
|
||||
expect(json['schema'], 'gamecult.eve.surface.v1');
|
||||
expect(slot.embeddedDocuments, hasLength(1));
|
||||
expect(slot.embeddedDocuments.single.slotId, 'inventory.dropdown');
|
||||
expect(slot.embeddedDocuments.single.schemaId, 'gamecult.eve.surface.v1');
|
||||
expect(slot.embeddedDocuments.single.presentationKind, 'inventory.dropdown');
|
||||
});
|
||||
}
|
||||
|
||||
const fixtureId = String.fromEnvironment('EVE_PARITY_FIXTURE', defaultValue: 'cultui-inspector');
|
||||
|
|
|
|||
Loading…
Reference in a new issue