462 lines
18 KiB
Dart
462 lines
18 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:aiplot/network/NetworkConfig.dart';
|
|
import 'package:cached_network_image/cached_network_image.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
|
|
|
import '../../bean/user_center_bean.dart';
|
|
import '../../bean/works_info_bean.dart';
|
|
import '../../bean/works_list_bean.dart';
|
|
import '../../generated/l10n.dart';
|
|
import 'draw_details_model.dart';
|
|
import 'influential_details_page2.dart';
|
|
|
|
///达人用户详情
|
|
class ExpertUserDetailsPage extends StatefulWidget {
|
|
String workUserId;
|
|
String worksID;
|
|
|
|
ExpertUserDetailsPage({super.key, required this.workUserId, required this.worksID});
|
|
|
|
@override
|
|
State<ExpertUserDetailsPage> createState() => _ExpertUserDetailsPageState();
|
|
}
|
|
|
|
class _ExpertUserDetailsPageState extends State<ExpertUserDetailsPage> {
|
|
StreamSubscription? subscription;
|
|
final DrawDetailsModel _viewModel = DrawDetailsModel();
|
|
|
|
UserCenterBean? userCenterBean;
|
|
List<WorksInfoBean> workList = [];
|
|
int sortType = 0;
|
|
int worksIndex = 0;
|
|
int workId = 0;
|
|
|
|
Future getWorksInfo() async {
|
|
EasyLoading.show(status: 'loading...');
|
|
_viewModel.getWorksInfo(widget.workUserId, "$workId", "$sortType");
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
// TODO: implement initState
|
|
super.initState();
|
|
subscription = _viewModel.streamController.stream.listen((newData) {
|
|
String code = newData['code'];
|
|
if (code.isNotEmpty) {
|
|
EasyLoading.dismiss();
|
|
switch (code) {
|
|
case "getUserPersonalCenter":
|
|
userCenterBean = newData['data'];
|
|
workId = userCenterBean!.WorksList![0].WorkId!;
|
|
break;
|
|
case "getWorksInfo":
|
|
workList = newData['data'];
|
|
NetworkConfig.workList = workList;
|
|
break;
|
|
case "userFollow":
|
|
userCenterBean?.IsFollow = newData['data'];
|
|
EasyLoading.showToast(newData['message']);
|
|
break;
|
|
default:
|
|
// EasyLoading.showToast(newData['data']);
|
|
break;
|
|
}
|
|
setState(() {});
|
|
}
|
|
});
|
|
EasyLoading.show(status: 'loading...');
|
|
_viewModel.getUserPersonalCenter(widget.workUserId, widget.worksID);
|
|
getWorksInfo();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
// TODO: implement dispose
|
|
subscription?.cancel();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final size = MediaQuery.of(context).size;
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
backgroundColor: Colors.white,
|
|
title: Text(
|
|
S.of(context).User_details,
|
|
style: const TextStyle(color: Colors.black),
|
|
),
|
|
centerTitle: true,
|
|
iconTheme: const IconThemeData(color: Colors.black),
|
|
elevation: 0,
|
|
leading: IconButton(
|
|
icon: const Icon(Icons.arrow_back_ios_new),
|
|
onPressed: () {
|
|
Navigator.pop(context);
|
|
},
|
|
),
|
|
),
|
|
body: SingleChildScrollView(
|
|
child: userCenterBean != null
|
|
? Stack(
|
|
children: [
|
|
Column(
|
|
children: [
|
|
SizedBox(
|
|
width: size.width,
|
|
height: 70,
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Positioned(
|
|
left: 16,
|
|
child: ClipOval(
|
|
child: CachedNetworkImage(
|
|
width: 60,
|
|
height: 60,
|
|
imageUrl: userCenterBean!.UserIconUrl!,
|
|
errorWidget: (context, url, error) => const Icon(Icons.error),
|
|
),
|
|
),
|
|
),
|
|
Positioned(
|
|
top: 10,
|
|
left: 84,
|
|
child: SizedBox(
|
|
width: 180,
|
|
child: Text(
|
|
"${userCenterBean!.NickName}",
|
|
overflow: TextOverflow.ellipsis,
|
|
style: const TextStyle(fontSize: 18),
|
|
),
|
|
),
|
|
),
|
|
Positioned(
|
|
bottom: 10,
|
|
left: 84,
|
|
child: Row(
|
|
children: [
|
|
RichText(
|
|
text: TextSpan(children: [
|
|
TextSpan(
|
|
text: S.of(context).Liked,
|
|
style: const TextStyle(color: Color(0xFF999999), fontSize: 13),
|
|
),
|
|
TextSpan(
|
|
text: " ${userCenterBean!.LikeNum}",
|
|
style: const TextStyle(color: Colors.black, fontSize: 14),
|
|
),
|
|
]),
|
|
),
|
|
Container(
|
|
margin: const EdgeInsets.only(left: 20),
|
|
child: RichText(
|
|
text: TextSpan(children: [
|
|
TextSpan(
|
|
text: S.of(context).Fans,
|
|
style: const TextStyle(color: Color(0xFF999999), fontSize: 13),
|
|
),
|
|
TextSpan(
|
|
text: " ${userCenterBean!.FansNum}",
|
|
style: const TextStyle(color: Colors.black, fontSize: 14),
|
|
),
|
|
]),
|
|
),
|
|
),
|
|
],
|
|
)),
|
|
|
|
///关注
|
|
NetworkConfig.userId != "${userCenterBean!.UserId}"
|
|
? Positioned(
|
|
right: 20,
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
_viewModel.userFollow("${userCenterBean!.UserId}");
|
|
},
|
|
child: !userCenterBean!.IsFollow!
|
|
? Container(
|
|
width: 65,
|
|
height: 24,
|
|
alignment: Alignment.center,
|
|
decoration:
|
|
const BoxDecoration(color: Color(0xFF8841FF), borderRadius: BorderRadius.all(Radius.circular(12))),
|
|
child: Text(
|
|
"+${S.of(context).follow}",
|
|
style: const TextStyle(color: Colors.white, fontSize: 12),
|
|
),
|
|
)
|
|
: Container(
|
|
width: 62,
|
|
height: 24,
|
|
alignment: Alignment.center,
|
|
decoration:
|
|
const BoxDecoration(color: Color(0xFFC3C3C3), borderRadius: BorderRadius.all(Radius.circular(12))),
|
|
child: Text(
|
|
S.of(context).Followed,
|
|
style: const TextStyle(color: Colors.white, fontSize: 12),
|
|
),
|
|
),
|
|
))
|
|
: Container(),
|
|
],
|
|
),
|
|
),
|
|
|
|
///日期排序 //获赞排序
|
|
Container(
|
|
margin: EdgeInsets.only(left: 16, top: 20),
|
|
child: Row(
|
|
children: [
|
|
GestureDetector(
|
|
onTap: () {
|
|
sortType = 0;
|
|
getWorksInfo();
|
|
setState(() {});
|
|
},
|
|
child: Column(
|
|
children: [
|
|
Text(
|
|
S.of(context).Date_sort,
|
|
style: TextStyle(color: Color(sortType == 0 ? 0xFF8841FF : 0xFFA3A3A3)),
|
|
),
|
|
sortType == 0
|
|
? Container(
|
|
width: 59,
|
|
height: 2,
|
|
color: const Color(0xFF8841FF),
|
|
)
|
|
: Container(
|
|
height: 2,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
GestureDetector(
|
|
onTap: () {
|
|
sortType = 1;
|
|
getWorksInfo();
|
|
setState(() {});
|
|
},
|
|
child: Container(
|
|
margin: const EdgeInsets.only(left: 18),
|
|
child: Column(
|
|
children: [
|
|
Text(
|
|
S.of(context).Like_sorting,
|
|
style: TextStyle(color: Color(sortType == 1 ? 0xFF8841FF : 0xFFA3A3A3)),
|
|
),
|
|
sortType == 1
|
|
? Container(
|
|
width: 59,
|
|
height: 2,
|
|
color: const Color(0xFF8841FF),
|
|
)
|
|
: Container(
|
|
height: 2,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
|
|
///标签列表
|
|
userCenterBean!.WorksList != null && userCenterBean!.WorksList!.isNotEmpty
|
|
? Container(
|
|
width: size.width,
|
|
height: 24,
|
|
margin: const EdgeInsets.only(left: 16, top: 21),
|
|
child: ListView.builder(
|
|
itemCount: userCenterBean!.WorksList?.length,
|
|
itemBuilder: (context, index) {
|
|
return _worksItem(userCenterBean!.WorksList![index], index);
|
|
},
|
|
scrollDirection: Axis.horizontal),
|
|
)
|
|
: Container(),
|
|
|
|
///列表
|
|
Container(
|
|
margin: const EdgeInsets.only(top: 16, right: 16, left: 16),
|
|
child: MasonryGridView.count(
|
|
crossAxisCount: 2,
|
|
itemCount: workList.length,
|
|
itemBuilder: (BuildContext context, int index) {
|
|
return _galleryItem(workList[index], index);
|
|
},
|
|
shrinkWrap: true,
|
|
// 纵向元素间距
|
|
mainAxisSpacing: 0,
|
|
// 横向元素间距
|
|
crossAxisSpacing: 10,
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
)
|
|
: Container(),
|
|
),
|
|
);
|
|
}
|
|
|
|
_worksItem(WorksListBean data, index) {
|
|
return GestureDetector(
|
|
onTap: () {
|
|
worksIndex = index;
|
|
workId = data.WorkId!;
|
|
getWorksInfo();
|
|
setState(() {});
|
|
},
|
|
child: Container(
|
|
height: 24,
|
|
margin: const EdgeInsets.only(right: 5),
|
|
padding: const EdgeInsets.only(left: 7, right: 7),
|
|
decoration: BoxDecoration(
|
|
border: Border.all(color: worksIndex == index ? Colors.black : const Color(0xFFC4C4C4), width: 1),
|
|
borderRadius: const BorderRadius.all(Radius.circular(3))),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Image(
|
|
width: 13,
|
|
height: 9,
|
|
image: AssetImage(worksIndex == index ? 'assets/images/ic_works.png' : 'assets/images/ic_works_f.png'),
|
|
),
|
|
Container(
|
|
margin: const EdgeInsets.only(left: 5),
|
|
child: Text(
|
|
'${data.WorkName}',
|
|
style: TextStyle(fontSize: 12, color: Color(worksIndex == index ? 0xFF000000 : 0xFFC4C4C4)),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
//画列表
|
|
_galleryItem(WorksInfoBean bean, int index) {
|
|
return GestureDetector(
|
|
onTap: () {},
|
|
child: Column(
|
|
children: [
|
|
///Ai图
|
|
ClipRRect(
|
|
borderRadius: BorderRadius.circular(7),
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => InfluentialDetailsPage2(bean.DrawId.toString()),
|
|
));
|
|
},
|
|
child: Stack(
|
|
children: [
|
|
CachedNetworkImage(
|
|
imageUrl: bean.TaskResult,
|
|
errorWidget: (context, url, error) => const Icon(Icons.error),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
|
|
Container(
|
|
height: 25,
|
|
margin: const EdgeInsets.only(bottom: 10),
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
///头像
|
|
Positioned(
|
|
left: 0,
|
|
child: ClipOval(
|
|
child: CachedNetworkImage(
|
|
fit: BoxFit.fitHeight,
|
|
width: 18,
|
|
height: 18,
|
|
imageUrl: bean.UserIocn,
|
|
errorWidget: (context, url, error) => const Image(
|
|
fit: BoxFit.fitWidth,
|
|
width: 18,
|
|
height: 18,
|
|
image: AssetImage('assets/images/head.png'),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Positioned(
|
|
left: 23,
|
|
child: Container(
|
|
width: 80,
|
|
child: Text(
|
|
bean.UserNickName,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: const TextStyle(color: Colors.black, fontSize: 12),
|
|
),
|
|
),
|
|
),
|
|
|
|
///点赞收藏
|
|
Positioned(
|
|
right: 0,
|
|
child: GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: () {
|
|
if (NetworkConfig.userId == "${bean.UserId}") {
|
|
return;
|
|
}
|
|
|
|
bean.IsMyLike = !bean.IsMyLike;
|
|
if (bean.IsMyLike) {
|
|
bean.LikeNum = (bean.LikeNum + 1);
|
|
} else {
|
|
if (bean.LikeNum > 0) {
|
|
bean.LikeNum = (bean.LikeNum - 1);
|
|
}
|
|
}
|
|
setState(() {});
|
|
_viewModel.userDrawCollect(bean.IsMyLike, bean.DrawId.toString());
|
|
},
|
|
child: Container(
|
|
padding: EdgeInsets.all(15),
|
|
child: Row(
|
|
children: [
|
|
Image(
|
|
width: 13,
|
|
height: 12,
|
|
image: bean.IsMyLike
|
|
? const AssetImage('assets/images/ic_collect_s.png')
|
|
: const AssetImage('assets/images/ic_collect.png'),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(left: 5),
|
|
child: Text(
|
|
bean.LikeNum.toString(),
|
|
style: TextStyle(color: bean.IsMyLike ? Color(0xFFBB72E0) : Colors.black, fontSize: 12),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
)),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|