Skip to content

Commit

Permalink
Fix: editing order and width on SeetingsView
Browse files Browse the repository at this point in the history
  • Loading branch information
filimo committed Jan 9, 2020
1 parent 552025e commit b4b5b02
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion ReaderTranslator/Model/AvailableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ enum AvailableView: String, Codable, CaseIterable {

var width: Binding<String> {
Binding<String>(
get: { "\(ViewsStore.shared.viewWidth[self] ?? 500)" },
get: {
"\(ViewsStore.shared.viewWidth[self] ?? 500)"
},
set: {
ViewsStore.shared.viewWidth[self] = $0.cgFloatValue
}
Expand Down
2 changes: 1 addition & 1 deletion ReaderTranslator/Stores/ViewsStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<AvailableView> = [.reverso, .gTranslator]
@Published(key: "viewWidth") var viewWidth: [AvailableView: CGFloat] = [:]
Expand Down
2 changes: 1 addition & 1 deletion ReaderTranslator/Views/StatusBarView/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit b4b5b02

Please sign in to comment.