feat: create/update/del follow tag

opt: owner follow page

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-23 11:12:17 +08:00
parent e212144250
commit 0d27d88719
9 changed files with 405 additions and 87 deletions

View File

@@ -4,14 +4,21 @@ import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/models/follow/result.dart';
import 'package:PiliPlus/pages/follow/child_controller.dart';
import 'package:PiliPlus/pages/follow/controller.dart';
import 'package:PiliPlus/pages/follow/widgets/follow_item.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class FollowChildPage extends StatefulWidget {
const FollowChildPage({super.key, required this.mid, this.tagid});
const FollowChildPage({
super.key,
required this.controller,
required this.mid,
this.tagid,
});
final FollowController controller;
final int mid;
final int? tagid;
@@ -22,30 +29,50 @@ class FollowChildPage extends StatefulWidget {
class _FollowChildPageState extends State<FollowChildPage>
with AutomaticKeepAliveClientMixin {
late final _followController = Get.put(
FollowChildController(widget.mid, widget.tagid),
FollowChildController(widget.controller, widget.mid, widget.tagid),
tag: Utils.generateRandomString(8));
late final _isOwner = widget.tagid != null;
@override
Widget build(BuildContext context) {
super.build(context);
return refreshIndicator(
onRefresh: () async {
await _followController.onRefresh();
},
child: CustomScrollView(
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
SliverPadding(
padding: EdgeInsets.only(
bottom: MediaQuery.paddingOf(context).bottom + 80),
sliver: Obx(() => _buildBody(_followController.loadingState.value)),
),
],
),
);
if (widget.controller.isOwner && widget.tagid == null) {
return Scaffold(
backgroundColor: Colors.transparent,
body: _child,
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
_followController
..orderType.value =
_followController.orderType.value == OrderType.def
? OrderType.attention
: OrderType.def
..onReload();
},
icon: const Icon(Icons.format_list_bulleted, size: 20),
label: Obx(() => Text(_followController.orderType.value.title)),
),
);
}
return _child;
}
Widget get _child => refreshIndicator(
onRefresh: () async {
await _followController.onRefresh();
},
child: CustomScrollView(
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(
@@ -63,7 +90,7 @@ class _FollowChildPageState extends State<FollowChildPage>
}
return FollowItem(
item: loadingState.response![index],
isOwner: _isOwner,
isOwner: widget.controller.isOwner,
callback: (attr) {
List<FollowItemModel> list =
(_followController.loadingState.value as Success)
@@ -86,5 +113,5 @@ class _FollowChildPageState extends State<FollowChildPage>
}
@override
bool get wantKeepAlive => widget.tagid != null;
bool get wantKeepAlive => widget.controller.tabController != null;
}