fix: 未登录访问up主页异常

This commit is contained in:
guozhigq
2023-12-20 00:34:26 +08:00
parent 7f7154bba4
commit d9859755e3
2 changed files with 222 additions and 189 deletions

View File

@ -290,7 +290,7 @@ class _MemberPageState extends State<MemberPage>
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
profile(_memberController),
ProfilePanel(ctr: _memberController),
const SizedBox(height: 20),
Row(
children: [
@ -388,7 +388,7 @@ class _MemberPageState extends State<MemberPage>
}
} else {
// 骨架屏
return profile(_memberController, loadingStatus: true);
return ProfilePanel(ctr: _memberController, loadingStatus: true);
}
},
),

View File

@ -6,12 +6,23 @@ import 'package:pilipala/models/live/item.dart';
import 'package:pilipala/models/member/info.dart';
import 'package:pilipala/utils/utils.dart';
Widget profile(ctr, {loadingStatus = false}) {
class ProfilePanel extends StatelessWidget {
final dynamic ctr;
final bool loadingStatus;
const ProfilePanel({
super.key,
required this.ctr,
this.loadingStatus = false,
});
@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),
padding:
EdgeInsets.only(top: MediaQuery.of(context).padding.top - 20),
child: Row(
children: [
Hero(
@ -118,9 +129,11 @@ Widget profile(ctr, {loadingStatus = false}) {
children: [
Text(
!loadingStatus
? ctr.userStat!['follower'] != null
? Utils.numFormat(
ctr.userStat!['follower'],
)
: '-'
: '-',
style: const TextStyle(
fontWeight: FontWeight.bold)),
@ -139,9 +152,11 @@ Widget profile(ctr, {loadingStatus = false}) {
children: [
Text(
!loadingStatus
? ctr.userStat!['likes'] != null
? Utils.numFormat(
ctr.userStat!['likes'],
)
: '-'
: '-',
style: const TextStyle(
fontWeight: FontWeight.bold)),
@ -159,7 +174,7 @@ Widget profile(ctr, {loadingStatus = false}) {
),
),
const SizedBox(height: 10),
if (ctr.ownerMid != ctr.mid) ...[
if (ctr.ownerMid != ctr.mid && ctr.ownerMid != -1) ...[
Row(
children: [
Obx(
@ -170,7 +185,9 @@ Widget profile(ctr, {loadingStatus = false}) {
foregroundColor: ctr.attribute.value == -1
? Colors.transparent
: ctr.attribute.value != 0
? Theme.of(context).colorScheme.outline
? Theme.of(context)
.colorScheme
.outline
: Theme.of(context)
.colorScheme
.onPrimary,
@ -200,7 +217,8 @@ Widget profile(ctr, {loadingStatus = false}) {
)
],
)
] else ...[
],
if (ctr.ownerMid == ctr.mid && ctr.ownerMid != -1) ...[
TextButton(
onPressed: () {
SmartDialog.showToast('功能开发中 💪');
@ -209,10 +227,24 @@ Widget profile(ctr, {loadingStatus = false}) {
padding: const EdgeInsets.only(left: 80, right: 80),
foregroundColor:
Theme.of(context).colorScheme.onPrimary,
backgroundColor: Theme.of(context).colorScheme.primary,
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('未登录'),
)
]
],
),
@ -222,4 +254,5 @@ Widget profile(ctr, {loadingStatus = false}) {
);
}),
);
}
}