Skip to content

Commit

Permalink
Bookmarks for mobile version #66: Speak Longman sentences
Browse files Browse the repository at this point in the history
  • Loading branch information
filimo committed Dec 15, 2019
1 parent 790effd commit 0af5958
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 8 deletions.
12 changes: 8 additions & 4 deletions ReaderTranslator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
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 */; };
F0AB182723A5508500A71CA6 /* bookmarksView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0AB182623A5508500A71CA6 /* bookmarksView.swift */; };
F0AB182723A5508500A71CA6 /* BookmarksView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0AB182623A5508500A71CA6 /* BookmarksView.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 */; };
Expand Down Expand Up @@ -236,6 +236,7 @@
F0EE0A1E2348A66E004A5EAD /* PDFKitViewRepresentable.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0EE0A1C2348A651004A5EAD /* PDFKitViewRepresentable.swift */; };
F0F256BD233D309F00C9D719 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0F256BC233D309F00C9D719 /* String.swift */; };
F0F256C2233E6C4C00C9D719 /* FavoriteVoiceName.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0F256C1233E6C4C00C9D719 /* FavoriteVoiceName.swift */; };
F0F506CD23A6701F003367BD /* LongmanView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0F506CC23A6701F003367BD /* LongmanView.swift */; };
F0FCDD40236189750016F23F /* MacmillanView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0FCDD3F2361890C0016F23F /* MacmillanView.swift */; };
F0FCDD41236189760016F23F /* MacmillanView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0FCDD3F2361890C0016F23F /* MacmillanView.swift */; };
F0FCDD422361897D0016F23F /* MacmillanRepresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = F04C8312236187D6003A25B4 /* MacmillanRepresenter.swift */; };
Expand Down Expand Up @@ -381,7 +382,7 @@
F0AB12B3233F599C005B9F2A /* StatusBarView_Voice_Favorite.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusBarView_Voice_Favorite.swift; sourceTree = "<group>"; };
F0AB12B5233F59B4005B9F2A /* StatusBarView_Voice_Volume.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusBarView_Voice_Volume.swift; sourceTree = "<group>"; };
F0AB182423A5504200A71CA6 /* SentencesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentencesView.swift; sourceTree = "<group>"; };
F0AB182623A5508500A71CA6 /* bookmarksView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = bookmarksView.swift; sourceTree = "<group>"; };
F0AB182623A5508500A71CA6 /* BookmarksView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarksView.swift; sourceTree = "<group>"; };
F0AD8B1A236413F60017C22F /* AvailableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AvailableView.swift; sourceTree = "<group>"; };
F0AD8B1D236414070017C22F /* TranslateAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TranslateAction.swift; sourceTree = "<group>"; };
F0C36A952359AF01001E396C /* StatusBarView_Bookmarks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusBarView_Bookmarks.swift; sourceTree = "<group>"; };
Expand All @@ -404,6 +405,7 @@
F0EE0A1C2348A651004A5EAD /* PDFKitViewRepresentable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PDFKitViewRepresentable.swift; sourceTree = "<group>"; };
F0F256BC233D309F00C9D719 /* String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = String.swift; sourceTree = "<group>"; };
F0F256C1233E6C4C00C9D719 /* FavoriteVoiceName.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteVoiceName.swift; sourceTree = "<group>"; };
F0F506CC23A6701F003367BD /* LongmanView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LongmanView.swift; sourceTree = "<group>"; };
F0FCDD3F2361890C0016F23F /* MacmillanView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MacmillanView.swift; sourceTree = "<group>"; };
F0FCDD442361A7650016F23F /* CollinsRepresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollinsRepresenter.swift; sourceTree = "<group>"; };
F0FCDD452361A7BF0016F23F /* CollinsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollinsView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -788,7 +790,8 @@
F08EBB0423956202009025D3 /* FileListView.swift */,
F02B04C223A2930D00F93B84 /* HostsView.swift */,
F0AB182423A5504200A71CA6 /* SentencesView.swift */,
F0AB182623A5508500A71CA6 /* bookmarksView.swift */,
F0AB182623A5508500A71CA6 /* BookmarksView.swift */,
F0F506CC23A6701F003367BD /* LongmanView.swift */,
);
path = ViewModes;
sourceTree = "<group>";
Expand Down Expand Up @@ -1213,6 +1216,7 @@
F012038823928634008D0B47 /* Published.swift in Sources */,
F02B04B123A2844700F93B84 /* NWParameters.swift in Sources */,
F06EAF8F2393A4E100AAE1A4 /* SafariView.swift in Sources */,
F0F506CD23A6701F003367BD /* LongmanView.swift in Sources */,
F058C7F82397FA67002C84F0 /* View.swift in Sources */,
F08EBAF223952AD6009025D3 /* WebViewContainer.swift in Sources */,
F058C7F72397FA56002C84F0 /* WKCoordinator.swift in Sources */,
Expand All @@ -1231,7 +1235,7 @@
F046182E23A3A4AF0041E726 /* ConnectionClientStatus.swift in Sources */,
F02B04BD23A2896900F93B84 /* PeerListener.swift in Sources */,
F08EBAED23943835009025D3 /* LongmanRepresenter.swift in Sources */,
F0AB182723A5508500A71CA6 /* bookmarksView.swift in Sources */,
F0AB182723A5508500A71CA6 /* BookmarksView.swift in Sources */,
F058C7F42397F9DB002C84F0 /* WKPageView.swift in Sources */,
F058C7FA2397FA7C002C84F0 /* NSObject.swift in Sources */,
F012037A239182DA008D0B47 /* ContentView.swift in Sources */,
Expand Down
54 changes: 54 additions & 0 deletions ReaderTranslatorPlayer/Views/ViewModes/BookmarksView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// bookmarksView.swift
// ReaderTranslatorPlayer
//
// Created by Viktor Kushnerov on 14/12/19.
// Copyright © 2019 Viktor Kushnerov. All rights reserved.
//

