Skip to content

Commit

Permalink
rev
Browse files Browse the repository at this point in the history
  • Loading branch information
catalunha committed Dec 13, 2022
1 parent 291a7a9 commit d24e68b
Show file tree
Hide file tree
Showing 30 changed files with 2,981 additions and 9 deletions.
Binary file added assets/images/b4a_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/db_relation.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
99 changes: 99 additions & 0 deletions lib/app/core/models/author_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import 'dart:convert';

import 'package:learning_about_b4a_flutter/app/core/models/genre_model.dart';

class AuthorModel {
final String? objectId;
final String? typeString;
final bool? typeBoolean;
final num? typeNumber;
final DateTime? typeDateTime;
final List<String>? typeArray;
final GenreModel? typePointerGenre;
AuthorModel({
this.objectId,
this.typeString,
this.typeBoolean,
this.typeNumber,
this.typeDateTime,
this.typeArray,
this.typePointerGenre,
});

AuthorModel copyWith({
String? objectId,
String? typeString,
bool? typeBoolean,
num? typeNumber,
DateTime? typeDate,
Map<String, dynamic>? typeObject,
List<String>? typeArray,
GenreModel? typePointer,
}) {
return AuthorModel(
objectId: objectId ?? this.objectId,
typeString: typeString ?? this.typeString,
typeBoolean: typeBoolean ?? this.typeBoolean,
typeNumber: typeNumber ?? this.typeNumber,
typeDateTime: typeDate ?? typeDateTime,
typeArray: typeArray ?? this.typeArray,
typePointerGenre: typePointer ?? typePointerGenre,
);
}

Map<String, dynamic> toMap() {
final result = <String, dynamic>{};

if (objectId != null) {
result.addAll({'objectId': objectId});
}
if (typeString != null) {
result.addAll({'typeString': typeString});
}
if (typeBoolean != null) {
result.addAll({'typeBoolean': typeBoolean});
}
if (typeNumber != null) {
result.addAll({'typeNumber': typeNumber});
}
if (typeDateTime != null) {
result.addAll({'typeDate': typeDateTime!.millisecondsSinceEpoch});
}

if (typeArray != null) {
result.addAll({'typeArray': typeArray});
}

if (typePointerGenre != null) {
result.addAll({'typePointer': typePointerGenre!.toMap()});
}

return result;
}

factory AuthorModel.fromMap(Map<String, dynamic> map) {
return AuthorModel(
objectId: map['objectId'],
typeString: map['typeString'],
typeBoolean: map['typeBoolean'],
typeNumber: map['typeNumber'],
typeDateTime: map['typeDate'] != null
? DateTime.fromMillisecondsSinceEpoch(map['typeDate'])
: null,
typeArray: List<String>.from(map['typeArray']),
typePointerGenre: map['typePointer'] != null
? GenreModel.fromMap(map['typePointer'])
: null,
);
}

String toJson() => json.encode(toMap());

factory AuthorModel.fromJson(String source) =>
AuthorModel.fromMap(json.decode(source));

@override
String toString() {
return 'AuthorModel(objectId: $objectId, typeString: $typeString, typeBoolean: $typeBoolean, typeNumber: $typeNumber, typeDate: $typeDateTime, typeArray: $typeArray, typePointer: $typePointerGenre)';
}
}
110 changes: 110 additions & 0 deletions lib/app/core/models/book_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import 'dart:convert';

import 'package:learning_about_b4a_flutter/app/core/models/author_model.dart';
import 'package:learning_about_b4a_flutter/app/core/models/publisher_model.dart';

