Skip to content

Commit

Permalink
Merge pull request #293 from Darock-Studio/fix/ui
Browse files Browse the repository at this point in the history
fix: fixed bangumi UI on iOS devices
  • Loading branch information
WindowsMEMZ authored Mar 2, 2024
2 parents 44b7b1f + a839b33 commit 6622d4d
Show file tree
Hide file tree
Showing 8 changed files with 199 additions and 78 deletions.
30 changes: 15 additions & 15 deletions DarockBili.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@

/* Begin PBXFileReference section */
8C0557E02B7A0480009D9CD0 /* MeowBili.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = MeowBili.entitlements; sourceTree = "<group>"; };
8C617F5B2B924C5B000A3687 /* ci_post_clone.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = ci_post_clone.sh; sourceTree = "<group>"; };
8C617F3E2B92334B000A3687 /* SafariExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = SafariExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
8C617F402B92334B000A3687 /* SafariWebExtensionHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariWebExtensionHandler.swift; sourceTree = "<group>"; };
8C617F432B92334B000A3687 /* _locales */ = {isa = PBXFileReference; lastKnownFileType = folder; path = _locales; sourceTree = "<group>"; };
Expand All @@ -391,6 +390,7 @@
8C617F4F2B92334B000A3687 /* popup.css */ = {isa = PBXFileReference; lastKnownFileType = text.css; path = popup.css; sourceTree = "<group>"; };
8C617F512B92334B000A3687 /* popup.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = popup.js; sourceTree = "<group>"; };
8C617F532B92334B000A3687 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8C617F5B2B924C5B000A3687 /* ci_post_clone.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = ci_post_clone.sh; sourceTree = "<group>"; };
8C72E32A2B6605B80087486E /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
8CA370D92B82724400CE0E9E /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
8CA370E82B83BB4F00CE0E9E /* MeowBili Vision App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "MeowBili Vision App.app"; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -1581,7 +1581,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 881;
CURRENT_PROJECT_VERSION = 885;
DEVELOPMENT_TEAM = B57D8PP775;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = SafariExtension/Info.plist;
Expand All @@ -1593,7 +1593,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 1.0.0;
OTHER_LDFLAGS = (
"-framework",
SafariServices,
Expand All @@ -1612,7 +1612,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 881;
CURRENT_PROJECT_VERSION = 885;
DEVELOPMENT_TEAM = B57D8PP775;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = SafariExtension/Info.plist;
Expand All @@ -1624,7 +1624,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 1.0.0;
OTHER_LDFLAGS = (
"-framework",
SafariServices,
Expand All @@ -1648,7 +1648,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Vision App.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 881;
CURRENT_PROJECT_VERSION = 885;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1683,7 +1683,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Vision App.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 881;
CURRENT_PROJECT_VERSION = 885;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1720,7 +1720,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = MeowBili/MeowBili.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 881;
CURRENT_PROJECT_VERSION = 885;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1767,7 +1767,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = MeowBili/MeowBili.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 881;
CURRENT_PROJECT_VERSION = 885;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1811,7 +1811,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIconWatch;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 881;
CURRENT_PROJECT_VERSION = 885;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview\\ Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1847,7 +1847,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIconWatch;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 881;
CURRENT_PROJECT_VERSION = 885;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview\\ Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1886,7 +1886,7 @@
CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Mac App.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 881;
CURRENT_PROJECT_VERSION = 885;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_HARDENED_RUNTIME = YES;
Expand Down Expand Up @@ -1919,7 +1919,7 @@
CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Mac App.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 881;
CURRENT_PROJECT_VERSION = 885;
DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\"";
DEVELOPMENT_TEAM = B57D8PP775;
ENABLE_HARDENED_RUNTIME = YES;
Expand Down Expand Up @@ -1948,7 +1948,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 881;
CURRENT_PROJECT_VERSION = 885;
DEVELOPMENT_TEAM = B57D8PP775;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
Expand All @@ -1971,7 +1971,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 881;
CURRENT_PROJECT_VERSION = 885;
DEVELOPMENT_TEAM = B57D8PP775;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
Expand Down
3 changes: 3 additions & 0 deletions Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@
}
}
}
},
"%@粉丝" : {

},
"%lld" : {
"extractionState" : "stale",
Expand Down
88 changes: 80 additions & 8 deletions MeowBili/Bangumi/BangumiDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@ import SDWebImageSwiftUI
#endif

struct BangumiDetailView: View {
public static var willPlayBangumiLink = ""
public static var willPlayBangumiData: BangumiData?
@State var bangumiData: BangumiData
@AppStorage("DedeUserID") var dedeUserID = ""
@AppStorage("DedeUserID__ckMd5") var dedeUserID__ckMd5 = ""
@AppStorage("SESSDATA") var sessdata = ""
@AppStorage("bili_jct") var biliJct = ""
@AppStorage("RecordHistoryTime") var recordHistoryTime = "into"
@AppStorage("IsDanmakuEnabled") var isDanmakuEnabled = true
@State var paymentData: BangumiPayment?
@State var epDatas = [BangumiEp]()
@State var isLoading = false
Expand All @@ -43,15 +42,37 @@ struct BangumiDetailView: View {
@State var isMoreMenuPresented = false
@State var backgroundPicOpacity = 0.0
@State var navigationSelectedEpdata: BangumiEp?
@State var bangumiLink = ""
@State var isDecoded = false
@State var isShouldPause = false
@State var currentPlayTime = 0.0
var body: some View {
TabView {
ZStack {
Group {
#if os(watchOS)
ScrollView {
DetailViewFirstPageBase(bangumiData: $bangumiData, isBangumiPlayerPresented: $isBangumiPlayerPresented, isLoading: $isLoading)
DetailViewSecondPageBase(bangumiData: $bangumiData, paymentData: $paymentData)
EpisodeListView(bangumiData: $bangumiData, epDatas: $epDatas, isBangumiPlayerPresented: $isBangumiPlayerPresented, isLoading: $isLoading)
EpisodeListView(bangumiData: $bangumiData, epDatas: $epDatas, isBangumiPlayerPresented: $isBangumiPlayerPresented, isLoading: $isLoading, bangumiLink: $bangumiLink)
}
#else
VStack {
if isDecoded {
BangumiPlayerView(bangumiData: $bangumiData, isDanmakuEnabled: $isDanmakuEnabled, bangumiLink: $bangumiLink, shouldPause: $isShouldPause, currentPlayTime: $currentPlayTime)
.frame(height: 240)
} else {
Rectangle()
.frame(height: 240)
.redacted(reason: .placeholder)
.accessibilityIdentifier("BangumiNotLoadPlaceholder")
}
ScrollView {
EpisodeListView(bangumiData: $bangumiData, epDatas: $epDatas, isBangumiPlayerPresented: $isBangumiPlayerPresented, isLoading: $isLoading, bangumiLink: $bangumiLink)
DetailViewSecondPageBase(bangumiData: $bangumiData, paymentData: $paymentData)
}
}
#endif
}
.blur(radius: isLoading ? 14 : 0)
if isLoading {
Expand Down Expand Up @@ -102,6 +123,15 @@ struct BangumiDetailView: View {
for ep in respJson["result"]["main_section"]["episodes"] {
epDatas.append(BangumiEp(aid: ep.1["aid"].int64 ?? 0, epid: ep.1["id"].int64 ?? 0, cid: ep.1["cid"].int64 ?? 0, cover: ep.1["cover"].string ?? "E", title: ep.1["title"].string ?? "[加载失败]", longTitle: ep.1["long_title"].string ?? "[加载失败]"))
}
#if !os(watchOS)
DarockKit.Network.shared.requestJSON("https://api.bilibili.com/pgc/player/web/playurl?ep_id=\(epDatas[0].epid)&qn=16&fnval=1", headers: headers) { respJson, isSuccess in
if isSuccess {
if !CheckBApiError(from: respJson) { return }
bangumiLink = respJson["result"]["durl"][0]["url"].string!.replacingOccurrences(of: "\\u0026", with: "&")
isDecoded = true
}
}
#endif
}
}
}
Expand All @@ -116,7 +146,6 @@ struct BangumiDetailView: View {
@AppStorage("SESSDATA") var sessdata = ""
@AppStorage("bili_jct") var biliJct = ""
@State var isCoverImageViewPresented = false

var body: some View {
VStack {
Spacer()
Expand Down Expand Up @@ -229,20 +258,63 @@ struct BangumiDetailView: View {
@Binding var epDatas: [BangumiEp]
@Binding var isBangumiPlayerPresented: Bool
@Binding var isLoading: Bool
@Binding var bangumiLink: String
@Environment(\.colorScheme) var colorScheme
@AppStorage("DedeUserID") var dedeUserID = ""
@AppStorage("DedeUserID__ckMd5") var dedeUserID__ckMd5 = ""
@AppStorage("SESSDATA") var sessdata = ""
@AppStorage("bili_jct") var biliJct = ""
@State var playingPageIndex = 0
var body: some View {
#if os(watchOS)
if #available(watchOS 10, *) {
List {
DetailCore(bangumiData: $bangumiData, epDatas: $epDatas, isBangumiPlayerPresented: $isBangumiPlayerPresented, isLoading: $isLoading)
DetailCore(bangumiData: $bangumiData, epDatas: $epDatas, isBangumiPlayerPresented: $isBangumiPlayerPresented, isLoading: $isLoading, bangumiLink: $bangumiLink)
}
} else {
VStack {
DetailCore(bangumiData: $bangumiData, epDatas: $epDatas, isBangumiPlayerPresented: $isBangumiPlayerPresented, isLoading: $isLoading)
DetailCore(bangumiData: $bangumiData, epDatas: $epDatas, isBangumiPlayerPresented: $isBangumiPlayerPresented, isLoading: $isLoading, bangumiLink: $bangumiLink)
}
}
#else
if epDatas.count != 0 {
ScrollView(.horizontal) {
HStack {
ForEach(0..<epDatas.count, id: \.self) { i in
Button(action: {
playingPageIndex = i
let headers: HTTPHeaders = [
"cookie": "SESSDATA=\(sessdata)",
"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"
]
DarockKit.Network.shared.requestJSON("https://api.bilibili.com/pgc/player/web/playurl?ep_id=\(epDatas[i].epid)&qn=16&fnval=1", headers: headers) { respJson, isSuccess in
if isSuccess {
if !CheckBApiError(from: respJson) { return }
bangumiLink = respJson["result"]["durl"][0]["url"].string!.replacingOccurrences(of: "\\u0026", with: "&")
}
}
}, label: {
HStack {
VStack {
Text(String(i + 1))
.foregroundColor(playingPageIndex == i ? .accentColor : (colorScheme == .dark ? .white : .black))
Spacer()
}
Text(epDatas[i].longTitle)
.lineLimit(2)
.foregroundColor(playingPageIndex == i ? .accentColor : (colorScheme == .dark ? .white : .black))
}
.font(.system(size: 14))
})
.buttonStyle(.bordered)
.frame(height: 60)
.frame(maxWidth: 160)
}
}
}
.scrollIndicators(.never)
}
#endif
}

// OS 10- support
Expand All @@ -251,6 +323,7 @@ struct BangumiDetailView: View {
@Binding var epDatas: [BangumiEp]
@Binding var isBangumiPlayerPresented: Bool
@Binding var isLoading: Bool
@Binding var bangumiLink: String
@AppStorage("DedeUserID") var dedeUserID = ""
@AppStorage("DedeUserID__ckMd5") var dedeUserID__ckMd5 = ""
@AppStorage("SESSDATA") var sessdata = ""
Expand All @@ -268,8 +341,7 @@ struct BangumiDetailView: View {
DarockKit.Network.shared.requestJSON("https://api.bilibili.com/pgc/player/web/playurl?ep_id=\(epDatas[i].epid)&qn=16&fnval=1", headers: headers) { respJson, isSuccess in
if isSuccess {
if !CheckBApiError(from: respJson) { return }
BangumiDetailView.willPlayBangumiLink = respJson["result"]["durl"][0]["url"].string!.replacingOccurrences(of: "\\u0026", with: "&")
BangumiDetailView.willPlayBangumiData = bangumiData
bangumiLink = respJson["result"]["durl"][0]["url"].string!.replacingOccurrences(of: "\\u0026", with: "&")
isBangumiPlayerPresented = true
isLoading = false
}
Expand Down
Loading

0 comments on commit 6622d4d

Please sign in to comment.