diff --git a/ReaderTranslator/Model/AvailableView.swift b/ReaderTranslator/Model/AvailableView.swift index bf6758d..2200801 100644 --- a/ReaderTranslator/Model/AvailableView.swift +++ b/ReaderTranslator/Model/AvailableView.swift @@ -28,7 +28,9 @@ enum AvailableView: String, Codable, CaseIterable { var width: Binding { Binding( - get: { "\(ViewsStore.shared.viewWidth[self] ?? 500)" }, + get: { + "\(ViewsStore.shared.viewWidth[self] ?? 500)" + }, set: { ViewsStore.shared.viewWidth[self] = $0.cgFloatValue } diff --git a/ReaderTranslator/Stores/ViewsStore.swift b/ReaderTranslator/Stores/ViewsStore.swift index 928863a..08ad748 100644 --- a/ReaderTranslator/Stores/ViewsStore.swift +++ b/ReaderTranslator/Stores/ViewsStore.swift @@ -10,7 +10,7 @@ import Foundation final class ViewsStore: ObservableObject { private init() {} - static var shared = ViewsStore() + static let shared = ViewsStore() @Published(key: "enabledViews") var enabledViews: Set = [.reverso, .gTranslator] @Published(key: "viewWidth") var viewWidth: [AvailableView: CGFloat] = [:] diff --git a/ReaderTranslator/Views/StatusBarView/SettingsView.swift b/ReaderTranslator/Views/StatusBarView/SettingsView.swift index 57be858..2cfd639 100644 --- a/ReaderTranslator/Views/StatusBarView/SettingsView.swift +++ b/ReaderTranslator/Views/StatusBarView/SettingsView.swift @@ -9,7 +9,7 @@ import SwiftUI struct SettingsView: View { - @ObservedObject var store = Store.shared + @ObservedObject var viewStore = ViewsStore.shared //TextField uses ViewsStore via enum AvailableView @State var isShow = false