class BookModel {
final String? objectId;
final String? typeString;
final bool? typeBoolean;
final num? typeNumber;
final DateTime? typeDateTime;
final List<String>? typeArray;
final PublisherModel? typePointerPublisher;
final List<AuthorModel>? typeRelationAuthor;
BookModel({
this.objectId,
this.typeString,
this.typeBoolean,
this.typeNumber,
this.typeDateTime,
this.typeArray,
this.typePointerPublisher,
this.typeRelationAuthor,
});
BookModel copyWith({
String? objectId,
String? typeString,
bool? typeBoolean,
num? typeNumber,
DateTime? typeDate,
Map<String, dynamic>? typeObject,
List<String>? typeArray,
String? typeFile,
PublisherModel? typePointer,
List<AuthorModel>? typeRelation,
}) {
return BookModel(
objectId: objectId ?? this.objectId,
typeString: typeString ?? this.typeString,
typeBoolean: typeBoolean ?? this.typeBoolean,
typeNumber: typeNumber ?? this.typeNumber,
typeDateTime: typeDate ?? typeDateTime,
typeArray: typeArray ?? this.typeArray,
typePointerPublisher: typePointer ?? typePointerPublisher,
typeRelationAuthor: typeRelation ?? typeRelationAuthor,
);
}

Map<String, dynamic> toMap() {
final result = <String, dynamic>{};

if (objectId != null) {
result.addAll({'objectId': objectId});
}
if (typeString != null) {
result.addAll({'typeString': typeString});
}
if (typeBoolean != null) {
result.addAll({'typeBoolean': typeBoolean});
}
if (typeNumber != null) {
result.addAll({'typeNumber': typeNumber});
}
if (typeDateTime != null) {
result.addAll({'typeDate': typeDateTime!.millisecondsSinceEpoch});
}
if (typeArray != null) {
result.addAll({'typeArray': typeArray});
}
if (typePointerPublisher != null) {
result.addAll({'typePointer': typePointerPublisher!.toMap()});
}
if (typeRelationAuthor != null) {
result.addAll(
{'typeRelation': typeRelationAuthor!.map((x) => x.toMap()).toList()});
}

return result;
}

factory BookModel.fromMap(Map<String, dynamic> map) {
return BookModel(
objectId: map['objectId'],
typeString: map['typeString'],
typeBoolean: map['typeBoolean'],
typeNumber: map['typeNumber'],
typeDateTime: map['typeDate'] != null
? DateTime.fromMillisecondsSinceEpoch(map['typeDate'])
: null,
typeArray: List<String>.from(map['typeArray']),
typePointerPublisher: map['typePointer'] != null
? PublisherModel.fromMap(map['typePointer'])
: null,
typeRelationAuthor: map['typeRelation'] != null
? List<AuthorModel>.from(
map['typeRelation']?.map((x) => AuthorModel.fromMap(x)))
: null,
);
}

String toJson() => json.encode(toMap());

factory BookModel.fromJson(String source) =>
BookModel.fromMap(json.decode(source));

@override
String toString() {
return 'BookModel(objectId: $objectId, typeString: $typeString, typeBoolean: $typeBoolean, typeNumber: $typeNumber, typeDate: $typeDateTime, typeArray: $typeArray, typePointer: $typePointerPublisher, typeRelation: $typeRelationAuthor)';
}
}
85 changes: 85 additions & 0 deletions lib/app/core/models/genre_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import 'dart:convert';

