create fav tag from fav panel

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-04-26 20:36:59 +08:00
parent b9ce4bad67
commit dccb5d4bf5
6 changed files with 163 additions and 110 deletions

View File

@@ -45,36 +45,35 @@ class FollowController extends GetxController with GetTickerProviderStateMixin {
tabs
..assign(MemberTagItemModel(name: '全部关注'))
..addAll(response);
int initialIndex = 0;
if (tabController != null) {
initialIndex = tabController!.index.clamp(0, tabs.length - 1);
tabController!.dispose();
}
tabController = TabController(
initialIndex: initialIndex,
length: tabs.length,
vsync: this,
);
onInitTab();
followState.value = Success(tabs.hashCode);
} else {
followState.value = res;
}
}
@override
void onClose() {
tabController?.dispose();
super.onClose();
void onInitTab() {
int initialIndex = 0;
if (tabController != null) {
initialIndex = tabController!.index.clamp(0, tabs.length - 1);
tabController!.dispose();
}
tabController = TabController(
initialIndex: initialIndex,
length: tabs.length,
vsync: this,
);
}
Future<void> onCreateTag(String tagName) async {
final res = await MemberHttp.createFollowTag(tagName);
if (res.isSuccess) {
void onCreateFavTag(({int tagid, String tagName}) res) {
if (isClosed) return;
if (followState.value.isSuccess) {
tabs.add(MemberTagItemModel.fromCreate(res));
onInitTab();
followState.refresh();
} else {
followState.value = LoadingState.loading();
queryFollowUpTags();
SmartDialog.showToast('创建成功');
} else {
res.toast();
}
}
@@ -89,14 +88,22 @@ class FollowController extends GetxController with GetTickerProviderStateMixin {
}
}
Future<void> onDelTag(int tagid) async {
Future<void> onDelTag(int index, int tagid) async {
final res = await MemberHttp.delFollowTag(tagid);
if (res.isSuccess) {
followState.value = LoadingState.loading();
queryFollowUpTags();
tabs.removeAt(index);
onInitTab();
followState.refresh();
SmartDialog.showToast('删除成功');
} else {
res.toast();
}
}
@override
void onClose() {
tabController?.dispose();
tabController = null;
super.onClose();
}
}