| 
						
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -1,5 +1,5 @@
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				//
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				//  Copyright (c) 2017 Open Whisper Systems. All rights reserved.
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				//  Copyright (c) 2018 Open Whisper Systems. All rights reserved.
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				//
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import Foundation
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -9,7 +9,7 @@ class ReminderView: UIView {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    let TAG = "[ReminderView]"
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    let label = UILabel()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    let defaultTapAction = {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    static let defaultTapAction = {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        Logger.debug("[ReminderView] tapped.")
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -25,30 +25,51 @@ class ReminderView: UIView {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    required init?(coder: NSCoder) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        self.tapAction = defaultTapAction
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        super.init(coder: coder)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    enum ReminderViewMode {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        // Nags are urgent interactive prompts, bidding for the user's attention.
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        case nag
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        // Explanations are not interactive or urgent.
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        case explanation
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    let mode: ReminderViewMode
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        setupSubviews()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    @available(*, unavailable, message:"use other constructor instead.")
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    required init?(coder aDecoder: NSCoder) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        fatalError("\(#function) is unimplemented.")
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    @available(*, unavailable, message:"use other constructor instead.")
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    override init(frame: CGRect) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        self.tapAction = defaultTapAction
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        fatalError("\(#function) is unimplemented.")
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        super.init(frame: frame)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    private init(mode: ReminderViewMode,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				         text: String, tapAction: @escaping () -> Void) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        self.mode = mode
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        self.tapAction = tapAction
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        super.init(frame: .zero)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        self.text = text
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        setupSubviews()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    convenience init(text: String, tapAction: @escaping () -> Void) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        self.init(frame: .zero)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        self.text = text
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        self.tapAction = tapAction
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    @objc public class func nag(text: String, tapAction: @escaping () -> Void) -> ReminderView {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        return ReminderView(mode: .nag, text: text, tapAction: tapAction)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    @objc public class func explanation(text: String) -> ReminderView {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        return ReminderView(mode: .explanation, text: text, tapAction: ReminderView.defaultTapAction)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    func setupSubviews() {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        self.backgroundColor = UIColor.ows_reminderYellow
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        switch (mode) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        case .nag:
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            self.backgroundColor = UIColor.ows_reminderYellow
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        case .explanation:
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            self.backgroundColor = UIColor(rgbHex: 0xf5f5f5)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        self.clipsToBounds = true
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTap(gestureRecognizer:)))
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -66,19 +87,25 @@ class ReminderView: UIView {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        label.numberOfLines = 0
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        label.lineBreakMode = .byWordWrapping
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        label.autoPinEdge(toSuperviewEdge: .top)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        label.autoPinEdge(toSuperviewEdge: .left)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        label.autoPinLeadingToSuperviewMargin()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        label.autoPinEdge(toSuperviewEdge: .bottom)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        label.textColor = UIColor.black.withAlphaComponent(0.9)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        guard mode == .nag else {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            label.autoPinTrailingToSuperviewMargin()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            return
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        // Icon
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        let iconImage = #imageLiteral(resourceName: "system_disclosure_indicator").withRenderingMode(.alwaysTemplate)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        let iconName = (self.isRTL() ? "system_disclosure_indicator_rtl" : "system_disclosure_indicator")
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        let iconImage = UIImage(named: iconName)?.withRenderingMode(.alwaysTemplate)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        let iconView = UIImageView(image: iconImage)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        iconView.contentMode = .scaleAspectFit
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        iconView.tintColor = UIColor.black.withAlphaComponent(0.6)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        container.addSubview(iconView)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        iconView.autoPinEdge(toSuperviewEdge: .right)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        iconView.autoPinEdge(.left, to: .right, of: label, withOffset: 28)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        iconView.autoPinLeading(toTrailingEdgeOf: label, offset: 28)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        iconView.autoPinTrailingToSuperviewMargin()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        iconView.autoVCenterInSuperview()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        iconView.autoSetDimension(.width, toSize: 13)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
			
			 | 
			 | 
			
				
 
 |