turbo-native-initializer 0.0.15 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d5b3658efa201b5340d0e5ecdc401395f6659c235a5177c1e7a6b908b69a2f09
4
- data.tar.gz: 7327665391ec9be569354ad811f9565a6164da08aea90c3e8bfe04f65e03cf5a
3
+ metadata.gz: a6841be700aef23b3f08578ca5600a2b04f749b0759b78524b9eeee25b401761
4
+ data.tar.gz: 150fcb0fdb292a111db55d614684162201e46fef74df2dd0d5e3bb07d1e631eb
5
5
  SHA512:
6
- metadata.gz: 1dcedc375f6de7437ff80b816424e599b7b266713c94417a6752bf16104e8ac719f0cbbed03b500efe891a3590f84c000a16f254d25e8fac5c6546883a4b8a30
7
- data.tar.gz: b5e35c0791bf2a6b3fdc6eeaec4c45b5b14388b796c9d51f3539d2547fd93f106c01d483ec6a90d7cb6d73359cdfb2d76501226dab9fd070535f082922c6ef1c
6
+ metadata.gz: 94495c27a497d66a322a394b5d0892d38ffd4b6db121dff707598864283efe3afd48ed50ab4f31ff08e60f64171ec2e7c2803131939e4aea202a1499e9d3bf31
7
+ data.tar.gz: dc44d0613e6e02f30de088a3f329297c8fd38e310e56c921a55d913c199862f6d44dfe468ff206bd0381dfedde8daf1def0acb41eef353b1dd93643421850b01
@@ -2,11 +2,11 @@
2
2
  "settings": {},
3
3
  "rules": [
4
4
  { "patterns": [".*"], "properties": { "uri": "turbo://fragment/web", "pull_to_refresh_enabled": true } },
5
- { "patterns": ["/refresh_historical_location"], "properties": { "presentation": "refresh" } },
6
5
  { "patterns": ["/recede_historical_location"], "properties": { "presentation": "pop" } },
7
6
  { "patterns": ["/resume_historical_location"], "properties": { "presentation": "none" } },
8
- { "patterns": ["^/$"], "properties": { "uri": "turbo://fragment/web/home", "presentation": "replace_all" } },
7
+ { "patterns": ["/refresh_historical_location"], "properties": { "presentation": "refresh" } },
9
8
  { "patterns": ["/new$", "/edit$", "/signin$", "/strada-form$"], "properties": { "context": "modal", "uri": "turbo://fragment/web/modal", "pull_to_refresh_enabled": false } },
9
+ { "patterns": ["^/$"], "properties": { "uri": "turbo://fragment/web/home", "presentation": "replace_all" } },
10
10
  { "patterns": ["/numbers$"], "properties": { "uri": "turbo://fragment/numbers", "title": "Numbers" } }
11
11
  ]
12
12
  }
@@ -2,11 +2,11 @@
2
2
  "settings": {},
3
3
  "rules": [
4
4
  { "patterns": [".*"], "properties": { "uri": "turbo://fragment/web", "pull_to_refresh_enabled": true } },
5
- { "patterns": ["/refresh_historical_location"], "properties": { "presentation": "refresh" } },
6
5
  { "patterns": ["/recede_historical_location"], "properties": { "presentation": "pop" } },
7
6
  { "patterns": ["/resume_historical_location"], "properties": { "presentation": "none" } },
8
- { "patterns": ["^/$"], "properties": { "uri": "turbo://fragment/web/home", "presentation": "replace_all" } },
7
+ { "patterns": ["/refresh_historical_location"], "properties": { "presentation": "refresh" } },
9
8
  { "patterns": ["/new$", "/edit$", "/signin$", "/strada-form$"], "properties": { "context": "modal", "uri": "turbo://fragment/web/modal", "pull_to_refresh_enabled": false } },
9
+ { "patterns": ["^/$"], "properties": { "uri": "turbo://fragment/web/home", "presentation": "replace_all" } },
10
10
  { "patterns": ["/numbers$"], "properties": { "uri": "turbo://fragment/numbers", "title": "Numbers" } }
11
11
  ]
12
12
  }
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "settings": {},
3
3
  "rules": [
4
- { "patterns": ["/refresh_historical_location"], "properties": { "presentation": "refresh", "visitable": false } },
5
- { "patterns": ["/recede_historical_location"], "properties": { "presentation": "pop", "visitable": false } },
4
+ { "patterns": ["/recede_historical_location"], "properties": { "presentation": "back", "visitable": false } },
6
5
  { "patterns": ["/resume_historical_location"], "properties": { "presentation": "none", "visitable": false } },
6
+ { "patterns": ["/refresh_historical_location"], "properties": { "presentation": "refresh", "visitable": false } },
7
+ { "patterns": ["/new$", "/edit$", "/signin$", "/strada-form$"], "properties": { "presentation": "modal", "pull-to-refresh-enabled": false } },
7
8
  { "patterns": ["^/$"], "properties": { "presentation": "replace-all" } },
8
- { "patterns": ["/new$", "/edit$", "/signin$", "/strada-form$"], "properties": { "presentation": "modal" } },
9
9
  { "patterns": ["/numbers$"], "properties": { "view-controller": "numbers" } }
10
10
  ]
