fix: 未登录访问up主页异常
This commit is contained in:
@ -290,7 +290,7 @@ class _MemberPageState extends State<MemberPage>
|
|||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
profile(_memberController),
|
ProfilePanel(ctr: _memberController),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
@ -388,7 +388,7 @@ class _MemberPageState extends State<MemberPage>
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 骨架屏
|
// 骨架屏
|
||||||
return profile(_memberController, loadingStatus: true);
|
return ProfilePanel(ctr: _memberController, loadingStatus: true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@ -6,126 +6,162 @@ import 'package:pilipala/models/live/item.dart';
|
|||||||
import 'package:pilipala/models/member/info.dart';
|
import 'package:pilipala/models/member/info.dart';
|
||||||
import 'package:pilipala/utils/utils.dart';
|
import 'package:pilipala/utils/utils.dart';
|
||||||
|
|
||||||
Widget profile(ctr, {loadingStatus = false}) {
|
class ProfilePanel extends StatelessWidget {
|
||||||
MemberInfoModel memberInfo = ctr.memberInfo.value;
|
final dynamic ctr;
|
||||||
return Builder(
|
final bool loadingStatus;
|
||||||
builder: ((context) {
|
const ProfilePanel({
|
||||||
return Padding(
|
super.key,
|
||||||
padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top - 20),
|
required this.ctr,
|
||||||
child: Row(
|
this.loadingStatus = false,
|
||||||
children: [
|
});
|
||||||
Hero(
|
|
||||||
tag: ctr.heroTag!,
|
@override
|
||||||
child: Stack(
|
Widget build(BuildContext context) {
|
||||||
children: [
|
MemberInfoModel memberInfo = ctr.memberInfo.value;
|
||||||
NetworkImgLayer(
|
return Builder(
|
||||||
width: 90,
|
builder: ((context) {
|
||||||
height: 90,
|
return Padding(
|
||||||
type: 'avatar',
|
padding:
|
||||||
src: !loadingStatus ? memberInfo.face : ctr.face.value,
|
EdgeInsets.only(top: MediaQuery.of(context).padding.top - 20),
|
||||||
),
|
child: Row(
|
||||||
if (!loadingStatus &&
|
children: [
|
||||||
memberInfo.liveRoom != null &&
|
Hero(
|
||||||
memberInfo.liveRoom!.liveStatus == 1)
|
tag: ctr.heroTag!,
|
||||||
Positioned(
|
child: Stack(
|
||||||
bottom: 0,
|
children: [
|
||||||
left: 14,
|
NetworkImgLayer(
|
||||||
child: GestureDetector(
|
width: 90,
|
||||||
onTap: () {
|
height: 90,
|
||||||
LiveItemModel liveItem = LiveItemModel.fromJson({
|
type: 'avatar',
|
||||||
'title': memberInfo.liveRoom!.title,
|
src: !loadingStatus ? memberInfo.face : ctr.face.value,
|
||||||
'uname': memberInfo.name,
|
),
|
||||||
'face': memberInfo.face,
|
if (!loadingStatus &&
|
||||||
'roomid': memberInfo.liveRoom!.roomId,
|
memberInfo.liveRoom != null &&
|
||||||
'watched_show': memberInfo.liveRoom!.watchedShow,
|
memberInfo.liveRoom!.liveStatus == 1)
|
||||||
});
|
Positioned(
|
||||||
Get.toNamed(
|
bottom: 0,
|
||||||
'/liveRoom?roomid=${memberInfo.liveRoom!.roomId}',
|
left: 14,
|
||||||
arguments: {'liveItem': liveItem},
|
child: GestureDetector(
|
||||||
);
|
|
||||||
},
|
|
||||||
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),
|
|
||||||
)
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
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: () {
|
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(
|
Get.toNamed(
|
||||||
'/follow?mid=${memberInfo.mid}&name=${memberInfo.name}');
|
'/liveRoom?roomid=${memberInfo.liveRoom!.roomId}',
|
||||||
|
arguments: {'liveItem': liveItem},
|
||||||
|
);
|
||||||
},
|
},
|
||||||
child: Column(
|
child: Container(
|
||||||
children: [
|
padding: const EdgeInsets.fromLTRB(6, 2, 6, 2),
|
||||||
Text(
|
decoration: BoxDecoration(
|
||||||
!loadingStatus
|
color: Theme.of(context).colorScheme.primary,
|
||||||
? ctr.userStat!['following'].toString()
|
borderRadius:
|
||||||
: '-',
|
const BorderRadius.all(Radius.circular(10)),
|
||||||
style: const TextStyle(
|
),
|
||||||
fontWeight: FontWeight.bold),
|
child: Row(children: [
|
||||||
|
Image.asset(
|
||||||
|
'assets/images/live.gif',
|
||||||
|
height: 10,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'关注',
|
' 直播中',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
fontSize: Theme.of(context)
|
fontSize: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
.labelMedium!
|
.labelSmall!
|
||||||
.fontSize),
|
.fontSize),
|
||||||
)
|
)
|
||||||
],
|
]),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
InkWell(
|
)
|
||||||
onTap: () {
|
],
|
||||||
Get.toNamed(
|
),
|
||||||
'/fan?mid=${memberInfo.mid}&name=${memberInfo.name}');
|
),
|
||||||
},
|
const SizedBox(width: 12),
|
||||||
child: Column(
|
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),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
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: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
!loadingStatus
|
!loadingStatus
|
||||||
? Utils.numFormat(
|
? ctr.userStat!['likes'] != null
|
||||||
ctr.userStat!['follower'],
|
? Utils.numFormat(
|
||||||
)
|
ctr.userStat!['likes'],
|
||||||
|
)
|
||||||
|
: '-'
|
||||||
: '-',
|
: '-',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontWeight: FontWeight.bold)),
|
fontWeight: FontWeight.bold)),
|
||||||
Text(
|
Text(
|
||||||
'粉丝',
|
'获赞',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: Theme.of(context)
|
fontSize: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
@ -134,92 +170,89 @@ Widget profile(ctr, {loadingStatus = false}) {
|
|||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
Column(
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
!loadingStatus
|
|
||||||
? Utils.numFormat(
|
|
||||||
ctr.userStat!['likes'],
|
|
||||||
)
|
|
||||||
: '-',
|
|
||||||
style: const TextStyle(
|
|
||||||
fontWeight: FontWeight.bold)),
|
|
||||||
Text(
|
|
||||||
'获赞',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.labelMedium!
|
|
||||||
.fontSize),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
if (ctr.ownerMid != ctr.mid) ...[
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Obx(
|
|
||||||
() => Expanded(
|
|
||||||
child: TextButton(
|
|
||||||
onPressed: () => 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: () {},
|
|
||||||
style: TextButton.styleFrom(
|
|
||||||
backgroundColor: Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.onInverseSurface,
|
|
||||||
),
|
|
||||||
child: const Text('发消息'),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
)
|
|
||||||
] else ...[
|
|
||||||
TextButton(
|
|
||||||
onPressed: () {
|
|
||||||
SmartDialog.showToast('功能开发中 💪');
|
|
||||||
},
|
|
||||||
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('编辑资料'),
|
),
|
||||||
)
|
const SizedBox(height: 10),
|
||||||
]
|
if (ctr.ownerMid != ctr.mid && ctr.ownerMid != -1) ...[
|
||||||
],
|
Row(
|
||||||
|
children: [
|
||||||
|
Obx(
|
||||||
|
() => Expanded(
|
||||||
|
child: TextButton(
|
||||||
|
onPressed: () => 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: () {},
|
||||||
|
style: TextButton.styleFrom(
|
||||||
|
backgroundColor: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.onInverseSurface,
|
||||||
|
),
|
||||||
|
child: const Text('发消息'),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
if (ctr.ownerMid == ctr.mid && ctr.ownerMid != -1) ...[
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
SmartDialog.showToast('功能开发中 💪');
|
||||||
|
},
|
||||||
|
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('未登录'),
|
||||||
|
)
|
||||||
|
]
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
);
|
||||||
);
|
}),
|
||||||
}),
|
);
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user