opt: member page

This commit is contained in:
bggRGjQaUbCoE
2024-10-18 11:25:35 +08:00
parent 122328c18e
commit b57d1a0a62
6 changed files with 100 additions and 59 deletions

View File

@@ -16,7 +16,7 @@ Tab _$TabFromJson(Map<String, dynamic> json) => Tab(
coin: json['coin'] as bool?, coin: json['coin'] as bool?,
like: json['like'] as bool?, like: json['like'] as bool?,
community: json['community'] as bool?, community: json['community'] as bool?,
dyn: json['dynamic'] as bool?, dyn: false, //json['dynamic'] as bool?,
audios: json['audios'] as bool?, audios: json['audios'] as bool?,
shop: json['shop'] as bool?, shop: json['shop'] as bool?,
mall: json['mall'] as bool?, mall: json['mall'] as bool?,

View File

@@ -53,7 +53,7 @@ class _MemberVideoState extends State<MemberVideo>
} }
_buildBody(LoadingState loadingState) { _buildBody(LoadingState loadingState) {
return loadingState is Success return loadingState is Success && loadingState.response is List
? RefreshIndicator( ? RefreshIndicator(
onRefresh: () async { onRefresh: () async {
await _controller.onRefresh(); await _controller.onRefresh();
@@ -137,20 +137,22 @@ class _MemberVideoState extends State<MemberVideo>
], ],
), ),
) )
: loadingState is Error : loadingState is Loading
? Center( ? Center(
child: CircularProgressIndicator(),
)
: Center(
child: CustomScrollView( child: CustomScrollView(
shrinkWrap: true, shrinkWrap: true,
slivers: [ slivers: [
HttpError( HttpError(
errMsg: loadingState.errMsg, errMsg: loadingState is Error
? (loadingState as Error?)?.errMsg
: 'EMPTY',
fn: _controller.onReload, fn: _controller.onReload,
), ),
], ],
), ),
)
: Center(
child: CircularProgressIndicator(),
); );
} }
} }

View File

