Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-07-23 16:47:11 +08:00
parent 148e0872b4
commit 418a1e8d39
821 changed files with 29467 additions and 25520 deletions

View File

@@ -56,8 +56,8 @@ class _FollowChildPageState extends State<FollowChildPage>
onPressed: () => _followController
..orderType.value =
_followController.orderType.value == FollowOrderType.def
? FollowOrderType.attention
: FollowOrderType.def
? FollowOrderType.attention
: FollowOrderType.def
..onReload(),
icon: const Icon(Icons.format_list_bulleted, size: 20),
label: Obx(() => Text(_followController.orderType.value.title)),
@@ -70,53 +70,54 @@ class _FollowChildPageState extends State<FollowChildPage>
}
Widget get _child => refreshIndicator(
onRefresh: _followController.onRefresh,
child: CustomScrollView(
controller: _followController.scrollController,
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
SliverPadding(
padding: EdgeInsets.only(
bottom: MediaQuery.paddingOf(context).bottom + 80),
sliver:
Obx(() => _buildBody(_followController.loadingState.value)),
),
],
onRefresh: _followController.onRefresh,
child: CustomScrollView(
controller: _followController.scrollController,
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
SliverPadding(
padding: EdgeInsets.only(
bottom: MediaQuery.paddingOf(context).bottom + 80,
),
sliver: Obx(() => _buildBody(_followController.loadingState.value)),
),
);
],
),
);
Widget _buildBody(LoadingState<List<FollowItemModel>?> loadingState) {
return switch (loadingState) {
Loading() => SliverList.builder(
itemCount: 12,
itemBuilder: (context, index) {
return const MsgFeedTopSkeleton();
},
),
Success(:var response) => response?.isNotEmpty == true
? SliverList.builder(
itemCount: response!.length,
itemBuilder: (context, index) {
if (index == response.length - 1) {
_followController.onLoadMore();
}
final item = response[index];
return FollowItem(
item: item,
isOwner: widget.controller?.isOwner,
onSelect: widget.onSelect,
callback: (attr) {
item.attribute = attr == 0 ? -1 : 0;
_followController.loadingState.refresh();
},
);
},
)
: HttpError(onReload: _followController.onReload),
itemCount: 12,
itemBuilder: (context, index) {
return const MsgFeedTopSkeleton();
},
),
Success(:var response) =>
response?.isNotEmpty == true
? SliverList.builder(
itemCount: response!.length,
itemBuilder: (context, index) {
if (index == response.length - 1) {
_followController.onLoadMore();
}
final item = response[index];
return FollowItem(
item: item,
isOwner: widget.controller?.isOwner,
onSelect: widget.onSelect,
callback: (attr) {
item.attribute = attr == 0 ? -1 : 0;
_followController.loadingState.refresh();
},
);
},
)
: HttpError(onReload: _followController.onReload),
Error(:var errMsg) => HttpError(
errMsg: errMsg,
onReload: _followController.onReload,
),
errMsg: errMsg,
onReload: _followController.onReload,
),
};
}

View File

@@ -20,8 +20,10 @@ class FollowPage extends StatefulWidget {
class _FollowPageState extends State<FollowPage> {
final _tag = Utils.generateRandomString(8);
late final FollowController _followController =
Get.put(FollowController(), tag: _tag);
late final FollowController _followController = Get.put(
FollowController(),
tag: _tag,
);
@override
Widget build(BuildContext context) {
@@ -60,7 +62,7 @@ class _FollowPageState extends State<FollowPage> {
Text('黑名单管理'),
],
),
)
),
],
),
const SizedBox(width: 6),
@@ -74,11 +76,11 @@ class _FollowPageState extends State<FollowPage> {
}
Widget _childPage([MemberTagItemModel? item]) => FollowChildPage(
tag: _tag,
controller: _followController,
mid: _followController.mid,
tagid: item?.tagid,
);
tag: _tag,
controller: _followController,
mid: _followController.mid,
tagid: item?.tagid,
);
bool _isCustomTag(int? tagid) {
return tagid != null && tagid != 0 && tagid != -10 && tagid != -2;
@@ -88,64 +90,66 @@ class _FollowPageState extends State<FollowPage> {
return switch (loadingState) {
Loading() => loadingWidget,
Success() => Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SafeArea(
top: false,
bottom: false,
child: TabBar(
isScrollable: true,
tabAlignment: TabAlignment.start,
controller: _followController.tabController,
tabs: List.generate(_followController.tabs.length, (index) {
return Obx(() {
final item = _followController.tabs[index];
int? count = item.count;
if (_isCustomTag(item.tagid)) {
return GestureDetector(
behavior: HitTestBehavior.translucent,
onLongPress: () {
Feedback.forLongPress(context);
_onHandleTag(index, item);
},
child: Tab(
child: Row(
children: [
Text(
'${item.name}${count != null ? '($count)' : ''} ',
),
const Icon(Icons.menu, size: 18),
],
),
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SafeArea(
top: false,
bottom: false,
child: TabBar(
isScrollable: true,
tabAlignment: TabAlignment.start,
controller: _followController.tabController,
tabs: List.generate(_followController.tabs.length, (index) {
return Obx(() {
final item = _followController.tabs[index];
int? count = item.count;
if (_isCustomTag(item.tagid)) {
return GestureDetector(
behavior: HitTestBehavior.translucent,
onLongPress: () {
Feedback.forLongPress(context);
_onHandleTag(index, item);
},
child: Tab(
child: Row(
children: [
Text(
'${item.name}${count != null ? '($count)' : ''} ',
),
const Icon(Icons.menu, size: 18),
],
),
);
}
return Tab(
text: '${item.name}${count != null ? '($count)' : ''}');
});
}),
onTap: (value) {
if (!_followController.tabController!.indexIsChanging) {
final item = _followController.tabs[value];
// if (_isCustomTag(item.tagid)) {
// _onHandleTag(value, item);
// }
try {
Get.find<FollowChildController>(tag: '$_tag${item.tagid}')
.animateToTop();
} catch (_) {}
),
);
}
},
),
return Tab(
text: '${item.name}${count != null ? '($count)' : ''}',
);
});
}),
onTap: (value) {
if (!_followController.tabController!.indexIsChanging) {
final item = _followController.tabs[value];
// if (_isCustomTag(item.tagid)) {
// _onHandleTag(value, item);
// }
try {
Get.find<FollowChildController>(
tag: '$_tag${item.tagid}',
).animateToTop();
} catch (_) {}
}
},
),
Expanded(
child: tabBarView(
controller: _followController.tabController,
children: _followController.tabs.map(_childPage).toList(),
),
),
Expanded(
child: tabBarView(
controller: _followController.tabController,
children: _followController.tabs.map(_childPage).toList(),
),
],
),
),
],
),
Error() => _childPage(),
};
}
@@ -174,8 +178,9 @@ class _FollowPageState extends State<FollowPage> {
inputFormatters: [
LengthLimitingTextInputFormatter(16),
],
decoration:
const InputDecoration(border: OutlineInputBorder()),
decoration: const InputDecoration(
border: OutlineInputBorder(),
),
),
onConfirm: () {
if (tagName.isNotEmpty) {

View File

@@ -95,8 +95,9 @@ class FollowItem extends StatelessWidget {
),
style: FilledButton.styleFrom(
padding: const EdgeInsets.fromLTRB(15, 0, 15, 0),
foregroundColor:
item.attribute == -1 ? null : theme.colorScheme.outline,
foregroundColor: item.attribute == -1
? null
: theme.colorScheme.outline,
backgroundColor: item.attribute == -1
? null
: theme.colorScheme.onInverseSurface,