class GenreModel {
final String? objectId;
final String? typeString;
final bool? typeBoolean;
final num? typeNumber;
final DateTime? typeDateTime;
final List<String>? typeArray;
GenreModel({
this.objectId,
this.typeString,
this.typeBoolean,
this.typeNumber,
this.typeDateTime,
this.typeArray,
});

GenreModel copyWith({
String? objectId,
String? typeString,
bool? typeBoolean,
num? typeNumber,
DateTime? typeDate,
Map<String, dynamic>? typeObject,
List<String>? typeArray,
}) {
return GenreModel(
objectId: objectId ?? this.objectId,
typeString: typeString ?? this.typeString,
typeBoolean: typeBoolean ?? this.typeBoolean,
typeNumber: typeNumber ?? this.typeNumber,
typeDateTime: typeDate ?? this.typeDateTime,
typeArray: typeArray ?? this.typeArray,
);
}

Map<String, dynamic> toMap() {
final result = <String, dynamic>{};

if (objectId != null) {
result.addAll({'objectId': objectId});
}
if (typeString != null) {
result.addAll({'typeString': typeString});
}
if (typeBoolean != null) {
result.addAll({'typeBoolean': typeBoolean});
}
if (typeNumber != null) {
result.addAll({'typeNumber': typeNumber});
}
if (typeDateTime != null) {
result.addAll({'typeDate': typeDateTime!.millisecondsSinceEpoch});
}
if (typeArray != null) {
result.addAll({'typeArray': typeArray});
}

return result;
}

factory GenreModel.fromMap(Map<String, dynamic> map) {
return GenreModel(
objectId: map['objectId'],
typeString: map['typeString'],
typeBoolean: map['typeBoolean'],
typeNumber: map['typeNumber'],
typeDateTime: map['typeDate'] != null
? DateTime.fromMillisecondsSinceEpoch(map['typeDate'])
: null,
typeArray: List<String>.from(map['typeArray']),
);
}

String toJson() => json.encode(toMap());

factory GenreModel.fromJson(String source) =>
GenreModel.fromMap(json.decode(source));

@override
String toString() {
return 'GenreModel(objectId: $objectId, typeString: $typeString, typeBoolean: $typeBoolean, typeNumber: $typeNumber, typeDate: $typeDateTime, typeArray: $typeArray)';
}
}
96 changes: 96 additions & 0 deletions lib/app/core/models/publisher_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import 'dart:convert';

import 'package:learning_about_b4a_flutter/app/core/models/shape_model.dart';

class PublisherModel {
final String? objectId;
final String? typeString;
final bool? typeBoolean;
final num? typeNumber;
final DateTime? typeDateTime;
final List<String>? typeArray;
final ShapeModel? typePointerShape;
PublisherModel({
this.objectId,
this.typeString,
this.typeBoolean,
this.typeNumber,
this.typeDateTime,
this.typeArray,
this.typePointerShape,
});

PublisherModel copyWith({
String? objectId,
String? typeString,
bool? typeBoolean,
num? typeNumber,
DateTime? typeDate,
List<String>? typeArray,
ShapeModel? typePointerShape,
}) {
return PublisherModel(
objectId: objectId ?? this.objectId,
typeString: typeString ?? this.typeString,
typeBoolean: typeBoolean ?? this.typeBoolean,
typeNumber: typeNumber ?? this.typeNumber,
typeDateTime: typeDate ?? typeDateTime,
typeArray: typeArray ?? this.typeArray,
typePointerShape: typePointerShape ?? this.typePointerShape,
);
}

Map<String, dynamic> toMap() {
final result = <String, dynamic>{};

if (objectId != null) {
result.addAll({'objectId': objectId});
}
if (typeString != null) {
result.addAll({'typeString': typeString});
}
if (typeBoolean != null) {
result.addAll({'typeBoolean': typeBoolean});
}
if (typeNumber != null) {
result.addAll({'typeNumber': typeNumber});
}
if (typeDateTime != null) {
result.addAll({'typeDate': typeDateTime!.millisecondsSinceEpoch});
}
if (typeArray != null) {
result.addAll({'typeArray': typeArray});
}
if (typePointerShape != null) {
result.addAll({'typePointerShape': typePointerShape!.toMap()});
}

return result;
}

factory PublisherModel.fromMap(Map<String, dynamic> map) {
return PublisherModel(
objectId: map['objectId'],
typeString: map['typeString'],
typeBoolean: map['typeBoolean'],
typeNumber: map['typeNumber'],
typeDateTime: map['typeDate'] != null
? DateTime.fromMillisecondsSinceEpoch(map['typeDate'])
: null,
typeArray: List<String>.from(map['typeArray']),
typePointerShape: map['typePointerShape'] != null
? ShapeModel.fromMap(map['typePointerShape'])
: null,
);
}

String toJson() => json.encode(toMap());

factory PublisherModel.fromJson(String source) =>
PublisherModel.fromMap(json.decode(source));

@override
String toString() {
return 'PublisherModel(objectId: $objectId, typeString: $typeString, typeBoolean: $typeBoolean, typeNumber: $typeNumber, typeDate: $typeDateTime, typeArray: $typeArray, typePointerShape: $typePointerShape)';
}
}
Loading

0 comments on commit d24e68b

Please sign in to comment.