@@ -4,33 +4,41 @@ import 'dart:typed_data';
44import 'package:corecoder_develop/modules/module_minecraft.dart' ;
55import 'package:corecoder_develop/util/plugins_manager.dart' ;
66import 'package:flutter/material.dart' ;
7- class ModulesManager {
7+
8+ class ModulesManager {
89 static List <Module > internalModules = List .empty (growable: true );
910 static List <Module > externalModules = List .empty (growable: true );
10- static List <Module > get modules{
11+ Function ? onFinishedLoading;
12+
13+ static List <Module > get modules {
1114 return List .from (internalModules)..addAll (externalModules);
1215 }
16+
1317 static const JsonDecoder decoder = JsonDecoder ();
1418 static const JsonEncoder encoder = JsonEncoder .withIndent ('\t ' );
15- void initialize (BuildContext context) async {
16- await PluginsManager .reloadPlugins (this ,context);
19+
20+ Future <void > initialize (BuildContext context) async {
21+ await PluginsManager .reloadPlugins (this , context);
1722 }
1823
19- void onInitialized (BuildContext context){ /// called by PluginsManager so the timing is right
24+ void onInitialized (BuildContext context) {
25+ /// called by PluginsManager so the timing is right
2026 debugPrint ("Initializing modules (${modules .length })" );
2127 for (Module m in modules) {
2228 m.onInitialized (this , context);
2329 }
30+ if (onFinishedLoading != null ) {
31+ onFinishedLoading !();
32+ }
2433 }
2534
2635 ModulesManager (BuildContext context) {
2736 internalModules.add (MinecraftModule ());
28- initialize (context);
2937 }
3038
31- static Module ? getModuleByIdentifier (String id){
32- for (var m in modules){
33- if (m.identifier == id){
39+ static Module ? getModuleByIdentifier (String id) {
40+ for (var m in modules) {
41+ if (m.identifier == id) {
3442 return m;
3543 }
3644 }
@@ -48,7 +56,8 @@ class ModulesManager{
4856 return null ;
4957 }
5058}
51- class Template {
59+
60+ class Template {
5261 String title = "Template.Title" ,
5362 desc = "Template.Desc" ,
5463 version = "Template.Version" ,
@@ -61,22 +70,32 @@ class Template{
6170 this .icon, this .identifier);
6271}
6372
64- abstract class Module {
73+ abstract class Module {
6574 List <Template > templates = List .empty (growable: true );
66- String name= "Module.name" , desc= "Module.desc" , author= "Module.author" , version= "Module.version" ;
75+ String name = "Module.name" ,
76+ desc = "Module.desc" ,
77+ author = "Module.author" ,
78+ version = "Module.version" ;
6779 Uint8List ? imageRaw;
68- Widget get icon{
69- if (imageRaw != null ) {
80+
81+ Widget get icon {
82+ if (imageRaw != null ) {
7083 return Image (
71- image: ResizeImage .resizeIfNeeded (48 , 48 , Image .memory (imageRaw! ).image));
84+ image: ResizeImage .resizeIfNeeded (
85+ 48 , 48 , Image .memory (imageRaw! ).image));
7286 }
7387 return const Icon (Icons .insert_drive_file);
7488 }
89+
7590 String identifier;
76- Module (this .name, this .desc, this .author, this .version, this .imageRaw, this .identifier);
91+
92+ Module (this .name, this .desc, this .author, this .version, this .imageRaw,
93+ this .identifier);
94+
7795 void onInitialized (ModulesManager modulesManager, BuildContext buildContext);
78- void addTemplate (Template template){
96+
97+ void addTemplate (Template template) {
7998 templates.add (template);
8099 }
81- //TODO: void onGetAutoComplete(...)
82- }
100+ //TODO: void onGetAutoComplete(...)
101+ }
0 commit comments