Merge branch 'main' into feature-minePage
This commit is contained in:
@ -17,253 +17,245 @@ class ProfilePanel extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
MemberInfoModel memberInfo = ctr.memberInfo.value;
|
||||
return Builder(
|
||||
builder: ((context) {
|
||||
return Padding(
|
||||
padding:
|
||||
EdgeInsets.only(top: MediaQuery.of(context).padding.top - 20),
|
||||
child: Row(
|
||||
children: [
|
||||
Hero(
|
||||
tag: ctr.heroTag!,
|
||||
child: Stack(
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
width: 90,
|
||||
height: 90,
|
||||
type: 'avatar',
|
||||
src: !loadingStatus ? memberInfo.face : ctr.face.value,
|
||||
),
|
||||
if (!loadingStatus &&
|
||||
memberInfo.liveRoom != null &&
|
||||
memberInfo.liveRoom!.liveStatus == 1)
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
left: 14,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
LiveItemModel liveItem = LiveItemModel.fromJson({
|
||||
'title': memberInfo.liveRoom!.title,
|
||||
'uname': memberInfo.name,
|
||||
'face': memberInfo.face,
|
||||
'roomid': memberInfo.liveRoom!.roomId,
|
||||
'watched_show': memberInfo.liveRoom!.watchedShow,
|
||||
});
|
||||
Get.toNamed(
|
||||
'/liveRoom?roomid=${memberInfo.liveRoom!.roomId}',
|
||||
arguments: {'liveItem': liveItem},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.fromLTRB(6, 2, 6, 2),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(10)),
|
||||
),
|
||||
child: Row(children: [
|
||||
Image.asset(
|
||||
'assets/images/live.gif',
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
' 直播中',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
.labelSmall!
|
||||
.fontSize),
|
||||
)
|
||||
]),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
final int? mid = memberInfo.mid;
|
||||
final String? name = memberInfo.name;
|
||||
|
||||
Map<String, dynamic> buildStatItem({
|
||||
required String label,
|
||||
required String value,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
return {
|
||||
'label': label,
|
||||
'value': value,
|
||||
'fn': onTap,
|
||||
};
|
||||
}
|
||||
|
||||
final List<Map<String, dynamic>> statList = [
|
||||
buildStatItem(
|
||||
label: '关注',
|
||||
value: !loadingStatus ? "${ctr.userStat!['following']}" : '-',
|
||||
onTap: () {
|
||||
Get.toNamed('/follow?mid=$mid&name=$name');
|
||||
},
|
||||
),
|
||||
buildStatItem(
|
||||
label: '粉丝',
|
||||
value: !loadingStatus
|
||||
? ctr.userStat!['follower'] != null
|
||||
? Utils.numFormat(ctr.userStat!['follower'])
|
||||
: '-'
|
||||
: '-',
|
||||
onTap: () {
|
||||
Get.toNamed('/fan?mid=$mid&name=$name');
|
||||
},
|
||||
),
|
||||
buildStatItem(
|
||||
label: '获赞',
|
||||
value: !loadingStatus
|
||||
? ctr.userStat!['likes'] != null
|
||||
? Utils.numFormat(ctr.userStat!['likes'])
|
||||
: '-'
|
||||
: '-',
|
||||
onTap: () {},
|
||||
),
|
||||
];
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 30, left: 4),
|
||||
child: Row(
|
||||
children: [
|
||||
Hero(
|
||||
tag: ctr.heroTag!,
|
||||
child: Stack(
|
||||
children: [
|
||||
NetworkImgLayer(
|
||||
width: 90,
|
||||
height: 90,
|
||||
type: 'avatar',
|
||||
src: !loadingStatus ? memberInfo.face : ctr.face.value,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(top: 10, left: 10, right: 10),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Get.toNamed(
|
||||
'/follow?mid=${memberInfo.mid}&name=${memberInfo.name}');
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
!loadingStatus
|
||||
? ctr.userStat!['following'].toString()
|
||||
: '-',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(
|
||||
'关注',
|
||||
style: TextStyle(
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
.labelMedium!
|
||||
.fontSize),
|
||||
)
|
||||
],
|
||||
),
|
||||
if (!loadingStatus &&
|
||||
memberInfo.liveRoom != null &&
|
||||
memberInfo.liveRoom!.liveStatus == 1)
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
left: 14,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
LiveItemModel liveItem = LiveItemModel(
|
||||
title: memberInfo.liveRoom!.title,
|
||||
uname: memberInfo.name,
|
||||
face: memberInfo.face,
|
||||
roomId: memberInfo.liveRoom!.roomId,
|
||||
watchedShow: memberInfo.liveRoom!.watchedShow,
|
||||
);
|
||||
Get.toNamed(
|
||||
'/liveRoom?roomid=${memberInfo.liveRoom!.roomId}',
|
||||
arguments: {'liveItem': liveItem},
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.fromLTRB(6, 2, 6, 2),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
borderRadius:
|
||||
const BorderRadius.all(Radius.circular(10)),
|
||||
),
|
||||
child: Row(children: [
|
||||
Image.asset(
|
||||
'assets/images/live.gif',
|
||||
height: 10,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Get.toNamed(
|
||||
'/fan?mid=${memberInfo.mid}&name=${memberInfo.name}');
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
!loadingStatus
|
||||
? ctr.userStat!['follower'] != null
|
||||
? Utils.numFormat(
|
||||
ctr.userStat!['follower'],
|
||||
)
|
||||
: '-'
|
||||
: '-',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold)),
|
||||
Text(
|
||||
'粉丝',
|
||||
style: TextStyle(
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
.labelMedium!
|
||||
.fontSize),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
Text(
|
||||
!loadingStatus
|
||||
? ctr.userStat!['likes'] != null
|
||||
? Utils.numFormat(
|
||||
ctr.userStat!['likes'],
|
||||
)
|
||||
: '-'
|
||||
: '-',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold)),
|
||||
Text(
|
||||
'获赞',
|
||||
style: TextStyle(
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
.labelMedium!
|
||||
.fontSize),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
Text(
|
||||
' 直播中',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: Theme.of(context)
|
||||
.textTheme
|
||||
.labelSmall!
|
||||
.fontSize),
|
||||
)
|
||||
]),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
if (ctr.ownerMid != ctr.mid && ctr.ownerMid != -1) ...[
|
||||
Row(
|
||||
children: [
|
||||
Obx(
|
||||
() => Expanded(
|
||||
child: TextButton(
|
||||
onPressed: () => loadingStatus
|
||||
? null
|
||||
: ctr.actionRelationMod(),
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: ctr.attribute.value == -1
|
||||
? Colors.transparent
|
||||
: ctr.attribute.value != 0
|
||||
? Theme.of(context)
|
||||
.colorScheme
|
||||
.outline
|
||||
: Theme.of(context)
|
||||
.colorScheme
|
||||
.onPrimary,
|
||||
backgroundColor: ctr.attribute.value != 0
|
||||
? Theme.of(context)
|
||||
.colorScheme
|
||||
.onInverseSurface
|
||||
: Theme.of(context)
|
||||
.colorScheme
|
||||
.primary, // 设置按钮背景色
|
||||
),
|
||||
child: Obx(() => Text(ctr.attributeText.value)),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
Get.toNamed(
|
||||
'/whisperDetail',
|
||||
parameters: {
|
||||
'name': memberInfo.name!,
|
||||
'face': memberInfo.face!,
|
||||
'mid': memberInfo.mid.toString(),
|
||||
'heroTag': ctr.heroTag!,
|
||||
},
|
||||
);
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: Theme.of(context)
|
||||
.colorScheme
|
||||
.onInverseSurface,
|
||||
),
|
||||
child: const Text('发消息'),
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
if (ctr.ownerMid == ctr.mid && ctr.ownerMid != -1) ...[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Get.toNamed('/mineEdit');
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
padding: const EdgeInsets.only(left: 80, right: 80),
|
||||
foregroundColor:
|
||||
Theme.of(context).colorScheme.onPrimary,
|
||||
backgroundColor:
|
||||
Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
child: const Text('编辑资料'),
|
||||
)
|
||||
],
|
||||
if (ctr.ownerMid == -1) ...[
|
||||
TextButton(
|
||||
onPressed: () {},
|
||||
style: TextButton.styleFrom(
|
||||
padding: const EdgeInsets.only(left: 80, right: 80),
|
||||
foregroundColor:
|
||||
Theme.of(context).colorScheme.outline,
|
||||
backgroundColor:
|
||||
Theme.of(context).colorScheme.onInverseSurface,
|
||||
),
|
||||
child: const Text('未登录'),
|
||||
)
|
||||
]
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: statList.map((item) {
|
||||
return buildStatColumn(
|
||||
context,
|
||||
item['label'],
|
||||
item['value'],
|
||||
item['fn'],
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
if (ctr.ownerMid != ctr.mid && ctr.ownerMid != -1)
|
||||
buildActionButtons(context, ctr, memberInfo),
|
||||
if (ctr.ownerMid == ctr.mid && ctr.ownerMid != -1)
|
||||
buildEditProfileButton(context),
|
||||
if (ctr.ownerMid == -1) buildNotLoggedInButton(context),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildStatColumn(
|
||||
BuildContext context,
|
||||
String label,
|
||||
String value,
|
||||
VoidCallback? onTap,
|
||||
) {
|
||||
return InkWell(
|
||||
onTap: onTap,
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
value,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
|
||||
),
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: Theme.of(context).textTheme.labelMedium!.fontSize,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildActionButtons(
|
||||
BuildContext context,
|
||||
dynamic ctr,
|
||||
MemberInfoModel memberInfo,
|
||||
) {
|
||||
ColorScheme colorScheme = Theme.of(context).colorScheme;
|
||||
return Row(
|
||||
children: [
|
||||
const SizedBox(width: 20),
|
||||
Obx(
|
||||
() => Expanded(
|
||||
child: TextButton(
|
||||
onPressed: () => loadingStatus ? null : ctr.actionRelationMod(),
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: ctr.attribute.value == -1
|
||||
? Colors.transparent
|
||||
: ctr.attribute.value != 0
|
||||
? colorScheme.outline
|
||||
: colorScheme.onPrimary,
|
||||
backgroundColor: ctr.attribute.value != 0
|
||||
? colorScheme.onInverseSurface
|
||||
: colorScheme.primary,
|
||||
),
|
||||
child: Obx(() => Text(ctr.attributeText.value)),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
Get.toNamed(
|
||||
'/whisperDetail',
|
||||
parameters: {
|
||||
'name': memberInfo.name!,
|
||||
'face': memberInfo.face!,
|
||||
'mid': memberInfo.mid.toString(),
|
||||
'heroTag': ctr.heroTag!,
|
||||
},
|
||||
);
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: colorScheme.onInverseSurface,
|
||||
),
|
||||
child: const Text('发消息'),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildEditProfileButton(BuildContext context) {
|
||||
return TextButton(
|
||||
onPressed: () {
|
||||
Get.toNamed('/mineEdit');
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 80),
|
||||
foregroundColor: Theme.of(context).colorScheme.onPrimary,
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
child: const Text('编辑资料'),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildNotLoggedInButton(BuildContext context) {
|
||||
return TextButton(
|
||||
onPressed: () {},
|
||||
style: TextButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 80),
|
||||
foregroundColor: Theme.of(context).colorScheme.outline,
|
||||
backgroundColor: Theme.of(context).colorScheme.onInverseSurface,
|
||||
),
|
||||
child: const Text('未登录'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user