Skip to content

Commit

Permalink
ReaderTranslatorMobile #76: First implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
filimo committed Feb 28, 2020
1 parent b302d72 commit 322a697
Show file tree
Hide file tree
Showing 35 changed files with 1,138 additions and 10 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ Explore features, limitations and bugs *SwiftUI, Combine and Catalyst*.
![](files/Release_2.0.0_1.png)

## Coming features
- [Voicing selected words and phrases by Longman speakers](https://github.com/filimo/ReaderTranslator/issues/62)
- [New features for ReaderTranslatorPlayer](https://github.com/filimo/ReaderTranslator/issues/58)
- [Sync bookmarks between macOS and mobile apps](https://github.com/filimo/ReaderTranslator/issues/63)
- [Bookmarks for mobile version](https://github.com/filimo/ReaderTranslator/issues/66)
Expand All @@ -100,6 +99,15 @@ Explore features, limitations and bugs *SwiftUI, Combine and Catalyst*.
## Releases
### Download .dmg from [here](https://github.com/filimo/ReaderTranslator/releases)

**1.10.0**
- [ReaderTranslatorMobile #76](https://github.com/filimo/ReaderTranslator/issues/76)

![](files/Release_1.10.0_1.gif)


**1.9.2**
- [Voicing selected words and phrases by Longman speakers](https://github.com/filimo/ReaderTranslator/issues/62)

**1.9.1**
- [Merriam-Webster support #75](https://github.com/filimo/ReaderTranslator/issues/75)

Expand Down
367 changes: 367 additions & 0 deletions ReaderTranslator.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1130"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F09760B9240925680030F928"
BuildableName = "ReaderTranslatorMobile.app"
BlueprintName = "ReaderTranslatorMobile"
ReferencedContainer = "container:ReaderTranslator.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F09760B9240925680030F928"
BuildableName = "ReaderTranslatorMobile.app"
BlueprintName = "ReaderTranslatorMobile"
ReferencedContainer = "container:ReaderTranslator.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F09760B9240925680030F928"
BuildableName = "ReaderTranslatorMobile.app"
BlueprintName = "ReaderTranslatorMobile"
ReferencedContainer = "container:ReaderTranslator.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<key>ReaderTranslator.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>2</integer>
<integer>3</integer>
</dict>
<key>ReaderTranslatorMac.xcscheme_^#shared#^_</key>
<dict>
Expand All @@ -22,7 +22,12 @@
<key>ReaderTranslatorMac_Player_Test.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>4</integer>
<integer>5</integer>
</dict>
<key>ReaderTranslatorMobile.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>2</integer>
</dict>
<key>ReaderTranslatorPlayer.xcscheme_^#shared#^_</key>
<dict>
Expand All @@ -32,17 +37,17 @@
<key>ReaderTranslatorPlayer_Mac_Test.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>5</integer>
<integer>6</integer>
</dict>
<key>ReaderTranslatorSafari.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>3</integer>
<integer>4</integer>
</dict>
<key>ReaderTranslatorShare.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>6</integer>
<integer>7</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
Expand All @@ -62,6 +67,11 @@
<key>primary</key>
<true/>
</dict>
<key>F09760B9240925680030F928</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>F0A2179723A9355E00968133</key>
<dict>
<key>primary</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ struct GTranslatorRepresenter: ViewRepresentable, WKScriptsSetup {
]

if let url = urlComponent.url {
print("\(theClassName)_updateView_reload", url)
print("\(Self.self)_updateView_reload", url)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
view.load(URLRequest(url: url))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ import SwiftUI
Self.pdfView.autoresizingMask = [.flexibleWidth]
Self.pdfView.autoScales = true
Self.pdfView.document = PDFDocument(url: url)
Self.pdfView.delegate = context.server
Self.pdfView.delegate = context.coordinator
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@
document.addEventListener("mouseup", (event) => {
keysStatus = {}
})

document.addEventListener("selectionchange", (event) => {
let selection = document.getSelection()

if(selection) {} else return

if(selection.toString().trim()) {
sendIn1000('selectionchange', 'document', event)
}
})

// Use click event instead of selectionchange to avoid firing the event when using text search on a page
document.addEventListener('click', (event) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class WKCoordinator: NSObject {
init(_ parent: WKScriptsSetup) {
self.parent = parent
super.init()
print("\(theClassName)_makeCoordinator")
print("\(Self.self)_makeCoordinator")
}

deinit {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct WKRepresenter: ViewRepresentable, WKScriptsSetup {
// TODO: view.scrollView.zoomScale = store.zoom
// view.setNeedsDisplay(view.bounds)
#else
view.setZoom(zoomLevel: store.zoom)
// view.setZoom(zoomLevel: store.zoom)
#endif
if view.newUrl != lastWebPage { view.newUrl = lastWebPage }
}
Expand Down
10 changes: 10 additions & 0 deletions ReaderTranslator/Extentions/Image.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ import SwiftUI
.frame(height: 20)
}
}
#else
extension Image {
static func sfSymbol(_ systemName: String) -> some View {
Image(systemName: systemName)
.resizable()
.aspectRatio(contentMode: .fit)
.colorInvert()
.frame(height: 20)
}
}
#endif

struct ImageView_Previews: PreviewProvider {
Expand Down
1 change: 1 addition & 0 deletions ReaderTranslator/Stores/PdfStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Foundation
import CoreGraphics

final class PdfStore: ObservableObject {
private init() {}
Expand Down
1 change: 1 addition & 0 deletions ReaderTranslator/Stores/ViewsStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Foundation
import CoreGraphics

final class ViewsStore: ObservableObject {
private init() {}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
6 changes: 6 additions & 0 deletions ReaderTranslatorMobile/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
25 changes: 25 additions & 0 deletions ReaderTranslatorMobile/Base.lproj/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>

0 comments on commit 322a697

Please sign in to comment.