Skip to content

Commit

Permalink
fix: fix test implementation
Browse files Browse the repository at this point in the history
Fix test implementation.

Signed-off-by: Alex Manoel Ferreira Silva <alex@legytma.com.br>
  • Loading branch information
Alex Manoel Ferreira Silva committed Aug 12, 2020
1 parent 7c2aafd commit 9e9b058
Show file tree
Hide file tree
Showing 5 changed files with 270 additions and 7 deletions.
112 changes: 110 additions & 2 deletions README.md
@@ -1,2 +1,110 @@
# google_maps_schema_parser
A google_maps_flutter Schema Parser.
[![GitHub issues](https://img.shields.io/github/issues/Legytma/google_maps_schema_parser)](https://github.com/Legytma/google_maps_schema_parser/issues "GitHub issues")
[![GitHub forks](https://img.shields.io/github/forks/Legytma/google_maps_schema_parser)](https://github.com/Legytma/google_maps_schema_parser/network "GitHub forks")
[![GitHub stars](https://img.shields.io/github/stars/Legytma/google_maps_schema_parser)](https://github.com/Legytma/google_maps_schema_parser/stargazers "GitHub stars")
[![GitHub license](https://img.shields.io/github/license/Legytma/google_maps_schema_parser)](https://github.com/Legytma/google_maps_schema_parser/blob/master/LICENSE "GitHub license")
[![Pub](https://img.shields.io/pub/v/google_maps_schema_parser)](https://pub.dev/packages/google_maps_schema_parser "Pub")
[![style: effective dart](https://img.shields.io/badge/style-effective_dart-40c4ff.svg)](https://github.com/tenhobi/effective_dart "style: effective dart")
![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/Legytma/google_maps_schema_parser "GitHub tag (latest SemVer)")
![GitHub top language](https://img.shields.io/github/languages/top/Legytma/google_maps_schema_parser "GitHub top language")
![GitHub contributors](https://img.shields.io/github/contributors/Legytma/google_maps_schema_parser "GitHub contributors")
![GitHub last commit](https://img.shields.io/github/last-commit/Legytma/google_maps_schema_parser "GitHub last commit")
![Flutter CI](https://github.com/Legytma/google_maps_schema_parser/workflows/Flutter%20CI/badge.svg "Flutter CI")

# Convert JSON to Widget validating with JSON Schema for Flutter apps

* [What is it](#what-is-it "What is it")
* [TYPE SCHEMA PARSER SUPPORT](TYPE_SCHEMA_PARSER_SUPPORT.md "TYPE SCHEMA PARSER SUPPORT")
* [Getting Started](#getting-started "Getting Started")
* [Installation](#installation "Installation")
* [Usage](#usage "Usage")
* [CHANGELOG](CHANGELOG.md "CHANGELOG")
* [Next steps](#next-steps "Next steps")
* [LICENSE](LICENSE "LICENSE")

## What is it

The [google_maps_schema_parser](https://pub.dev/packages/google_maps_schema_parser "google_maps_schema_parser") is a parser implementation to [google_maps_flutter](https://pub.dev/packages/google_maps_flutter "google_maps_flutter") Flutter package implemented with base on [schema_widget](https://pub.dev/packages/schema_widget "schema_widget") package that produces widgets dynamically interpreting JSON objects.

### Installation

* Add this to your package's pubspec.yaml file:
```yaml
dependencies:
get_it:
schema_widget:
google_maps_schema_parser: ^1.1.0-0
```
* Install packages from the command line:
with Flutter:
```shell script
$ flutter packages get
```
* Import it into the code file:
```dart
import 'package:google_maps_schema_parser/google_maps_schema_parser.dart';
```

### Usage

```dart
import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';
import 'package:schema_widget/schema_widget.dart';
import 'package:google_maps_schema_parser/google_maps_schema_parser.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Google Maps Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: FutureBuilder(
future: GetIt.I.allReady(ignorePendingAsyncCreation: false),
builder: (buildContext, snapshot) {
if (snapshot.hasData) {
return SchemaWidget.parse<Widget>(context, {
"type": "GoogleMap",
"initialCameraPosition": {
"target": {
"latitude": 0.0,
"longitude": 0.0
}
}
});
}
return Container();
},
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
),
),
);
}
}
```

## Next steps

- [x] Publish Package;
- [x] Make MVP;
- [x] Minimal documentation;
- [x] Add list of default supported Widgets;
- [x] Add list of default supported Types;
- [ ] Create content about;
154 changes: 154 additions & 0 deletions assets/draft06.schema.json
@@ -0,0 +1,154 @@
{
"$schema": "http://json-schema.org/draft-06/schema#",
"$id": "http://json-schema.org/draft-06/schema#",
"title": "Core schema meta-schema",
"definitions": {
"schemaArray": {
"type": "array",
"minItems": 1,
"items": { "$ref": "#" }
},
"nonNegativeInteger": {
"type": "integer",
"minimum": 0
},
"nonNegativeIntegerDefault0": {
"allOf": [
{ "$ref": "#/definitions/nonNegativeInteger" },
{ "default": 0 }
]
},
"simpleTypes": {
"enum": [
"array",
"boolean",
"integer",
"null",
"number",
"object",
"string"
]
},
"stringArray": {
"type": "array",
"items": { "type": "string" },
"uniqueItems": true,
"default": []
}
},
"type": ["object", "boolean"],
"properties": {
"$id": {
"type": "string",
"format": "uri-reference"
},
"$schema": {
"type": "string",
"format": "uri"
},
"$ref": {
"type": "string",
"format": "uri-reference"
},
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"default": {},
"examples": {
"type": "array",
"items": {}
},
"multipleOf": {
"type": "number",
"exclusiveMinimum": 0
},
"maximum": {
"type": "number"
},
"exclusiveMaximum": {
"type": "number"
},
"minimum": {
"type": "number"
},
"exclusiveMinimum": {
"type": "number"
},
"maxLength": { "$ref": "#/definitions/nonNegativeInteger" },
"minLength": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
"pattern": {
"type": "string",
"format": "regex"
},
"additionalItems": { "$ref": "#" },
"items": {
"anyOf": [
{ "$ref": "#" },
{ "$ref": "#/definitions/schemaArray" }
],
"default": {}
},
"maxItems": { "$ref": "#/definitions/nonNegativeInteger" },
"minItems": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
"uniqueItems": {
"type": "boolean",
"default": false
},
"contains": { "$ref": "#" },
"maxProperties": { "$ref": "#/definitions/nonNegativeInteger" },
"minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
"required": { "$ref": "#/definitions/stringArray" },
"additionalProperties": { "$ref": "#" },
"definitions": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
},
"properties": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
},
"patternProperties": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
},
"dependencies": {
"type": "object",
"additionalProperties": {
"anyOf": [
{ "$ref": "#" },
{ "$ref": "#/definitions/stringArray" }
]
}
},
"propertyNames": { "$ref": "#" },
"const": {},
"enum": {
"type": "array",
"minItems": 1,
"uniqueItems": true
},
"type": {
"anyOf": [
{ "$ref": "#/definitions/simpleTypes" },
{
"type": "array",
"items": { "$ref": "#/definitions/simpleTypes" },
"minItems": 1,
"uniqueItems": true
}
]
},
"format": { "type": "string" },
"allOf": { "$ref": "#/definitions/schemaArray" },
"anyOf": { "$ref": "#/definitions/schemaArray" },
"oneOf": { "$ref": "#/definitions/schemaArray" },
"not": { "$ref": "#" }
},
"default": {}
}
2 changes: 1 addition & 1 deletion assets/schema
6 changes: 4 additions & 2 deletions lib/parser/google_map_schema_widget_parser.dart
Expand Up @@ -46,12 +46,14 @@ class GoogleMapSchemaWidgetParser extends SchemaWidgetParser<GoogleMap> {
compassEnabled: value["compassEnabled"] ?? true,
onTap: SchemaWidget.parse<ArgumentCallback<LatLng>>(
buildContext, value['onTap']),
padding: SchemaWidget.parse<EdgeInsets>(buildContext, value['padding']),
padding: SchemaWidget.parse<EdgeInsets>(buildContext, value['padding'],
const EdgeInsets.all(0)),
onLongPress: SchemaWidget.parse<ArgumentCallback<LatLng>>(
buildContext, value['onLongPress']),
buildingsEnabled: value['buildingsEnabled'] ?? true,
cameraTargetBounds: SchemaWidget.parse<CameraTargetBounds>(
buildContext, value['cameraTargetBounds']),
buildContext, value['cameraTargetBounds'],
CameraTargetBounds.unbounded),
circles: SchemaWidget.parse<Set<Circle>>(buildContext, value['circles']),
gestureRecognizers:
SchemaWidget.parse<Set<Factory<OneSequenceGestureRecognizer>>>(
Expand Down
3 changes: 1 addition & 2 deletions test/common.dart
Expand Up @@ -33,8 +33,7 @@ String schemaLocator(Uri uri) {
if (uriString.startsWith(schemasBaseUri)) {
final fileName = uriString.substring(schemasBaseUri.length);

return path.join(
schemasBasePath, "assets", "LegytmaSchemas", "schema", fileName);
return path.join(schemasBasePath, "assets", "schema", fileName);
}

if (uriString.endsWith("://json-schema.org/draft-06/schema#")) {
Expand Down

0 comments on commit 9e9b058

Please sign in to comment.