@@ -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/pages/member/new/controller.dart';
import 'package:PiliPalaX/utils/grid.dart'; import 'package:PiliPalaX/utils/grid.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
class MemberHome extends StatefulWidget { 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) ...[ if (loadingState.response?.article?.item?.isNotEmpty == true) ...[
_videoHeader( _videoHeader(
title: '专栏', title: '专栏',
@@ -159,27 +187,30 @@ class _MemberHomeState extends State<MemberHome>
onTap: () { onTap: () {
int index = int index =
_ctr.tab2!.indexWhere((item) => item.param == param); _ctr.tab2!.indexWhere((item) => item.param == param);
if (['video', 'article', 'audio'].contains(param1)) {
List<Item> items = _ctr.tab2!
.firstWhere((item) => item.param == param)
.items!;
int index1 =
items.indexWhere((item) => item.param == param1);
try {
final contributeCtr =
Get.find<MemberContributeCtr>(tag: widget.heroTag);
// contributeCtr.tabController?.animateTo(index1);
if (contributeCtr.tabController?.index != index1) {
contributeCtr.tabController?.index = index1;
}
print('initialized');
} catch (e) {
_ctr.contributeInitialIndex.value = index1;
print('not initialized');
}
}
if (index != -1) { if (index != -1) {
if (['video', 'article', 'audio'].contains(param1)) {
List<Item> items = _ctr.tab2!
.firstWhere((item) => item.param == param)
.items!;
int index1 =
items.indexWhere((item) => item.param == param1);
try {
final contributeCtr =
Get.find<MemberContributeCtr>(tag: widget.heroTag);
// contributeCtr.tabController?.animateTo(index1);
if (contributeCtr.tabController?.index != index1) {
contributeCtr.tabController?.index = index1;
}
print('initialized');
} catch (e) {
_ctr.contributeInitialIndex.value = index1;
print('not initialized');
}
}
_ctr.tabController.animateTo(index); _ctr.tabController.animateTo(index);
} else {
// TODO
SmartDialog.showToast('view $param');
} }
}, },
child: Text.rich( child: Text.rich(

View File

@@ -39,26 +39,25 @@ class MemberControllerNew extends CommonController
relation.value = response.response?.relation ?? 1; relation.value = response.response?.relation ?? 1;
tab2 = response.response.tab2; tab2 = response.response.tab2;
if (tab2 != null && tab2!.isNotEmpty) { if (tab2 != null && tab2!.isNotEmpty) {
int initialIndex = tab2! if (!response.response.tab.toJson().values.contains(true) &&
.indexWhere((item) => item.param == response.response.defaultTab); tab2!.first.param == 'home') {
if (initialIndex == 0 && // remove empty home tab
!response.response.tab.toJson().values.contains('true')) { tab2!.removeAt(0);
if (tab2!.length > 1) { }
initialIndex = 1; if (tab2!.isNotEmpty) {
} if (response.response.defaultTab == 'video') {
// TODO response.response.defaultTab = 'dynamic';
// tab2!.removeAt(0); }
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 ? 0 : initialIndex,
);
} }
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,
);
} }
loadingState.value = response; loadingState.value = response;
return true; return true;

View File

@@ -67,8 +67,7 @@ class _MemberPageNewState extends State<MemberPageNew>
), ),
]; ];
}, },
body: _userController.tab2 != null && body: _userController.tab2?.isNotEmpty == true
_userController.tab2!.isNotEmpty
? LayoutBuilder( ? LayoutBuilder(
builder: (context, _) { builder: (context, _) {
return Padding( return Padding(
@@ -103,8 +102,16 @@ class _MemberPageNewState extends State<MemberPageNew>
child: Column( child: Column(
children: [ children: [
SizedBox(height: _userController.top), SizedBox(height: _userController.top),
_buildTab, if ((_userController.tab2?.length ?? -1) > 1)
Expanded(child: _buildBody), _buildTab,
Expanded(
child:
_userController.tab2?.isNotEmpty == true
? _buildBody
: Center(
child: const Text('EMPTY'),
),
),
], ],
), ),
), ),
@@ -172,9 +179,7 @@ class _MemberPageNewState extends State<MemberPageNew>
pinned: true, pinned: true,
scrolledUnderElevation: 0, scrolledUnderElevation: 0,
flexibleSpace: _buildUserInfo(_userController.loadingState.value), flexibleSpace: _buildUserInfo(_userController.loadingState.value),
bottom: needTab && bottom: needTab && (_userController.tab2?.length ?? -1) > 1
_userController.tab2 != null &&
_userController.tab2!.isNotEmpty
? PreferredSize( ? PreferredSize(
preferredSize: Size.fromHeight(48), preferredSize: Size.fromHeight(48),
child: Material( child: Material(
@@ -293,12 +298,16 @@ class _MemberPageNewState extends State<MemberPageNew>
return _errorWidget(userState.errMsg); return _errorWidget(userState.errMsg);
case Success(): case Success():
return Obx( return Obx(
() => UserInfoCard( () => Padding(
relation: _userController.relation.value, padding: EdgeInsets.only(
isFollow: _userController.isFollow.value, bottom: (_userController.tab2?.length ?? 0) > 1 ? 48 : 0),
card: userState.response.card, child: UserInfoCard(
images: userState.response.images, relation: _userController.relation.value,
onFollow: () => _userController.onFollow(context), isFollow: _userController.isFollow.value,
card: userState.response.card,
images: userState.response.images,
onFollow: () => _userController.onFollow(context),
),
), ),
); );
} }

View File

@@ -416,7 +416,7 @@ class UserInfoCard extends StatelessWidget {
// .toList(), // .toList(),
// ), // ),
// ), // ),
const SizedBox(height: 50), const SizedBox(height: 5),
], ],
); );
} }