发现页面

This commit is contained in:
2022-10-20 14:33:16 +08:00
parent 42ba10ec61
commit 36b860752a
25 changed files with 2150 additions and 19 deletions

View File

@@ -0,0 +1,91 @@
import 'package:chat/models/page_model.dart';
import 'package:chat/models/user_info_model.dart';
class MomentModel {
MomentModel({
this.data,
this.page,
});
List<MomentItemModel>? data;
PageModel? page;
factory MomentModel.fromMap(Map<String, dynamic> json) => MomentModel(
data: List<MomentItemModel>.from(
json['data'].map(
(x) => MomentItemModel.fromMap(x),
),
),
page: PageModel.fromJson(json['page']),
);
}
class MomentItemModel {
MomentItemModel({
this.dynamicId,
this.user,
this.description,
this.pictures,
this.isLike,
this.isMe,
this.likerCount,
this.liker,
this.comments,
this.createdAt,
this.time,
});
int? dynamicId;
UserInfoModel? user;
String? description;
bool? isLike;
bool? isMe;
int? likerCount;
List<String>? pictures;
List<UserInfoModel>? liker;
List<Comment>? comments;
String? createdAt;
String? time;
factory MomentItemModel.fromMap(Map<String, dynamic> json) => MomentItemModel(
dynamicId: json['dynamic_id'],
user: UserInfoModel.fromJson(json['user']),
description: json['description'],
pictures: List<String>.from(json['pictures'].map((x) => x)),
isLike: json['is_like'],
isMe: json['is_me'],
likerCount: json['liker_count'],
liker: List<UserInfoModel>.from(
json['liker'].map((x) => UserInfoModel.fromJson(x))),
comments:
List<Comment>.from(json['comments'].map((x) => Comment.fromMap(x))),
createdAt: json['created_at'],
time: json['time'],
);
}
class Comment {
Comment({
this.id,
this.user,
this.parent,
this.content,
required this.isMe,
});
int? id;
UserInfoModel? user;
UserInfoModel? parent;
String? content;
bool isMe;
factory Comment.fromMap(Map<String, dynamic> json) => Comment(
id: json['comment_id'],
parent: json['parent'] == null
? null
: UserInfoModel.fromJson(json['parent']),
user: UserInfoModel.fromJson(json['user']),
content: json['content'],
isMe: json['is_me'],
);
}

View File

@@ -0,0 +1,23 @@
class PageModel {
PageModel({
required this.current,
required this.totalPage,
required this.perPage,
required this.hasMore,
required this.total,
});
final int current;
final int totalPage;
final int perPage;
final bool hasMore;
final int total;
factory PageModel.fromJson(Map<String, dynamic> json) => PageModel(
current: json['current'],
totalPage: json['total_page'],
perPage: json['per_page'],
hasMore: json['has_more'],
total: json['total'],
);
}

View File

@@ -0,0 +1,20 @@
class UploadModel {
final bool exists;
final int size;
final String path;
final String url;
UploadModel({
required this.exists,
required this.size,
required this.path,
required this.url,
});
factory UploadModel.fromJson(Map<String, dynamic> json) => UploadModel(
exists: json['exists'],
size: json['size'],
path: json['path'],
url: json['url'],
);
}

View File

@@ -0,0 +1,23 @@
class UserInfoModel {
UserInfoModel({
required this.userId,
required this.username,
required this.nickname,
required this.avatar,
required this.address,
});
int userId;
String username;
String nickname;
String avatar;
String? address;
factory UserInfoModel.fromJson(Map<String, dynamic> json) => UserInfoModel(
userId: json['user_id'],
username: json['username'],
nickname: json['nickname'],
avatar: json['avatar'],
address: json['address'],
);
}