feat: member search dynamic
This commit is contained in:
@ -260,7 +260,8 @@ class Api {
|
||||
static const String memberArchive = '/x/space/wbi/arc/search';
|
||||
|
||||
// 用户动态搜索
|
||||
static const String memberDynamicSearch = '/x/space/dynamic/search';
|
||||
static const String memberDynamicSearch =
|
||||
'/x/polymer/web-dynamic/v1/feed/space/search';
|
||||
|
||||
// 用户动态
|
||||
static const String memberDynamic = '/x/polymer/web-dynamic/v1/feed/space';
|
||||
|
@ -91,6 +91,11 @@ class MemberHttp {
|
||||
String order = 'pubdate',
|
||||
bool orderAvoided = true,
|
||||
}) async {
|
||||
String? wWebid;
|
||||
if ((await getWWebid(mid: mid!))['status']) {
|
||||
wWebid = GlobalDataCache.wWebid;
|
||||
}
|
||||
|
||||
String dmImgStr = Utils.base64EncodeRandomString(16, 64);
|
||||
String dmCoverImgStr = Utils.base64EncodeRandomString(32, 128);
|
||||
Map params = await WbiSign().makSign({
|
||||
@ -112,7 +117,8 @@ class MemberHttp {
|
||||
'order': 'pubdate',
|
||||
'special_type': 'charging',
|
||||
}
|
||||
: {}
|
||||
: {},
|
||||
...wWebid != null ? {'w_webid': wWebid} : {},
|
||||
});
|
||||
|
||||
var res = await Request().get(
|
||||
@ -120,6 +126,7 @@ class MemberHttp {
|
||||
data: params,
|
||||
extra: {'ua': 'pc'},
|
||||
);
|
||||
|
||||
if (res.data['code'] == 0) {
|
||||
return {
|
||||
'status': true,
|
||||
@ -163,13 +170,17 @@ class MemberHttp {
|
||||
}
|
||||
|
||||
// 搜索用户动态
|
||||
static Future memberDynamicSearch({int? pn, int? ps, int? mid}) async {
|
||||
var res = await Request().get(Api.memberDynamic, data: {
|
||||
'keyword': '海拔',
|
||||
'mid': mid,
|
||||
'pn': pn,
|
||||
'ps': ps,
|
||||
'platform': 'web'
|
||||
static Future memberDynamicSearch({
|
||||
int? pn,
|
||||
int? mid,
|
||||
String? offset,
|
||||
required String keyword,
|
||||
}) async {
|
||||
var res = await Request().get(Api.memberDynamicSearch, data: {
|
||||
'host_mid': mid,
|
||||
'page': pn,
|
||||
'offset': offset,
|
||||
'keyword': keyword,
|
||||
});
|
||||
if (res.data['code'] == 0) {
|
||||
return {
|
||||
|
@ -5,10 +5,12 @@ class DynamicsDataModel {
|
||||
this.hasMore,
|
||||
this.items,
|
||||
this.offset,
|
||||
this.total,
|
||||
});
|
||||
bool? hasMore;
|
||||
List<DynamicItemModel>? items;
|
||||
String? offset;
|
||||
int? total;
|
||||
|
||||
DynamicsDataModel.fromJson(Map<String, dynamic> json) {
|
||||
hasMore = json['has_more'];
|
||||
@ -16,6 +18,7 @@ class DynamicsDataModel {
|
||||
.map<DynamicItemModel>((e) => DynamicItemModel.fromJson(e))
|
||||
.toList();
|
||||
offset = json['offset'];
|
||||
total = json['total'];
|
||||
}
|
||||
}
|
||||
|
||||
|
132
lib/pages/member_search/archive.dart
Normal file
132
lib/pages/member_search/archive.dart
Normal file
@ -0,0 +1,132 @@
|
||||
import 'package:easy_debounce/easy_throttle.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/common/skeleton/video_card_h.dart';
|
||||
import 'package:pilipala/common/widgets/http_error.dart';
|
||||
import 'package:pilipala/common/widgets/no_data.dart';
|
||||
import 'package:pilipala/common/widgets/video_card_h.dart';
|
||||
import 'controller.dart';
|
||||
|
||||
class SearchArchivePage extends StatefulWidget {
|
||||
const SearchArchivePage({
|
||||
super.key,
|
||||
required this.searchKeyWord,
|
||||
required this.controller,
|
||||
});
|
||||
|
||||
final String searchKeyWord;
|
||||
final MemberSearchController controller;
|
||||
|
||||
@override
|
||||
State<SearchArchivePage> createState() => _SearchArchivePageState();
|
||||
}
|
||||
|
||||
class _SearchArchivePageState extends State<SearchArchivePage>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
late Future _futureBuilderFuture;
|
||||
ScrollController scrollController = ScrollController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_futureBuilderFuture = widget.controller.searchArchives();
|
||||
scrollController.addListener(
|
||||
() {
|
||||
if (scrollController.position.pixels >=
|
||||
scrollController.position.maxScrollExtent - 300) {
|
||||
EasyThrottle.throttle('search_archive', const Duration(seconds: 1),
|
||||
() {
|
||||
widget.controller.onLoad();
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
widget.controller.searchKeyWord.listen((p0) {
|
||||
if (context.mounted) {
|
||||
setState(() {
|
||||
_futureBuilderFuture = widget.controller.searchArchives();
|
||||
});
|
||||
}
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
scrollController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 6),
|
||||
child: FutureBuilder(
|
||||
future: _futureBuilderFuture,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
Map? data = snapshot.data;
|
||||
if (data != null && data['status']) {
|
||||
return Obx(
|
||||
() => widget.controller.archiveList.isNotEmpty
|
||||
? ListView.builder(
|
||||
controller: scrollController,
|
||||
itemCount: widget.controller.archiveList.length + 1,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == widget.controller.archiveList.length) {
|
||||
return Container(
|
||||
height: MediaQuery.paddingOf(context).bottom + 60,
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.paddingOf(context).bottom),
|
||||
child: Center(
|
||||
child: Obx(
|
||||
() => Text(
|
||||
widget.controller.loadingArchiveText.value,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline,
|
||||
fontSize: 13),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return VideoCardH(
|
||||
videoItem:
|
||||
widget.controller.archiveList[index]);
|
||||
}
|
||||
},
|
||||
)
|
||||
: const CustomScrollView(
|
||||
slivers: <Widget>[
|
||||
NoData(),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return HttpError(
|
||||
errMsg: data?['msg'] ?? '请求异常',
|
||||
fn: () => setState(() {
|
||||
_futureBuilderFuture = widget.controller.searchArchives();
|
||||
}),
|
||||
isInSliver: false,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return ListView.builder(
|
||||
itemCount: 10,
|
||||
itemBuilder: (context, index) {
|
||||
return const VideoCardHSkeleton();
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,91 +1,147 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/http/member.dart';
|
||||
import 'package:pilipala/models/dynamics/result.dart';
|
||||
import 'package:pilipala/models/member/archive.dart';
|
||||
|
||||
class MemberSearchController extends GetxController {
|
||||
class MemberSearchController extends GetxController
|
||||
with GetTickerProviderStateMixin {
|
||||
final ScrollController scrollController = ScrollController();
|
||||
Rx<TextEditingController> controller = TextEditingController().obs;
|
||||
TextEditingController textController = TextEditingController();
|
||||
final FocusNode searchFocusNode = FocusNode();
|
||||
RxString searchKeyWord = ''.obs;
|
||||
String hintText = '搜索';
|
||||
RxString loadingStatus = 'init'.obs;
|
||||
RxString loadingText = '加载中...'.obs;
|
||||
bool hasRequest = false;
|
||||
late int mid;
|
||||
RxString uname = ''.obs;
|
||||
int archivePn = 1;
|
||||
int archiveCount = 0;
|
||||
RxList<VListItemModel> archiveList = <VListItemModel>[].obs;
|
||||
int dynamic_pn = 1;
|
||||
RxList<VListItemModel> dynamicList = <VListItemModel>[].obs;
|
||||
|
||||
int ps = 30;
|
||||
// 投稿相关
|
||||
final int ps = 30;
|
||||
int archivePn = 1;
|
||||
int _archiveCount = 0;
|
||||
RxString loadingArchiveText = '加载中...'.obs;
|
||||
RxList<VListItemModel> archiveList = <VListItemModel>[].obs;
|
||||
|
||||
// 动态相关
|
||||
String dynamicOffset = '';
|
||||
int dynamicPn = 1;
|
||||
int _dynamicCount = 0;
|
||||
bool dynamicHasMore = true;
|
||||
RxString loadingDynamicText = '加载中...'.obs;
|
||||
RxList<DynamicItemModel> dynamicList = <DynamicItemModel>[].obs;
|
||||
|
||||
late TabController tabController;
|
||||
RxList<String> tabs = <String>['视频', '动态'].obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
mid = int.parse(Get.parameters['mid']!);
|
||||
uname.value = Get.parameters['uname']!;
|
||||
tabController = TabController(length: tabs.length, vsync: this);
|
||||
}
|
||||
|
||||
// 清空搜索
|
||||
void onClear() {
|
||||
if (searchKeyWord.value.isNotEmpty && controller.value.text != '') {
|
||||
controller.value.clear();
|
||||
if (textController.text.isNotEmpty) {
|
||||
textController.clear();
|
||||
searchKeyWord.value = '';
|
||||
tabController.index = 0;
|
||||
reset();
|
||||
} else {
|
||||
Get.back();
|
||||
}
|
||||
loadingStatus.value = 'init';
|
||||
}
|
||||
|
||||
void onChange(value) {
|
||||
searchKeyWord.value = value;
|
||||
}
|
||||
|
||||
// 提交搜索内容
|
||||
void submit() {
|
||||
loadingStatus.value = 'loading';
|
||||
if (hasRequest) {
|
||||
archivePn = 1;
|
||||
searchArchives();
|
||||
if (searchKeyWord.value != textController.text) {
|
||||
reset();
|
||||
searchKeyWord.value = textController.text;
|
||||
}
|
||||
}
|
||||
|
||||
// 搜索视频
|
||||
Future searchArchives({type = 'init'}) async {
|
||||
if (type == 'onLoad' && loadingText.value == '没有更多了') {
|
||||
if (type == 'onLoad' && loadingArchiveText.value == '没有更多了') {
|
||||
return;
|
||||
}
|
||||
var res = await MemberHttp.memberArchive(
|
||||
mid: mid,
|
||||
pn: archivePn,
|
||||
keyword: controller.value.text,
|
||||
keyword: textController.text,
|
||||
order: 'pubdate',
|
||||
);
|
||||
if (res['status']) {
|
||||
if (type == 'init' || archivePn == 1) {
|
||||
archiveList.value = res['data'].list.vlist;
|
||||
_archiveCount = res['data'].page['count'];
|
||||
setCount();
|
||||
} else {
|
||||
archiveList.addAll(res['data'].list.vlist);
|
||||
}
|
||||
archiveCount = res['data'].page['count'];
|
||||
if (archiveList.length == archiveCount) {
|
||||
loadingText.value = '没有更多了';
|
||||
if (archiveList.length == _archiveCount) {
|
||||
loadingArchiveText.value = '没有更多了';
|
||||
}
|
||||
archivePn += 1;
|
||||
hasRequest = true;
|
||||
}
|
||||
loadingStatus.value = 'finish';
|
||||
return res;
|
||||
}
|
||||
|
||||
// 搜索动态
|
||||
Future searchDynamic() async {}
|
||||
Future searchDynamic({type = 'init'}) async {
|
||||
if (!dynamicHasMore) {
|
||||
return;
|
||||
}
|
||||
var res = await MemberHttp.memberDynamicSearch(
|
||||
pn: dynamicPn,
|
||||
mid: mid,
|
||||
offset: dynamicOffset,
|
||||
keyword: textController.text,
|
||||
);
|
||||
if (res['status']) {
|
||||
dynamicOffset = res['data'].offset;
|
||||
dynamicHasMore = res['data'].hasMore;
|
||||
if (type == 'init') {
|
||||
dynamicList.value = res['data'].items;
|
||||
_dynamicCount = res['data'].total;
|
||||
setCount();
|
||||
} else {
|
||||
dynamicList.addAll(res['data'].items);
|
||||
}
|
||||
if (!dynamicHasMore) {
|
||||
loadingDynamicText.value = '没有更多了';
|
||||
}
|
||||
dynamicPn += 1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
//
|
||||
onLoad() {
|
||||
searchArchives(type: 'onLoad');
|
||||
if (tabController.index == 0) {
|
||||
searchArchives(type: 'onLoad');
|
||||
} else {
|
||||
searchDynamic(type: 'onLoad');
|
||||
}
|
||||
}
|
||||
|
||||
// 重置状态
|
||||
void reset() {
|
||||
archiveList.clear();
|
||||
dynamicList.clear();
|
||||
archivePn = 1;
|
||||
dynamicPn = 1;
|
||||
dynamicOffset = '';
|
||||
dynamicHasMore = true;
|
||||
_archiveCount = 0;
|
||||
_dynamicCount = 0;
|
||||
loadingArchiveText.value = '加载中...';
|
||||
loadingDynamicText.value = '加载中...';
|
||||
}
|
||||
|
||||
setCount() {
|
||||
tabs.value = [
|
||||
"视频${_archiveCount > 0 ? '($_archiveCount)' : ''}",
|
||||
"动态${_dynamicCount > 0 ? '($_dynamicCount)' : ''}"
|
||||
];
|
||||
}
|
||||
}
|
||||
|
140
lib/pages/member_search/dynamic.dart
Normal file
140
lib/pages/member_search/dynamic.dart
Normal file
@ -0,0 +1,140 @@
|
||||
import 'package:easy_debounce/easy_throttle.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/common/skeleton/dynamic_card.dart';
|
||||
import 'package:pilipala/common/widgets/http_error.dart';
|
||||
import 'package:pilipala/common/widgets/no_data.dart';
|
||||
import 'package:pilipala/models/dynamics/result.dart';
|
||||
import 'package:pilipala/pages/dynamics/widgets/dynamic_panel.dart';
|
||||
|
||||
import 'controller.dart';
|
||||
|
||||
class SearchDynamicPage extends StatefulWidget {
|
||||
const SearchDynamicPage({
|
||||
super.key,
|
||||
required this.searchKeyWord,
|
||||
required this.controller,
|
||||
});
|
||||
|
||||
final String searchKeyWord;
|
||||
final MemberSearchController controller;
|
||||
|
||||
@override
|
||||
State<SearchDynamicPage> createState() => _SearchDynamicPageState();
|
||||
}
|
||||
|
||||
class _SearchDynamicPageState extends State<SearchDynamicPage>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
late Future _futureBuilderFuture;
|
||||
ScrollController scrollController = ScrollController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_futureBuilderFuture = widget.controller.searchDynamic();
|
||||
scrollController.addListener(
|
||||
() {
|
||||
if (scrollController.position.pixels >=
|
||||
scrollController.position.maxScrollExtent - 300) {
|
||||
EasyThrottle.throttle('search_dynamic', const Duration(seconds: 1),
|
||||
() {
|
||||
widget.controller.onLoad();
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
widget.controller.searchKeyWord.listen((p0) {
|
||||
if (context.mounted) {
|
||||
setState(() {
|
||||
_futureBuilderFuture = widget.controller.searchDynamic();
|
||||
});
|
||||
}
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
scrollController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 6),
|
||||
child: CustomScrollView(
|
||||
controller: scrollController,
|
||||
slivers: [
|
||||
FutureBuilder(
|
||||
future: _futureBuilderFuture,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
Map? data = snapshot.data;
|
||||
if (data != null && data['status']) {
|
||||
RxList<DynamicItemModel> list = widget.controller.dynamicList;
|
||||
return Obx(
|
||||
() => list.isNotEmpty
|
||||
? SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
bool isLastItem = index == list.length;
|
||||
double bottom =
|
||||
MediaQuery.paddingOf(context).bottom;
|
||||
if (isLastItem) {
|
||||
return Container(
|
||||
height: bottom + 60,
|
||||
padding: EdgeInsets.only(bottom: bottom),
|
||||
child: Center(
|
||||
child: Obx(
|
||||
() => Text(
|
||||
widget.controller.loadingDynamicText
|
||||
.value,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline,
|
||||
fontSize: 13),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return DynamicPanel(item: list[index]);
|
||||
}
|
||||
},
|
||||
childCount: list.length + 1,
|
||||
),
|
||||
)
|
||||
: const NoData(),
|
||||
);
|
||||
} else {
|
||||
return HttpError(
|
||||
errMsg: data?['msg'] ?? '请求异常',
|
||||
fn: () => setState(() {
|
||||
_futureBuilderFuture = widget.controller.searchDynamic();
|
||||
}),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return skeleton();
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget skeleton() {
|
||||
return SliverList(
|
||||
delegate: SliverChildBuilderDelegate((context, index) {
|
||||
return const DynamicCardSkeleton();
|
||||
}, childCount: 5),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,13 +1,9 @@
|
||||
import 'package:easy_debounce/easy_throttle.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pilipala/common/skeleton/video_card_h.dart';
|
||||
import 'package:pilipala/common/widgets/http_error.dart';
|
||||
import 'package:pilipala/common/widgets/no_data.dart';
|
||||
import 'package:pilipala/common/widgets/video_card_h.dart';
|
||||
|
||||
import 'archive.dart';
|
||||
import 'controller.dart';
|
||||
import 'dynamic.dart';
|
||||
|
||||
class MemberSearchPage extends StatefulWidget {
|
||||
const MemberSearchPage({super.key});
|
||||
@ -20,30 +16,6 @@ class _MemberSearchPageState extends State<MemberSearchPage>
|
||||
with SingleTickerProviderStateMixin {
|
||||
final MemberSearchController _memberSearchCtr =
|
||||
Get.put(MemberSearchController());
|
||||
late ScrollController scrollController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
scrollController = _memberSearchCtr.scrollController;
|
||||
scrollController.addListener(
|
||||
() {
|
||||
if (scrollController.position.pixels >=
|
||||
scrollController.position.maxScrollExtent - 300) {
|
||||
EasyThrottle.throttle('history', const Duration(seconds: 1), () {
|
||||
_memberSearchCtr.onLoad();
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
// _tabController = TabController(length: 2, vsync: this);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// _tabController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -51,141 +23,74 @@ class _MemberSearchPageState extends State<MemberSearchPage>
|
||||
appBar: AppBar(
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () => _memberSearchCtr.submit(),
|
||||
icon: const Icon(CupertinoIcons.search, size: 22)),
|
||||
onPressed: () => _memberSearchCtr.submit(),
|
||||
icon: const Icon(CupertinoIcons.search, size: 22),
|
||||
),
|
||||
const SizedBox(width: 10)
|
||||
],
|
||||
title: Obx(
|
||||
() => TextField(
|
||||
autofocus: true,
|
||||
focusNode: _memberSearchCtr.searchFocusNode,
|
||||
controller: _memberSearchCtr.controller.value,
|
||||
textInputAction: TextInputAction.search,
|
||||
onChanged: (value) => _memberSearchCtr.onChange(value),
|
||||
decoration: InputDecoration(
|
||||
hintText: _memberSearchCtr.hintText,
|
||||
border: InputBorder.none,
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
Icons.clear,
|
||||
size: 22,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
onPressed: () => _memberSearchCtr.onClear(),
|
||||
),
|
||||
),
|
||||
onSubmitted: (String value) => _memberSearchCtr.submit(),
|
||||
),
|
||||
),
|
||||
title: searchTextField(),
|
||||
),
|
||||
body: Obx(
|
||||
() => Column(
|
||||
children: _memberSearchCtr.loadingStatus.value == 'init'
|
||||
? [
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Text('搜索「${_memberSearchCtr.uname.value}」的动态、视频'),
|
||||
),
|
||||
),
|
||||
]
|
||||
: [
|
||||
// TabBar(
|
||||
// controller: _tabController,
|
||||
// tabs: const [
|
||||
// Tab(text: "视频"),
|
||||
// Tab(text: "动态"),
|
||||
// ],
|
||||
// ),
|
||||
Expanded(
|
||||
child:
|
||||
// TabBarView(
|
||||
// controller: _tabController,
|
||||
// children: [
|
||||
FutureBuilder(
|
||||
future: _memberSearchCtr.searchArchives(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
Map data = snapshot.data as Map;
|
||||
if (data['status']) {
|
||||
return Obx(
|
||||
() => _memberSearchCtr.archiveList.isNotEmpty
|
||||
? ListView.builder(
|
||||
controller: scrollController,
|
||||
itemCount:
|
||||
_memberSearchCtr.archiveList.length +
|
||||
1,
|
||||
itemBuilder: (context, index) {
|
||||
if (index ==
|
||||
_memberSearchCtr
|
||||
.archiveList.length) {
|
||||
return Container(
|
||||
height: MediaQuery.of(context)
|
||||
.padding
|
||||
.bottom +
|
||||
60,
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.of(context)
|
||||
.padding
|
||||
.bottom),
|
||||
child: Center(
|
||||
child: Obx(
|
||||
() => Text(
|
||||
_memberSearchCtr
|
||||
.loadingText.value,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.outline,
|
||||
fontSize: 13),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return VideoCardH(
|
||||
videoItem: _memberSearchCtr
|
||||
.archiveList[index]);
|
||||
}
|
||||
},
|
||||
)
|
||||
: _memberSearchCtr.loadingStatus.value ==
|
||||
'loading'
|
||||
? ListView.builder(
|
||||
itemCount: 10,
|
||||
itemBuilder: (context, index) {
|
||||
return const VideoCardHSkeleton();
|
||||
},
|
||||
)
|
||||
: const CustomScrollView(
|
||||
slivers: <Widget>[
|
||||
NoData(),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return HttpError(
|
||||
errMsg: data['msg'],
|
||||
fn: () => setState(() {}),
|
||||
isInSliver: false,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// 骨架屏
|
||||
return ListView.builder(
|
||||
itemCount: 10,
|
||||
itemBuilder: (context, index) {
|
||||
return const VideoCardHSkeleton();
|
||||
},
|
||||
);
|
||||
}
|
||||
() => _memberSearchCtr.searchKeyWord.value.isEmpty
|
||||
? SizedBox(
|
||||
height: 300,
|
||||
child: Center(
|
||||
child: Text('搜索「${_memberSearchCtr.uname.value}」的动态、视频'),
|
||||
),
|
||||
)
|
||||
: Column(
|
||||
children: [
|
||||
TabBar(
|
||||
controller: _memberSearchCtr.tabController,
|
||||
dividerColor: Colors.transparent,
|
||||
splashBorderRadius: BorderRadius.circular(8),
|
||||
indicatorSize: TabBarIndicatorSize.label,
|
||||
tabs: _memberSearchCtr.tabs.map(
|
||||
(element) {
|
||||
return Tab(text: element);
|
||||
},
|
||||
),
|
||||
// ],
|
||||
// ),
|
||||
).toList(),
|
||||
),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
controller: _memberSearchCtr.tabController,
|
||||
children: [
|
||||
SearchArchivePage(
|
||||
searchKeyWord: _memberSearchCtr.textController.text,
|
||||
controller: _memberSearchCtr,
|
||||
),
|
||||
SearchDynamicPage(
|
||||
searchKeyWord: _memberSearchCtr.textController.text,
|
||||
controller: _memberSearchCtr,
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget searchTextField() {
|
||||
return TextField(
|
||||
autofocus: true,
|
||||
focusNode: _memberSearchCtr.searchFocusNode,
|
||||
controller: _memberSearchCtr.textController,
|
||||
textInputAction: TextInputAction.search,
|
||||
decoration: InputDecoration(
|
||||
hintText: '搜索',
|
||||
border: InputBorder.none,
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
Icons.clear,
|
||||
size: 22,
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
onPressed: _memberSearchCtr.onClear,
|
||||
),
|
||||
),
|
||||
onSubmitted: (String value) => _memberSearchCtr.submit(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user