Skip to content

Commit

Permalink
Separated ObservableObject stores #67: LongmanStore in iOS target.
Browse files Browse the repository at this point in the history
  • Loading branch information
filimo committed Dec 21, 2019
1 parent 67e4438 commit f817ba4
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 20 deletions.
4 changes: 2 additions & 2 deletions ReaderTranslator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
F065096823AE0DBA003D2410 /* WebStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = F065096623AE0D39003D2410 /* WebStore.swift */; };
F065096923AE0DBD003D2410 /* WebStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = F065096623AE0D39003D2410 /* WebStore.swift */; };
F065096E23AE0F9E003D2410 /* ReaderTranslatorSafari.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = F075444E23447A2700E1D88E /* ReaderTranslatorSafari.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
F065097423AE1146003D2410 /* LongmanStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0553727239BE3C700BA24BA /* LongmanStore.swift */; };
F0667CF023A6B2E70063BAC6 /* GTranslatorRepresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0667CEF23A6B2E70063BAC6 /* GTranslatorRepresenter.swift */; };
F06B0946239CB8FA00A39A86 /* BookmarksView_List_Detail.swift in Sources */ = {isa = PBXBuildFile; fileRef = F06B0945239CB88000A39A86 /* BookmarksView_List_Detail.swift */; };
F06B0947239CB8FA00A39A86 /* BookmarksView_List_Detail.swift in Sources */ = {isa = PBXBuildFile; fileRef = F06B0945239CB88000A39A86 /* BookmarksView_List_Detail.swift */; };
Expand Down Expand Up @@ -252,7 +253,6 @@
F0B4843D23A8C6860031A811 /* URL.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0B4843B23A8C6860031A811 /* URL.swift */; };
F0B4843E23A8C6860031A811 /* URL.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0B4843B23A8C6860031A811 /* URL.swift */; };
F0B4843F23A8C6860031A811 /* URL.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0B4843B23A8C6860031A811 /* URL.swift */; };
F0B5361F23A52E5900E68E74 /* LongmanStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0553727239BE3C700BA24BA /* LongmanStore.swift */; };
F0B5362023A52F0900E68E74 /* Stack.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0EDE34C23641B1300E0B81C /* Stack.swift */; };
F0BB436C2344842200ADBEF1 /* ReaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0AA69D2232E9762007CC07B /* ReaderView.swift */; };
F0BB436E2344843400ADBEF1 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0F256BC233D309F00C9D719 /* String.swift */; };
Expand Down Expand Up @@ -1341,7 +1341,6 @@
buildActionMask = 2147483647;
files = (
F065095C23ADF971003D2410 /* AudioStore.swift in Sources */,
F0B5361F23A52E5900E68E74 /* LongmanStore.swift in Sources */,
F08EBB0D23956A20009025D3 /* NetworkManager.swift in Sources */,
F058C7F32397F968002C84F0 /* WKScriptsSetup.swift in Sources */,
F012038723928631008D0B47 /* UserDefault.swift in Sources */,
Expand Down Expand Up @@ -1383,6 +1382,7 @@
F08EBAED23943835009025D3 /* LongmanRepresenter.swift in Sources */,
F058C7F42397F9DB002C84F0 /* WKPageView.swift in Sources */,
F058C7FA2397FA7C002C84F0 /* NSObject.swift in Sources */,
F065097423AE1146003D2410 /* LongmanStore.swift in Sources */,
F012037A239182DA008D0B47 /* ContentView.swift in Sources */,
F0C0040A23A899EA002B6060 /* CircleButton.swift in Sources */,
F058C7F92397FA70002C84F0 /* DOMEvent.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion ReaderTranslatorMac/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>1637</string>
<string>1638</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.education</string>
<key>LSMinimumSystemVersion</key>
Expand Down
9 changes: 0 additions & 9 deletions ReaderTranslatorPlayer/Store/Store.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,4 @@ class Store: ObservableObject {
var lastWebPage = ""

@Published(key: "bookmarks") var bookmarks: BookmarksStore.Bookmarks = []

@Published var longmanSentences: LongmanSentences = [LongmanSentence.empty]
@Published var longmanSelectedBookmark = "" {
willSet {
longmanSentences = []
LongmanStore.shared.fetchInfo(text: newValue)
}
}
@Published var longmanAudioRate: Float = 1
}
5 changes: 3 additions & 2 deletions ReaderTranslatorPlayer/Views/ViewModes/LongmanView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ struct LongmanView: View {
var phrase: String

@ObservedObject var store = Store.shared
@ObservedObject var longmanStore = LongmanStore.shared

var body: some View {
LongmanRepresenter(phrase: phrase)
.onAppear {
self.store.hideNavBar = false
if self.store.longmanSelectedBookmark != self.phrase {
if self.longmanStore.word != self.phrase {
RunLoop.main.perform {
self.store.longmanSelectedBookmark = self.phrase
self.longmanStore.word = self.phrase
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@
import SwiftUI

struct SentencesView: View {
@ObservedObject var store = Store.shared
let bookmark: String

@ObservedObject var store = Store.shared
@ObservedObject var longmanStore = LongmanStore.shared

@State var showGTranlator: LongmanSentence?
@State var showLongmanView = false

var body: some View {
VStack {
ScrollView {
VStack {
ForEach(store.longmanSentences, id: \.self) { sentence in
ForEach(longmanStore.sentences, id: \.self) { sentence in
SentencesView_Row(
sentence: sentence,
showGTranlator: self.$showGTranlator,
Expand All @@ -30,9 +33,9 @@ struct SentencesView: View {
}
.onAppear {
self.store.hideNavBar = false
if self.store.longmanSelectedBookmark != self.bookmark {
if self.longmanStore.word != self.bookmark {
RunLoop.main.perform {
self.store.longmanSelectedBookmark = self.bookmark
self.longmanStore.word = self.bookmark
}
}
self.showGTranlator = nil
Expand All @@ -50,7 +53,7 @@ struct SentencesView: View {
}
if showLongmanView {
NavigationLink(
destination: LongmanView(phrase: store.longmanSelectedBookmark),
destination: LongmanView(phrase: longmanStore.word),
isActive: .constant(true),
label: { EmptyView() })
}
Expand Down
2 changes: 1 addition & 1 deletion ReaderTranslatorSafari/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>2531</string>
<string>2532</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSAppleEventsUsageDescription</key>
Expand Down

0 comments on commit f817ba4

Please sign in to comment.