Skip to content

Commit

Permalink
modify the form looks
Browse files Browse the repository at this point in the history
  • Loading branch information
sirily11 committed Jul 12, 2020
1 parent b95c297 commit c32b042
Show file tree
Hide file tree
Showing 14 changed files with 303 additions and 206 deletions.
2 changes: 1 addition & 1 deletion example/.flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"barcode_scan","path":"/Users/liqiwei/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/barcode_scan-3.0.0/","dependencies":[]},{"name":"file_picker","path":"/Users/liqiwei/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.12.0/","dependencies":[]},{"name":"image_picker","path":"/Users/liqiwei/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.6.5/","dependencies":[]},{"name":"permission_handler","path":"/Users/liqiwei/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.0.1+1/","dependencies":[]}],"android":[{"name":"barcode_scan","path":"/Users/liqiwei/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/barcode_scan-3.0.0/","dependencies":[]},{"name":"file_picker","path":"/Users/liqiwei/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.12.0/","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","path":"/Users/liqiwei/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_plugin_android_lifecycle-1.0.8/","dependencies":[]},{"name":"image_picker","path":"/Users/liqiwei/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.6.5/","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"permission_handler","path":"/Users/liqiwei/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.0.1+1/","dependencies":[]}],"macos":[{"name":"file_chooser","path":"/Users/liqiwei/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/file_chooser-0.1.3/","dependencies":[]}],"linux":[{"name":"file_chooser","path":"/Users/liqiwei/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/file_chooser-0.1.3/","dependencies":[]}],"windows":[{"name":"file_chooser","path":"/Users/liqiwei/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/file_chooser-0.1.3/","dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"barcode_scan","dependencies":[]},{"name":"file_chooser","dependencies":[]},{"name":"file_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"image_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"permission_handler","dependencies":[]}],"date_created":"2020-07-11 22:02:42.702604","version":"1.20.0-7.1.pre"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"barcode_scan","path":"/Users/liqiwei/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/barcode_scan-3.0.0/","dependencies":[]},{"name":"file_picker","path":"/Users/liqiwei/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.12.0/","dependencies":[]},{"name":"image_picker","path":"/Users/liqiwei/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.6.5/","dependencies":[]},{"name":"permission_handler","path":"/Users/liqiwei/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.0.1+1/","dependencies":[]}],"android":[{"name":"barcode_scan","path":"/Users/liqiwei/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/barcode_scan-3.0.0/","dependencies":[]},{"name":"file_picker","path":"/Users/liqiwei/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/file_picker-1.12.0/","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","path":"/Users/liqiwei/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_plugin_android_lifecycle-1.0.8/","dependencies":[]},{"name":"image_picker","path":"/Users/liqiwei/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.6.5/","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"permission_handler","path":"/Users/liqiwei/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.0.1+1/","dependencies":[]}],"macos":[{"name":"file_chooser","path":"/Users/liqiwei/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/file_chooser-0.1.3/","dependencies":[]}],"linux":[{"name":"file_chooser","path":"/Users/liqiwei/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/file_chooser-0.1.3/","dependencies":[]}],"windows":[{"name":"file_chooser","path":"/Users/liqiwei/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/file_chooser-0.1.3/","dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"barcode_scan","dependencies":[]},{"name":"file_chooser","dependencies":[]},{"name":"file_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"image_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"permission_handler","dependencies":[]}],"date_created":"2020-07-11 23:49:39.200979","version":"1.20.0-7.1.pre"}
33 changes: 18 additions & 15 deletions example/lib/components/CheckBoxDemo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,24 @@ class CheckBoxDemo extends StatelessWidget {
appBar: AppBar(
title: Text("CheckBox Preview"),
),
body: Stack(
children: <Widget>[
JSONSchemaForm(
schema: schema,
showSubmitButton: homeProvider.showSubmitButton,
filled: homeProvider.isFilled,
rounded: homeProvider.isRounded,
onFetchingSchema: null,
onFetchingforeignKeyChoices: null,
onAddforeignKeyField: null,
onUpdateforeignKeyField: null,
onDeleteforeignKeyField: null,
),
MenuButton(),
],
body: Container(
height: MediaQuery.of(context).size.height,
child: Stack(
children: <Widget>[
JSONSchemaForm(
schema: schema,
showSubmitButton: homeProvider.showSubmitButton,
filled: homeProvider.isFilled,
rounded: homeProvider.isRounded,
onFetchingSchema: null,
onFetchingforeignKeyChoices: null,
onAddforeignKeyField: null,
onUpdateforeignKeyField: null,
onDeleteforeignKeyField: null,
),
MenuButton(),
],
),
),
);
}
Expand Down
33 changes: 18 additions & 15 deletions example/lib/components/DatetimeFieldDemo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,24 @@ class DatetimeFieldDemo extends StatelessWidget {
appBar: AppBar(
title: Text("CheckBox Preview"),
),
body: Stack(
children: <Widget>[
JSONSchemaForm(
schema: schema,
showSubmitButton: homeProvider.showSubmitButton,
filled: homeProvider.isFilled,
rounded: homeProvider.isRounded,
onFetchingSchema: null,
onFetchingforeignKeyChoices: null,
onAddforeignKeyField: null,
onUpdateforeignKeyField: null,
onDeleteforeignKeyField: null,
),
MenuButton(),
],
body: Container(
height: MediaQuery.of(context).size.height,
child: Stack(
children: <Widget>[
JSONSchemaForm(
schema: schema,
showSubmitButton: homeProvider.showSubmitButton,
filled: homeProvider.isFilled,
rounded: homeProvider.isRounded,
onFetchingSchema: null,
onFetchingforeignKeyChoices: null,
onAddforeignKeyField: null,
onUpdateforeignKeyField: null,
onDeleteforeignKeyField: null,
),
MenuButton(),
],
),
),
);
}
Expand Down
53 changes: 28 additions & 25 deletions example/lib/components/FileFieldDemo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,34 @@ class FileFieldDemo extends StatelessWidget {
appBar: AppBar(
title: Text("CheckBox Preview"),
),
body: Stack(
children: <Widget>[
JSONSchemaForm(
schema: schema,
showSubmitButton: homeProvider.showSubmitButton,
filled: homeProvider.isFilled,
rounded: homeProvider.isRounded,
useDropdownButton: homeProvider.useDropdown,
onFetchingSchema: null,
onFetchingforeignKeyChoices: null,
onAddforeignKeyField: null,
onUpdateforeignKeyField: null,
onDeleteforeignKeyField: null,
values: {
"cover": FileFieldValue(path: "https://s3.amazon.com/test.jpg"),
},
icons: [
FieldIcon(
iconData: Icons.title,
schemaName: "unit",
),
],
),
MenuButton(),
],
body: Container(
height: MediaQuery.of(context).size.height,
child: Stack(
children: <Widget>[
JSONSchemaForm(
schema: schema,
showSubmitButton: homeProvider.showSubmitButton,
filled: homeProvider.isFilled,
rounded: homeProvider.isRounded,
useDropdownButton: homeProvider.useDropdown,
onFetchingSchema: null,
onFetchingforeignKeyChoices: null,
onAddforeignKeyField: null,
onUpdateforeignKeyField: null,
onDeleteforeignKeyField: null,
values: {
"cover": FileFieldValue(path: "https://s3.amazon.com/test.jpg"),
},
icons: [
FieldIcon(
iconData: Icons.title,
schemaName: "unit",
),
],
),
MenuButton(),
],
),
),
);
}
Expand Down
112 changes: 58 additions & 54 deletions example/lib/components/ForeignkeyDemo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,64 +51,68 @@ class _ForeignkeyDemoState extends State<ForeignkeyDemo> {
appBar: AppBar(
title: Text("ForeignKey Preview"),
),
body: Stack(
children: <Widget>[
JSONSchemaForm(
schema: schema,
showSubmitButton: homeProvider.showSubmitButton,
filled: homeProvider.isFilled,
rounded: homeProvider.isRounded,
useDropdownButton: homeProvider.useDropdown,
onFetchingSchema: (path, isEdit, id) async {
if (isEdit) {
var choice = choices.firstWhere(
(element) => element.value == id,
orElse: () => null,
);
if (choice != null) {
return SchemaValues(
schema: detailSchema,
values: choice.toJson(),
body: Container(
height: MediaQuery.of(context).size.height,
child: Stack(
children: <Widget>[
JSONSchemaForm(
schema: schema,
showSubmitButton: homeProvider.showSubmitButton,
filled: homeProvider.isFilled,
rounded: homeProvider.isRounded,
useDropdownButton: homeProvider.useDropdown,
onFetchingSchema: (path, isEdit, id) async {
if (isEdit) {
var choice = choices.firstWhere(
(element) => element.value == id,
orElse: () => null,
);
if (choice != null) {
return SchemaValues(
schema: detailSchema,
values: choice.toJson(),
);
}
}
}
return SchemaValues(schema: detailSchema, values: {});
},
onFetchingforeignKeyChoices: (path) async {
return choices;
},
onAddforeignKeyField: (path, values) async {
var choice = Choice(
label: values['title'],
value: choices.length,
);
setState(() {
choices.add(choice);
});
return choice;
},
onUpdateforeignKeyField: (path, values, id) async {
var index = choices.indexWhere((element) => element.value == id);
if (index > -1) {
return SchemaValues(schema: detailSchema, values: {});
},
onFetchingforeignKeyChoices: (path) async {
return choices;
},
onAddforeignKeyField: (path, values) async {
var choice = Choice(
label: values['title'],
value: choices.length,
);
setState(() {
choices[index].label = values['title'];
choices.add(choice);
});
}
return choices[index];
},
onDeleteforeignKeyField: (path, id) async {
var removed = choices.removeAt(id);
return removed;
},
icons: [
FieldIcon(
iconData: Icons.title,
schemaName: "unit",
),
],
),
MenuButton(),
],
return choice;
},
onUpdateforeignKeyField: (path, values, id) async {
var index =
choices.indexWhere((element) => element.value == id);
if (index > -1) {
setState(() {
choices[index].label = values['title'];
});
}
return choices[index];
},
onDeleteforeignKeyField: (path, id) async {
var removed = choices.removeAt(id);
return removed;
},
icons: [
FieldIcon(
iconData: Icons.title,
schemaName: "unit",
),
],
),
MenuButton(),
],
),
),
);
}
Expand Down
47 changes: 25 additions & 22 deletions example/lib/components/SelectionFieldDemo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,31 @@ class SelectionFieldDemo extends StatelessWidget {
appBar: AppBar(
title: Text("CheckBox Preview"),
),
body: Stack(
children: <Widget>[
JSONSchemaForm(
schema: schema,
showSubmitButton: homeProvider.showSubmitButton,
filled: homeProvider.isFilled,
rounded: homeProvider.isRounded,
useDropdownButton: homeProvider.useDropdown,
onFetchingSchema: null,
onFetchingforeignKeyChoices: null,
onAddforeignKeyField: null,
onUpdateforeignKeyField: null,
onDeleteforeignKeyField: null,
icons: [
FieldIcon(
iconData: Icons.title,
schemaName: "unit",
),
],
),
MenuButton(),
],
body: Container(
height: MediaQuery.of(context).size.height,
child: Stack(
children: <Widget>[
JSONSchemaForm(
schema: schema,
showSubmitButton: homeProvider.showSubmitButton,
filled: homeProvider.isFilled,
rounded: homeProvider.isRounded,
useDropdownButton: homeProvider.useDropdown,
onFetchingSchema: null,
onFetchingforeignKeyChoices: null,
onAddforeignKeyField: null,
onUpdateforeignKeyField: null,
onDeleteforeignKeyField: null,
icons: [
FieldIcon(
iconData: Icons.title,
schemaName: "unit",
),
],
),
MenuButton(),
],
),
),
);
}
Expand Down
51 changes: 27 additions & 24 deletions example/lib/components/TextFieidDemo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,33 @@ class TextFieldDemo extends StatelessWidget {
appBar: AppBar(
title: Text("TextField Preview"),
),
body: Stack(
children: <Widget>[
JSONSchemaForm(
schema: schema,
showSubmitButton: homeProvider.showSubmitButton,
filled: homeProvider.isFilled,
rounded: homeProvider.isRounded,
onFetchingSchema: null,
onFetchingforeignKeyChoices: null,
onAddforeignKeyField: null,
onUpdateforeignKeyField: null,
onDeleteforeignKeyField: null,
icons: [
FieldIcon(
iconData: Icons.title,
schemaName: "description",
),
],
values: {
"description": "Hello world",
},
),
MenuButton(),
],
body: Container(
height: MediaQuery.of(context).size.height,
child: Stack(
children: <Widget>[
JSONSchemaForm(
schema: schema,
showSubmitButton: homeProvider.showSubmitButton,
filled: homeProvider.isFilled,
rounded: homeProvider.isRounded,
onFetchingSchema: null,
onFetchingforeignKeyChoices: null,
onAddforeignKeyField: null,
onUpdateforeignKeyField: null,
onDeleteforeignKeyField: null,
icons: [
FieldIcon(
iconData: Icons.title,
schemaName: "description",
),
],
values: {
"description": "Hello world",
},
),
MenuButton(),
],
),
),
);
}
Expand Down
Loading

0 comments on commit c32b042

Please sign in to comment.