Skip to content

Commit

Permalink
Merge pull request #397 from Darock-Studio/feat/downloaded-audio
Browse files Browse the repository at this point in the history
feat: Playing audio only for downloaded videos
  • Loading branch information
Mark Chan authored Aug 15, 2024
2 parents f647e49 + c41b066 commit 2e5f144
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 30 deletions.
15 changes: 6 additions & 9 deletions Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,6 @@
},
"“喵哩喵哩”新功能" : {

},
"[Hex Data]" : {

},
"[Privacy Hidden]" : {

},
"%@" : {
"localizations" : {
Expand Down Expand Up @@ -9292,6 +9286,9 @@
}
}
}
},
"更新标签" : {

},
"未完成的编辑" : {

Expand Down Expand Up @@ -9364,6 +9361,9 @@
}
}
}
},
"标签不会被本地化,因为它们是动态添加的。" : {

},
"标题" : {
"localizations" : {
Expand Down Expand Up @@ -9957,9 +9957,6 @@
}
}
}
},
"通知令牌" : {

},
"重新载入" : {
"localizations" : {
Expand Down
106 changes: 96 additions & 10 deletions MeowBili/Errors/FeedbackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,43 @@ struct InAppFeedbackView: View {
Text(from[i].split(separator: "").count > 1 ? String(from[i].split(separator: "")[1]) : from[i])
.font(.system(size: 14))
}
} else if (from[i].contains("") && from[i] != "" ? from[i].split(separator: "")[0] : "") == "NotificationToken" {
Text("[Hex Data]")
.font(.system(size: 14))
} else if (from[i].contains("") && from[i] != "" ? from[i].split(separator: "")[0] : "") == "Settings" {
Text("[Privacy Hidden]")
.font(.system(size: 14))
} else if (from[i].contains("") && from[i] != "" ? from[i].split(separator: "")[0] : "") == "UpdateTitle" {
if let source = from[i].split(separator: "")[from: 1]?.split(separator: "__->__")[from: 0],
let to = from[i].split(separator: "")[from: 1]?.split(separator: "__->__")[from: 1] {
Markdown("~\(source)~ → **\(to)**")
.markdownTheme(.gitHub)
}
} else if (from[i].contains("") && from[i] != "" ? from[i].split(separator: "")[0] : "") == "UpdateTags" {
if let combined = from[i].split(separator: "")[from: 1] {
let tags = Array<FeedbackTag>(fromCombined: String(combined))
if !tags.isEmpty {
ScrollView(.horizontal) {
HStack {
ForEach(0..<tags.count, id: \.self) { i in
Text(tags[i].name)
.font(.system(size: 15, weight: .semibold))
.foregroundStyle(Color.white)
.padding(.horizontal, 8)
.padding(.vertical, 3)
.background {
if #available(watchOS 10.0, *) {
Capsule()
.fill(tags[i].color)
.stroke(Material.ultraThin.opacity(0.2), lineWidth: 2)
} else {
tags[i].color
.clipShape(Capsule())
}
}
}
}
}
.scrollIndicators(.never)
if NSLocale.current.language.languageCode!.identifier != "zh" {
Text("标签不会被本地化,因为它们是动态添加的。")
}
}
}
} else if (from[i].contains("") && from[i] != ""
? from[i].split(separator: "")[0]
: "") == "AddDuplicateDelete"
Expand Down Expand Up @@ -543,10 +574,8 @@ extension String {
return "与此反馈重复"
case "AddDuplicateDelete":
return "关联反馈"
case "NotificationToken":
return "通知令牌"
case "Settings":
return "设置"
case "UpdateTags":
return "更新标签"
default:
return LocalizedStringKey(self)
}
Expand All @@ -563,3 +592,60 @@ extension Data {
return self.map { String(format: format, $0) }.joined()
}
}

struct FeedbackTag: Equatable {
var name: String
var color: Color

init(name: String, color: Color) {
self.name = name
self.color = color
}
init?(fromCombined string: String) {
let spd = string.components(separatedBy: "&&&")
if let name = spd[from: 0], let colors = spd[from: 1] {
let colorSplited = colors.components(separatedBy: ",")
if let red = colorSplited[from: 0], let green = colorSplited[from: 1], let blue = colorSplited[from: 2],
let red = Double(red), let green = Double(green), let blue = Double(blue) {
self.name = name
self.color = Color(red: red, green: green, blue: blue)
return
}
}

return nil
}

func toString() -> String {
let uiColor = UIColor(color)
var red: CGFloat = 0
var green: CGFloat = 0
var blue: CGFloat = 0
uiColor.getRed(&red, green: &green, blue: &blue, alpha: nil)
return "\(name)&&&\(red),\(green),\(blue)"
}

static func == (lhs: FeedbackTag, rhs: FeedbackTag) -> Bool {
return lhs.name == rhs.name
}
}
extension Array<FeedbackTag> {
init(fromCombined string: String) {
var result = [FeedbackTag]()
let spd = string.components(separatedBy: "<****>")
for tag in spd {
if let tag = FeedbackTag(fromCombined: tag) {
result.append(tag)
}
}

self = result
}

func toString() -> String {
if isEmpty {
return "[None]"
}
return map { $0.toString() }.joined(separator: "<****>")
}
}
16 changes: 7 additions & 9 deletions MeowBili/PersonalCenter/DownloadsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,6 @@ struct DownloadsView: View {
@State var searchInput = ""
var body: some View {
List {
#if os(watchOS)
if #unavailable(watchOS 10) {
Section {
NavigationLink(destination: { DownloadingListView() }, label: {
Label("Download.list", systemImage: "list.bullet.below.rectangle")
})
}
}
#endif
Section {
if metadatas.count != 0 {
ForEach(0...metadatas.count - 1, id: \.self) { i in
Expand Down Expand Up @@ -79,6 +70,13 @@ struct DownloadsView: View {
}, label: {
Image(systemName: "xmark.bin.fill")
})
#if os(watchOS)
Button(action: {
playAudio(url: URL(filePath: vRootPath + metadatas[i]["Path"]!).absoluteString)
}, label: {
Image(systemName: "music.note")
})
#endif
}
}
} else {
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@

使用[最新的 Release](https://github.com/Darock-Studio/Darock-Bili/releases/latest) 编译以获取与官方分发相同的稳定版本。

由于一个未知问题,您可能需要使用 [Xcode 15.2](https://developer.apple.com/download/all/) (而不是最新的 15.3) 来进行编译。

## 🙌贡献
欢迎提交Issue和Pull Request帮助我们变得更好!

Expand Down

0 comments on commit 2e5f144

Please sign in to comment.