Skip to content

Commit

Permalink
Fix: The default width for all Views
Browse files Browse the repository at this point in the history
  • Loading branch information
filimo committed Jan 12, 2020
1 parent a184212 commit 0845b49
Show file tree
Hide file tree
Showing 14 changed files with 15 additions and 15 deletions.
2 changes: 0 additions & 2 deletions ReaderTranslator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@
F0AB12B4233F599C005B9F2A /* StatusBarView_Voice_Favorite.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0AB12B3233F599C005B9F2A /* StatusBarView_Voice_Favorite.swift */; };
F0AB12B6233F59B4005B9F2A /* StatusBarView_Voice_Volume.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0AB12B5233F59B4005B9F2A /* StatusBarView_Voice_Volume.swift */; };
F0AB182523A5504200A71CA6 /* SentencesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0AB182423A5504200A71CA6 /* SentencesView.swift */; };
F0AD8B1B236413F60017C22F /* AvailableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0AD8B1A236413F60017C22F /* AvailableView.swift */; };
F0AD8B1C236413F60017C22F /* AvailableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0AD8B1A236413F60017C22F /* AvailableView.swift */; };
F0AD8B1E236414070017C22F /* TranslateAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0AD8B1D236414070017C22F /* TranslateAction.swift */; };
F0AD8B1F236414070017C22F /* TranslateAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0AD8B1D236414070017C22F /* TranslateAction.swift */; };
Expand Down Expand Up @@ -1730,7 +1729,6 @@
F0814BA223562AF300212F52 /* Set.swift in Sources */,
F0C36A962359AF75001E396C /* StatusBarView_Bookmarks.swift in Sources */,
F06B0946239CB8FA00A39A86 /* BookmarksView_List_Detail.swift in Sources */,
F0AD8B1B236413F60017C22F /* AvailableView.swift in Sources */,
F049244F2341F54800F3C728 /* Image.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForTesting = "NO"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
buildForAnalyzing = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F0754436234479DA00E1D88E"
Expand Down
2 changes: 1 addition & 1 deletion ReaderTranslator/Model/AvailableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ enum AvailableView: String, Codable, CaseIterable {
var width: Binding<String> {
Binding<String>(
get: {
"\(ViewsStore.shared.viewWidth[self] ?? 500)"
"\(ViewsStore.shared.viewWidth[self] ?? ViewsStore.defaultWidth)"
},
set: {
ViewsStore.shared.viewWidth[self] = $0.cgFloatValue
Expand Down
2 changes: 2 additions & 0 deletions ReaderTranslator/Stores/ViewsStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import Foundation
final class ViewsStore: ObservableObject {
private init() {}
static let shared = ViewsStore()

static let defaultWidth: CGFloat = 500

@Published(key: "enabledViews") var enabledViews: Set<AvailableView> = [.reverso, .gTranslator]
@Published(key: "viewWidth") var viewWidth: [AvailableView: CGFloat] = [:]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct BookmarksView: View {
TextField("", text: $filter).frame(width: bookmarkWidth * CGFloat(columnts))
BookmarksView_List(columnts: columnts, width: bookmarkWidth, filter: $filter)
BookmarksView_Controls()
}.frame(width: viewsStore.viewWidth[.bookmarks])
}.frame(width: viewsStore.viewWidth[.bookmarks] ?? ViewsStore.defaultWidth)
}
}

Expand Down
2 changes: 1 addition & 1 deletion ReaderTranslator/Views/ReaderView/Modes/CollinsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct CollinsView: View {
var body: some View {
WebViewContainer {
CollinsRepresenter(selectedText: self.$store.translateAction)
}.frame(width: viewsStore.viewWidth[.collins])
}.frame(width: viewsStore.viewWidth[.collins] ?? ViewsStore.defaultWidth)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct GTranslatorView: View {
var body: some View {
WebViewContainer {
GTranslatorRepresenter(selectedText: self.$store.translateAction)
}.frame(width: viewsStore.viewWidth[.gTranslator])
}.frame(width: viewsStore.viewWidth[.gTranslator] ?? ViewsStore.defaultWidth)
}
}

Expand Down
2 changes: 1 addition & 1 deletion ReaderTranslator/Views/ReaderView/Modes/LongmanView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct LongmanView: View {
var body: some View {
WebViewContainer {
LongmanRepresenter(selectedText: self.$store.translateAction)
}.frame(width: viewsStore.viewWidth[.longman])
}.frame(width: viewsStore.viewWidth[.longman] ?? ViewsStore.defaultWidth)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct MacmillanView: View {
var body: some View {
WebViewContainer {
MacmillanRepresenter(selectedText: self.$store.translateAction)
}.frame(width: viewsStore.viewWidth[.macmillan])
}.frame(width: viewsStore.viewWidth[.macmillan] ?? ViewsStore.defaultWidth)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct ReaderView_Pdf: View {
VStack {
PDFKitView()
ReaderView_Pdf_Toolbar()
}.frame(width: viewsStore.viewWidth[.pdf])
}.frame(width: viewsStore.viewWidth[.pdf] ?? ViewsStore.defaultWidth)
}
}

Expand Down
2 changes: 1 addition & 1 deletion ReaderTranslator/Views/ReaderView/Modes/ReversoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct ReversoView: View {
var body: some View {
WebViewContainer {
ReversoRepresenter(selectedText: self.$store.translateAction)
}.frame(width: viewsStore.viewWidth[.reverso])
}.frame(width: viewsStore.viewWidth[.reverso] ?? ViewsStore.defaultWidth)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct StackExchangeView: View {
var body: some View {
WebViewContainer {
StackExchangeRepresenter(selectedText: self.$store.translateAction)
}.frame(width: viewsStore.viewWidth[.stackExchange])
}.frame(width: viewsStore.viewWidth[.stackExchange] ?? ViewsStore.defaultWidth)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct WikipediaView: View {
var body: some View {
WebViewContainer {
WikipediaRepresenter(selectedText: self.$store.translateAction)
}.frame(width: viewsStore.viewWidth[.wikipedia])
}.frame(width: viewsStore.viewWidth[.wikipedia] ?? ViewsStore.defaultWidth)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct YTranslatorView: View {
var body: some View {
WebViewContainer {
YTranslatorRepresenter(selectedText: self.$store.translateAction)
}.frame(width: viewsStore.viewWidth[.yTranslator])
}.frame(width: viewsStore.viewWidth[.yTranslator] ?? ViewsStore.defaultWidth)
}
}

Expand Down

0 comments on commit 0845b49

Please sign in to comment.