import 'dart:convert'; import 'package:flutter/services.dart'; import 'package:lumen/domain/library.dart'; class FixtureBundle extends CachingAssetBundle { FixtureBundle(this.data); final Map data; @override Future load(String key) async { final value = data[key]; if (value == null) return rootBundle.load(key); return ByteData.sublistView( Uint8List.fromList(utf8.encode(jsonEncode(value))), ); } } StoryDefinition definition(String id) => StoryDefinition({ 'id': id, 'title': 'A fixture story', 'defaultLanguage': 'en', 'campaignAsset': 'fixture/campaign.json', 'notebookAsset': 'fixture/notebook.json', 'tracksAsset': 'fixture/audio.json', 'languages': { 'en': {'label': 'English'}, 'de': {'label': 'Deutsch', 'asset': 'fixture/de.json'}, }, }); Map fixture() => { 'fixture/campaign.json': { 'premise': 'A starting point.', 'levels': [ for (var i = 0; i < 3; i++) { 'id': 'puzzle-$i', 'size': 5, 'chapterId': i < 2 ? 'first' : 'second', 'chapter': i < 2 ? 'First chapter' : 'Second chapter', 'title': 'Puzzle $i', 'object': 'Object $i', 'before': 'Before $i', 'after': 'After $i', 'picture': '1000001000001000001000001', 'clues': '', 'areas': '', }, ], }, 'fixture/notebook.json': { 'pages': [ for (var i = 0; i < 3; i++) ...[ { 'id': 'entry-$i', 'type': 'entry', 'title': 'Entry $i', 'campaignIndex': i, 'textSource': 'before', }, { 'id': 'puzzle-$i', 'type': 'puzzle', 'title': 'Puzzle $i', 'campaignIndex': i, }, { 'id': 'memory-$i', 'type': 'memory', 'title': 'Memory $i', 'campaignIndex': i, 'textSource': 'after', }, ], ], }, 'fixture/audio.json': { 'tracks': { 'entry-0': {'file': 'english.wav'}, }, }, 'fixture/de.json': { 'title': 'Eine Testgeschichte', 'levels': { 'puzzle-0': { 'title': 'Ein Muster', 'before': 'Vorher', // Translation records cannot replace the puzzle or its identity. 'id': 'tampered', 'picture': '0000', 'chapterId': 'tampered', }, }, 'pages': { 'entry-0': {'title': 'Ein Anfang', 'id': 'tampered'}, }, }, };