From 883c29348405e7ffdcc9df729cf2082061fe3b73 Mon Sep 17 00:00:00 2001 From: WindowsMEMZ Date: Sat, 6 Jan 2024 15:41:04 +0800 Subject: [PATCH] Featured - Choose favorite folder, fixed issue at the same time --- .../Video/VideoDetailView.swift | 106 +++++++++++++++--- 1 file changed, 92 insertions(+), 14 deletions(-) diff --git a/DarockBili Watch App/Video/VideoDetailView.swift b/DarockBili Watch App/Video/VideoDetailView.swift index 9daadd098..2ad205efd 100644 --- a/DarockBili Watch App/Video/VideoDetailView.swift +++ b/DarockBili Watch App/Video/VideoDetailView.swift @@ -608,6 +608,7 @@ struct VideoDetailView: View { @State var bvidTextOffset: CGFloat = 20 @State var descOffset: CGFloat = 20 @State var tagOffset: CGFloat = 20 + @State var isFavoriteChoosePresented = false var body: some View { ScrollView { VStack { @@ -689,20 +690,7 @@ struct VideoDetailView: View { .buttonBorderShape(.roundedRectangle(radius: 18)) .sheet(isPresented: $isCoinViewPresented, content: {VideoThrowCoinView(bvid: videoDetails["BV"]!)}) Button(action: { - let headers: HTTPHeaders = [ - "cookie": "SESSDATA=\(sessdata); buvid3=\(globalBuvid3)", - "referer": "https://www.bilibili.com/video/\(videoDetails["BV"]!)/", - "User-Agent": "Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" - ] - let avid = bv2av(bvid: videoDetails["BV"]!) - AF.request("https://api.bilibili.com/x/v3/fav/resource/deal", method: .post, parameters: BiliVideoFavourite(rid: avid, csrf: biliJct), headers: headers).response { response in - debugPrint(response) - if let rpd = response.data { - if !CheckBApiError(from: try! JSON(data: rpd)) { return } - isLiked ? tipWithText("取消成功", symbol: "checkmark.circle.fill") : tipWithText("收藏成功", symbol: "checkmark.circle.fill") - isFavoured.toggle() - } - } + isFavoriteChoosePresented = true }, label: { VStack { Image(systemName: isFavoured ? "star.fill" : "star") @@ -722,6 +710,7 @@ struct VideoDetailView: View { .onAppear { statLineOffset = 0 } + .sheet(isPresented: $isFavoriteChoosePresented, content: {VideoFavoriteAddView(videoDetails: $videoDetails, isFavoured: $isFavoured)}) Spacer() .frame(height: 10) VStack { @@ -811,6 +800,95 @@ struct VideoDetailView: View { } } } + + struct VideoFavoriteAddView: View { + @Binding var videoDetails: [String: String] + @Binding var isFavoured: Bool + @Environment(\.dismiss) var dismiss + @AppStorage("DedeUserID") var dedeUserID = "" + @AppStorage("DedeUserID__ckMd5") var dedeUserID__ckMd5 = "" + @AppStorage("SESSDATA") var sessdata = "" + @AppStorage("bili_jct") var biliJct = "" + @State var favoriteFolderList = [[String: String]]() + @State var isFavoriteTargetIn = [Bool]() + @State var isItemLoading = [Bool]() + var body: some View { + NavigationStack { + List { + if isItemLoading.count != 0 { + ForEach(0..