mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: member page
This commit is contained in:
@@ -16,7 +16,7 @@ Tab _$TabFromJson(Map<String, dynamic> json) => Tab(
|
||||
coin: json['coin'] as bool?,
|
||||
like: json['like'] as bool?,
|
||||
community: json['community'] as bool?,
|
||||
dyn: json['dynamic'] as bool?,
|
||||
dyn: false, //json['dynamic'] as bool?,
|
||||
audios: json['audios'] as bool?,
|
||||
shop: json['shop'] as bool?,
|
||||
mall: json['mall'] as bool?,
|
||||
|
||||
@@ -53,7 +53,7 @@ class _MemberVideoState extends State<MemberVideo>
|
||||
}
|
||||
|
||||
_buildBody(LoadingState loadingState) {
|
||||
return loadingState is Success
|
||||
return loadingState is Success && loadingState.response is List
|
||||
? RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
await _controller.onRefresh();
|
||||
@@ -137,20 +137,22 @@ class _MemberVideoState extends State<MemberVideo>
|
||||
],
|
||||
),
|
||||
)
|
||||
: loadingState is Error
|
||||
: loadingState is Loading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: Center(
|
||||
child: CustomScrollView(
|
||||
shrinkWrap: true,
|
||||
slivers: [
|
||||
HttpError(
|
||||
errMsg: loadingState.errMsg,
|
||||
errMsg: loadingState is Error
|
||||
? (loadingState as Error?)?.errMsg
|
||||
: 'EMPTY',
|
||||
fn: _controller.onReload,
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:PiliPalaX/pages/member/new/content/member_contribute/member_cont
|
||||
import 'package:PiliPalaX/pages/member/new/controller.dart';
|
||||
import 'package:PiliPalaX/utils/grid.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class MemberHome extends StatefulWidget {
|
||||
@@ -70,6 +71,33 @@ class _MemberHomeState extends State<MemberHome>
|
||||
),
|
||||
),
|
||||
],
|
||||
if (loadingState.response?.favourite2?.item?.isNotEmpty ==
|
||||
true) ...[
|
||||
_videoHeader(
|
||||
title: '收藏',
|
||||
param: 'favorite',
|
||||
count: loadingState.response.favourite2.count,
|
||||
),
|
||||
// TODO
|
||||
],
|
||||
if (loadingState.response?.coinArchive?.item?.isNotEmpty ==
|
||||
true) ...[
|
||||
_videoHeader(
|
||||
title: '最近投币的视频',
|
||||
param: 'coinArchive',
|
||||
count: loadingState.response.coinArchive.count,
|
||||
),
|
||||
// TODO
|
||||
],
|
||||
if (loadingState.response?.likeArchive?.item?.isNotEmpty ==
|
||||
true) ...[
|
||||
_videoHeader(
|
||||
title: '最近点赞的视频',
|
||||
param: 'coinArchive',
|
||||
count: loadingState.response.likeArchive.count,
|
||||
),
|
||||
// TODO
|
||||
],
|
||||
if (loadingState.response?.article?.item?.isNotEmpty == true) ...[
|
||||
_videoHeader(
|
||||
title: '专栏',
|
||||
@@ -159,6 +187,7 @@ class _MemberHomeState extends State<MemberHome>
|
||||
onTap: () {
|
||||
int index =
|
||||
_ctr.tab2!.indexWhere((item) => item.param == param);
|
||||
if (index != -1) {
|
||||
if (['video', 'article', 'audio'].contains(param1)) {
|
||||
List<Item> items = _ctr.tab2!
|
||||
.firstWhere((item) => item.param == param)
|
||||
@@ -178,8 +207,10 @@ class _MemberHomeState extends State<MemberHome>
|
||||
print('not initialized');
|
||||
}
|
||||
}
|
||||
if (index != -1) {
|
||||
_ctr.tabController.animateTo(index);
|
||||
} else {
|
||||
// TODO
|
||||
SmartDialog.showToast('view $param');
|
||||
}
|
||||
},
|
||||
child: Text.rich(
|
||||
|
||||
@@ -39,27 +39,26 @@ class MemberControllerNew extends CommonController
|
||||
relation.value = response.response?.relation ?? 1;
|
||||
tab2 = response.response.tab2;
|
||||
if (tab2 != null && tab2!.isNotEmpty) {
|
||||
int initialIndex = tab2!
|
||||
.indexWhere((item) => item.param == response.response.defaultTab);
|
||||
if (initialIndex == 0 &&
|
||||
!response.response.tab.toJson().values.contains('true')) {
|
||||
if (tab2!.length > 1) {
|
||||
initialIndex = 1;
|
||||
if (!response.response.tab.toJson().values.contains(true) &&
|
||||
tab2!.first.param == 'home') {
|
||||
// remove empty home tab
|
||||
tab2!.removeAt(0);
|
||||
}
|
||||
// TODO
|
||||
// tab2!.removeAt(0);
|
||||
if (tab2!.isNotEmpty) {
|
||||
if (response.response.defaultTab == 'video') {
|
||||
response.response.defaultTab = 'dynamic';
|
||||
}
|
||||
int initialIndex = tab2!.indexWhere((item) {
|
||||
return item.param == response.response.defaultTab;
|
||||
});
|
||||
tabs = tab2!.map((item) => Tab(text: item.title ?? '')).toList();
|
||||
tabController = TabController(
|
||||
vsync: this,
|
||||
length: response.response.tab2.length,
|
||||
initialIndex: initialIndex == -1
|
||||
? tab2!.length > 1
|
||||
? 1
|
||||
: 0
|
||||
: initialIndex,
|
||||
initialIndex: initialIndex == -1 ? 0 : initialIndex,
|
||||
);
|
||||
}
|
||||
}
|
||||
loadingState.value = response;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -67,8 +67,7 @@ class _MemberPageNewState extends State<MemberPageNew>
|
||||
),
|
||||
];
|
||||
},
|
||||
body: _userController.tab2 != null &&
|
||||
_userController.tab2!.isNotEmpty
|
||||
body: _userController.tab2?.isNotEmpty == true
|
||||
? LayoutBuilder(
|
||||
builder: (context, _) {
|
||||
return Padding(
|
||||
@@ -103,8 +102,16 @@ class _MemberPageNewState extends State<MemberPageNew>
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(height: _userController.top),
|
||||
if ((_userController.tab2?.length ?? -1) > 1)
|
||||
_buildTab,
|
||||
Expanded(child: _buildBody),
|
||||
Expanded(
|
||||
child:
|
||||
_userController.tab2?.isNotEmpty == true
|
||||
? _buildBody
|
||||
: Center(
|
||||
child: const Text('EMPTY'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -172,9 +179,7 @@ class _MemberPageNewState extends State<MemberPageNew>
|
||||
pinned: true,
|
||||
scrolledUnderElevation: 0,
|
||||
flexibleSpace: _buildUserInfo(_userController.loadingState.value),
|
||||
bottom: needTab &&
|
||||
_userController.tab2 != null &&
|
||||
_userController.tab2!.isNotEmpty
|
||||
bottom: needTab && (_userController.tab2?.length ?? -1) > 1
|
||||
? PreferredSize(
|
||||
preferredSize: Size.fromHeight(48),
|
||||
child: Material(
|
||||
@@ -293,13 +298,17 @@ class _MemberPageNewState extends State<MemberPageNew>
|
||||
return _errorWidget(userState.errMsg);
|
||||
case Success():
|
||||
return Obx(
|
||||
() => UserInfoCard(
|
||||
() => Padding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: (_userController.tab2?.length ?? 0) > 1 ? 48 : 0),
|
||||
child: UserInfoCard(
|
||||
relation: _userController.relation.value,
|
||||
isFollow: _userController.isFollow.value,
|
||||
card: userState.response.card,
|
||||
images: userState.response.images,
|
||||
onFollow: () => _userController.onFollow(context),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return const CircularProgressIndicator();
|
||||
|
||||
@@ -416,7 +416,7 @@ class UserInfoCard extends StatelessWidget {
|
||||
// .toList(),
|
||||
// ),
|
||||
// ),
|
||||
const SizedBox(height: 50),
|
||||
const SizedBox(height: 5),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user