mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-04 09:09:48 +08:00
create fav tag from fav panel
Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user