turbo-native-initializer 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/LICENSE.txt +21 -0
- data/README.md +53 -0
- data/Rakefile +2 -0
- data/exe/turbo-native-initializer +3 -0
- data/lib/turbo-native-initializer.rb +1 -0
- data/lib/turbo_native_initializer/generator.rb +79 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/.gitignore +1 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/build.gradle.kts.tt +44 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/proguard-rules.pro +21 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/debug/AndroidManifest.xml.tt +4 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/AndroidManifest.xml.tt +29 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/assets/json/configuration.json +11 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/java/dev/hotwire/turbo/turbonativeproject/base/NavDestination.kt.tt +69 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/java/dev/hotwire/turbo/turbonativeproject/features/web/WebFragment.kt.tt +37 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/java/dev/hotwire/turbo/turbonativeproject/features/web/WebHomeFragment.kt.tt +15 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/java/dev/hotwire/turbo/turbonativeproject/features/web/WebModalFragment.kt.tt +17 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/java/dev/hotwire/turbo/turbonativeproject/main/MainActivity.kt.tt +18 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/java/dev/hotwire/turbo/turbonativeproject/main/MainSessionNavHostFragment.kt.tt +37 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/java/dev/hotwire/turbo/turbonativeproject/util/Constants.kt.tt +8 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/anim/nav_slide_enter.xml +10 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/anim/nav_slide_exit.xml +7 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/anim/nav_slide_pop_enter.xml +15 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/anim/nav_slide_pop_exit.xml +15 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/anim/overshoot_interpolator.xml +4 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/drawable/ic_close.xml +5 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/drawable/ic_launcher_foreground.xml +17 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/layout/activity_main.xml.tt +17 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/layout/fragment_web_home.xml +36 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/layout/toolbar_progress.xml +13 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/menu/web.xml +14 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +5 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +5 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/values/colors.xml +5 -0
- data/lib/turbo_native_initializer/templates/android_stack/app/src/main/res/values/themes.xml.tt +5 -0
- data/lib/turbo_native_initializer/templates/android_stack/build.gradle.kts +5 -0
- data/lib/turbo_native_initializer/templates/android_stack/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/lib/turbo_native_initializer/templates/android_stack/gradle/wrapper/gradle-wrapper.properties +6 -0
- data/lib/turbo_native_initializer/templates/android_stack/gradle.properties +23 -0
- data/lib/turbo_native_initializer/templates/android_stack/gradlew +185 -0
- data/lib/turbo_native_initializer/templates/android_stack/gradlew.bat +89 -0
- data/lib/turbo_native_initializer/templates/android_stack/local.properties +10 -0
- data/lib/turbo_native_initializer/templates/android_stack/settings.gradle.kts.tt +17 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/.gitignore +1 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/build.gradle.kts.tt +44 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/proguard-rules.pro +21 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/debug/AndroidManifest.xml.tt +4 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/AndroidManifest.xml.tt +29 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/assets/json/configuration.json +11 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/java/dev/hotwire/turbo/turbonativeproject/base/NavDestination.kt.tt +69 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/java/dev/hotwire/turbo/turbonativeproject/features/web/WebFragment.kt.tt +29 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/java/dev/hotwire/turbo/turbonativeproject/features/web/WebHomeFragment.kt.tt +15 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/java/dev/hotwire/turbo/turbonativeproject/features/web/WebModalFragment.kt.tt +17 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/java/dev/hotwire/turbo/turbonativeproject/main/MainActivity.kt.tt +47 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/java/dev/hotwire/turbo/turbonativeproject/main/TabOneSessionNavHostFragment.kt.tt +37 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/java/dev/hotwire/turbo/turbonativeproject/main/TabTwoSessionNavHostFragment.kt.tt +37 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/java/dev/hotwire/turbo/turbonativeproject/util/Constants.kt.tt +8 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/anim/nav_slide_enter.xml +10 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/anim/nav_slide_exit.xml +7 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/anim/nav_slide_pop_enter.xml +15 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/anim/nav_slide_pop_exit.xml +15 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/anim/overshoot_interpolator.xml +4 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/drawable/ic_close.xml +5 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/drawable/ic_home.xml +5 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/drawable/ic_launcher_foreground.xml +17 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/drawable/ic_settings.xml +5 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/layout/activity_main.xml.tt +34 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/layout/fragment_web_home.xml +36 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/layout/toolbar_progress.xml +13 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/menu/bottom_navigation_menu.xml +12 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/menu/web.xml +14 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +5 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +5 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/values/colors.xml +5 -0
- data/lib/turbo_native_initializer/templates/android_tabs/app/src/main/res/values/themes.xml.tt +5 -0
- data/lib/turbo_native_initializer/templates/android_tabs/build.gradle.kts +5 -0
- data/lib/turbo_native_initializer/templates/android_tabs/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/lib/turbo_native_initializer/templates/android_tabs/gradle/wrapper/gradle-wrapper.properties +6 -0
- data/lib/turbo_native_initializer/templates/android_tabs/gradle.properties +23 -0
- data/lib/turbo_native_initializer/templates/android_tabs/gradlew +185 -0
- data/lib/turbo_native_initializer/templates/android_tabs/gradlew.bat +89 -0
- data/lib/turbo_native_initializer/templates/android_tabs/local.properties +10 -0
- data/lib/turbo_native_initializer/templates/android_tabs/settings.gradle.kts.tt +17 -0
- data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Configuration/Info.plist +29 -0
- data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Configuration/path-configuration.json +10 -0
- data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Controllers/ErrorPresenter.swift +74 -0
- data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Controllers/TurboNavigationController.swift +123 -0
- data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Controllers/ViewController.swift +20 -0
- data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Delegates/AppDelegate.swift +8 -0
- data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Delegates/SceneDelegate.swift.tt +139 -0
- data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Resources/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
- data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json +14 -0
- data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Resources/Assets.xcassets/AppIcon.appiconset/turbo.png +0 -0
- data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Resources/Assets.xcassets/Contents.json +6 -0
- data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Resources/Assets.xcassets/SplashIcon.imageset/Contents.json +21 -0
- data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Resources/Assets.xcassets/SplashIcon.imageset/turbo.png +0 -0
- data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Resources/Base.lproj/LaunchScreen.storyboard +39 -0
- data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/Resources/Base.lproj/Main.storyboard.tt +32 -0
- data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/TurboNativeProject.swift.tt +10 -0
- data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject.xcodeproj/project.pbxproj.tt +436 -0
- data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +14 -0
- data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Configuration/Info.plist +29 -0
- data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Configuration/path-configuration.json +10 -0
- data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Controllers/ErrorPresenter.swift +74 -0
- data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Controllers/TurboNavigationController.swift +123 -0
- data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Controllers/ViewController.swift +20 -0
- data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Delegates/AppDelegate.swift +8 -0
- data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Delegates/SceneDelegate.swift.tt +156 -0
- data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Resources/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
- data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json +14 -0
- data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Resources/Assets.xcassets/AppIcon.appiconset/turbo.png +0 -0
- data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Resources/Assets.xcassets/Contents.json +6 -0
- data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Resources/Assets.xcassets/SplashIcon.imageset/Contents.json +21 -0
- data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Resources/Assets.xcassets/SplashIcon.imageset/turbo.png +0 -0
- data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Resources/Base.lproj/LaunchScreen.storyboard +39 -0
- data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/Resources/Base.lproj/Main.storyboard +69 -0
- data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject/TurboNativeProject.swift.tt +10 -0
- data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject.xcodeproj/project.pbxproj.tt +436 -0
- data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- data/lib/turbo_native_initializer/templates/ios_tabs/TurboNativeProject.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +14 -0
- data/lib/turbo_native_initializer/version.rb +3 -0
- data/lib/turbo_native_initializer.rb +5 -0
- metadata +199 -0
@@ -0,0 +1,139 @@
|
|
1
|
+
import UIKit
|
2
|
+
import WebKit
|
3
|
+
import SafariServices
|
4
|
+
import Turbo
|
5
|
+
|
6
|
+
final class SceneDelegate: UIResponder {
|
7
|
+
private static var sharedProcessPool = WKProcessPool()
|
8
|
+
|
9
|
+
var window: UIWindow?
|
10
|
+
private let rootURL = <%= name %>.homeURL
|
11
|
+
private var navigationController: TurboNavigationController!
|
12
|
+
|
13
|
+
// MARK: - Setup
|
14
|
+
|
15
|
+
private func configureRootViewController() {
|
16
|
+
guard let window = window else { fatalError() }
|
17
|
+
|
18
|
+
window.tintColor = UIColor(named: "Tint")
|
19
|
+
|
20
|
+
navigationController = (window.rootViewController as! TurboNavigationController)
|
21
|
+
navigationController.session = session
|
22
|
+
navigationController.modalSession = modalSession
|
23
|
+
}
|
24
|
+
|
25
|
+
// MARK: - Authentication
|
26
|
+
|
27
|
+
private func promptForAuthentication() {
|
28
|
+
let authURL = <%= name %>.signInURL
|
29
|
+
let properties = pathConfiguration.properties(for: authURL)
|
30
|
+
navigationController.route(url: authURL, options: VisitOptions(), properties: properties)
|
31
|
+
}
|
32
|
+
|
33
|
+
// MARK: - Sessions
|
34
|
+
|
35
|
+
private lazy var session = makeSession()
|
36
|
+
private lazy var modalSession = makeSession()
|
37
|
+
|
38
|
+
private func makeSession() -> Session {
|
39
|
+
let configuration = WKWebViewConfiguration()
|
40
|
+
configuration.applicationNameForUserAgent = "Turbo Native iOS"
|
41
|
+
configuration.processPool = Self.sharedProcessPool
|
42
|
+
|
43
|
+
let webView = WKWebView(frame: .zero, configuration: configuration)
|
44
|
+
webView.uiDelegate = self
|
45
|
+
|
46
|
+
let session = Session(webView: webView)
|
47
|
+
session.delegate = self
|
48
|
+
session.pathConfiguration = pathConfiguration
|
49
|
+
return session
|
50
|
+
}
|
51
|
+
|
52
|
+
// MARK: - Path Configuration
|
53
|
+
|
54
|
+
private lazy var pathConfiguration = PathConfiguration(sources: [
|
55
|
+
.file(Bundle.main.url(forResource: "path-configuration", withExtension: "json")!),
|
56
|
+
])
|
57
|
+
}
|
58
|
+
|
59
|
+
extension SceneDelegate: UIWindowSceneDelegate {
|
60
|
+
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
|
61
|
+
guard let _ = scene as? UIWindowScene else { return }
|
62
|
+
|
63
|
+
configureRootViewController()
|
64
|
+
navigationController.route(url: rootURL, options: VisitOptions(action: .replace), properties: [:])
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
extension SceneDelegate: SessionDelegate {
|
69
|
+
func session(_ session: Session, didProposeVisit proposal: VisitProposal) {
|
70
|
+
navigationController.route(url: proposal.url, options: proposal.options, properties: proposal.properties)
|
71
|
+
}
|
72
|
+
|
73
|
+
func session(_ session: Session, didFailRequestForVisitable visitable: Visitable, error: Error) {
|
74
|
+
if let turboError = error as? TurboError, case let .http(statusCode) = turboError, statusCode == 401 {
|
75
|
+
promptForAuthentication()
|
76
|
+
} else if let errorPresenter = visitable as? ErrorPresenter {
|
77
|
+
errorPresenter.presentError(error) { [weak self] in
|
78
|
+
self?.session.reload()
|
79
|
+
}
|
80
|
+
} else {
|
81
|
+
assertionFailure("Visit failed!")
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
// When a form submission completes in the modal session, we need to
|
86
|
+
// manually clear the snapshot cache in the default session, since we
|
87
|
+
// don't want potentially stale cached snapshots to be used
|
88
|
+
func sessionDidFinishFormSubmission(_ session: Session) {
|
89
|
+
if (session == modalSession) {
|
90
|
+
self.session.clearSnapshotCache()
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
func sessionDidLoadWebView(_ session: Session) {
|
95
|
+
session.webView.navigationDelegate = self
|
96
|
+
}
|
97
|
+
|
98
|
+
func sessionWebViewProcessDidTerminate(_ session: Session) {
|
99
|
+
session.reload()
|
100
|
+
}
|
101
|
+
}
|
102
|
+
|
103
|
+
extension SceneDelegate: WKNavigationDelegate {
|
104
|
+
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
|
105
|
+
if navigationAction.navigationType == .linkActivated {
|
106
|
+
// Any link that's not on the same domain as the Turbo root url will go through here
|
107
|
+
// Other links on the domain, but that have an extension that is non-html will also go here
|
108
|
+
// You can decide how to handle those, by default if you're not the navigationDelegate
|
109
|
+
// the Session will open them in the default browser
|
110
|
+
|
111
|
+
let url = navigationAction.request.url!
|
112
|
+
|
113
|
+
// For this demo, we'll load files from our domain in a SafariViewController so you
|
114
|
+
// don't need to leave the app. You might expand this in your app
|
115
|
+
// to open all audio/video/images in a native media viewer
|
116
|
+
if url.host == rootURL.host, !url.pathExtension.isEmpty {
|
117
|
+
let safariViewController = SFSafariViewController(url: url)
|
118
|
+
navigationController.present(safariViewController, animated: true)
|
119
|
+
} else {
|
120
|
+
UIApplication.shared.open(url)
|
121
|
+
}
|
122
|
+
|
123
|
+
decisionHandler(.cancel)
|
124
|
+
} else {
|
125
|
+
decisionHandler(.allow)
|
126
|
+
}
|
127
|
+
}
|
128
|
+
}
|
129
|
+
|
130
|
+
extension SceneDelegate: WKUIDelegate {
|
131
|
+
func webView(_ webView: WKWebView, runJavaScriptConfirmPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (Bool) -> Void) {
|
132
|
+
let confirm = UIAlertController(title: nil, message: message, preferredStyle: .alert)
|
133
|
+
confirm.addAction(UIAlertAction(title: "Cancel", style: .cancel) { _ in completionHandler(false) })
|
134
|
+
confirm.addAction(UIAlertAction(title: "OK", style: .default) { _ in completionHandler(true) })
|
135
|
+
|
136
|
+
// JavaScript alerts in Turbo Native
|
137
|
+
navigationController.present(confirm, animated: true)
|
138
|
+
}
|
139
|
+
}
|
Binary file
|
@@ -0,0 +1,21 @@
|
|
1
|
+
{
|
2
|
+
"images" : [
|
3
|
+
{
|
4
|
+
"filename" : "turbo.png",
|
5
|
+
"idiom" : "universal",
|
6
|
+
"scale" : "1x"
|
7
|
+
},
|
8
|
+
{
|
9
|
+
"idiom" : "universal",
|
10
|
+
"scale" : "2x"
|
11
|
+
},
|
12
|
+
{
|
13
|
+
"idiom" : "universal",
|
14
|
+
"scale" : "3x"
|
15
|
+
}
|
16
|
+
],
|
17
|
+
"info" : {
|
18
|
+
"author" : "xcode",
|
19
|
+
"version" : 1
|
20
|
+
}
|
21
|
+
}
|
Binary file
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
|
3
|
+
<device id="retina5_9" orientation="portrait" appearance="light"/>
|
4
|
+
<dependencies>
|
5
|
+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21679"/>
|
6
|
+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
7
|
+
<capability name="System colors in document resources" minToolsVersion="11.0"/>
|
8
|
+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
9
|
+
</dependencies>
|
10
|
+
<scenes>
|
11
|
+
<!--View Controller-->
|
12
|
+
<scene sceneID="EHf-IW-A2E">
|
13
|
+
<objects>
|
14
|
+
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
15
|
+
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
16
|
+
<rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
|
17
|
+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
18
|
+
<subviews>
|
19
|
+
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" fixedFrame="YES" image="SplashIcon" translatesAutoresizingMaskIntoConstraints="NO" id="eXr-0W-qZz">
|
20
|
+
<rect key="frame" x="137" y="356" width="100" height="100"/>
|
21
|
+
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
|
22
|
+
</imageView>
|
23
|
+
</subviews>
|
24
|
+
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
|
25
|
+
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
26
|
+
</view>
|
27
|
+
</viewController>
|
28
|
+
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
29
|
+
</objects>
|
30
|
+
<point key="canvasLocation" x="50.399999999999999" y="373.89162561576359"/>
|
31
|
+
</scene>
|
32
|
+
</scenes>
|
33
|
+
<resources>
|
34
|
+
<image name="SplashIcon" width="1024" height="1024"/>
|
35
|
+
<systemColor name="systemBackgroundColor">
|
36
|
+
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
37
|
+
</systemColor>
|
38
|
+
</resources>
|
39
|
+
</document>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Y6W-OH-hqX">
|
3
|
+
<device id="retina6_12" orientation="portrait" appearance="light"/>
|
4
|
+
<dependencies>
|
5
|
+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21679"/>
|
6
|
+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
7
|
+
<capability name="System colors in document resources" minToolsVersion="11.0"/>
|
8
|
+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
9
|
+
</dependencies>
|
10
|
+
<scenes>
|
11
|
+
<!--Turbo Navigation Controller-->
|
12
|
+
<scene sceneID="s0d-6b-0kx">
|
13
|
+
<objects>
|
14
|
+
<viewController id="Y6W-OH-hqX" customClass="TurboNavigationController" customModule="<%= name %>" customModuleProvider="target" sceneMemberID="viewController">
|
15
|
+
<view key="view" contentMode="scaleToFill" id="5EZ-qb-Rvc">
|
16
|
+
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
|
17
|
+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
18
|
+
<viewLayoutGuide key="safeArea" id="vDu-zF-Fre"/>
|
19
|
+
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
20
|
+
</view>
|
21
|
+
</viewController>
|
22
|
+
<placeholder placeholderIdentifier="IBFirstResponder" id="Ief-a0-LHa" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
|
23
|
+
</objects>
|
24
|
+
<point key="canvasLocation" x="130" y="-2"/>
|
25
|
+
</scene>
|
26
|
+
</scenes>
|
27
|
+
<resources>
|
28
|
+
<systemColor name="systemBackgroundColor">
|
29
|
+
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
30
|
+
</systemColor>
|
31
|
+
</resources>
|
32
|
+
</document>
|
data/lib/turbo_native_initializer/templates/ios_stack/TurboNativeProject/TurboNativeProject.swift.tt
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
import Foundation
|
2
|
+
|
3
|
+
struct <%= name %> {
|
4
|
+
private static let developmentURL = URL(string: "http://localhost:3000")!
|
5
|
+
private static let productionURL = URL(string: "https://turbo-native-demo.glitch.me")!
|
6
|
+
|
7
|
+
static var baseURL: URL { productionURL }
|
8
|
+
static var homeURL: URL { baseURL.appendingPathComponent("/") }
|
9
|
+
static var signInURL: URL { baseURL.appendingPathComponent("/signin") }
|
10
|
+
}
|