Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/ios.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarinofaggiana <marino@marinofaggiana.com>2019-08-22 11:52:00 +0300
committermarinofaggiana <marino@marinofaggiana.com>2019-08-22 11:52:00 +0300
commit63b2ecf11f69ceb662c50d30c4a3e79ff78fa267 (patch)
tree82b75a8e14025c6ff6f94ca6f237f8da625c8c78 /iOSClient/BrowserWeb
parente12c58e61f52d91ca0e8f93c48cb6e6817db2f7e (diff)
new class browserweb
Diffstat (limited to 'iOSClient/BrowserWeb')
-rw-r--r--iOSClient/BrowserWeb/NCBrowserWeb.storyboard52
-rw-r--r--iOSClient/BrowserWeb/NCBrowserWeb.swift88
2 files changed, 140 insertions, 0 deletions
diff --git a/iOSClient/BrowserWeb/NCBrowserWeb.storyboard b/iOSClient/BrowserWeb/NCBrowserWeb.storyboard
new file mode 100644
index 000000000..d7c23615d
--- /dev/null
+++ b/iOSClient/BrowserWeb/NCBrowserWeb.storyboard
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="OOi-qQ-BCK">
+ <device id="retina6_1" orientation="portrait">
+ <adaptation id="fullscreen"/>
+ </device>
+ <dependencies>
+ <deployment identifier="iOS"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
+ <capability name="Safe area layout guides" minToolsVersion="9.0"/>
+ <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+ </dependencies>
+ <scenes>
+ <!--Browser Web-->
+ <scene sceneID="qXu-Mk-wdV">
+ <objects>
+ <viewController id="OOi-qQ-BCK" customClass="NCBrowserWeb" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
+ <view key="view" contentMode="scaleToFill" id="Aai-ip-ntL">
+ <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ <subviews>
+ <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Lht-2f-Ep4">
+ <rect key="frame" x="374" y="54" width="30" height="30"/>
+ <constraints>
+ <constraint firstAttribute="height" constant="30" id="ckh-Eb-Ze8"/>
+ <constraint firstAttribute="width" constant="30" id="oHS-Ba-9eq"/>
+ </constraints>
+ <state key="normal" image="exit"/>
+ <connections>
+ <action selector="touchUpInsideButtonExit:" destination="OOi-qQ-BCK" eventType="touchUpInside" id="hcA-Hb-TJd"/>
+ </connections>
+ </button>
+ </subviews>
+ <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+ <constraints>
+ <constraint firstItem="Lht-2f-Ep4" firstAttribute="top" secondItem="fTU-bd-6qR" secondAttribute="top" constant="10" id="Qy7-ho-gnO"/>
+ <constraint firstItem="fTU-bd-6qR" firstAttribute="trailing" secondItem="Lht-2f-Ep4" secondAttribute="trailing" constant="10" id="ysf-ri-C7p"/>
+ </constraints>
+ <viewLayoutGuide key="safeArea" id="fTU-bd-6qR"/>
+ </view>
+ <connections>
+ <outlet property="buttonExit" destination="Lht-2f-Ep4" id="dsx-PX-MaQ"/>
+ </connections>
+ </viewController>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="4JZ-dx-ros" userLabel="First Responder" sceneMemberID="firstResponder"/>
+ </objects>
+ <point key="canvasLocation" x="4511.594202898551" y="-1210.0446428571429"/>
+ </scene>
+ </scenes>
+ <resources>
+ <image name="exit" width="300" height="300"/>
+ </resources>
+</document>
diff --git a/iOSClient/BrowserWeb/NCBrowserWeb.swift b/iOSClient/BrowserWeb/NCBrowserWeb.swift
new file mode 100644
index 000000000..52ab90bb8
--- /dev/null
+++ b/iOSClient/BrowserWeb/NCBrowserWeb.swift
@@ -0,0 +1,88 @@
+//
+// NCBrowserWeb.swift
+// Nextcloud
+//
+// Created by Marino Faggiana on 22/08/2019.
+// Copyright © 2019 TWS. All rights reserved.
+//
+
+import Foundation
+
+@objc protocol NCBrowserWebDelegate: class {
+ @objc optional func browserWebDismiss()
+}
+
+class NCBrowserWeb: UIViewController {
+
+ var webView: WKWebView?
+ let appDelegate = UIApplication.shared.delegate as! AppDelegate
+
+ @objc var urlBase = ""
+ @objc weak var delegate: NCBrowserWebDelegate?
+
+ @IBOutlet weak var buttonExit: UIButton!
+
+ override func viewDidLoad() {
+ super.viewDidLoad()
+
+ webView = WKWebView(frame: CGRect.zero)
+ webView!.navigationDelegate = self
+ view.addSubview(webView!)
+ webView!.translatesAutoresizingMaskIntoConstraints = false
+ webView!.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0).isActive = true
+ webView!.rightAnchor.constraint(equalTo: view.rightAnchor, constant: 0).isActive = true
+ webView!.topAnchor.constraint(equalTo: view.topAnchor, constant: 0).isActive = true
+ webView!.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0).isActive = true
+
+ // button exit
+ self.view.bringSubviewToFront(buttonExit)
+
+ loadWebPage(webView: webView!, url: URL(string: urlBase)!)
+ }
+
+ func loadWebPage(webView: WKWebView, url: URL) {
+
+ let language = NSLocale.preferredLanguages[0] as String
+ var request = URLRequest(url: url)
+
+ request.setValue(CCUtility.getUserAgent(), forHTTPHeaderField: "User-Agent")
+ request.addValue("true", forHTTPHeaderField: "OCS-APIRequest")
+ request.addValue(language, forHTTPHeaderField: "Accept-Language")
+
+ webView.load(request)
+ }
+
+ @IBAction func touchUpInsideButtonExit(_ sender: UIButton) {
+ self.dismiss(animated: true) {
+ self.delegate?.browserWebDismiss?()
+ }
+ }
+}
+
+extension NCBrowserWeb: WKNavigationDelegate {
+
+
+ public func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
+ if let serverTrust = challenge.protectionSpace.serverTrust {
+ completionHandler(Foundation.URLSession.AuthChallengeDisposition.useCredential, URLCredential(trust: serverTrust))
+ } else {
+ completionHandler(URLSession.AuthChallengeDisposition.useCredential, nil);
+ }
+ }
+
+ public func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
+ decisionHandler(.allow)
+ }
+
+ public func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
+ print("didStartProvisionalNavigation");
+ }
+
+ public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
+ print("didFinishProvisionalNavigation");
+ }
+
+ public func webView(_ webView: WKWebView, didReceiveServerRedirectForProvisionalNavigation navigation: WKNavigation!) {
+ print("didReceiveServerRedirectForProvisionalNavigation");
+ }
+}