发现页面
This commit is contained in:
@@ -52,7 +52,8 @@ class MomentController extends GetxController {
|
|||||||
|
|
||||||
Future<void> loadMoreList() async {
|
Future<void> loadMoreList() async {
|
||||||
final res = await MomentProvider.fetchMomentList(
|
final res = await MomentProvider.fetchMomentList(
|
||||||
momentData.value?.data?.last.createdAt);
|
momentData.value?.data?.last.createdAt,
|
||||||
|
);
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
final data = res.data ?? [];
|
final data = res.data ?? [];
|
||||||
if (data.isEmpty || res.page?.hasMore == true) {
|
if (data.isEmpty || res.page?.hasMore == true) {
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ class MomentModel {
|
|||||||
List<MomentItemModel>? data;
|
List<MomentItemModel>? data;
|
||||||
PageModel? page;
|
PageModel? page;
|
||||||
|
|
||||||
factory MomentModel.fromMap(Map<String, dynamic> json) => MomentModel(
|
factory MomentModel.fromJson(Map<String, dynamic> json) => MomentModel(
|
||||||
data: List<MomentItemModel>.from(
|
data: List<MomentItemModel>.from(
|
||||||
json['data'].map(
|
json['data'].map(
|
||||||
(x) => MomentItemModel.fromMap(x),
|
(x) => MomentItemModel.fromJson(x),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
page: PageModel.fromJson(json['page']),
|
page: PageModel.fromJson(json['page']),
|
||||||
@@ -47,7 +47,8 @@ class MomentItemModel {
|
|||||||
String? createdAt;
|
String? createdAt;
|
||||||
String? time;
|
String? time;
|
||||||
|
|
||||||
factory MomentItemModel.fromMap(Map<String, dynamic> json) => MomentItemModel(
|
factory MomentItemModel.fromJson(Map<String, dynamic> json) =>
|
||||||
|
MomentItemModel(
|
||||||
dynamicId: json['dynamic_id'],
|
dynamicId: json['dynamic_id'],
|
||||||
user: UserInfoModel.fromJson(json['user']),
|
user: UserInfoModel.fromJson(json['user']),
|
||||||
description: json['description'],
|
description: json['description'],
|
||||||
@@ -57,8 +58,8 @@ class MomentItemModel {
|
|||||||
likerCount: json['liker_count'],
|
likerCount: json['liker_count'],
|
||||||
liker: List<UserInfoModel>.from(
|
liker: List<UserInfoModel>.from(
|
||||||
json['liker'].map((x) => UserInfoModel.fromJson(x))),
|
json['liker'].map((x) => UserInfoModel.fromJson(x))),
|
||||||
comments:
|
comments: List<Comment>.from(
|
||||||
List<Comment>.from(json['comments'].map((x) => Comment.fromMap(x))),
|
json['comments'].map((x) => Comment.fromJson(x))),
|
||||||
createdAt: json['created_at'],
|
createdAt: json['created_at'],
|
||||||
time: json['time'],
|
time: json['time'],
|
||||||
);
|
);
|
||||||
@@ -79,7 +80,7 @@ class Comment {
|
|||||||
String? content;
|
String? content;
|
||||||
bool isMe;
|
bool isMe;
|
||||||
|
|
||||||
factory Comment.fromMap(Map<String, dynamic> json) => Comment(
|
factory Comment.fromJson(Map<String, dynamic> json) => Comment(
|
||||||
id: json['comment_id'],
|
id: json['comment_id'],
|
||||||
parent: json['parent'] == null
|
parent: json['parent'] == null
|
||||||
? null
|
? null
|
||||||
|
|||||||
@@ -9,10 +9,12 @@ class MomentProvider {
|
|||||||
static Future<MomentModel?> fetchMomentList([String? createAt]) async {
|
static Future<MomentModel?> fetchMomentList([String? createAt]) async {
|
||||||
try {
|
try {
|
||||||
final result = await Http.get(
|
final result = await Http.get(
|
||||||
'user/dynamics',
|
'dynamics',
|
||||||
params: {'created_at': createAt},
|
params: {
|
||||||
|
'created_at': createAt,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
return MomentModel.fromMap(result);
|
return MomentModel.fromJson(result);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
UiTools.toast('获取发现列表失败');
|
UiTools.toast('获取发现列表失败');
|
||||||
}
|
}
|
||||||
@@ -60,7 +62,7 @@ class MomentProvider {
|
|||||||
'parent_id': parentId,
|
'parent_id': parentId,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
return Comment.fromMap(result);
|
return Comment.fromJson(result);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
UiTools.toast('评论失败');
|
UiTools.toast('评论失败');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:chat/configs/app_colors.dart';
|
import 'package:chat/configs/app_colors.dart';
|
||||||
import 'package:chat/routes/moments_routes.dart';
|
import 'package:chat/routes/moments_routes.dart';
|
||||||
|
import 'package:chat/services/auth_service.dart';
|
||||||
import 'package:chat/services/tabbar_service.dart';
|
import 'package:chat/services/tabbar_service.dart';
|
||||||
import 'package:chat/widgets/custom_avatar.dart';
|
import 'package:chat/widgets/custom_avatar.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -79,7 +80,7 @@ class _HeaderBackground extends StatelessWidget {
|
|||||||
bottom: 32,
|
bottom: 32,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
child: Image.asset(
|
child: Image.asset(
|
||||||
'assets/backgrounds/moment_3.jpg',
|
'assets/images/login_bg.png',
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -94,9 +95,9 @@ class _HeaderBackground extends StatelessWidget {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
height: 52,
|
height: 52,
|
||||||
child: Obx(() {
|
child: Obx(() {
|
||||||
return const Text(
|
return Text(
|
||||||
"UserController.to.userInfo.value?.nickname ?? ''",
|
AuthService.to.userInfo.value.nickname ?? '',
|
||||||
style: TextStyle(
|
style: const TextStyle(
|
||||||
color: AppColors.white,
|
color: AppColors.white,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
@@ -109,7 +110,7 @@ class _HeaderBackground extends StatelessWidget {
|
|||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () => TabbarService.to.index = 4,
|
onTap: () => TabbarService.to.index = 4,
|
||||||
child: CustomAvatar(
|
child: CustomAvatar(
|
||||||
'',
|
AuthService.to.userInfo.value.avatar,
|
||||||
size: 64,
|
size: 64,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'package:chat/configs/app_colors.dart';
|
|||||||
import 'package:chat/services/tabbar_service.dart';
|
import 'package:chat/services/tabbar_service.dart';
|
||||||
import 'package:chat/views/contact/index/index_page.dart';
|
import 'package:chat/views/contact/index/index_page.dart';
|
||||||
import 'package:chat/views/home/index_page.dart';
|
import 'package:chat/views/home/index_page.dart';
|
||||||
|
import 'package:chat/views/moments/index/index_page.dart';
|
||||||
import 'package:chat/views/user/index/index_page.dart';
|
import 'package:chat/views/user/index/index_page.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -13,7 +14,7 @@ class AppPage extends StatelessWidget {
|
|||||||
final List<IndexedStackChild> _tabBarPageList = [
|
final List<IndexedStackChild> _tabBarPageList = [
|
||||||
IndexedStackChild(child: const HomePage()),
|
IndexedStackChild(child: const HomePage()),
|
||||||
IndexedStackChild(child: const ContactPage()),
|
IndexedStackChild(child: const ContactPage()),
|
||||||
// IndexedStackChild(child: const MomentsPage()),
|
IndexedStackChild(child: const MomentsPage()),
|
||||||
IndexedStackChild(child: const UserPage()),
|
IndexedStackChild(child: const UserPage()),
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -28,11 +29,11 @@ class AppPage extends StatelessWidget {
|
|||||||
'active_icon': Icons.contact_page,
|
'active_icon': Icons.contact_page,
|
||||||
'label': '通讯录',
|
'label': '通讯录',
|
||||||
},
|
},
|
||||||
// {
|
{
|
||||||
// 'icon': Icons.explore_outlined,
|
'icon': Icons.explore_outlined,
|
||||||
// 'active_icon': Icons.explore,
|
'active_icon': Icons.explore,
|
||||||
// 'label': '发现',
|
'label': '发现',
|
||||||
// },
|
},
|
||||||
{
|
{
|
||||||
'icon': Icons.person_outline,
|
'icon': Icons.person_outline,
|
||||||
'active_icon': Icons.person,
|
'active_icon': Icons.person,
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ class _UserInfoPageState extends State<UserInfoPage> {
|
|||||||
Get.context!,
|
Get.context!,
|
||||||
pickerConfig: const AssetPickerConfig(
|
pickerConfig: const AssetPickerConfig(
|
||||||
maxAssets: 1,
|
maxAssets: 1,
|
||||||
|
textDelegate: AssetPickerTextDelegate(),
|
||||||
requestType: RequestType.image,
|
requestType: RequestType.image,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -77,12 +78,12 @@ class _UserInfoPageState extends State<UserInfoPage> {
|
|||||||
sourcePath: imagePath,
|
sourcePath: imagePath,
|
||||||
maxHeight: 128,
|
maxHeight: 128,
|
||||||
maxWidth: 128,
|
maxWidth: 128,
|
||||||
compressQuality: 70,
|
compressQuality: 100,
|
||||||
aspectRatio: const CropAspectRatio(
|
aspectRatio: const CropAspectRatio(
|
||||||
ratioX: 1,
|
ratioX: 1,
|
||||||
ratioY: 1,
|
ratioY: 1,
|
||||||
),
|
),
|
||||||
compressFormat: ImageCompressFormat.png,
|
compressFormat: ImageCompressFormat.jpg,
|
||||||
uiSettings: [
|
uiSettings: [
|
||||||
IOSUiSettings(
|
IOSUiSettings(
|
||||||
title: '头像剪裁',
|
title: '头像剪裁',
|
||||||
|
|||||||
Reference in New Issue
Block a user