Skip to content

Commit

Permalink
new release
Browse files Browse the repository at this point in the history
  • Loading branch information
chunlee-thong committed Feb 26, 2023
1 parent fa9dd1d commit e41d8de
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [2.3.0] - 26 February 2023

- Support unlimited history
- update `DateTime` parse method
- field's name that contains `id` now always use `int` type if it's a number

## [2.2.0] - 13 January 2023

- Add generate JSON keys
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Dart QuickType

### version: 2.2.0
### version: 2.3.0

A custom implemenation of JSON to Dart model class from [QuickType](https://github.com/quicktype/quicktype).

Expand Down
4 changes: 2 additions & 2 deletions front-end/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<div class="container py-5">
<div class="row h-100 align-items-center py-5">
<div class="col-lg-6">
<h1 class="display-4">Dart Quicktype 2.2.0</h1>
<h1 class="display-4">Dart Quicktype 2.3.0</h1>
<p class="lead text-muted mb-0">Generate a Dart class from JSON powered by QuickType</p>
<p class="lead text-muted">Maintainer: <a href="https://github.com/chunlee-thong"
target="_blank" class="text-muted">
Expand All @@ -55,4 +55,4 @@ <h1 class="display-4">Dart Quicktype 2.2.0</h1>
</div>
</body>

</html>
</html>
12 changes: 9 additions & 3 deletions front-end/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ <h2>Class name</h2>

<div class="form-check">
<input class="form-check-input" type="checkbox" id="use-num">
<label for="use-num">Always use <span class="code">num</span> type</label>
<label for="use-num">Always use <span class="code">num</span> type for
number</label>
</div>

</div>
Expand All @@ -102,8 +103,13 @@ <h2>Class name</h2>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="use-default-value">
<label for="use-default-value">Use default value</label>
<p>int, double, bool, String won't be null and replace with default value</p>
<label for="use-default-value">Use default value <span class="my-tooltip"><span
class="tooltiptext">int, double, bool, String won't be null and replace with
default value</span></span></label>
</div>
<div class="form-check" style="visibility: hidden;">
<input class="form-check-input" type="checkbox" id="gen-json-comment">
<label for="generate-json-comment">Generate json as comment</label>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion front-end/quicktype.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions front-end/script/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const options = {
useSerializable: "use-serializable",
useNum: "use-num",
genJsonKey: "gen-key",
genJsonComment: "gen-json-comment",
};

var jsonEditor;
Expand Down Expand Up @@ -77,6 +78,7 @@ function doConvert() {
useSerializable: isEnable(keys[5]),
useNum: isEnable(keys[6]),
generateKey: isEnable(keys[7]),
genJsonComment: isEnable(keys[8]),
})
.then((output) => {
localStorage.setItem(classNameInput, className);
Expand Down
26 changes: 26 additions & 0 deletions front-end/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,29 @@ p {
width: 100%;
margin-top: 24px;
}

.my-tooltip {
position: relative;
display: inline-block;
border-bottom: 1px dotted black; /* If you want dots under the hoverable text */
}

/* Tooltip text */
.my-tooltip .tooltiptext {
visibility: hidden;
width: 15rem;
background-color: black;
color: #fff;
text-align: center;
padding: 12px;
border-radius: 8px;
position: absolute;
z-index: 1;
top: -100px;
left: -100px;
}

/* Show the tooltip text when you mouse over the tooltip container */
.my-tooltip:hover .tooltiptext {
visibility: visible;
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dart-quicktype",
"version": "2.2.0",
"version": "2.3.0",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
6 changes: 5 additions & 1 deletion src/custom_dart_renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ export class CustomDartRenderer extends ConvenienceRenderer {
switch (transformedStringType.kind) {
case "date-time":
case "date":
return ["DateTime.tryParse(", dynamic, ")"];
return ["DateTime.tryParse(", dynamic, ` ?? ""`, ")"];
default:
return dynamic;
}
Expand Down Expand Up @@ -777,6 +777,10 @@ export class CustomDartRenderer extends ConvenienceRenderer {
});
this.emitLine(data, "];");
}

if (this.customDartOption.generateJsonComment) {
this.ensureBlankLine();
}
}
);
}
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type CustomDartOption = {
useEquatable: boolean;
useNum: boolean;
generateKey: boolean;
generateJsonComment: boolean;
};

export async function runQuickType(
Expand Down
2 changes: 2 additions & 0 deletions src/test/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ async function test() {
useEquatable: false,
useNum: true,
generateKey: false,
generateJsonComment: true,
});
fs.writeFileSync("dart-result/lib/output.dart", result);

Expand All @@ -24,6 +25,7 @@ async function test() {
useEquatable: false,
useNum: true,
generateKey: false,
generateJsonComment: false,
});
fs.writeFileSync("dart-result/lib/filename.dart", result2);
}
Expand Down

0 comments on commit e41d8de

Please sign in to comment.