11
11
  }
@@ -22,9 +22,14 @@ class TurboNavigationController : UINavigationController {
22
22
  }
23
23
 
24
24
  // - Create view controller appropriate for url/properties
25
- // - Navigate to that with the correct presentation
26
25
  let viewController = makeViewController(for: url, properties: properties)
27
- navigate(to: viewController, action: options.action, properties: properties)
26
+
27
+ // - Navigate to that with the correct presentation
28
+ if session.topmostVisitable?.visitableURL == url {
29
+ navigate(to: viewController, action: .replace, properties: properties)
30
+ } else {
31
+ navigate(to: viewController, action: options.action, properties: properties)
32
+ }
28
33
 
29
34
  // Initiate the visit with Turbo
30
35
  if isVisitable(properties) {
@@ -43,8 +48,8 @@ extension TurboNavigationController {
43
48
  return properties["presentation"] as? String == "modal"
44
49
  }
45
50
 
46
- private func isPop(_ properties: PathProperties) -> Bool {
47
- return properties["presentation"] as? String == "pop"
51
+ private func isBack(_ properties: PathProperties) -> Bool {
52
+ return properties["presentation"] as? String == "back"
48
53
  }
49
54
 
50
55
  private func isRefresh(_ properties: PathProperties) -> Bool {
@@ -71,6 +76,14 @@ extension TurboNavigationController {
71
76
  return properties["visitable"] as? Bool ?? true
72
77
  }
73
78
 
79
+ private func isPullToRefreshEnabled(_ properties: PathProperties) -> Bool {
80
+ return properties["pull-to-refresh-enabled"] as? Bool ?? true
81
+ }
82
+
83
+ private func title(from properties: PathProperties) -> String? {
84
+ return properties["title"] as? String
85
+ }
86
+
74
87
  private func noticeMessage(from url: URL) -> String? {
75
88
  URLComponents(url: url, resolvingAgainstBaseURL: false)?.queryItems?.first(where: { $0.name == "notice" })?.value
76
89
  }
@@ -90,13 +103,16 @@ extension TurboNavigationController {
90
103
  }
91
104
  }
92
105
 
93
- return TurboWebViewController(url: url)
106
+ let viewController = TurboWebViewController(url: url)
107
+ viewController.pullToRefreshEnabled = isPullToRefreshEnabled(properties)
108
+ viewController.title = title(from: properties)
109
+ return viewController
94
110
  }
95
111
 
96
112
  private func navigate(to viewController: UIViewController, action: VisitAction, properties: PathProperties = [:]) {
97
113
  if isModal(properties) {
98
114
  present(UINavigationController(rootViewController: viewController), animated: true)
99
- } else if isPop(properties) {
115
+ } else if isBack(properties) {
100
116
  popViewController(animated: true)
101
117
  } else if isRefresh(properties) {
102
118
  session.reload()
@@ -5,6 +5,8 @@ import WebKit
5
5
 
6
6
  final class TurboWebViewController: VisitableViewController, ErrorPresenter, BridgeDestination {
7
7
 
8
+ var pullToRefreshEnabled = true
9
+
8
10
  private lazy var bridgeDelegate: BridgeDelegate = {
9
11
  BridgeDelegate(location: visitableURL.absoluteString, destination: self, componentTypes: BridgeComponent.allTypes)
10
12
  }()
@@ -20,6 +22,8 @@ final class TurboWebViewController: VisitableViewController, ErrorPresenter, Bri
20
22
 
21
23
  navigationItem.backButtonTitle = "Back"
22
24
 
25
+ visitableView.allowsPullToRefresh = pullToRefreshEnabled
26
+
23
27
  if presentingViewController != nil {
24
28
  navigationItem.leftBarButtonItem = dismissModalButton
25
29
  }
@@ -49,6 +53,10 @@ final class TurboWebViewController: VisitableViewController, ErrorPresenter, Bri
49
53
 
50
54
  // MARK: Visitable
51
55
 
56
+ override func visitableDidRender() {
57
+ title = title ?? visitableView.webView?.title
58
+ }
59
+
52
60
  override func visitableDidActivateWebView(_ webView: WKWebView) {
53
61
  bridgeDelegate.webViewDidBecomeActive(webView)
54
62
  }
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "settings": {},
3
3
  "rules": [
4
- { "patterns": ["/refresh_historical_location"], "properties": { "presentation": "refresh", "visitable": false } },
5
- { "patterns": ["/recede_historical_location"], "properties": { "presentation": "pop", "visitable": false } },
4
+ { "patterns": ["/recede_historical_location"], "properties": { "presentation": "back", "visitable": false } },
6
5
  { "patterns": ["/resume_historical_location"], "properties": { "presentation": "none", "visitable": false } },
6
+ { "patterns": ["/refresh_historical_location"], "properties": { "presentation": "refresh", "visitable": false } },
7
+ { "patterns": ["/new$", "/edit$", "/signin$", "/strada-form$"], "properties": { "presentation": "modal", "pull-to-refresh-enabled": false } },
7
8
  { "patterns": ["^/$"], "properties": { "presentation": "replace-all" } },
8
- { "patterns": ["/new$", "/edit$", "/signin$", "/strada-form$"], "properties": { "presentation": "modal" } },
9
9
  { "patterns": ["/numbers$"], "properties": { "view-controller": "numbers" } }
10
10
  ]
11
11
  }
@@ -22,9 +22,14 @@ class TurboNavigationController : UINavigationController {
22
22
  }
23
23
 
24
24
  // - Create view controller appropriate for url/properties
25
- // - Navigate to that with the correct presentation
26
25
  let viewController = makeViewController(for: url, properties: properties)
27
- navigate(to: viewController, action: options.action, properties: properties)
26
+
27
+ // - Navigate to that with the correct presentation
28
+ if session.topmostVisitable?.visitableURL == url {
29
+ navigate(to: viewController, action: .replace, properties: properties)
30
+ } else {
31
+ navigate(to: viewController, action: options.action, properties: properties)
32
+ }
28
33
 
29
34
  // Initiate the visit with Turbo
30
35
  if isVisitable(properties) {
@@ -43,8 +48,8 @@ extension TurboNavigationController {
43
48
  return properties["presentation"] as? String == "modal"
44
49
  }
45
50
 
46
- private func isPop(_ properties: PathProperties) -> Bool {
47
- return properties["presentation"] as? String == "pop"
51
+ private func isBack(_ properties: PathProperties) -> Bool {
52
+ return properties["presentation"] as? String == "back"
48
53
  }
49
54
 
50
55
  private func isRefresh(_ properties: PathProperties) -> Bool {
@@ -71,6 +76,14 @@ extension TurboNavigationController {
71
76
  return properties["visitable"] as? Bool ?? true
72
77
  }
73
78
 
79
+ private func isPullToRefreshEnabled(_ properties: PathProperties) -> Bool {
80
+ return properties["pull-to-refresh-enabled"] as? Bool ?? true
81
+ }
82
+
83
+ private func title(from properties: PathProperties) -> String? {
84
+ return properties["title"] as? String
85
+ }
86
+
74
87
  private func noticeMessage(from url: URL) -> String? {
75
88
  URLComponents(url: url, resolvingAgainstBaseURL: false)?.queryItems?.first(where: { $0.name == "notice" })?.value
76
89
  }
@@ -90,13 +103,16 @@ extension TurboNavigationController {
90
103
  }
91
104
  }
92
105
 
93
- return TurboWebViewController(url: url)
106
+ let viewController = TurboWebViewController(url: url)
107
+ viewController.pullToRefreshEnabled = isPullToRefreshEnabled(properties)
108
+ viewController.title = title(from: properties)
109
+ return viewController
94
110
  }
95
111
 
96
112
  private func navigate(to viewController: UIViewController, action: VisitAction, properties: PathProperties = [:]) {
97
113
  if isModal(properties) {
98
114
  present(UINavigationController(rootViewController: viewController), animated: true)
99
- } else if isPop(properties) {
115
+ } else if isBack(properties) {
100
116
  popViewController(animated: true)
101
117
  } else if isRefresh(properties) {
102
118
  session.reload()
@@ -5,6 +5,8 @@ import WebKit
5
5
 
6
6
  final class TurboWebViewController: VisitableViewController, ErrorPresenter, BridgeDestination {
7
7
 
8
+ var pullToRefreshEnabled = true
9
+
8
10
  private lazy var bridgeDelegate: BridgeDelegate = {
9
11
  BridgeDelegate(location: visitableURL.absoluteString, destination: self, componentTypes: BridgeComponent.allTypes)
10
12
  }()
@@ -20,6 +22,8 @@ final class TurboWebViewController: VisitableViewController, ErrorPresenter, Bri
20
22
 
21
23
  navigationItem.backButtonTitle = "Back"
22
24
 
25
+ visitableView.allowsPullToRefresh = pullToRefreshEnabled
26
+
23
27
  if presentingViewController != nil {
24
28
  navigationItem.leftBarButtonItem = dismissModalButton
25
29
  }
@@ -49,6 +53,10 @@ final class TurboWebViewController: VisitableViewController, ErrorPresenter, Bri
49
53
 
50
54
  // MARK: Visitable
51
55
 
56
+ override func visitableDidRender() {
57
+ title = title ?? visitableView.webView?.title
58
+ }
59
+
52
60
  override func visitableDidActivateWebView(_ webView: WKWebView) {
53
61
  bridgeDelegate.webViewDidBecomeActive(webView)
54
62
  }
@@ -1,3 +1,3 @@
1
1
  module TurboNativeInitializer
2
- VERSION = "0.0.15"
2
+ VERSION = "0.0.16"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbo-native-initializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nixon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-04 00:00:00.000000000 Z
11
+ date: 2023-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor