-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added App open models. Fixed map <-> string type casting error. Impro… (
#10) * Added App open models. Fixed map <-> string type casting error. Improved data type information. * Fixed NstackBuilder to use specific data types instead of dynamic types. Improved formatting. * More type safety. Replaced double quotes with single quotes. Improved formatting. * Refactoring: Improved section generation. Replaced normal constructors with const constructors. Added reserved keywords. Improved repositories. * Moved extensions to the end of the generated file. * Simplified even more the Sections classes getters.
- Loading branch information
Showing
26 changed files
with
928 additions
and
339 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"version": 1, | ||
"nstack_project_id": "bOdrNuZd4syxuAz6gyCb3xwBCjA8U4h4IcQI", | ||
"nstack_api_key": "X0ENl5QpKI51tS9CzKSt1PGwfZeq2gBMTU58" | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'package:meta/meta.dart'; | ||
import 'package:nstack/models/app_open_data.dart'; | ||
import 'package:nstack/models/app_open_meta.dart'; | ||
|
||
class AppOpen { | ||
final AppOpenData data; | ||
final AppOpenMeta meta; | ||
|
||
AppOpen({ | ||
@required this.data, | ||
@required this.meta, | ||
}); | ||
|
||
factory AppOpen.fromJson(Map json) { | ||
return AppOpen( | ||
data: AppOpenData.fromJson(json['data']), | ||
meta: AppOpenMeta.fromJson(json['meta']), | ||
); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import 'package:meta/meta.dart'; | ||
import 'package:nstack/models/app_update.dart'; | ||
import 'package:nstack/models/localize_index.dart'; | ||
import 'package:nstack/models/message.dart'; | ||
import 'package:nstack/models/rate_reminder.dart'; | ||
import 'package:nstack/models/terms.dart'; | ||
import 'package:nstack/other/extensions.dart'; | ||
|
||
class AppOpenData { | ||
final int count; | ||
final AppUpdate update; | ||
final List<LocalizeIndex> localize; | ||
final String platform; | ||
final DateTime createdAt; | ||
final DateTime updatedAt; | ||
final Message message; | ||
final RateReminder rateReminder; | ||
final List<Terms> terms; | ||
|
||
AppOpenData({ | ||
@required this.count, | ||
@required this.update, | ||
@required this.localize, | ||
@required this.platform, | ||
@required this.createdAt, | ||
@required this.updatedAt, | ||
@required this.message, | ||
@required this.rateReminder, | ||
@required this.terms, | ||
}); | ||
|
||
factory AppOpenData.fromJson(Map json) { | ||
return AppOpenData( | ||
count: json['count'], | ||
update: AppUpdate.fromJson(json['update']), | ||
localize: (json['localize'] as List)?.let( | ||
(it) => it.map((e) => LocalizeIndex.fromJson(e)).toList(), | ||
), | ||
platform: json['platform'], | ||
createdAt: (json['created_at'] as String)?.let( | ||
(it) => DateTime.parse(it), | ||
), | ||
updatedAt: (json['last_updated'] as String)?.let( | ||
(it) => DateTime.parse(it), | ||
), | ||
message: (json['message'] as Map)?.let((it) => Message.fromJson(it)), | ||
rateReminder: json['rateReminder']?.let( | ||
(it) => RateReminder.fromJson(it), | ||
), | ||
terms: json['terms']?.let((it) => it), | ||
); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import 'package:meta/meta.dart'; | ||
|
||
class AppOpenMeta { | ||
final String acceptLanguage; | ||
|
||
AppOpenMeta({@required this.acceptLanguage}); | ||
|
||
factory AppOpenMeta.fromJson(Map json) { | ||
return AppOpenMeta( | ||
acceptLanguage: json['accept_Language'], | ||
); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import 'package:meta/meta.dart'; | ||
import 'package:nstack/models/app_update_state.dart'; | ||
import 'package:nstack/models/update_info.dart'; | ||
import 'package:nstack/other/extensions.dart'; | ||
|
||
class AppUpdate { | ||
final UpdateInfo newerVersion; | ||
final UpdateInfo newInVersion; | ||
|
||
AppUpdate({ | ||
@required this.newerVersion, | ||
@required this.newInVersion, | ||
}); | ||
|
||
factory AppUpdate.fromJson(Map json) { | ||
return AppUpdate( | ||
newerVersion: (json['newer_version'] as Map)?.let( | ||
(it) => UpdateInfo.fromJson(it), | ||
), | ||
newInVersion: (json['new_in_version'] as Map)?.let( | ||
(it) => UpdateInfo.fromJson(it), | ||
), | ||
); | ||
} | ||
|
||
UpdateInfo get update { | ||
return newerVersion ?? newInVersion; | ||
} | ||
|
||
AppUpdateState get state { | ||
if (update?.state == "yes") { | ||
return AppUpdateState.update; | ||
} | ||
if (update?.state == "force") { | ||
return AppUpdateState.force; | ||
} | ||
if (newInVersion != null) { | ||
return AppUpdateState.changelog; | ||
} | ||
return AppUpdateState.none; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
enum AppUpdateState { | ||
none, | ||
update, | ||
force, | ||
changelog, | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,28 @@ | ||
class Language { | ||
int id; | ||
String name; | ||
String locale; | ||
String direction; | ||
bool isDefault; | ||
bool isBestFit; | ||
final int id; | ||
final String name; | ||
final String locale; | ||
final String direction; | ||
final bool isDefault; | ||
final bool isBestFit; | ||
|
||
Language({this.id, this.name, this.locale, this.direction, this.isDefault, this.isBestFit}); | ||
const Language({ | ||
this.id, | ||
this.name, | ||
this.locale, | ||
this.direction, | ||
this.isDefault, | ||
this.isBestFit, | ||
}); | ||
|
||
Language.fromJson(Map<String, dynamic> json) { | ||
id = json['id']; | ||
name = json['name']; | ||
locale = json['locale']; | ||
direction = json['direction']; | ||
isDefault = json['is_default']; | ||
isBestFit = json['is_best_fit']; | ||
} | ||
} | ||
factory Language.fromJson(Map<String, dynamic> json) { | ||
return Language( | ||
id: json['id'], | ||
name: json['name'], | ||
locale: json['locale'], | ||
direction: json['direction'], | ||
isDefault: json['is_default'], | ||
isBestFit: json['is_best_fit'], | ||
); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class LocalizationData { | ||
final Map<String, dynamic> data; | ||
|
||
LocalizationData(this.data); | ||
|
||
factory LocalizationData.fromJson(Map json) { | ||
return LocalizationData(json['data']); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'package:nstack/models/language.dart'; | ||
import 'package:nstack/other/extensions.dart'; | ||
|
||
class LocalizeIndex { | ||
final int id; | ||
final String url; | ||
final DateTime lastUpdatedAt; | ||
final bool shouldUpdate; | ||
final Language language; | ||
|
||
LocalizeIndex({ | ||
this.id, | ||
this.url, | ||
this.lastUpdatedAt, | ||
this.shouldUpdate, | ||
this.language, | ||
}); | ||
|
||
factory LocalizeIndex.fromJson(Map json) { | ||
return LocalizeIndex( | ||
id: json['id'], | ||
url: json['url'], | ||
lastUpdatedAt: | ||
(json['last_updated_at'] as String)?.let((it) => DateTime.parse(it)), | ||
shouldUpdate: json['should_update'] ?? false, | ||
language: (json['language'] as Map)?.let((it) => Language.fromJson(it)), | ||
); | ||
} | ||
|
||
@override | ||
String toString() { | ||
return 'LocalizeIndex(id: $id, url $url, lastUpdatedAt: $lastUpdatedAt, shouldUpdate: $shouldUpdate, language: $language)'; | ||
} | ||
} |
Oops, something went wrong.