D1APP-48 new models + model edits
This commit is contained in:
parent
96c80e2d75
commit
c5daae34d5
|
|
@ -0,0 +1,51 @@
|
||||||
|
import 'feedback.dart';
|
||||||
|
import 'reply.dart';
|
||||||
|
import 'user.dart';
|
||||||
|
|
||||||
|
class Comment {
|
||||||
|
final int id;
|
||||||
|
final String text;
|
||||||
|
final String createdAt;
|
||||||
|
final bool liked;
|
||||||
|
final bool disliked;
|
||||||
|
final Feedback feedback;
|
||||||
|
final User user;
|
||||||
|
final List<Reply> replies;
|
||||||
|
|
||||||
|
Comment({
|
||||||
|
required this.id,
|
||||||
|
required this.text,
|
||||||
|
required this.createdAt,
|
||||||
|
required this.liked,
|
||||||
|
required this.disliked,
|
||||||
|
required this.feedback,
|
||||||
|
required this.user,
|
||||||
|
required this.replies,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Comment.fromJson(Map<String, dynamic> json) => Comment(
|
||||||
|
id: json['id'],
|
||||||
|
text: json['text'],
|
||||||
|
createdAt: json['createdAt'],
|
||||||
|
liked: json['liked'],
|
||||||
|
disliked: json['disliked'],
|
||||||
|
feedback: Feedback.fromJson(json['feedback']),
|
||||||
|
user: User.fromJson(json['user']),
|
||||||
|
replies: List<Reply>.from(
|
||||||
|
json['replies'].map(
|
||||||
|
(reply) => Reply.fromJson(reply),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'id': id,
|
||||||
|
'text': text,
|
||||||
|
'createdAt': createdAt,
|
||||||
|
'liked': liked,
|
||||||
|
'disliked': disliked,
|
||||||
|
'feedback': feedback.toJson(),
|
||||||
|
'user': user.toJson(),
|
||||||
|
'replies': replies.map((e) => e.toJson()).toList(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
class Feedback {
|
||||||
|
final int like;
|
||||||
|
final int dislike;
|
||||||
|
|
||||||
|
const Feedback({required this.like, required this.dislike});
|
||||||
|
|
||||||
|
factory Feedback.fromJson(Map<String, dynamic> json) => Feedback(
|
||||||
|
like: json['like'],
|
||||||
|
dislike: json['dislike'],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'like': like,
|
||||||
|
'dislike': dislike,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
import 'feedback.dart';
|
||||||
|
import 'user.dart';
|
||||||
|
|
||||||
|
class Reply {
|
||||||
|
final int id;
|
||||||
|
final String text;
|
||||||
|
final String createdAt;
|
||||||
|
final bool liked;
|
||||||
|
final bool disliked;
|
||||||
|
final Feedback feedback;
|
||||||
|
final User user;
|
||||||
|
|
||||||
|
const Reply({
|
||||||
|
required this.id,
|
||||||
|
required this.text,
|
||||||
|
required this.createdAt,
|
||||||
|
required this.liked,
|
||||||
|
required this.disliked,
|
||||||
|
required this.feedback,
|
||||||
|
required this.user,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Reply.fromJson(Map<String, dynamic> json) => Reply(
|
||||||
|
id: json['id'],
|
||||||
|
text: json['text'],
|
||||||
|
createdAt: json['createdAt'],
|
||||||
|
liked: json['liked'],
|
||||||
|
disliked: json['disliked'],
|
||||||
|
feedback: Feedback.fromJson(json['feedback']),
|
||||||
|
user: User.fromJson(json['user']),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'id': id,
|
||||||
|
'text': text,
|
||||||
|
'createdAt': createdAt,
|
||||||
|
'liked': liked,
|
||||||
|
'disliked': disliked,
|
||||||
|
'feedback': feedback.toJson(),
|
||||||
|
'user': user.toJson(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
class User {
|
||||||
|
final int id;
|
||||||
|
final String fullName;
|
||||||
|
final String? photo;
|
||||||
|
|
||||||
|
const User({required this.id, required this.fullName, required this.photo});
|
||||||
|
|
||||||
|
factory User.fromJson(Map<String, dynamic> json) => User(
|
||||||
|
id: json['id'],
|
||||||
|
fullName: json['fullName'],
|
||||||
|
photo: json['photo'],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'id': id,
|
||||||
|
'fullName': fullName,
|
||||||
|
'photo': photo,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
class NewsOverview {
|
||||||
|
final int id;
|
||||||
|
final String title;
|
||||||
|
final String reference;
|
||||||
|
final String description;
|
||||||
|
final String image;
|
||||||
|
final String createdAt;
|
||||||
|
final bool marked;
|
||||||
|
|
||||||
|
const NewsOverview({
|
||||||
|
required this.id,
|
||||||
|
required this.title,
|
||||||
|
required this.reference,
|
||||||
|
required this.description,
|
||||||
|
required this.image,
|
||||||
|
required this.createdAt,
|
||||||
|
required this.marked,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory NewsOverview.fromJson(Map<String, dynamic> json) => NewsOverview(
|
||||||
|
id: json['id'],
|
||||||
|
title: json['title'],
|
||||||
|
reference: json['reference'],
|
||||||
|
description: json['description'],
|
||||||
|
image: json['image'],
|
||||||
|
createdAt: json['createdAt'],
|
||||||
|
marked: json['marked'],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'id': id,
|
||||||
|
'title': title,
|
||||||
|
'reference': reference,
|
||||||
|
'description': description,
|
||||||
|
'image': image,
|
||||||
|
'createdAt': createdAt,
|
||||||
|
'marked': marked,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
class Content {
|
||||||
|
final int order;
|
||||||
|
final String? text;
|
||||||
|
final String? audio;
|
||||||
|
final String? video;
|
||||||
|
final String? image;
|
||||||
|
|
||||||
|
const Content({
|
||||||
|
required this.order,
|
||||||
|
required this.text,
|
||||||
|
required this.audio,
|
||||||
|
required this.video,
|
||||||
|
required this.image,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Content.fromJson(Map<String, dynamic> json) => Content(
|
||||||
|
order: json['order'],
|
||||||
|
text: json['text'],
|
||||||
|
audio: json['audio'],
|
||||||
|
video: json['video'],
|
||||||
|
image: json['image'],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'order': order,
|
||||||
|
'text': text,
|
||||||
|
'audio': audio,
|
||||||
|
'video': video,
|
||||||
|
'image': image,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
import 'package:didvan/models/category.dart';
|
||||||
|
|
||||||
|
import 'content.dart';
|
||||||
|
import 'tag.dart';
|
||||||
|
|
||||||
|
class RadarDetailsData {
|
||||||
|
final int id;
|
||||||
|
final String title;
|
||||||
|
final String image;
|
||||||
|
final String description;
|
||||||
|
final int timeToRead;
|
||||||
|
final String createdAt;
|
||||||
|
final String? podcast;
|
||||||
|
final bool forManagers;
|
||||||
|
final bool marked;
|
||||||
|
final int comments;
|
||||||
|
final List<Tag> tags;
|
||||||
|
final List<Content> contents;
|
||||||
|
final List<Category> categories;
|
||||||
|
|
||||||
|
const RadarDetailsData({
|
||||||
|
required this.id,
|
||||||
|
required this.title,
|
||||||
|
required this.image,
|
||||||
|
required this.description,
|
||||||
|
required this.timeToRead,
|
||||||
|
required this.createdAt,
|
||||||
|
required this.podcast,
|
||||||
|
required this.forManagers,
|
||||||
|
required this.marked,
|
||||||
|
required this.comments,
|
||||||
|
required this.tags,
|
||||||
|
required this.contents,
|
||||||
|
required this.categories,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory RadarDetailsData.fromJson(Map<String, dynamic> json) {
|
||||||
|
return RadarDetailsData(
|
||||||
|
id: json['id'],
|
||||||
|
title: json['title'],
|
||||||
|
image: json['image'],
|
||||||
|
description: json['description'],
|
||||||
|
timeToRead: json['timeToRead'],
|
||||||
|
createdAt: json['createdAt'],
|
||||||
|
podcast: json['podcast'],
|
||||||
|
forManagers: json['forManagers'],
|
||||||
|
marked: json['marked'],
|
||||||
|
comments: json['comments'],
|
||||||
|
tags: List<Tag>.from(json['tags'].map((tag) => Tag.fromJson(tag))),
|
||||||
|
contents: List<Content>.from(
|
||||||
|
json['contents'].map(
|
||||||
|
(content) => Content.fromJson(content),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
categories: List<Category>.from(
|
||||||
|
json['categories'].map(
|
||||||
|
(cat) => Category.fromJson(cat),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'id': id,
|
||||||
|
'title': title,
|
||||||
|
'image': image,
|
||||||
|
'description': description,
|
||||||
|
'timeToRead': timeToRead,
|
||||||
|
'createdAt': createdAt,
|
||||||
|
'podcast': podcast,
|
||||||
|
'forManagers': forManagers,
|
||||||
|
'marked': marked,
|
||||||
|
'comments': comments,
|
||||||
|
'tags': tags.map((e) => e.toJson()).toList(),
|
||||||
|
'contents': contents.map((e) => e.toJson()).toList(),
|
||||||
|
'categories': categories.map((e) => e.toJson()).toList(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
class Tag {
|
||||||
|
final int id;
|
||||||
|
final String label;
|
||||||
|
|
||||||
|
const Tag({required this.id, required this.label});
|
||||||
|
|
||||||
|
factory Tag.fromJson(Map<String, dynamic> json) => Tag(
|
||||||
|
id: json['id'],
|
||||||
|
label: json['label'],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
'id': id,
|
||||||
|
'label': label,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import 'category.dart';
|
import '../category.dart';
|
||||||
|
|
||||||
class RadarOverview {
|
class RadarOverview {
|
||||||
final int id;
|
final int id;
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,12 @@
|
||||||
|
import 'package:didvan/services/network/request_helper.dart';
|
||||||
|
|
||||||
class User {
|
class User {
|
||||||
final int id;
|
final int id;
|
||||||
final String phoneNumber;
|
final String phoneNumber;
|
||||||
final String fullName;
|
final String fullName;
|
||||||
final String? username;
|
final String? username;
|
||||||
final String? photo;
|
final String? photo;
|
||||||
|
final String? email;
|
||||||
|
|
||||||
const User({
|
const User({
|
||||||
required this.id,
|
required this.id,
|
||||||
|
|
@ -11,14 +14,17 @@ class User {
|
||||||
required this.phoneNumber,
|
required this.phoneNumber,
|
||||||
required this.photo,
|
required this.photo,
|
||||||
required this.fullName,
|
required this.fullName,
|
||||||
|
required this.email,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory User.fromJson(Map<String, dynamic> json) => User(
|
factory User.fromJson(Map<String, dynamic> json) => User(
|
||||||
id: json['id'],
|
id: json['id'],
|
||||||
username: json['username'],
|
username: json['username'],
|
||||||
phoneNumber: json['phoneNumber'],
|
phoneNumber: json['phoneNumber'],
|
||||||
photo: json['photo'],
|
photo: RequestHelper.baseUrl + json['photo'],
|
||||||
fullName: json['fullName']);
|
fullName: json['fullName'],
|
||||||
|
email: json['email'],
|
||||||
|
);
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
Map<String, dynamic> toJson() => {
|
||||||
'id': id,
|
'id': id,
|
||||||
|
|
@ -26,6 +32,7 @@ class User {
|
||||||
'phoneNumber': phoneNumber,
|
'phoneNumber': phoneNumber,
|
||||||
'photo': photo,
|
'photo': photo,
|
||||||
'fullName': fullName,
|
'fullName': fullName,
|
||||||
|
'email': email,
|
||||||
};
|
};
|
||||||
|
|
||||||
User copyWith({
|
User copyWith({
|
||||||
|
|
@ -34,6 +41,7 @@ class User {
|
||||||
String? phoneNumber,
|
String? phoneNumber,
|
||||||
String? photo,
|
String? photo,
|
||||||
String? fullName,
|
String? fullName,
|
||||||
|
String? email,
|
||||||
}) {
|
}) {
|
||||||
return User(
|
return User(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
|
|
@ -41,6 +49,7 @@ class User {
|
||||||
phoneNumber: phoneNumber ?? this.phoneNumber,
|
phoneNumber: phoneNumber ?? this.phoneNumber,
|
||||||
photo: photo ?? this.photo,
|
photo: photo ?? this.photo,
|
||||||
fullName: fullName ?? this.fullName,
|
fullName: fullName ?? this.fullName,
|
||||||
|
email: email ?? this.email,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue