Created
April 16, 2019 08:28
-
-
Save Tomucha/d42a595dea77bacf9272f2ae39e814d9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
Scheme s = Scheme(); | |
{ | |
// Jedna skupina dokladu ... | |
Group prijemka = Group(); | |
prijemka.name['cs'] = "Příjemka"; | |
prijemka.name['en'] = "The Prijemka"; | |
prijemka.icon = "prijemka.png"; | |
// Doklad v teto skupine ma nasl. fieldy. | |
// cascade operator ".." viz | |
// https://news.dartlang.org/2012/02/method-cascades-in-dart-posted-by-gilad.html | |
prijemka.fields.add(Field() | |
..id = "name" | |
..type = FieldType.STRING | |
..name['cs'] = "Jméno" | |
..name['en'] = "The jméno" | |
..help['cs'] = "Zadej jmeno" | |
..help['en'] = "Input the name"); | |
prijemka.fields.add(Field() | |
..id = "created" | |
..type = FieldType.DATETIME | |
..name['cs'] = "Vytvořen" | |
..name['en'] = "Created"); | |
s.groups.add(prijemka); | |
} | |
s.groups.add(Group()..name['cs'] = "Babička"); | |
s.groups.add(Group()..name['cs'] = "Dědeček"); | |
s.groups.forEach((g) { | |
print("Doklad: ${g.name['cs']}"); | |
g.fields.forEach((f) { | |
print(" ⎿ pole: ${f.id}, ${f.name['cs']}, ${f.type.typeId}"); | |
}); | |
}); | |
} | |
class Scheme { | |
List<Group> groups = []; | |
} | |
class Group { | |
Map<String, String> name = {}; | |
String icon; | |
List<Field> fields = []; | |
} | |
class FieldType { | |
final String typeId; | |
static FieldType STRING = FieldType._("string"); | |
static FieldType INT = FieldType._("int"); | |
static FieldType DOUBLE = FieldType._("double"); | |
static FieldType DATE = FieldType._("date"); | |
static FieldType DATETIME = FieldType._("datetime"); | |
static FieldType ENUM = FieldType._("enum"); | |
// privatni konstruktor :-) | |
FieldType._(this.typeId); | |
} | |
class Field { | |
String id; | |
Map<String, String> name = {}; | |
Map<String, String> help = {}; | |
FieldType type; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment