mod: 用户页面投稿加载
This commit is contained in:
@ -9,13 +9,22 @@ class FansController extends GetxController {
|
|||||||
int pn = 1;
|
int pn = 1;
|
||||||
int total = 0;
|
int total = 0;
|
||||||
RxList<FansItemModel> fansList = [FansItemModel()].obs;
|
RxList<FansItemModel> fansList = [FansItemModel()].obs;
|
||||||
|
late int mid;
|
||||||
|
late String name;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onInit() {
|
||||||
|
super.onInit();
|
||||||
|
mid = int.parse(Get.parameters['mid'] ?? user.get(UserBoxKey.userMid));
|
||||||
|
name = Get.parameters['name'] ?? user.get(UserBoxKey.userName);
|
||||||
|
}
|
||||||
|
|
||||||
Future queryFans(type) async {
|
Future queryFans(type) async {
|
||||||
if (type == 'init') {
|
if (type == 'init') {
|
||||||
pn = 1;
|
pn = 1;
|
||||||
}
|
}
|
||||||
var res = await FanHttp.fans(
|
var res = await FanHttp.fans(
|
||||||
vmid: user.get(UserBoxKey.userMid),
|
vmid: mid,
|
||||||
pn: pn,
|
pn: pn,
|
||||||
ps: 20,
|
ps: 20,
|
||||||
orderType: 'attention',
|
orderType: 'attention',
|
||||||
|
@ -46,7 +46,7 @@ class _FansPageState extends State<FansPage> {
|
|||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
titleSpacing: 0,
|
titleSpacing: 0,
|
||||||
title: Text(
|
title: Text(
|
||||||
'我的粉丝',
|
'${_fansController.name}的粉丝',
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -9,13 +9,22 @@ class FollowController extends GetxController {
|
|||||||
int pn = 1;
|
int pn = 1;
|
||||||
int total = 0;
|
int total = 0;
|
||||||
RxList<FollowItemModel> followList = [FollowItemModel()].obs;
|
RxList<FollowItemModel> followList = [FollowItemModel()].obs;
|
||||||
|
late int mid;
|
||||||
|
late String name;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onInit() {
|
||||||
|
super.onInit();
|
||||||
|
mid = int.parse(Get.parameters['mid'] ?? user.get(UserBoxKey.userMid));
|
||||||
|
name = Get.parameters['name'] ?? user.get(UserBoxKey.userName);
|
||||||
|
}
|
||||||
|
|
||||||
Future queryFollowings(type) async {
|
Future queryFollowings(type) async {
|
||||||
if (type == 'init') {
|
if (type == 'init') {
|
||||||
pn = 1;
|
pn = 1;
|
||||||
}
|
}
|
||||||
var res = await FollowHttp.followings(
|
var res = await FollowHttp.followings(
|
||||||
vmid: user.get(UserBoxKey.userMid),
|
vmid: mid,
|
||||||
pn: pn,
|
pn: pn,
|
||||||
ps: 20,
|
ps: 20,
|
||||||
orderType: 'attention',
|
orderType: 'attention',
|
||||||
|
@ -46,7 +46,7 @@ class _FollowPageState extends State<FollowPage> {
|
|||||||
titleSpacing: 0,
|
titleSpacing: 0,
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
title: Text(
|
title: Text(
|
||||||
'我的关注',
|
'${_followController.name}的关注',
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -72,9 +72,13 @@ class _FollowPageState extends State<FollowPage> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return HttpError(
|
return CustomScrollView(
|
||||||
errMsg: data['msg'],
|
slivers: [
|
||||||
fn: () => _followController.queryFollowings('init'),
|
HttpError(
|
||||||
|
errMsg: data['msg'],
|
||||||
|
fn: () => _followController.queryFollowings('init'),
|
||||||
|
)
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -4,6 +4,7 @@ import 'package:pilipala/http/member.dart';
|
|||||||
class ArchiveController extends GetxController {
|
class ArchiveController extends GetxController {
|
||||||
int? mid;
|
int? mid;
|
||||||
int pn = 1;
|
int pn = 1;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
@ -15,6 +16,7 @@ class ArchiveController extends GetxController {
|
|||||||
Future getMemberArchive() async {
|
Future getMemberArchive() async {
|
||||||
var res = await MemberHttp.memberArchive(mid: mid, pn: pn);
|
var res = await MemberHttp.memberArchive(mid: mid, pn: pn);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
|
count = res['data'].page['count'];
|
||||||
pn += 1;
|
pn += 1;
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:loading_more_list/loading_more_list.dart';
|
import 'package:loading_more_list/loading_more_list.dart';
|
||||||
@ -40,7 +41,6 @@ class _ArchivePanelState extends State<ArchivePanel>
|
|||||||
return PullToRefreshHeader(info, lastRefreshTime);
|
return PullToRefreshHeader(info, lastRefreshTime);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: LoadingMoreList<VListItemModel>(
|
child: LoadingMoreList<VListItemModel>(
|
||||||
ListConfig<VListItemModel>(
|
ListConfig<VListItemModel>(
|
||||||
@ -49,9 +49,7 @@ class _ArchivePanelState extends State<ArchivePanel>
|
|||||||
(BuildContext c, VListItemModel item, int index) {
|
(BuildContext c, VListItemModel item, int index) {
|
||||||
return VideoCardH(videoItem: item);
|
return VideoCardH(videoItem: item);
|
||||||
},
|
},
|
||||||
indicatorBuilder: (context, status) {
|
indicatorBuilder: _buildIndicator,
|
||||||
return const Center(child: Text('加载中'));
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -61,18 +59,104 @@ class _ArchivePanelState extends State<ArchivePanel>
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildIndicator(BuildContext context, IndicatorStatus status) {
|
||||||
|
TextStyle style =
|
||||||
|
TextStyle(fontSize: 13, color: Theme.of(context).colorScheme.outline);
|
||||||
|
Widget? widget;
|
||||||
|
switch (status) {
|
||||||
|
case IndicatorStatus.none:
|
||||||
|
widget = Container(height: 0.0);
|
||||||
|
break;
|
||||||
|
case IndicatorStatus.loadingMoreBusying:
|
||||||
|
widget = Text('加载中...', style: style);
|
||||||
|
widget = _setbackground(false, widget, height: 60.0);
|
||||||
|
break;
|
||||||
|
case IndicatorStatus.fullScreenBusying:
|
||||||
|
widget = Text('加载中...', style: style);
|
||||||
|
widget = _setbackground(true, widget);
|
||||||
|
break;
|
||||||
|
case IndicatorStatus.error:
|
||||||
|
|
||||||
|
/// TODO 异常逻辑
|
||||||
|
widget = Text('没有更多了', style: style);
|
||||||
|
widget = _setbackground(false, widget);
|
||||||
|
|
||||||
|
widget = GestureDetector(
|
||||||
|
onTap: () {},
|
||||||
|
child: widget,
|
||||||
|
);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case IndicatorStatus.fullScreenError:
|
||||||
|
|
||||||
|
/// TODO 异常逻辑
|
||||||
|
widget = Text('没有更多了', style: style);
|
||||||
|
widget = _setbackground(true, widget);
|
||||||
|
widget = GestureDetector(
|
||||||
|
onTap: () {},
|
||||||
|
child: widget,
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case IndicatorStatus.noMoreLoad:
|
||||||
|
widget = Text('没有更多了', style: style);
|
||||||
|
widget = _setbackground(false, widget, height: 60.0);
|
||||||
|
break;
|
||||||
|
case IndicatorStatus.empty:
|
||||||
|
widget = Text('用户没有投稿', style: style);
|
||||||
|
widget = _setbackground(true, widget);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _setbackground(bool full, Widget widget, {double height = 100}) {
|
||||||
|
widget = Padding(
|
||||||
|
padding: height == double.infinity
|
||||||
|
? EdgeInsets.zero
|
||||||
|
: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom),
|
||||||
|
child: Container(
|
||||||
|
width: double.infinity,
|
||||||
|
height: height,
|
||||||
|
color: Theme.of(context).colorScheme.background,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: widget,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget getIndicator(BuildContext context) {
|
||||||
|
final TargetPlatform platform = Theme.of(context).platform;
|
||||||
|
return platform == TargetPlatform.iOS
|
||||||
|
? const CupertinoActivityIndicator(
|
||||||
|
animating: true,
|
||||||
|
radius: 16.0,
|
||||||
|
)
|
||||||
|
: CircularProgressIndicator(
|
||||||
|
strokeWidth: 2.0,
|
||||||
|
valueColor:
|
||||||
|
AlwaysStoppedAnimation<Color>(Theme.of(context).primaryColor),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadMoreListSource extends LoadingMoreBase<VListItemModel> {
|
class LoadMoreListSource extends LoadingMoreBase<VListItemModel> {
|
||||||
final ArchiveController _archiveController = Get.put(ArchiveController());
|
final ArchiveController _archiveController = Get.put(ArchiveController());
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<bool> loadData([bool isloadMoreAction = false]) {
|
Future<bool> loadData([bool isloadMoreAction = false]) async {
|
||||||
return Future<bool>(() async {
|
bool isSuccess = false;
|
||||||
var res = await _archiveController.getMemberArchive();
|
var res = await _archiveController.getMemberArchive();
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
addAll(res['data'].list.vlist);
|
addAll(res['data'].list.vlist);
|
||||||
}
|
}
|
||||||
return true;
|
print(length);
|
||||||
});
|
if (length < res['data'].page['count']) {
|
||||||
|
isSuccess = true;
|
||||||
|
} else {
|
||||||
|
isSuccess = false;
|
||||||
|
}
|
||||||
|
return isSuccess;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ class _MemberPageState extends State<MemberPage>
|
|||||||
const SizedBox(height: 14),
|
const SizedBox(height: 14),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Flexible(
|
||||||
child: Text(
|
child: Text(
|
||||||
_memberController
|
_memberController
|
||||||
.memberInfo.value.name!,
|
.memberInfo.value.name!,
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
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';
|
||||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||||
import 'package:pilipala/models/live/item.dart';
|
import 'package:pilipala/models/live/item.dart';
|
||||||
@ -81,42 +82,54 @@ Widget profile(ctr, {loadingStatus = false}) {
|
|||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: [
|
children: [
|
||||||
Column(
|
InkWell(
|
||||||
children: [
|
onTap: () {
|
||||||
Text(
|
Get.toNamed(
|
||||||
!loadingStatus
|
'/follow?mid=${memberInfo.mid}&name=${memberInfo.name}');
|
||||||
? ctr.userStat!['following'].toString()
|
},
|
||||||
: '-',
|
child: Column(
|
||||||
style:
|
children: [
|
||||||
const TextStyle(fontWeight: FontWeight.bold),
|
Text(
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'关注',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.labelMedium!
|
|
||||||
.fontSize),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Column(
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
!loadingStatus
|
!loadingStatus
|
||||||
? Utils.numFormat(
|
? ctr.userStat!['following'].toString()
|
||||||
ctr.userStat!['follower'],
|
|
||||||
)
|
|
||||||
: '-',
|
: '-',
|
||||||
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
|
||||||
.labelMedium!
|
.labelMedium!
|
||||||
.fontSize))
|
.fontSize),
|
||||||
],
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
InkWell(
|
||||||
|
onTap: () {
|
||||||
|
Get.toNamed(
|
||||||
|
'/fan?mid=${memberInfo.mid}&name=${memberInfo.name}');
|
||||||
|
},
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
!loadingStatus
|
||||||
|
? Utils.numFormat(
|
||||||
|
ctr.userStat!['follower'],
|
||||||
|
)
|
||||||
|
: '-',
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.bold)),
|
||||||
|
Text('粉丝',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.labelMedium!
|
||||||
|
.fontSize))
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
@ -172,7 +185,9 @@ Widget profile(ctr, {loadingStatus = false}) {
|
|||||||
)
|
)
|
||||||
] else ...[
|
] else ...[
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {},
|
onPressed: () {
|
||||||
|
SmartDialog.showToast('功能开发中 💪');
|
||||||
|
},
|
||||||
style: TextButton.styleFrom(
|
style: TextButton.styleFrom(
|
||||||
padding: const EdgeInsets.only(left: 80, right: 80),
|
padding: const EdgeInsets.only(left: 80, right: 80),
|
||||||
foregroundColor:
|
foregroundColor:
|
||||||
|
@ -36,6 +36,13 @@ class MineController extends GetxController {
|
|||||||
'pageTitle': '登录bilibili',
|
'pageTitle': '登录bilibili',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
int mid = user.get(UserBoxKey.userMid);
|
||||||
|
String face = user.get(UserBoxKey.userFace);
|
||||||
|
Get.toNamed(
|
||||||
|
'/member?mid=$mid',
|
||||||
|
arguments: {'face': face},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user