 

import 'index.dart';

class MindMapData {
  final Node root;
  final String template;
  final String theme;
  final String version;

  late BaseTheme mapTheme;
  late BaseTemplate mapTemplate;

  MindMapData(this.root, this.template, this.theme, this.version)  {
    //处理主题
    mapTheme = DarkTheme();
    mapTemplate = DefaultTemplate(mapTheme);
  }


  factory MindMapData.fromJson(Map<String, dynamic> json) {
    return  MindMapData(
        Node.fromJson(json['root']),
        json['template'] ?? 'default',
        json['theme'] ?? 'fresh-blue',
        json['version'] ?? '1.0'
    );
  }

  Map<String, dynamic> _$MindMapToJson(MindMapData instance) {
    var map = <String, dynamic>{};
    map['root'] = instance.root.toJson();
    map['template'] = instance.template;
    map['theme'] = instance.theme;
    map['version'] = instance.version;
    return map;
  }

  Map<String, dynamic> toJson() => _$MindMapToJson(this);

}