-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1197 from WalletConnect/develop
1.9.1
- Loading branch information
Showing
30 changed files
with
358 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
Example/WalletApp/PresentationLayer/Wallet/Browser/BrowserInteractor.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
final class BrowserInteractor { | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
Example/WalletApp/PresentationLayer/Wallet/Browser/BrowserModule.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import SwiftUI | ||
|
||
final class BrowserModule { | ||
@discardableResult | ||
static func create(app: Application) -> UIViewController { | ||
let router = BrowserRouter(app: app) | ||
let interactor = BrowserInteractor() | ||
let presenter = BrowserPresenter(interactor: interactor, router: router) | ||
let view = BrowserView().environmentObject(presenter) | ||
let viewController = SceneViewController(viewModel: presenter, content: view) | ||
|
||
router.viewController = viewController | ||
|
||
return viewController | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
Example/WalletApp/PresentationLayer/Wallet/Browser/BrowserPresenter.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import UIKit | ||
import Combine | ||
import WebKit | ||
|
||
import WalletConnectNetworking | ||
|
||
final class BrowserPresenter: ObservableObject { | ||
private let interactor: BrowserInteractor | ||
private let router: BrowserRouter | ||
|
||
weak var webView: WKWebView? | ||
|
||
@Published var urlString = "https://react-app.walletconnect.com" | ||
|
||
private var disposeBag = Set<AnyCancellable>() | ||
|
||
init(interactor: BrowserInteractor, router: BrowserRouter) { | ||
defer { setupInitialState() } | ||
self.interactor = interactor | ||
self.router = router | ||
} | ||
|
||
func loadURLString() { | ||
if let url = URL(string: urlString) { | ||
webView?.load(URLRequest(url: url.sanitise)) | ||
} | ||
} | ||
|
||
func reload() { | ||
webView?.reload() | ||
} | ||
} | ||
|
||
// MARK: SceneViewModel | ||
extension BrowserPresenter: SceneViewModel { | ||
var sceneTitle: String? { | ||
return "Browser" | ||
} | ||
|
||
var largeTitleDisplayMode: UINavigationItem.LargeTitleDisplayMode { | ||
return .always | ||
} | ||
} | ||
|
||
// MARK: Privates | ||
private extension BrowserPresenter { | ||
func setupInitialState() { | ||
|
||
} | ||
} | ||
|
||
extension URL { | ||
var sanitise: URL { | ||
if var components = URLComponents(url: self, resolvingAgainstBaseURL: false) { | ||
if components.scheme == nil { | ||
components.scheme = "https" | ||
} | ||
return components.url ?? self | ||
} | ||
return self | ||
} | ||
} |
Oops, something went wrong.