forked from organicmaps/organicmaps
[ios] update authorization ui, add new controls
This commit is contained in:
parent
4993023b09
commit
cd834d31ba
6 changed files with 192 additions and 15 deletions
|
@ -55,5 +55,6 @@
|
|||
+ (BOOL)isNightMode;
|
||||
|
||||
- (UIColor *)opposite;
|
||||
- (UIColor *)colorByBlendingWithColor:(UIColor * _Nonnull)color;
|
||||
|
||||
@end
|
||||
|
|
|
@ -378,4 +378,26 @@ UIColor * color(SEL cmd)
|
|||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
- (UIColor *)colorByBlendingWithColor:(UIColor *)color {
|
||||
CGFloat bgR;
|
||||
CGFloat bgG;
|
||||
CGFloat bgB;
|
||||
CGFloat bgA;
|
||||
|
||||
CGFloat fgR;
|
||||
CGFloat fgG;
|
||||
CGFloat fgB;
|
||||
CGFloat fgA;
|
||||
|
||||
[self getRed:&bgR green:&bgG blue:&bgB alpha:&bgA];
|
||||
[color getRed:&fgR green:&fgG blue:&fgB alpha:&fgA];
|
||||
|
||||
CGFloat r = fgA * fgR + (1 - fgA) * bgR;
|
||||
CGFloat g = fgA * fgG + (1 - fgA) * bgG;
|
||||
CGFloat b = fgA * fgB + (1 - fgA) * bgB;
|
||||
|
||||
return [UIColor colorWithRed:r green:g blue:b alpha:bgA];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
|
92
iphone/Maps/Classes/Components/Checkmark.swift
Normal file
92
iphone/Maps/Classes/Components/Checkmark.swift
Normal file
|
@ -0,0 +1,92 @@
|
|||
//
|
||||
// Checkmark.swift
|
||||
// MAPS.ME
|
||||
//
|
||||
// Created by Aleksey Belousov on 15/05/2018.
|
||||
// Copyright © 2018 MapsWithMe. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
@IBDesignable
|
||||
class Checkmark: UIControl {
|
||||
|
||||
private let imageView = UIImageView(frame: .zero)
|
||||
|
||||
@IBInspectable
|
||||
var offImage: UIImage? {
|
||||
didSet {
|
||||
updateImage(animated: false)
|
||||
}
|
||||
}
|
||||
|
||||
@IBInspectable
|
||||
var onImage: UIImage? {
|
||||
didSet {
|
||||
updateImage(animated: false)
|
||||
}
|
||||
}
|
||||
|
||||
@IBInspectable
|
||||
var offTintColor: UIColor? {
|
||||
didSet {
|
||||
updateTintColor()
|
||||
}
|
||||
}
|
||||
|
||||
@IBInspectable
|
||||
var onTintColor: UIColor? {
|
||||
didSet {
|
||||
updateTintColor()
|
||||
}
|
||||
}
|
||||
|
||||
@IBInspectable
|
||||
var isChecked: Bool = false {
|
||||
didSet {
|
||||
updateImage(animated: true)
|
||||
updateTintColor()
|
||||
}
|
||||
}
|
||||
|
||||
override var isHighlighted: Bool {
|
||||
didSet {
|
||||
imageView.tintColor = isHighlighted ? tintColor.blending(with: UIColor(white: 0, alpha: 0.5)) : nil
|
||||
}
|
||||
}
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
initViews()
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
super.init(coder: aDecoder)
|
||||
initViews()
|
||||
}
|
||||
|
||||
private func initViews() {
|
||||
addSubview(imageView)
|
||||
addTarget(self, action: #selector(onTouch), for: .touchUpInside)
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
|
||||
imageView.sizeToFit()
|
||||
imageView.center = CGPoint(x: bounds.width / 2, y: bounds.height / 2)
|
||||
}
|
||||
|
||||
@objc func onTouch() {
|
||||
isChecked = !isChecked
|
||||
sendActions(for: .valueChanged)
|
||||
}
|
||||
|
||||
private func updateImage(animated: Bool) {
|
||||
self.imageView.image = self.isChecked ? self.onImage : self.offImage
|
||||
}
|
||||
|
||||
private func updateTintColor() {
|
||||
tintColor = isChecked ? onTintColor : offTintColor
|
||||
}
|
||||
}
|
|
@ -345,6 +345,7 @@
|
|||
4586D0E71F4813AB00DF9CE5 /* libmwm_diff.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4586D0E61F4813AB00DF9CE5 /* libmwm_diff.a */; };
|
||||
45CBCCBA20590AAB006B55C2 /* libkml.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 45CBCCBB20590AAB006B55C2 /* libkml.a */; };
|
||||
45FFD65D1E965EBE00DB854E /* liblocal_ads.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 45FFD65C1E965EBE00DB854E /* liblocal_ads.a */; };
|
||||
4767CD9F20AAD48A00BD8166 /* Checkmark.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4767CD9E20AAD48A00BD8166 /* Checkmark.swift */; };
|
||||
4A300ED51C6DCFD400140018 /* countries-strings in Resources */ = {isa = PBXBuildFile; fileRef = 4A300ED31C6DCFD400140018 /* countries-strings */; };
|
||||
56C74C391C74A3BC00B71B9F /* MWMInputEmailValidator.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34ABA62F1C2D58F300FE1BEC /* MWMInputEmailValidator.mm */; };
|
||||
56EE14D11FE804550036F20C /* libtransit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 56EE14D21FE804550036F20C /* libtransit.a */; };
|
||||
|
@ -1271,6 +1272,7 @@
|
|||
46F26CD610F623BA00ECCA39 /* EAGLView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = EAGLView.h; sourceTree = "<group>"; };
|
||||
46F26CD710F623BA00ECCA39 /* EAGLView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = EAGLView.mm; sourceTree = "<group>"; };
|
||||
46F8A2EB10EB63040045521A /* MapViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = MapViewController.h; sourceTree = "<group>"; };
|
||||
4767CD9E20AAD48A00BD8166 /* Checkmark.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Checkmark.swift; sourceTree = "<group>"; };
|
||||
4A00DBDE1AB704C400113624 /* drules_proto_dark.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; name = drules_proto_dark.bin; path = ../../data/drules_proto_dark.bin; sourceTree = "<group>"; };
|
||||
4A23D1561B8B4DD700D4EB6F /* drules_proto_clear.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; name = drules_proto_clear.bin; path = ../../data/drules_proto_clear.bin; sourceTree = "<group>"; };
|
||||
4A23D1571B8B4DD700D4EB6F /* resources-6plus_clear */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "resources-6plus_clear"; path = "../../data/resources-6plus_clear"; sourceTree = "<group>"; };
|
||||
|
@ -2549,6 +2551,7 @@
|
|||
34C9BD011C6DB693000DC38D /* MWMViewController.mm */,
|
||||
344BEAEF1F66BDC30045DC45 /* RatingSummaryView */,
|
||||
348A8DF01F66775A00D83026 /* RatingView */,
|
||||
4767CD9E20AAD48A00BD8166 /* Checkmark.swift */,
|
||||
);
|
||||
path = Components;
|
||||
sourceTree = "<group>";
|
||||
|
@ -4535,6 +4538,7 @@
|
|||
34AB66171FC5AA320078E451 /* MWMiPhoneRoutePreview.mm in Sources */,
|
||||
6741A9E71BF340DE002C974C /* MWMCircularProgressView.mm in Sources */,
|
||||
34AC8FDB1EFC07FE00E7F910 /* UILabel+NumberOfVisibleLines.swift in Sources */,
|
||||
4767CD9F20AAD48A00BD8166 /* Checkmark.swift in Sources */,
|
||||
F6E2FD981E097BA00083EBEC /* MWMBookmarkTitleCell.m in Sources */,
|
||||
6741A9E81BF340DE002C974C /* MWMAPIBar.mm in Sources */,
|
||||
349A13831DEC138C00C7DB60 /* MWMMobileInternetAlert.mm in Sources */,
|
||||
|
|
|
@ -114,6 +114,49 @@ final class AuthorizationViewController: MWMViewController {
|
|||
facebookButtonHolder.clipsToBounds = true
|
||||
}
|
||||
}
|
||||
|
||||
@IBOutlet private weak var privacyPolicyCheck: UIButton! {
|
||||
didSet {
|
||||
privacyPolicyCheck.tintColor = .blackHintText()
|
||||
}
|
||||
}
|
||||
|
||||
@IBOutlet private weak var termsOfUseCheck: UIButton! {
|
||||
didSet {
|
||||
termsOfUseCheck.tintColor = .blackHintText()
|
||||
}
|
||||
}
|
||||
|
||||
@IBOutlet private weak var latestNewsCheck: UIButton! {
|
||||
didSet {
|
||||
latestNewsCheck.tintColor = .blackHintText()
|
||||
}
|
||||
}
|
||||
|
||||
@IBOutlet private weak var privacyPolicyTextView: UITextView! {
|
||||
didSet {
|
||||
let htmlString = L("sign_agree_pp_gdpr")
|
||||
guard let data = htmlString.data(using: .utf8) else { return }
|
||||
guard let text = try? NSMutableAttributedString(data: data,
|
||||
options: [.documentType: NSAttributedString.DocumentType.html,
|
||||
.characterEncoding: String.Encoding.utf8.rawValue],
|
||||
documentAttributes: nil) else { return }
|
||||
text.addAttributes([NSAttributedStringKey.font: UIFont.regular16()], range: NSMakeRange(0, text.length))
|
||||
privacyPolicyTextView.attributedText = text
|
||||
}
|
||||
}
|
||||
|
||||
@IBOutlet private weak var termsOfUseTextView: UITextView! {
|
||||
didSet {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@IBOutlet private weak var latestNewsTextView: UITextView! {
|
||||
didSet {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
typealias SuccessHandler = (MWMSocialTokenType) -> Void
|
||||
typealias ErrorHandler = (MWMAuthorizationError) -> Void
|
||||
|
@ -235,3 +278,9 @@ extension AuthorizationViewController: GIDSignInDelegate {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension AuthorizationViewController: UITextViewDelegate {
|
||||
func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange) -> Bool {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,14 @@
|
|||
<outlet property="contentView" destination="mb9-vK-FLE" id="NNo-Na-BYT"/>
|
||||
<outlet property="facebookButtonHolder" destination="iK0-TH-4mm" id="FRM-L8-FLN"/>
|
||||
<outlet property="googleButton" destination="8iU-Se-s8N" id="rSq-jz-U5t"/>
|
||||
<outlet property="latestNewsCheck" destination="Z2X-Qq-dwV" id="8oR-t5-2oo"/>
|
||||
<outlet property="latestNewsTextView" destination="p04-D7-97V" id="AIZ-wF-v4D"/>
|
||||
<outlet property="privacyPolicyCheck" destination="33D-0u-y3N" id="kAN-wB-yUl"/>
|
||||
<outlet property="privacyPolicyTextView" destination="LhW-gs-XN9" id="HWt-AO-vvH"/>
|
||||
<outlet property="separator" destination="hWD-aE-jYh" id="myS-1z-Saw"/>
|
||||
<outlet property="tapView" destination="5kf-Pd-KAZ" id="QD3-Pa-zgR"/>
|
||||
<outlet property="termsOfUseCheck" destination="3cN-Qb-mdM" id="lk9-6H-kB5"/>
|
||||
<outlet property="termsOfUseTextView" destination="PBR-9l-2Gh" id="aBv-qx-F9h"/>
|
||||
<outlet property="textLabel" destination="0EA-1u-hvB" id="oDy-2V-Lrx"/>
|
||||
<outlet property="titleLabel" destination="LFT-Lb-6jj" id="uQG-BI-EAe"/>
|
||||
<outlet property="view" destination="iN0-l3-epB" id="6le-MR-NDK"/>
|
||||
|
@ -63,14 +69,14 @@
|
|||
<rect key="frame" x="32" y="59" width="311" height="55.5"/>
|
||||
<subviews>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="33D-0u-y3N">
|
||||
<rect key="frame" x="0.0" y="0.0" width="44" height="55.5"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="40" height="55.5"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="44" id="awT-NV-5En"/>
|
||||
<constraint firstAttribute="width" constant="40" id="awT-NV-5En"/>
|
||||
</constraints>
|
||||
<state key="normal" image="radioBtnOff"/>
|
||||
</button>
|
||||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" editable="NO" text="I agree to Privacy Policy" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="LhW-gs-XN9">
|
||||
<rect key="frame" x="52" y="10" width="251" height="35.5"/>
|
||||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" editable="NO" text="I agree to Privacy Policy" translatesAutoresizingMaskIntoConstraints="NO" id="LhW-gs-XN9">
|
||||
<rect key="frame" x="40" y="10" width="263" height="35.5"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<fontDescription key="fontDescription" name=".AppleSystemUIFont" family=".AppleSystemUIFont" pointSize="16"/>
|
||||
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
|
||||
|
@ -82,6 +88,9 @@
|
|||
<rect key="value" x="0.0" y="0.0" width="0.0" height="0.0"/>
|
||||
</userDefinedRuntimeAttribute>
|
||||
</userDefinedRuntimeAttributes>
|
||||
<connections>
|
||||
<outlet property="delegate" destination="-1" id="JGn-dX-5rs"/>
|
||||
</connections>
|
||||
</textView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
|
@ -92,21 +101,21 @@
|
|||
<constraint firstItem="LhW-gs-XN9" firstAttribute="top" secondItem="Cdf-p5-Bbb" secondAttribute="top" constant="10" id="mhL-Bd-ArP"/>
|
||||
<constraint firstAttribute="trailing" secondItem="LhW-gs-XN9" secondAttribute="trailing" constant="8" id="v1T-SO-6ll"/>
|
||||
<constraint firstAttribute="bottom" secondItem="LhW-gs-XN9" secondAttribute="bottom" constant="10" id="xgl-tw-klI"/>
|
||||
<constraint firstItem="LhW-gs-XN9" firstAttribute="leading" secondItem="33D-0u-y3N" secondAttribute="trailing" constant="8" id="yOg-UF-SwU"/>
|
||||
<constraint firstItem="LhW-gs-XN9" firstAttribute="leading" secondItem="33D-0u-y3N" secondAttribute="trailing" id="yOg-UF-SwU"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="XHd-bd-GsP">
|
||||
<rect key="frame" x="32" y="115" width="311" height="55.5"/>
|
||||
<subviews>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3cN-Qb-mdM">
|
||||
<rect key="frame" x="0.0" y="0.0" width="44" height="55.5"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="40" height="55.5"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="44" id="Gsk-Bp-DHv"/>
|
||||
<constraint firstAttribute="width" constant="40" id="Gsk-Bp-DHv"/>
|
||||
</constraints>
|
||||
<state key="normal" image="radioBtnOff"/>
|
||||
</button>
|
||||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" editable="NO" text="I agree to Terms of Use" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="PBR-9l-2Gh">
|
||||
<rect key="frame" x="52" y="10" width="251" height="35.5"/>
|
||||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" editable="NO" text="I agree to Terms of Use" translatesAutoresizingMaskIntoConstraints="NO" id="PBR-9l-2Gh">
|
||||
<rect key="frame" x="40" y="10" width="263" height="35.5"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<fontDescription key="fontDescription" name=".AppleSystemUIFont" family=".AppleSystemUIFont" pointSize="16"/>
|
||||
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
|
||||
|
@ -124,7 +133,7 @@
|
|||
<constraints>
|
||||
<constraint firstAttribute="bottom" secondItem="PBR-9l-2Gh" secondAttribute="bottom" constant="10" id="0VT-4u-6Fg"/>
|
||||
<constraint firstItem="PBR-9l-2Gh" firstAttribute="top" secondItem="XHd-bd-GsP" secondAttribute="top" constant="10" id="9eq-98-ygD"/>
|
||||
<constraint firstItem="PBR-9l-2Gh" firstAttribute="leading" secondItem="3cN-Qb-mdM" secondAttribute="trailing" constant="8" id="IfC-hN-RRh"/>
|
||||
<constraint firstItem="PBR-9l-2Gh" firstAttribute="leading" secondItem="3cN-Qb-mdM" secondAttribute="trailing" id="IfC-hN-RRh"/>
|
||||
<constraint firstItem="3cN-Qb-mdM" firstAttribute="leading" secondItem="XHd-bd-GsP" secondAttribute="leading" id="Z3C-FT-yqQ"/>
|
||||
<constraint firstItem="3cN-Qb-mdM" firstAttribute="top" secondItem="XHd-bd-GsP" secondAttribute="top" id="dkg-sP-6gL"/>
|
||||
<constraint firstAttribute="bottom" secondItem="3cN-Qb-mdM" secondAttribute="bottom" id="pRC-nx-yBP"/>
|
||||
|
@ -135,14 +144,14 @@
|
|||
<rect key="frame" x="32" y="170.5" width="311" height="55.5"/>
|
||||
<subviews>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Z2X-Qq-dwV">
|
||||
<rect key="frame" x="0.0" y="0.0" width="44" height="55.5"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="40" height="55.5"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="44" id="Ed8-DA-DiE"/>
|
||||
<constraint firstAttribute="width" constant="40" id="Ed8-DA-DiE"/>
|
||||
</constraints>
|
||||
<state key="normal" image="radioBtnOff"/>
|
||||
</button>
|
||||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" editable="NO" text="I agree to recieve latest news about our products" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="p04-D7-97V">
|
||||
<rect key="frame" x="52" y="10" width="251" height="35.5"/>
|
||||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" editable="NO" text="I agree to recieve latest news about our products" translatesAutoresizingMaskIntoConstraints="NO" id="p04-D7-97V">
|
||||
<rect key="frame" x="40" y="10" width="263" height="35.5"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<fontDescription key="fontDescription" name=".AppleSystemUIFont" family=".AppleSystemUIFont" pointSize="16"/>
|
||||
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
|
||||
|
@ -163,7 +172,7 @@
|
|||
<constraint firstAttribute="bottom" secondItem="Z2X-Qq-dwV" secondAttribute="bottom" id="HMC-MX-Gom"/>
|
||||
<constraint firstItem="Z2X-Qq-dwV" firstAttribute="top" secondItem="4NF-GO-a8Q" secondAttribute="top" id="d3x-dj-I9Q"/>
|
||||
<constraint firstItem="Z2X-Qq-dwV" firstAttribute="leading" secondItem="4NF-GO-a8Q" secondAttribute="leading" id="gTk-JI-cfK"/>
|
||||
<constraint firstItem="p04-D7-97V" firstAttribute="leading" secondItem="Z2X-Qq-dwV" secondAttribute="trailing" constant="8" id="jda-uN-kLq"/>
|
||||
<constraint firstItem="p04-D7-97V" firstAttribute="leading" secondItem="Z2X-Qq-dwV" secondAttribute="trailing" id="jda-uN-kLq"/>
|
||||
<constraint firstAttribute="trailing" secondItem="p04-D7-97V" secondAttribute="trailing" constant="8" id="u9Y-IJ-lA3"/>
|
||||
</constraints>
|
||||
</view>
|
||||
|
|
Loading…
Add table
Reference in a new issue