diff --git a/iphone/Maps/Categories/UIColor+MapsMeColor.h b/iphone/Maps/Categories/UIColor+MapsMeColor.h index ff816a1fa9..921d3127ca 100644 --- a/iphone/Maps/Categories/UIColor+MapsMeColor.h +++ b/iphone/Maps/Categories/UIColor+MapsMeColor.h @@ -55,5 +55,6 @@ + (BOOL)isNightMode; - (UIColor *)opposite; +- (UIColor *)colorByBlendingWithColor:(UIColor * _Nonnull)color; @end diff --git a/iphone/Maps/Categories/UIColor+MapsMeColor.mm b/iphone/Maps/Categories/UIColor+MapsMeColor.mm index c1ad4b73ac..ec8e5bfe3f 100644 --- a/iphone/Maps/Categories/UIColor+MapsMeColor.mm +++ b/iphone/Maps/Categories/UIColor+MapsMeColor.mm @@ -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 diff --git a/iphone/Maps/Classes/Components/Checkmark.swift b/iphone/Maps/Classes/Components/Checkmark.swift new file mode 100644 index 0000000000..7288f3917f --- /dev/null +++ b/iphone/Maps/Classes/Components/Checkmark.swift @@ -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 + } +} diff --git a/iphone/Maps/Maps.xcodeproj/project.pbxproj b/iphone/Maps/Maps.xcodeproj/project.pbxproj index 6fe581460c..b5df52e898 100644 --- a/iphone/Maps/Maps.xcodeproj/project.pbxproj +++ b/iphone/Maps/Maps.xcodeproj/project.pbxproj @@ -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 = ""; }; 46F26CD710F623BA00ECCA39 /* EAGLView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = EAGLView.mm; sourceTree = ""; }; 46F8A2EB10EB63040045521A /* MapViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = MapViewController.h; sourceTree = ""; }; + 4767CD9E20AAD48A00BD8166 /* Checkmark.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Checkmark.swift; sourceTree = ""; }; 4A00DBDE1AB704C400113624 /* drules_proto_dark.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; name = drules_proto_dark.bin; path = ../../data/drules_proto_dark.bin; sourceTree = ""; }; 4A23D1561B8B4DD700D4EB6F /* drules_proto_clear.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; name = drules_proto_clear.bin; path = ../../data/drules_proto_clear.bin; sourceTree = ""; }; 4A23D1571B8B4DD700D4EB6F /* resources-6plus_clear */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "resources-6plus_clear"; path = "../../data/resources-6plus_clear"; sourceTree = ""; }; @@ -2549,6 +2551,7 @@ 34C9BD011C6DB693000DC38D /* MWMViewController.mm */, 344BEAEF1F66BDC30045DC45 /* RatingSummaryView */, 348A8DF01F66775A00D83026 /* RatingView */, + 4767CD9E20AAD48A00BD8166 /* Checkmark.swift */, ); path = Components; sourceTree = ""; @@ -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 */, diff --git a/iphone/Maps/UI/Authorization/AuthorizationViewController.swift b/iphone/Maps/UI/Authorization/AuthorizationViewController.swift index f1543bb578..a3fff5589f 100644 --- a/iphone/Maps/UI/Authorization/AuthorizationViewController.swift +++ b/iphone/Maps/UI/Authorization/AuthorizationViewController.swift @@ -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; + } +} diff --git a/iphone/Maps/UI/Authorization/AuthorizationViewController.xib b/iphone/Maps/UI/Authorization/AuthorizationViewController.xib index 9fa31e0663..adbb7a48c9 100644 --- a/iphone/Maps/UI/Authorization/AuthorizationViewController.xib +++ b/iphone/Maps/UI/Authorization/AuthorizationViewController.xib @@ -14,8 +14,14 @@ + + + + + + @@ -63,14 +69,14 @@ - - + + @@ -82,6 +88,9 @@ + + + @@ -92,21 +101,21 @@ - + - - + + @@ -124,7 +133,7 @@ - + @@ -135,14 +144,14 @@ - - + + @@ -163,7 +172,7 @@ - +