| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- //
- // HelpVC.swift
- // Sirani
- //
- // Created by Anhar Solehudin on 24/03/19.
- // Copyright © 2019 Anhar Solehudin. All rights reserved.
- //
- import UIKit
- import WebKit
- class HelpVC: UIViewController {
- @IBOutlet weak var dropdown1: UIImageView!
- @IBOutlet weak var lineWv1: UIView!
- @IBOutlet weak var wv1: WKWebView!
-
- // View Lifecycles
- override var preferredStatusBarStyle: UIStatusBarStyle {
- return .lightContent
- }
-
- override func viewDidLoad() {
- super.viewDidLoad()
-
- let html1 = """
- <html>
- <meta name='viewport' content='width=device-width; initial-scale=1.0; maximum-scale=1.0;'>
- <head>
- <style type='text/css'>
- html {-webkit-text-size-adjust: none;}
- body { font-family: -apple-system, BlinkMacSystemFont, sans-serif; padding: 8px;}
- .pixel {font-size: 14px}
- </style>
- </head>
- <body>
- <p class="pixel" align="justify" class="center">
- <b style="font-size:15px;">Direktorat Standardisasi Perangkat Pos dan Informatika</b>
- <br>
- Direktorat Jenderal Sumber Daya dan Perangkat Pos dan Informatika<br>
- Kementerian Komunikasi dan Informatika - Republik Indonesia<br><br>
- <b>Loket Pelayanan Terpadu SDPPI</b><br>
- Wisma Antara Lantai 1<br>
- Jl. Medan Merdeka Selatan No.17, Gambir, Jakarta Pusat, DKI Jakarta<br>
- <i class="icon-phone bigger-100"></i> Phone : 159<br>
- <i class="icon-envelope bigger-100"></i> Email : <a href="mailto:kontak@kominfo.go.id" target="_blank">kontak@kominfo.go.id</a><br>
- </p>
- </body>
- </html>
- """
-
- wv1.navigationDelegate = self
- wv1.loadHTMLString(html1, baseURL: nil)
- }
-
- @IBAction func onTitleOneTapped(_ sender: Any) {
- if self.wv1.isHidden {
- UIView.animate(withDuration: 0.25, delay: 0, options: .curveEaseOut, animations: {
- self.lineWv1.isHidden = false
- self.lineWv1.layoutIfNeeded()
- self.wv1.isHidden = false
- self.wv1.layoutIfNeeded()
- self.dropdown1.rotates(-.pi)
- })
- } else {
- UIView.animate(withDuration: 0, delay: 0, options: .curveEaseIn, animations: {
- self.lineWv1.isHidden = true
- self.lineWv1.layoutIfNeeded()
- self.wv1.isHidden = true
- self.wv1.layoutIfNeeded()
- self.dropdown1.rotates(0.0)
- })
- }
- }
- }
- extension UIView {
- func rotates(_ toValue: CGFloat, duration: CFTimeInterval = 0.3) {
- let animation = CABasicAnimation(keyPath: "transform.rotation")
- animation.toValue = toValue
- animation.duration = duration
- animation.isRemovedOnCompletion = false
- animation.fillMode = CAMediaTimingFillMode.forwards
- self.layer.add(animation, forKey: nil)
- }
- }
- extension HelpVC: WKNavigationDelegate {
- func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
- if navigationAction.navigationType == .linkActivated {
- guard let url = navigationAction.request.url else {
- decisionHandler(.allow)
- return
- }
-
- let components = URLComponents(url: url, resolvingAgainstBaseURL: false)
- if components?.scheme == "http" || components?.scheme == "https" || components?.scheme == "mailto"
- {
- if UIApplication.shared.canOpenURL(url) {
- if #available(iOS 10.0, *) {
- UIApplication.shared.open(url)
- } else {
- UIApplication.shared.openURL(url)
- }
- decisionHandler(.cancel)
- } else {
- decisionHandler(.allow)
- }
- } else {
- decisionHandler(.allow)
- }
- } else {
- decisionHandler(.allow)
- }
- }
- }
|