You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1396 lines
58 KiB

import 'dart:convert';
import 'dart:io';
import 'package:dio/dio.dart';
3 years ago
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/community/community_view/community_dynamic.dart';
import 'package:huixiang/community/photo_view_gallery_screen.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/main.dart';
import 'package:huixiang/retrofit/data/article.dart';
import 'package:huixiang/retrofit/data/base_data.dart';
import 'package:huixiang/retrofit/data/comunity_comment.dart';
import 'package:huixiang/retrofit/data/member_Infor.dart';
import 'package:huixiang/retrofit/data/page.dart';
import 'package:huixiang/retrofit/data/upload_result.dart';
3 years ago
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/classic_header.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:huixiang/view_widget/my_footer.dart';
import 'package:huixiang/view_widget/no_data_view.dart';
import 'package:image_pickers/image_pickers.dart';
import 'package:permission_handler/permission_handler.dart';
3 years ago
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
3 years ago
import '../retrofit/data/im_user.dart';
import '../view_widget/my_tab.dart';
3 years ago
class PersonalPage extends StatefulWidget {
final Map<String, dynamic> arguments;
PersonalPage({this.arguments});
3 years ago
3 years ago
@override
State<StatefulWidget> createState() {
return _PersonalPage();
}
}
class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver,SingleTickerProviderStateMixin{
3 years ago
ApiService apiService;
final RefreshController refreshController = RefreshController();
final ScrollController scrollController = ScrollController();
var isShrink = false;
int pageNum = 1;
String userId;
List<Article> articles = [];
MemberInfor memberInfor;
String filePath;
bool isLoadMore = false;
3 years ago
bool isRefresh = true;
bool isLoadingData = false;
String memberId;
3 years ago
Map<String, dynamic> modifyInfo = {"background": ""};
TabController tabController;
3 years ago
@override
void initState() {
super.initState();
memberId = widget.arguments["memberId"];
3 years ago
WidgetsBinding.instance.addObserver(this);
SharedPreferences.getInstance().then((value) => {
3 years ago
apiService = ApiService(Dio(),
context: context,
token: value.getString('token'),
showLoading: true),
_onRefresh(),
});
}
_onRefresh() async {
3 years ago
queryCommunity(null);
queryMember(memberId);
}
///查询会员信息
queryMember(id) async {
if (apiService == null) {
SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(
Dio(),
context: context,
token: value.getString("token"),
);
}
BaseData<MemberInfor> baseData =
3 years ago
await apiService.memberDetail(id).catchError((error) {
refreshController.refreshFailed();
debugPrint(error);
});
if (baseData != null && baseData.isSuccess) {
setState(() {
memberInfor = baseData.data;
});
refreshController.refreshCompleted();
3 years ago
} else {
refreshController.refreshFailed();
}
}
///关注/取关会员
vipFollow(followId, isFollow) async {
if (apiService == null) {
SharedPreferences value = await SharedPreferences.getInstance();
apiService = ApiService(
Dio(),
context: context,
token: value.getString("token"),
);
}
BaseData baseData = await apiService.follow(followId ?? "");
if (baseData != null && baseData.isSuccess) {
queryCommunity(null);
SmartDialog.showToast(isFollow ? "关注成功" : "取关成功",
alignment: Alignment.center);
setState(() {});
} else {
SmartDialog.showToast(baseData.msg, alignment: Alignment.center);
}
}
///动态列表
3 years ago
queryCommunity(String searchKey) async {
if (!isRefresh) {
3 years ago
isRefresh = true;
return;
}
if (isLoadingData) {
3 years ago
return;
}
isLoadingData = true;
if (apiService == null) {
SharedPreferences value = await SharedPreferences.getInstance();
userId = value.getString('userId');
apiService = ApiService(Dio(),
3 years ago
context: context,
token: value.getString("token"),
showLoading: false);
}
if (isLoadMore) {
pageNum += 1;
isLoadMore = false;
} else if (searchKey == null) pageNum = 1;
BaseData<PageInfo<ComunityComment>> baseData = await apiService.trendList({
3 years ago
"mid": memberId == "0" ? userId : memberId,
"onlyFollow": false,
"onlyMe": true,
"pageNum": searchKey == null ? pageNum : 1,
"pageSize": 10,
"searchKey": searchKey ?? ""
}).catchError((error) {
debugPrint(error);
if (searchKey == null) {
3 years ago
refreshController.refreshFailed();
refreshController.loadFailed();
}
});
if (searchKey == null) {
refreshController.refreshCompleted();
refreshController.loadComplete();
3 years ago
}
if (baseData.isSuccess) {
if (searchKey != null) {
if (baseData?.data?.list != null && baseData.data.list.isNotEmpty)
3 years ago
articles.forEach((element) {
if (element.id == searchKey) {
3 years ago
element.content = jsonEncode(baseData.data.list[0].subjectInfo);
element.mainTitle = baseData.data.list[0].subject;
3 years ago
element.followed = baseData.data.list[0].selfFollow;
element.liked = baseData.data.list[0].selfLike;
3 years ago
element.authorHeadImg = baseData.data.list[0].memberInfo?.avatar;
element.authorName = baseData.data.list[0].memberInfo?.nickname;
element.location = baseData.data.list[0].location;
element.createTime = baseData.data.list[0].createTime;
element.author = baseData.data.list[0].memberInfo?.mid;
element.viewers = baseData.data.list[0]?.viewers;
element.likes = baseData.data.list[0]?.likes;
element.comments = baseData.data.list[0]?.comments;
this.isRefresh = false;
setState(() {});
3 years ago
}
});
} else {
3 years ago
if (pageNum == 1) {
articles.clear();
}
baseData.data.list.forEach((element) {
var article = Article();
article.id = element.id;
article.content = jsonEncode(element.subjectInfo);
article.mainTitle = element.subject;
3 years ago
article.followed = element.selfFollow;
article.liked = element.selfLike;
3 years ago
article.authorHeadImg = element.memberInfo?.avatar;
article.authorName = element.memberInfo?.nickname;
article.location = element.location;
article.createTime = element.createTime;
article.author = element.memberInfo?.mid;
article.viewers = element?.viewers;
article.likes = element?.likes;
article.comments = element?.comments;
articles.add(article);
});
setState(() {});
3 years ago
// comments.sort((a,b)=>b.createTime.compareTo(a.createTime));
// print("comments: ${comments.length}");
if (int.tryParse(baseData.data.total) < (pageNum * 10)) {
refreshController.loadNoData();
}
}
}
3 years ago
isLoadingData = false;
}
///去编辑个人资料
_toUserInfo() async {
SharedPreferences shared = await SharedPreferences.getInstance();
if (shared.getString("token") == null || shared.getString("token") == "") {
Navigator.of(context)
3 years ago
.pushNamed('/router/new_login_page', arguments: {"login": "login"});
return;
}
3 years ago
await Navigator.of(context)
.pushNamed('/router/user_info_page')
.then((value) {
_onRefresh();
setState(() {});
});
setState(() {});
}
///显示图片选择方式
showImagePicker() {
showCupertinoModalPopup(
context: context,
builder: (contetx) {
return CupertinoActionSheet(
title: Text(S.of(context).genghuantouxiang),
actions: [
CupertinoActionSheetAction(
child: Text(S.of(context).paizhao),
onPressed: () {
openCamera();
Navigator.of(context).pop();
},
isDefaultAction: true,
isDestructiveAction: false,
),
CupertinoActionSheetAction(
child: Text(S.of(context).xiangce),
onPressed: () {
openStorage();
Navigator.of(context).pop();
},
isDefaultAction: true,
isDestructiveAction: false,
),
],
cancelButton: CupertinoActionSheetAction(
onPressed: () {
Navigator.of(context).pop();
},
child: Text(S.of(context).quxiao),
isDestructiveAction: true,
),
);
});
}
///拍照
openCamera() async {
if (await Permission.camera.isGranted) {
Media medias = await ImagePickers.openCamera(
cameraMimeType: CameraMimeType.photo,
cropConfig: CropConfig(
enableCrop: true,
width: 200,
height: 200,
),
compressSize: 500,
);
if (medias == null) return;
filePath = medias.path;
fileUpload();
} else {
await Permission.camera.request();
openCamera();
}
}
///打开相册
openStorage() async {
if (await Permission.storage.isGranted) {
List<Media> medias = await ImagePickers.pickerPaths(
galleryMode: GalleryMode.image,
selectCount: 1,
showGif: true,
showCamera: false,
compressSize: 500,
uiConfig: UIConfig(
uiThemeColor: Color(0xFFFFFFFF),
),
cropConfig: CropConfig(
enableCrop: true,
width: 200,
height: 200,
),
);
if (medias == null || medias.length == 0) return;
filePath = medias[0].path;
setState(() {});
fileUpload();
} else {
await Permission.storage.request();
openStorage();
}
3 years ago
}
///调用修改用户信息接口
modifyInfos() async {
var info = await apiService.editInfo(modifyInfo).catchError((onError) {});
if (info.isSuccess) {
setState(() {
SmartDialog.showToast("用户信息修改成功", alignment: Alignment.center);
});
_onRefresh();
}
}
3 years ago
///文件上传
fileUpload() async {
if (filePath != null && filePath != "" && await File(filePath).exists()) {
3 years ago
BaseData<UploadResult> baseData = await apiService
.upload(File(filePath), 123123123, false)
.catchError((onError) {});
if (baseData != null && baseData.isSuccess) {
UploadResult uploadResult = baseData.data;
modifyInfo["background"] = uploadResult.url;
modifyInfos();
}
}
3 years ago
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: SmartRefresher(
controller: refreshController,
enablePullDown: true,
enablePullUp: (articles == null || articles.length == 0) ? false: true,
header: MyHeader(),
footer: CustomFooter(
builder: (context, mode) {
return MyFooter(mode);
},
),
onRefresh: _onRefresh,
onLoading: () {
isLoadMore = true;
setState(() {
_onRefresh();
});
},
physics: BouncingScrollPhysics(),
scrollController: scrollController,
child: SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Stack(
children: [
Container(
color: Colors.black,
child: Opacity(
opacity: 0.9,
child: MImage(
memberInfor?.background ?? "",
width: double.infinity,
height: 210.h,
fit: BoxFit.cover,
errorSrc: "assets/image/default_1.webp",
fadeSrc: "assets/image/default_1.webp",
))),
Positioned(
top: MediaQuery.of(context).padding.top + 20.h,
left: 17.w,
child:GestureDetector(
child: Image.asset(
"assets/image/integral_return.webp",
width: 24,
height: 24,
),
onTap: () {
Navigator.of(context).pop();
},
),
),
if (memberId == "0")
Positioned(
bottom: 9.h,
right: 16.w,
child: GestureDetector(
onTap: () {
showImagePicker();
},
child: Container(
padding:
EdgeInsets.only(left: 2, right: 2),
width: 59.w,
height: 23.h,
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2),
color: Color(0x80000000),
3 years ago
),
child: Text(
S.of(context).genghuanbeijing,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFFFFFFFF),
),
),
),
3 years ago
),
),
],
),
Container(
// margin: EdgeInsets.only(bottom: 30.h),
decoration: BoxDecoration(
color: Color(0xFFFFFFFF),
borderRadius: BorderRadius.only(
topRight: Radius.circular(12),
topLeft: Radius.circular(12)),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
trendsInfo(),
Padding(
padding: EdgeInsets.only(left: 16.w,top:24.h),
child: Text(
memberId != "0" ? "TA的动态" : "我的动态",
style: TextStyle(
color: Color(0xFF353535),
fontSize: 15.sp,
fontWeight: MyFontWeight.semi_bold,
),
)),
dynamicList(),
],
3 years ago
),
),
// Container(
// height: 248.h,
// // color: Color(0xFFFFFFFF),
// // color: Colors.red,
// child: Stack(
// // alignment: Alignment.bottomLeft,
// children: [
// Positioned(
// top: 0,
// left: 0,
// bottom: 36.h,
// right: 0,
// child: Stack(
// alignment: Alignment.bottomRight,
// children: [
// Container(
// color: Colors.black,
// child: Opacity(
// opacity: 0.9,
// child: MImage(
// memberInfor?.background ?? "",
// width: double.infinity,
// height: 260.h,
// fit: BoxFit.cover,
// errorSrc: "assets/image/default_1.webp",
// fadeSrc: "assets/image/default_1.webp",
// ))),
// Container(
// margin: EdgeInsets.only(
// top: 50.h, left: 16.w, right: 16.w),
// alignment: Alignment.topLeft,
// decoration: BoxDecoration(
// color: Colors.transparent,
// ),
// child: Column(
// mainAxisAlignment:
// MainAxisAlignment.spaceBetween,
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// GestureDetector(
// child: Image.asset(
// "assets/image/integral_return.webp",
// width: 24,
// height: 24,
// ),
// onTap: () {
// Navigator.of(context).pop();
// },
// ),
// ],
// ),
// ),
// if (memberId == "0")
// Positioned(
// bottom: 9.h,
// right: 16.w,
// child: GestureDetector(
// onTap: () {
// showImagePicker();
// },
// child: Container(
// padding:
// EdgeInsets.only(left: 2, right: 2),
// width: 59.w,
// height: 23.h,
// alignment: Alignment.center,
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(2),
// color: Color(0x80000000),
// ),
// child: Text(
// S.of(context).genghuanbeijing,
// overflow: TextOverflow.ellipsis,
// style: TextStyle(
// fontSize: 12.sp,
// fontWeight: MyFontWeight.regular,
// color: Color(0xFFFFFFFF),
// ),
// ),
// ),
// ),
// ),
// ],
// ),
// ),
// homeInfo(),
// ],
// ),
// ),
// Container(
// color: Color(0xFFFFFFFF),
// margin: EdgeInsets.only(bottom: 30.h),
// child: Column(
// mainAxisAlignment: MainAxisAlignment.spaceAround,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Container(
// margin: EdgeInsets.only(
// left: 86.w, top: 12.h, right: 16.w),
// child: GestureDetector(
// onTap: () {
// setState(() {
// isShrink = !isShrink;
// });
// },
// child: Row(
// mainAxisAlignment: MainAxisAlignment.start,
// crossAxisAlignment: CrossAxisAlignment.end,
// children: [
// Expanded(
// flex: 1,
// child: Text(
// memberId == "0"
// ? ((memberInfor?.signature == "")
// ? "还未编辑个性签名~"
// : memberInfor?.signature ?? "")
// : "个性签名: ${(memberInfor?.signature == "") ? "还未编辑个性签名~" : memberInfor?.signature ?? ""}",
// overflow: isShrink
// ? TextOverflow.visible
// : TextOverflow.ellipsis,
// maxLines: isShrink ? 10 : 2,
// style: TextStyle(
// fontSize: 12.sp,
// color: Color(0xFF868686),
// fontWeight: MyFontWeight.regular,
// height: 1.5.h),
// )),
// Icon(
// (isShrink != null && !isShrink)
// ? Icons.keyboard_arrow_down
// : Icons.keyboard_arrow_up,
// color: Colors.black,
// size: 18,
// ),
// ],
// ),
// )),
// Container(
// margin: EdgeInsets.only(left: 16.w, right: 16.w),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceAround,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Expanded(
// child: GestureDetector(
// behavior: HitTestBehavior.opaque,
// onTap: () {},
// child: Container(
// color: Colors.transparent,
// padding: EdgeInsets.all(16),
// child: Column(
// children: [
// Text(
// memberInfor != null
// ? memberInfor.follow.toString()
// : "0",
// style: TextStyle(
// color: Color(0xFF353535),
// fontSize: 16.sp,
// fontWeight:
// MyFontWeight.semi_bold,
// ),
// ),
// SizedBox(
// height: 4.h,
// ),
// Text(
// S.of(context).guanzhu,
// style: TextStyle(
// color: Color(0xFF353535),
// fontSize: 12.sp,
// fontWeight: MyFontWeight.regular,
// ),
// ),
// ],
// )),
// ),
// ),
// Expanded(
// child: GestureDetector(
// behavior: HitTestBehavior.opaque,
// onTap: () {},
// child: Container(
// color: Colors.transparent,
// padding: EdgeInsets.all(16),
// child: Column(
// children: [
// Text(
// memberInfor != null
// ? memberInfor.fans.toString()
// : "0",
// style: TextStyle(
// color: Color(0xFF353535),
// fontSize: 16.sp,
// fontWeight:
// MyFontWeight.semi_bold,
// ),
// ),
// SizedBox(
// height: 4.h,
// ),
// Text(
// S.of(context).fensi,
// style: TextStyle(
// color: Color(0xFF353535),
// fontSize: 12.sp,
// fontWeight: MyFontWeight.regular,
// ),
// ),
// ],
// )),
// ),
// ),
// Expanded(
// child: GestureDetector(
// behavior: HitTestBehavior.opaque,
// onTap: () {},
// child: Container(
// color: Colors.transparent,
// padding: EdgeInsets.all(16),
// child: Column(
// children: [
// Text(
// (memberInfor?.trendTotal ?? 0)
// .toString(),
// style: TextStyle(
// color: Color(0xFF353535),
// fontSize: 16.sp,
// fontWeight:
// MyFontWeight.semi_bold,
// ),
// ),
// SizedBox(
// height: 4.h,
// ),
// Text(
// S.of(context).dongtai,
// style: TextStyle(
// color: Color(0xFF353535),
// fontSize: 12.sp,
// fontWeight: MyFontWeight.regular,
// ),
// ),
// ],
// )),
// ),
// ),
// Expanded(
// child: GestureDetector(
// behavior: HitTestBehavior.opaque,
// onTap: () {},
// child: Container(
// color: Colors.transparent,
// padding: EdgeInsets.all(16),
// child: Column(
// children: [
// Text(
// (memberInfor?.gainLikeTotal ?? 0)
// .toString(),
// style: TextStyle(
// color: Color(0xFF353535),
// fontSize: 16.sp,
// fontWeight:
// MyFontWeight.semi_bold,
// ),
// ),
// SizedBox(
// height: 4.h,
// ),
// Text(
// S.of(context).huozan,
// style: TextStyle(
// color: Color(0xFF353535),
// fontSize: 12.sp,
// fontWeight: MyFontWeight.regular,
// ),
// ),
// ],
// )),
// ),
// ),
// ],
// ),
// ),
// Container(
// margin: EdgeInsets.all(16),
// height: 1.h,
// color: Color(0xFFF7F7F7),
// ),
// Padding(
// padding: EdgeInsets.only(left: 16.w),
// child: Text(
// memberId != "0" ? "TA的动态" : "我的动态",
// style: TextStyle(
// color: Color(0xFF353535),
// fontSize: 15.sp,
// fontWeight: MyFontWeight.semi_bold,
// ),
// )),
// dynamicList(),
// ],
// ),
// ),
],
)),
));
3 years ago
}
///个人信息
Widget homeInfo() {
3 years ago
return Positioned(
3 years ago
top: 0,
3 years ago
bottom: 0,
3 years ago
left: 0,
right: 0,
child: Container(
3 years ago
padding: EdgeInsets.only(
left: 16.w,
right: 16.w,
),
3 years ago
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => PhotoViewGalleryScreen(
images: [
(memberInfor?.headimg ?? "").isEmpty
? "https://i.postimg.cc/Pq6vjfnw/default-1.webp"
3 years ago
: memberInfor?.headimg
], //传入图片list
index: 0, //传入当前点击的图片的index
),
));
},
child: MImage(
memberInfor?.headimg ?? "",
isCircle: true,
width: 66.h,
height: 66.h,
3 years ago
fit: BoxFit.cover,
errorSrc: "assets/image/default_user.webp",
fadeSrc: "assets/image/default_user.webp",
),
3 years ago
),
SizedBox(width: 10.w),
Text(
((memberInfor?.nickname ?? "") == "")
? "回乡"
: memberInfor?.nickname,
3 years ago
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 16.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF353535),
),
),
3 years ago
SizedBox(width: 4.w),
Image.asset(
"assets/image/vip_yk.webp",
width: 20,
height: 20,
),
Spacer(),
if (memberId == "0")
GestureDetector(
onTap: () {
setState(() {
_toUserInfo();
});
},
child: Container(
height: 23.h,
padding: EdgeInsets.only(
left: 6.w, right: 6.w, bottom: 2.h, top: 2.h),
3 years ago
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100),
border: Border.all(
width: 1.w,
3 years ago
color: Color(0xFF353535),
style: BorderStyle.solid,
),
),
child: Text(
S.of(context).bianjigerenziliao,
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF353535),
),
),
),
),
if (memberId != "0")
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
if (memberInfor?.id == sharedPreferences.getString("userId")) {
SmartDialog.showToast("不能跟自己聊天", alignment: Alignment.center);
return;
}
Navigator.of(context)
.pushNamed('/router/chat_details_page',arguments:{
"toUser": ImUser(
avatar: memberInfor?.headimg,
mid: memberInfor?.id,
nickname: memberInfor?.nickname)
});
},
child: Container(
padding:
EdgeInsets.symmetric(horizontal: 16.w, vertical: 3.h),
margin: EdgeInsets.only(right: 8.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100),
border: Border.all(
width: 1,
color: Color(0xFF32A060),
style: BorderStyle.solid,
),
color: Colors.white,
),
child: Text("私信",
style: TextStyle(
fontSize: 12.sp,
color: Color(0xFF32A060),
fontWeight: MyFontWeight.regular,
)),
),
),
if (memberId != "0")
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
setState(() {
if (articles.isNotEmpty)
vipFollow(memberId, articles.first.followed ?? false);
});
},
child: Container(
padding:
EdgeInsets.symmetric(horizontal: 16.w, vertical: 3.5.h),
margin: EdgeInsets.only(right: 8.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100),
color: (articles.isNotEmpty && articles.first.followed ?? false)
? Color(0xFFE6E6E6)
: Color(0xFF32A060),),
child: Text(
(articles.isNotEmpty && articles.first.followed ?? false)
? S.of(context).yiguanzhu
: S.of(context).guanzhu,
style: TextStyle(
fontSize: 12.sp,
color: (articles.isNotEmpty && articles.first.followed ?? false)
? Color(0xFF808080)
: Colors.white,
fontWeight: MyFontWeight.regular,
)),
),
),
3 years ago
],
),
));
3 years ago
}
///个人信息
Widget trendsInfo() {
return Container(
color: Colors.white,
margin: EdgeInsets.only(top: 17.h,left: 16.w,right: 16.w),
child:Column(
children: [
///个人信息
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => PhotoViewGalleryScreen(
images: [
(memberInfor?.headimg ?? "").isEmpty
? "https://i.postimg.cc/Pq6vjfnw/default-1.webp"
: memberInfor?.headimg
], //传入图片list
index: 0, //传入当前点击的图片的index
),
));
},
child: MImage(
memberInfor?.headimg ?? "",
isCircle: true,
width: 69.h,
height: 69.h,
fit: BoxFit.cover,
errorSrc: "assets/image/default_user.webp",
fadeSrc: "assets/image/default_user.webp",
),
),
Expanded(child:Container(padding:EdgeInsets.only(left: 10.w)
,child: Column(
children: [
Row(
children: [
Text(
((memberInfor?.nickname ?? "") == "")
? "回乡"
: memberInfor?.nickname,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 16.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF353535),
),
),
SizedBox(width: 4.w),
Image.asset(
"assets/image/vip_yk.webp",
width: 20,
height: 20,
),
Spacer(),
if (memberId == "0")
GestureDetector(
onTap: () {
setState(() {
_toUserInfo();
});
},
child: Container(
height: 23.h,
padding: EdgeInsets.only(
left: 6.w, right: 6.w, bottom: 2.h, top: 2.h),
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100),
border: Border.all(
width: 1.w,
color: Color(0xFF353535),
style: BorderStyle.solid,
),
),
child: Text(
S.of(context).bianjigerenziliao,
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Color(0xFF353535),
),
),
),
),
],
),
SizedBox(height: 13.h),
Container(
child: GestureDetector(
onTap: () {
setState(() {
isShrink = !isShrink;
});
},
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(
flex: 1,
child: Text(
memberId == "0"
? ((memberInfor?.signature == "")
? "还未编辑个性签名~"
: memberInfor?.signature ?? "")
: "个性签名: ${(memberInfor?.signature == "") ? "还未编辑个性签名~" : memberInfor?.signature ?? ""}",
overflow: isShrink
? TextOverflow.visible
: TextOverflow.ellipsis,
maxLines: isShrink ? 10 : 2,
style: TextStyle(
fontSize: 12.sp,
color: Color(0xFF868686),
fontWeight: MyFontWeight.regular,
height: 1.5.h),
)),
Icon(
(isShrink != null && !isShrink)
? Icons.keyboard_arrow_down
: Icons.keyboard_arrow_up,
color: Colors.black,
size: 18,
),
],
),
)),
],
))),
],
),
///关注,粉丝,动态,获赞,好友数量
Container(
margin: EdgeInsets.only(top:24.h,left:10.w,right:10.w,bottom:19.h),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {},
child: Container(
color: Colors.transparent,
child: Column(
children: [
Text(
memberInfor != null
? memberInfor.follow.toString()
: "0",
style: TextStyle(
color: Color(0xFF353535),
fontSize: 16.sp,
fontWeight:
MyFontWeight.semi_bold,
),
),
SizedBox(
height: 4.h,
),
Text(
S.of(context).guanzhu,
style: TextStyle(
color: Color(0xFF353535),
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
),
),
],
)),
),
),
SizedBox(width:56.w,),
Expanded(
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {},
child: Container(
color: Colors.transparent,
child: Column(
children: [
Text(
memberInfor != null
? memberInfor.fans.toString()
: "0",
style: TextStyle(
color: Color(0xFF353535),
fontSize: 16.sp,
fontWeight:
MyFontWeight.semi_bold,
),
),
SizedBox(
height: 4.h,
),
Text(
S.of(context).fensi,
style: TextStyle(
color: Color(0xFF353535),
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
),
),
],
)),
),
),
SizedBox(width:47.w,),
Expanded(
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {},
child: Container(
color: Colors.transparent,
child: Column(
children: [
Text(
(memberInfor?.trendTotal ?? 0)
.toString(),
style: TextStyle(
color: Color(0xFF353535),
fontSize: 16.sp,
fontWeight:
MyFontWeight.semi_bold,
),
),
SizedBox(
height: 4.h,
),
Text(
S.of(context).dongtai,
style: TextStyle(
color: Color(0xFF353535),
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
),
),
],
)),
),
),
SizedBox(width:44.w,),
Expanded(
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {},
child: Container(
color: Colors.transparent,
child: Column(
children: [
Text(
(memberInfor?.gainLikeTotal ?? 0)
.toString(),
style: TextStyle(
color: Color(0xFF353535),
fontSize: 16.sp,
fontWeight:
MyFontWeight.semi_bold,
),
),
SizedBox(
height: 4.h,
),
Text(
S.of(context).huozan,
style: TextStyle(
color: Color(0xFF353535),
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
),
),
],
)),
),
),
SizedBox(width:50.w,),
Expanded(
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {},
child: Container(
color: Colors.transparent,
child: Column(
children: [
Text(
(memberInfor?.gainLikeTotal ?? 0)
.toString(),
style: TextStyle(
color: Color(0xFF353535),
fontSize: 16.sp,
fontWeight:
MyFontWeight.semi_bold,
),
),
SizedBox(
height: 4.h,
),
Text(
S.of(context).haoyou,
style: TextStyle(
color: Color(0xFF353535),
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
),
),
],
)),
),
),
],
),
),
Container(
height: 1.h,
color:Color(0xFFF7F7F7),
margin:EdgeInsets.only(bottom:15.h),
),
///关注,聊天按钮
if (memberId != "0")
Row(
children: [
Expanded(child:GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
},
child: Container(
// padding: EdgeInsets.symmetric(vertical:12.h),
height:41.h,
margin: EdgeInsets.only(right: 8.w,left: 4),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.5),
color: (articles.isNotEmpty && articles.first.followed ?? false)
? Color(0xFFE6E6E6)
: Color(0xFF32A060)
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
(articles.isNotEmpty && articles.first.followed ?? false)
? Icons.check
: Icons.add,
color: (articles.isNotEmpty && articles.first.followed ?? false)
? Color(0xFF808080)
: Colors.white,
size: 18.sp,
),
SizedBox(width:5,),
Text(
(articles.isNotEmpty && articles.first.followed ?? false)
? S.of(context).yiguanzhu
: S.of(context).guanzhu,
style: TextStyle(
fontSize: 12.sp,
color: (articles.isNotEmpty && articles.first.followed ?? false)
? Color(0xFF808080)
: Colors.white,
fontWeight: MyFontWeight.regular,
)),
],
),
),
)),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
if (memberInfor?.id == sharedPreferences.getString("userId")) {
SmartDialog.showToast("不能跟自己聊天", alignment: Alignment.center);
return;
}
if(widget.arguments["inletType"] == 1){
//聊天框跳转到该页面inletType = 1,别的页面都是0,为了避免打开多个聊天框bug;
Navigator.of(context).pop();
}else{
Navigator.of(context)
.pushNamed('/router/chat_details_page', arguments: {
"toUser": ImUser(
avatar: memberInfor?.headimg,
mid: memberInfor?.id,
nickname: memberInfor?.nickname)
},);
}
},
child: Container(
width:110.w,
height:41.h,
margin: EdgeInsets.only(right:1.w),
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.5),
color: Color(0xFFFF9640)
),
child: Text(
"聊一聊",
style: TextStyle(
fontSize: 13.sp,
color: Colors.white,
fontWeight: MyFontWeight.regular,
)),
),
)
],
),
],
),
);
}
///动态
Widget dynamicList() {
return Container(
3 years ago
child: (articles == null || articles.length == 0)
? NoDataView(
src: "assets/image/dong_tai.webp",
isShowBtn: false,
text: "目前暂无发布动态,要把开心的事讲出来哦~",
fontSize: 16.sp,
margin: EdgeInsets.only(left: 60.w, right: 60.w, bottom: 80.h),
3 years ago
)
: ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, position) {
return InkWell(
child: CommunityDynamic(
articles[position],
memberId == "0" ? 1 : 3,
3 years ago
exitFull: () {
setState(() {
_onRefresh();
});
3 years ago
},
removalDynamic: () {
setState(() {
_onRefresh();
});
},
),
onTap: () {
Navigator.of(context).pushNamed(
'/router/community_details',
arguments: {
"businessId": articles[position].id,
"userId": userId,
},
).then((value) {
queryCommunity(articles[position].id);
});
},
);
},
3 years ago
itemCount: articles.length,
),
);
}
3 years ago
}