toggle for subtitles (#166)

* added persistance for subtitle toggling

* fixed typo

* now we good (i think fuck windows)

* adasd WSEFG

---------

Co-authored-by: cranci <100066266+cranci1@users.noreply.github.com>
This commit is contained in:
Seiike 2025-06-10 17:10:23 +02:00 committed by GitHub
parent c6e704c04d
commit 66353bc80c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 2 deletions

View file

@ -307,6 +307,7 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
setupPipIfSupported()
view.bringSubviewToFront(subtitleStackView)
subtitleStackView.isHidden = !SubtitleSettingsManager.shared.settings.enabled
AniListMutation().fetchMalID(animeId: aniListID) { [weak self] result in
switch result {

View file

@ -8,6 +8,7 @@
import UIKit
struct SubtitleSettings: Codable {
var enabled: Bool = true
var foregroundColor: String = "white"
var fontSize: Double = 20.0
var shadowRadius: Double = 1.0

View file

@ -342,12 +342,25 @@ struct SubtitleSettingsSection: View {
@State private var backgroundEnabled: Bool = SubtitleSettingsManager.shared.settings.backgroundEnabled
@State private var bottomPadding: Double = Double(SubtitleSettingsManager.shared.settings.bottomPadding)
@State private var subtitleDelay: Double = SubtitleSettingsManager.shared.settings.subtitleDelay
@AppStorage("subtitlesEnabled") private var subtitlesEnabled: Bool = true
private let colors = ["white", "yellow", "green", "blue", "red", "purple"]
private let shadowOptions = [0, 1, 3, 6]
var body: some View {
SettingsSection(title: "Subtitle Settings") {
SettingsSection(title: "Subtitle Settings") {
SettingsToggleRow(
icon: "captions.bubble",
title: "Enable Subtitles",
isOn: $subtitlesEnabled,
showDivider: false
)
.onChange(of: subtitlesEnabled) { newValue in
SubtitleSettingsManager.shared.update { settings in
settings.enabled = newValue
}
}
SettingsPickerRow(
icon: "paintbrush",
title: "Subtitle Color",
@ -416,4 +429,4 @@ struct SubtitleSettingsSection: View {
}
}
}
}
}