Skip to content

Commit

Permalink
优化visionOS UI (#265)
Browse files Browse the repository at this point in the history
* opt: Optimized User Interface for visionOS

* fix: fixed a build issue
  • Loading branch information
WindowsMEMZ committed Oct 12, 2024
1 parent 64a8956 commit d3cce6f
Show file tree
Hide file tree
Showing 26 changed files with 596 additions and 55 deletions.
Binary file added Artwork/macOS_Icon/icon-128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Artwork/macOS_Icon/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Artwork/macOS_Icon/icon-16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Artwork/macOS_Icon/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Artwork/macOS_Icon/icon-256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Artwork/macOS_Icon/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Artwork/macOS_Icon/icon-32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Artwork/macOS_Icon/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Artwork/macOS_Icon/icon-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Artwork/macOS_Icon/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
424 changes: 412 additions & 12 deletions DarockBili.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

68 changes: 68 additions & 0 deletions MeowBili/Assets.xcassets/AppIconMac.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"images" : [
{
"filename" : "icon-16.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"filename" : "[email protected]",
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"filename" : "icon-32.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"filename" : "[email protected]",
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"filename" : "icon-128.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"filename" : "[email protected]",
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"filename" : "icon-256.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"filename" : "[email protected]",
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"filename" : "icon-512.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"filename" : "[email protected]",
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions MeowBili/InMain/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ struct ContentView: View {
@State var userFaceUrl = ""
@FocusState var isSearchKeyboardFocused: Bool
var body: some View {
#if !os(visionOS) && !os(macOS)
NavigationStack {
TabView(selection: $mainTabSelection.onUpdate { oldValue, newValue in
if oldValue == newValue && newValue == 4 {
Expand Down Expand Up @@ -132,6 +133,19 @@ struct ContentView: View {
}
}
}
#else
TabView(selection: $mainTabSelection) {
NavigationSplitView(sidebar: {
MainView(mainTabSelection: $mainTabSelection)
}, detail: {

})
.tag(1)
.tabItem {
Label("navbar.suggest", systemImage: "sparkles")
}
}
#endif
}
}

Expand Down
12 changes: 12 additions & 0 deletions MeowBili/MeowBili Mac App.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>
24 changes: 24 additions & 0 deletions MeowBili/MeowBili-Mac-App-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>drkbili</string>
</array>
</dict>
</array>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict>
</plist>
109 changes: 66 additions & 43 deletions MeowBili/Video/VideoDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,21 @@ struct VideoDetailView: View {
Text("\(String(ownerFansCount).shorter()) 粉丝")
.font(.system(size: 11))
.lineLimit(1)
#if !os(visionOS)
.foregroundColor(.gray)
#else
.opacity(0.65)
#endif
Spacer()
}
}
Spacer()
}
.padding(5)
.background(Color.gray.opacity(0.35))
.cornerRadius(12)
#if !os(visionOS)
.background(Color.gray.opacity(0.35))
#endif
})
.onDrag {
PlayHaptic(sharpness: 0.05, intensity: 0.5)
Expand Down Expand Up @@ -285,8 +291,10 @@ struct VideoDetailView: View {
}
}, label: {
ZStack {
#if !os(visionOS)
RoundedRectangle(cornerRadius: 12)
.foregroundStyle(isLiked ? Color(hex: 0xfa678e) : Color.gray.opacity(0.35))
#endif
VStack {
Text(isLiked ? "" : "")
.font(.custom("bilibili", size: 20))
Expand Down Expand Up @@ -317,8 +325,10 @@ struct VideoDetailView: View {
}
}, label: {
ZStack {
#if !os(visionOS)
RoundedRectangle(cornerRadius: 12)
.foregroundStyle(isCoined ? Color(hex: 0xfa678e) : Color.gray.opacity(0.35))
#endif
VStack {
Text(isCoined ? "" : "")
.font(.custom("bilibili", size: 20))
Expand Down Expand Up @@ -347,8 +357,10 @@ struct VideoDetailView: View {
isFavoriteChoosePresented = true
}, label: {
ZStack {
#if !os(visionOS)
RoundedRectangle(cornerRadius: 12)
.foregroundStyle(isFavoured ? Color(hex: 0xfa678e) : Color.gray.opacity(0.35))
#endif
VStack {
Text(isFavoured ? "" : "")
.font(.custom("bilibili", size: 20))
Expand Down Expand Up @@ -839,58 +851,69 @@ struct VideoDetailView: View {
}
}
.sheet(isPresented: $isMoreMenuPresented) {
List {
Section {
Button(action: {
shouldPausePlayer = true
isAudioPlayerPresented = true
isMoreMenuPresented = false
}, label: {
Label("Video.play-in-audio", systemImage: "waveform")
})
}
Section {
Button(action: {
isDownloadPresented = true
}, label: {
Label("Video.download", systemImage: "arrow.down.doc")
})
.sheet(isPresented: $isDownloadPresented, content: { VideoDownloadView(bvid: videoDetails["BV"]!, videoDetails: videoDetails) })
}
Section {
Button(action: {
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"
]
AF.request("https://api.bilibili.com/x/v2/history/toview/add", method: .post, parameters: ["bvid": videoDetails["BV"]!, "csrf": biliJct], headers: headers).response { response in
do {
let json = try JSON(data: response.data ?? Data())
if let code = json["code"].int {
if code == 0 {
#if !os(visionOS)
AlertKitAPI.present(title: String(localized: "Video.added"), icon: .done, style: .iOS17AppleMusic, haptic: .success)
#endif
NavigationStack {
List {
Section {
Button(action: {
shouldPausePlayer = true
isAudioPlayerPresented = true
isMoreMenuPresented = false
}, label: {
Label("Video.play-in-audio", systemImage: "waveform")
})
}
Section {
Button(action: {
isDownloadPresented = true
}, label: {
Label("Video.download", systemImage: "arrow.down.doc")
})
.sheet(isPresented: $isDownloadPresented, content: { VideoDownloadView(bvid: videoDetails["BV"]!, videoDetails: videoDetails) })
}
Section {
Button(action: {
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"
]
AF.request("https://api.bilibili.com/x/v2/history/toview/add", method: .post, parameters: ["bvid": videoDetails["BV"]!, "csrf": biliJct], headers: headers).response { response in
do {
let json = try JSON(data: response.data ?? Data())
if let code = json["code"].int {
if code == 0 {
#if !os(visionOS)
AlertKitAPI.present(title: String(localized: "Video.added"), icon: .done, style: .iOS17AppleMusic, haptic: .success)
#endif
} else {
#if !os(visionOS)
AlertKitAPI.present(title: json["message"].string ?? String(localized: "Video.unkonwn-error"), icon: .error, style: .iOS17AppleMusic, haptic: .error)
#endif
}
} else {
#if !os(visionOS)
AlertKitAPI.present(title: json["message"].string ?? String(localized: "Video.unkonwn-error"), icon: .error, style: .iOS17AppleMusic, haptic: .error)
AlertKitAPI.present(title: String(localized: "Video.unkonwn-error"), icon: .error, style: .iOS17AppleMusic, haptic: .error)
#endif
}
} else {
} catch {
#if !os(visionOS)
AlertKitAPI.present(title: String(localized: "Video.unkonwn-error"), icon: .error, style: .iOS17AppleMusic, haptic: .error)
#endif
}
} catch {
#if !os(visionOS)
AlertKitAPI.present(title: String(localized: "Video.unkonwn-error"), icon: .error, style: .iOS17AppleMusic, haptic: .error)
#endif
isMoreMenuPresented = false
}
}, label: {
Label("Video.watch-later", systemImage: "memories.badge.plus")
})
}
}
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button(action: {
isMoreMenuPresented = false
}
}, label: {
Label("Video.watch-later", systemImage: "memories.badge.plus")
})
}, label: {
Text("完成")
})
}
}
}
.presentationDetents([.medium, .large])
Expand Down

0 comments on commit d3cce6f

Please sign in to comment.