import SwiftUI

struct BookmarksView: View {
@ObservedObject var store = Store.shared

var body: some View {
VStack {
ScrollView {
VStack(spacing: 0) {
ForEach(store.bookmarks, id: \.self) { bookmark in
HStack {
NavigationLink(
destination: LongmanView(),
label: { Text(bookmark.text).font(.largeTitle) }
)
NavigationLink(
destination: SentencesView(bookmark: bookmark.text),
label: { self.bookmarksIco }
)
Spacer()
self.counterImageIco(counter: bookmark.counter)
.onTapGesture { self.store.bookmarks.increase(bookmark: bookmark) }
}
}
}
}
}.padding()
}

private var bookmarksIco: some View {
Image(systemName: "book.circle")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(height: 25)
.padding(.trailing, 10)
}

private func counterImageIco(counter: Int) -> some View {
let name = counter == 0 ? "0.circle" : "\(counter).circle.fill"
return Image(systemName: name)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(height: 25)
.padding(.trailing, 5)
}
}
26 changes: 26 additions & 0 deletions ReaderTranslatorPlayer/Views/ViewModes/LongmanView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// LongmanView.swift
// ReaderTranslatorPlayer
//
// Created by Viktor Kushnerov on 15/12/19.
// Copyright © 2019 Viktor Kushnerov. All rights reserved.
//

import SwiftUI

struct LongmanView: View {
@ObservedObject var store = Store.shared

var body: some View {
LongmanRepresenter()
.onAppear {
self.store.hideNavBar = false
}
}
}

struct LongmanView_Previews: PreviewProvider {
static var previews: some View {
LongmanView()
}
}
32 changes: 29 additions & 3 deletions ReaderTranslatorPlayer/Views/ViewModes/SentencesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,25 @@ import SwiftUI
struct SentencesView: View {
@ObservedObject var store = Store.shared
var bookmark: String
@State var sentence = ""

var body: some View {
VStack {
List {
ForEach(store.longmanSentences, id: \.self) { sentence in
HStack {
NavigationLink(destination: LongmanRepresenter(), label: { Text(sentence.text) })
Spacer()
NavigationLink(destination: LongmanRepresenter(), label: {
Text(sentence.text)
self.soundIco
.onTapGesture {
LongmanStore.share.addAudio(url: sentence.url)
LongmanStore.share.next()
}
})
}
}
}
}
.navigationBarHidden(false)
.onAppear {
self.store.hideNavBar = false
if self.store.longmanSelectedBookmark != self.bookmark {
Expand All @@ -33,4 +39,24 @@ struct SentencesView: View {
}
}
}

private var soundIco: some View {
Image(systemName: "play.circle")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(height: 25)
.padding(.trailing, 10)
}

private var bookmarksIco: some View {
Image(systemName: "book.circle")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(height: 25)
.padding(.trailing, 10)
}

private func getColor(sentence: String) -> Color {
self.sentence == sentence ? Color.yellow : Color.primary
}
}
2 changes: 1 addition & 1 deletion ReaderTranslatorPlayer/Views/ViewModes/bookmarksView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct BookmarksView: View {
ForEach(store.bookmarks, id: \.self) { bookmark in
HStack {
NavigationLink(
destination: LongmanRepresenter().navigationBarHidden(false),
destination: LongmanView(),
label: { Text(bookmark.text).font(.largeTitle) }
)
NavigationLink(
Expand Down

0 comments on commit 0af5958

Please sign in to comment.