mirror of
https://github.com/cranci1/Sora.git
synced 2026-04-20 16:12:50 +00:00
Color picker in settings for intro and outro segments (#99)
* Color picker in settings for intro and outro segments * Color picker in settings for intro and outro segments * Auto: Update IPA [skip ci] --------- Co-authored-by: cranci1 <cranci1@github.com>
This commit is contained in:
parent
062e073eb0
commit
ce7913c578
3 changed files with 39 additions and 13 deletions
|
|
@ -389,6 +389,14 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
}
|
||||
}
|
||||
|
||||
private func getSegmentsColor() -> Color {
|
||||
if let data = UserDefaults.standard.data(forKey: "segmentsColorData"),
|
||||
let uiColor = try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as? UIColor {
|
||||
return Color(uiColor)
|
||||
}
|
||||
return .yellow
|
||||
}
|
||||
|
||||
func setupPlayerViewController() {
|
||||
playerViewController = AVPlayerViewController()
|
||||
playerViewController.player = player
|
||||
|
|
@ -499,6 +507,8 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
controlsContainerView.addSubview(forwardButton)
|
||||
forwardButton.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
let segmentsColor = self.getSegmentsColor()
|
||||
|
||||
let sliderView = MusicProgressSlider(
|
||||
value: Binding(
|
||||
get: { self.sliderViewModel.sliderValue },
|
||||
|
|
@ -533,8 +543,8 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
},
|
||||
introSegments: sliderViewModel.introSegments, // Added
|
||||
outroSegments: sliderViewModel.outroSegments, // Added
|
||||
introColor: .yellow, // Add your colors here
|
||||
outroColor: .yellow // Or use settings.accentColor
|
||||
introColor: segmentsColor, // Add your colors here
|
||||
outroColor: segmentsColor // Or use settings.accentColor
|
||||
)
|
||||
|
||||
sliderHostingController = UIHostingController(rootView: sliderView)
|
||||
|
|
@ -892,7 +902,9 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
let end = min(1, ed.end.seconds / duration)
|
||||
sliderViewModel.outroSegments.append(start...end)
|
||||
}
|
||||
// Force SwiftUI to update
|
||||
|
||||
let segmentsColor = self.getSegmentsColor()
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.sliderHostingController?.rootView = MusicProgressSlider(
|
||||
value: Binding(
|
||||
|
|
@ -916,8 +928,8 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
},
|
||||
introSegments: self.sliderViewModel.introSegments,
|
||||
outroSegments: self.sliderViewModel.outroSegments,
|
||||
introColor: .yellow, // Match your color choices
|
||||
outroColor: .yellow
|
||||
introColor: segmentsColor, // Match your color choices
|
||||
outroColor: segmentsColor
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -1310,6 +1322,7 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
|
||||
let current = self.currentTimeVal
|
||||
|
||||
let segmentsColor = self.getSegmentsColor()
|
||||
|
||||
DispatchQueue.main.async {
|
||||
if let currentItem = self.player.currentItem, currentItem.duration.seconds > 0 {
|
||||
|
|
@ -1365,8 +1378,8 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
},
|
||||
introSegments: self.sliderViewModel.introSegments,
|
||||
outroSegments: self.sliderViewModel.outroSegments,
|
||||
introColor: .yellow, // Match your color choices
|
||||
outroColor: .yellow
|
||||
introColor: segmentsColor, // Match your color choices
|
||||
outroColor: segmentsColor
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,9 +19,6 @@ struct SettingsViewPlayer: View {
|
|||
@AppStorage("doubleTapSeekEnabled") private var doubleTapSeekEnabled: Bool = false
|
||||
@AppStorage("skipIntroOutroVisible") private var skipIntroOutroVisible: Bool = true
|
||||
|
||||
// @AppStorage("introColor") private var introColor: Color = .yellow
|
||||
//@AppStorage("outroColor") private var outroColor: Color = .yellow
|
||||
|
||||
private let mediaPlayers = ["Default", "VLC", "OutPlayer", "Infuse", "nPlayer", "Sora"]
|
||||
|
||||
var body: some View {
|
||||
|
|
@ -65,9 +62,25 @@ struct SettingsViewPlayer: View {
|
|||
}
|
||||
}
|
||||
|
||||
Section(header: Text("Progress bar Marker Colors")) {
|
||||
// ColorPicker("Intro Color", selection: $introColor)
|
||||
//ColorPicker("Outro Color", selection: $outroColor)
|
||||
Section(header: Text("Progress bar Marker Color")) {
|
||||
ColorPicker("Segments Color", selection: Binding(
|
||||
get: {
|
||||
if let data = UserDefaults.standard.data(forKey: "segmentsColorData"),
|
||||
let uiColor = try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as? UIColor {
|
||||
return Color(uiColor)
|
||||
}
|
||||
return .yellow
|
||||
},
|
||||
set: { newColor in
|
||||
let uiColor = UIColor(newColor)
|
||||
if let data = try? NSKeyedArchiver.archivedData(
|
||||
withRootObject: uiColor,
|
||||
requiringSecureCoding: false
|
||||
) {
|
||||
UserDefaults.standard.set(data, forKey: "segmentsColorData")
|
||||
}
|
||||
}
|
||||
))
|
||||
}
|
||||
|
||||
Section(header: Text("Skip Settings"), footer : Text("Double tapping the screen on it's sides will skip with the short tap setting.")) {
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in a new issue