forked from organicmaps/organicmaps
[iOS] Added connection error placeholder to the catalog web view
This commit is contained in:
parent
a4190ccca5
commit
c570cd4339
8 changed files with 1758 additions and 1 deletions
|
@ -0,0 +1,47 @@
|
|||
import UIKit
|
||||
|
||||
class CatalogConnectionErrorView: UIView {
|
||||
|
||||
@IBOutlet var imageView: UIImageView!
|
||||
@IBOutlet var titleLabel: UILabel!
|
||||
@IBOutlet var actionButton: UIButton!
|
||||
var actionCallback: (() -> Void)?
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
xibSetup()
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
super.init(coder: aDecoder)
|
||||
xibSetup()
|
||||
}
|
||||
|
||||
convenience init(frame: CGRect, actionCallback callback: (() -> Void)?) {
|
||||
self.init(frame: frame)
|
||||
actionCallback = callback
|
||||
}
|
||||
|
||||
@IBAction func actionTapHandler() {
|
||||
actionCallback?()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension CatalogConnectionErrorView {
|
||||
func xibSetup() {
|
||||
backgroundColor = UIColor.clear
|
||||
let nib = UINib(nibName: "CatalogConnectionErrorView", bundle: nil)
|
||||
let view = nib.instantiate(withOwner: self, options: nil).first as! UIView
|
||||
view.translatesAutoresizingMaskIntoConstraints = false
|
||||
addSubview(view)
|
||||
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|[childView]|",
|
||||
options: [],
|
||||
metrics: nil,
|
||||
views: ["childView": view]))
|
||||
addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|[childView]|",
|
||||
options: [],
|
||||
metrics: nil,
|
||||
views: ["childView": view]))
|
||||
}
|
||||
}
|
86
iphone/Maps/Bookmarks/Catalog/CatalogConnectionErrorView.xib
Normal file
86
iphone/Maps/Bookmarks/Catalog/CatalogConnectionErrorView.xib
Normal file
|
@ -0,0 +1,86 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<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>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="CatalogConnectionErrorView" customModule="maps_me" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="actionButton" destination="kyS-Dc-8Qc" id="hBQ-hJ-tyA"/>
|
||||
<outlet property="imageView" destination="Pei-9A-n7i" id="vil-2f-cDC"/>
|
||||
<outlet property="titleLabel" destination="dSI-8v-q0T" id="Sut-eN-iDC"/>
|
||||
</connections>
|
||||
</placeholder>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<view contentMode="scaleToFill" id="iN0-l3-epB">
|
||||
<rect key="frame" x="0.0" y="0.0" width="280" height="371"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_no_internet_connection" translatesAutoresizingMaskIntoConstraints="NO" id="Pei-9A-n7i">
|
||||
<rect key="frame" x="24" y="0.0" width="182" height="175"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="175" id="CCZ-Hc-GEh"/>
|
||||
<constraint firstAttribute="width" constant="182" id="hiU-5U-9jy"/>
|
||||
</constraints>
|
||||
</imageView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dSI-8v-q0T">
|
||||
<rect key="frame" x="5" y="205" width="270" height="94"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="regular20"/>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="textColorName" value="blackPrimaryText"/>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="catalog_no_internet_title"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</label>
|
||||
<button opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="kyS-Dc-8Qc">
|
||||
<rect key="frame" x="0.0" y="323" width="280" height="48"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="48" id="hOC-5N-zNA"/>
|
||||
</constraints>
|
||||
<state key="normal" title="Button"/>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="textColorHighlightedName" value="whitePrimaryTextHighlighted"/>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="fontName" value="semibold14"/>
|
||||
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
|
||||
<integer key="value" value="8"/>
|
||||
</userDefinedRuntimeAttribute>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="textColorName" value="whitePrimaryText"/>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="backgroundColorName" value="linkBlue"/>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="backgroundHighlightedColorName" value="linkBlueHighlighted"/>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="localizedText" value="catalog_no_internet_button"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
<connections>
|
||||
<action selector="actionTapHandler" destination="-1" eventType="touchUpInside" id="D9p-hf-eMV"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" secondItem="kyS-Dc-8Qc" secondAttribute="trailing" id="2gU-Ct-ccl"/>
|
||||
<constraint firstAttribute="trailing" secondItem="dSI-8v-q0T" secondAttribute="trailing" constant="5" id="5lL-7g-AdH"/>
|
||||
<constraint firstItem="Pei-9A-n7i" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="Ubu-Af-XnV"/>
|
||||
<constraint firstAttribute="trailing" secondItem="Pei-9A-n7i" secondAttribute="trailing" constant="74" id="aKw-Tg-7Ds"/>
|
||||
<constraint firstItem="kyS-Dc-8Qc" firstAttribute="top" secondItem="dSI-8v-q0T" secondAttribute="bottom" constant="24" id="aR0-XD-Fkx"/>
|
||||
<constraint firstItem="dSI-8v-q0T" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="5" id="ejF-9v-wCy"/>
|
||||
<constraint firstItem="Pei-9A-n7i" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="24" id="fJ8-AE-Mbf"/>
|
||||
<constraint firstItem="dSI-8v-q0T" firstAttribute="top" secondItem="Pei-9A-n7i" secondAttribute="bottom" constant="30" id="quR-U0-o2h"/>
|
||||
<constraint firstItem="kyS-Dc-8Qc" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="tZT-IZ-ce5"/>
|
||||
<constraint firstAttribute="bottom" secondItem="kyS-Dc-8Qc" secondAttribute="bottom" id="xfW-xR-ToV"/>
|
||||
</constraints>
|
||||
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
|
||||
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
|
||||
<point key="canvasLocation" x="53.623188405797109" y="56.584821428571423"/>
|
||||
</view>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="ic_no_internet_connection" width="182" height="175"/>
|
||||
</resources>
|
||||
</document>
|
|
@ -31,6 +31,7 @@ final class CatalogWebViewController: WebViewController {
|
|||
var fwdButton: UIBarButtonItem!
|
||||
var toolbar = UIToolbar()
|
||||
var billing = InAppPurchase.inAppBilling()
|
||||
var noInternetView: CatalogConnectionErrorView!
|
||||
|
||||
@objc static func catalogFromAbsoluteUrl(_ url: URL? = nil, utm: MWMUTM = .none) -> CatalogWebViewController {
|
||||
return CatalogWebViewController(url, utm:utm, isAbsoluteUrl:true)
|
||||
|
@ -65,6 +66,16 @@ final class CatalogWebViewController: WebViewController {
|
|||
fwdButton.tintColor = .blackSecondaryText()
|
||||
backButton.isEnabled = false
|
||||
fwdButton.isEnabled = false
|
||||
noInternetView = CatalogConnectionErrorView(frame: .zero, actionCallback: { [weak self] in
|
||||
guard let self = self else { return }
|
||||
self.noInternetView.isHidden = true
|
||||
self.loadingIndicator.startAnimating()
|
||||
if self.webView.url != nil {
|
||||
self.webView.reload()
|
||||
} else {
|
||||
self.performURLRequest()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
|
@ -97,6 +108,12 @@ final class CatalogWebViewController: WebViewController {
|
|||
progressView.centerYAnchor.constraint(equalTo: progressBgView.centerYAnchor).isActive = true
|
||||
progressBgView.widthAnchor.constraint(equalToConstant: 48).isActive = true
|
||||
progressBgView.heightAnchor.constraint(equalToConstant: 48).isActive = true
|
||||
|
||||
noInternetView.isHidden = true
|
||||
noInternetView.translatesAutoresizingMaskIntoConstraints = false
|
||||
view.addSubview(noInternetView)
|
||||
noInternetView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
|
||||
noInternetView.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: -20.0).isActive = true
|
||||
|
||||
view.addSubview(toolbar)
|
||||
toolbar.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
@ -177,6 +194,7 @@ final class CatalogWebViewController: WebViewController {
|
|||
Statistics.logEvent("Bookmarks_Downloaded_Catalogue_error",
|
||||
withParameters: [kStatError : kStatUnknown])
|
||||
loadingIndicator.stopAnimating()
|
||||
noInternetView.isHidden = false
|
||||
}
|
||||
|
||||
override func webView(_ webView: WKWebView,
|
||||
|
@ -185,6 +203,7 @@ final class CatalogWebViewController: WebViewController {
|
|||
Statistics.logEvent("Bookmarks_Downloaded_Catalogue_error",
|
||||
withParameters: [kStatError : kStatUnknown])
|
||||
loadingIndicator.stopAnimating()
|
||||
noInternetView.isHidden = false
|
||||
}
|
||||
|
||||
private func showSubscribe() {
|
||||
|
|
|
@ -26,6 +26,7 @@ typedef void (^WebViewControllerWillLoadBlock)(BOOL, NSDictionary<NSString *, NS
|
|||
- (void)forward;
|
||||
- (void)back;
|
||||
- (NSString *)configuredHtmlWithText:(NSString *)htmlText;
|
||||
- (void)performURLRequest;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -93,6 +93,10 @@
|
|||
self.webView.backgroundColor = UIColor.whiteColor;
|
||||
self.webView.allowsLinkPreview = NO;
|
||||
|
||||
[self performURLRequest];
|
||||
}
|
||||
|
||||
- (void)performURLRequest {
|
||||
__weak __typeof(self) ws = self;
|
||||
[self willLoadUrl:^(BOOL load, NSDictionary<NSString *, NSString *> *headers) {
|
||||
__typeof(self) self = ws;
|
||||
|
@ -107,7 +111,7 @@
|
|||
for (NSString *header in headers.allKeys) {
|
||||
[request setValue:headers[header] forHTTPHeaderField:header];
|
||||
}
|
||||
|
||||
|
||||
[request setValue:@(GetPlatform().GetAppUserAgent().Get().c_str()) forHTTPHeaderField:@"User-Agent"];
|
||||
if (self.shouldAddAccessToken)
|
||||
{
|
||||
|
|
12
iphone/Maps/Images.xcassets/ic_no_internet_connection.imageset/Contents.json
vendored
Normal file
12
iphone/Maps/Images.xcassets/ic_no_internet_connection.imageset/Contents.json
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "ic_no_internet_connection.pdf"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
1580
iphone/Maps/Images.xcassets/ic_no_internet_connection.imageset/ic_no_internet_connection.pdf
vendored
Normal file
1580
iphone/Maps/Images.xcassets/ic_no_internet_connection.imageset/ic_no_internet_connection.pdf
vendored
Normal file
File diff suppressed because it is too large
Load diff
|
@ -591,6 +591,8 @@
|
|||
BB8123D62130427E00ADE512 /* MetalContextFactory.mm in Sources */ = {isa = PBXBuildFile; fileRef = BB8123D52130427E00ADE512 /* MetalContextFactory.mm */; };
|
||||
CD08887422B7ABB400C1368D /* MWMDiscoveryCollectionView.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD08887322B7ABB400C1368D /* MWMDiscoveryCollectionView.mm */; };
|
||||
CD4A1F132305872700F2A6B6 /* PromoBookingPresentationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD4A1F122305872700F2A6B6 /* PromoBookingPresentationController.swift */; };
|
||||
CD4A1F1A230EADC100F2A6B6 /* CatalogConnectionErrorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD4A1F19230EADC100F2A6B6 /* CatalogConnectionErrorView.swift */; };
|
||||
CD4A1F1C230EB43B00F2A6B6 /* CatalogConnectionErrorView.xib in Resources */ = {isa = PBXBuildFile; fileRef = CD4A1F1B230EB43B00F2A6B6 /* CatalogConnectionErrorView.xib */; };
|
||||
CD6E8677226774C700D1EDF7 /* CPConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD6E8676226774C700D1EDF7 /* CPConstants.swift */; };
|
||||
CD96C70C22A681C400DB7CFE /* DiscoveryGuideCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD96C70A22A681C400DB7CFE /* DiscoveryGuideCell.swift */; };
|
||||
CD96C70D22A681C400DB7CFE /* DiscoveryGuideCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = CD96C70B22A681C400DB7CFE /* DiscoveryGuideCell.xib */; };
|
||||
|
@ -1681,6 +1683,8 @@
|
|||
CD08888322BCF1C800C1368D /* maps.me rel.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = "maps.me rel.entitlements"; sourceTree = "<group>"; };
|
||||
CD08888422BCF1C900C1368D /* maps.me full.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = "maps.me full.entitlements"; sourceTree = "<group>"; };
|
||||
CD4A1F122305872700F2A6B6 /* PromoBookingPresentationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PromoBookingPresentationController.swift; sourceTree = "<group>"; };
|
||||
CD4A1F19230EADC100F2A6B6 /* CatalogConnectionErrorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CatalogConnectionErrorView.swift; sourceTree = "<group>"; };
|
||||
CD4A1F1B230EB43B00F2A6B6 /* CatalogConnectionErrorView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CatalogConnectionErrorView.xib; sourceTree = "<group>"; };
|
||||
CD6E8676226774C700D1EDF7 /* CPConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CPConstants.swift; sourceTree = "<group>"; };
|
||||
CD96C70A22A681C400DB7CFE /* DiscoveryGuideCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiscoveryGuideCell.swift; sourceTree = "<group>"; };
|
||||
CD96C70B22A681C400DB7CFE /* DiscoveryGuideCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DiscoveryGuideCell.xib; sourceTree = "<group>"; };
|
||||
|
@ -3674,6 +3678,8 @@
|
|||
4728F68F22CE430800E00028 /* BookmarksSubscriptionViewController.xib */,
|
||||
4710366322D3764600585272 /* BookmarksSubscriptionCellViewController.swift */,
|
||||
4710366422D3764600585272 /* BookmarksSubscriptionCellViewController.xib */,
|
||||
CD4A1F19230EADC100F2A6B6 /* CatalogConnectionErrorView.swift */,
|
||||
CD4A1F1B230EB43B00F2A6B6 /* CatalogConnectionErrorView.xib */,
|
||||
);
|
||||
path = Catalog;
|
||||
sourceTree = "<group>";
|
||||
|
@ -4878,6 +4884,7 @@
|
|||
4716EAC121A6E0570029B886 /* BookmarksVC.xib in Resources */,
|
||||
F6E2FEAC1E097BA00083EBEC /* PPPReview.xib in Resources */,
|
||||
F60C8BEF1FCED15A00DCF5FB /* DiscoverySearchCell.xib in Resources */,
|
||||
CD4A1F1C230EB43B00F2A6B6 /* CatalogConnectionErrorView.xib in Resources */,
|
||||
F65D1E1A20E4F11600FE31DD /* ugc_migration in Resources */,
|
||||
F6E2FEAF1E097BA00083EBEC /* _MWMPPPExternalTitle.xib in Resources */,
|
||||
F6E2FEB21E097BA00083EBEC /* _MWMPPPSchedule.xib in Resources */,
|
||||
|
@ -5484,6 +5491,7 @@
|
|||
3454D7CE1E07F045004AF2AD /* UIFont+MapsMeFonts.mm in Sources */,
|
||||
F682249B1E5B104600BC1C18 /* PPHotelDescriptionCell.swift in Sources */,
|
||||
3454D7DD1E07F045004AF2AD /* UISwitch+RuntimeAttributes.m in Sources */,
|
||||
CD4A1F1A230EADC100F2A6B6 /* CatalogConnectionErrorView.swift in Sources */,
|
||||
4719A647219CBD7F009F9AA7 /* IBillingPendingTransaction.swift in Sources */,
|
||||
340416581E7C0D4100E2B6D6 /* PhotosOverlayView.swift in Sources */,
|
||||
F6E2FE821E097BA00083EBEC /* MWMPlacePageOpeningHoursDayView.mm in Sources */,
|
||||
|
|
Loading…
Add table
Reference in a new issue