IOS-1455 4 ui utils IOS-1455
authorXavier Algarra <xavier@pep-project.org>
Thu, 14 Feb 2019 17:58:10 +0100
branchIOS-1455
changeset 76919b002092dba3
parent 7645 79f8a270b713
child 7692 1a80f7c40643
IOS-1455 4 ui utils
pEpForiOS.xcodeproj/project.pbxproj
pEpForiOS/Base.lproj/AccountCreation.storyboard
pEpForiOS/UI/Util/Extensions/UIAlertController+Extension.swift
pEpForiOS/UI/Util/Extensions/UINavigationController+Extensions.swift
pEpForiOS/UI/Util/Extensions/UIView+Autolayout.swift
pEpForiOS/UI/Util/Extensions/UIView+Util.swift
pEpForiOS/UI/Util/Extensions/UIViewController+Extension.swift
pEpForiOS/UI/Util/UIAlertController+Extension.swift
pEpForiOS/UI/Util/UIViewController+Extension.swift
subModules/pEpIOSToolbox/pEpIOSToolbox.xcodeproj/project.pbxproj
subModules/pEpIOSToolbox/pEpIOSToolbox/UIKit/Collection+Extensions.swift
subModules/pEpIOSToolbox/pEpIOSToolbox/UIKit/UINavigationController+Extensions.swift
subModules/pEpIOSToolbox/pEpIOSToolbox/UIKit/UIView+Autolayout.swift
subModules/pEpIOSToolbox/pEpIOSToolbox/UIKit/UIView+Util.swift
     1.1 --- a/pEpForiOS.xcodeproj/project.pbxproj	Wed Feb 13 18:25:26 2019 +0100
     1.2 +++ b/pEpForiOS.xcodeproj/project.pbxproj	Thu Feb 14 17:58:10 2019 +0100
     1.3 @@ -538,6 +538,9 @@
     1.4  		B78CF82B1E76E146008C1739 /* FilterCellViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B78CF82A1E76E146008C1739 /* FilterCellViewModel.swift */; };
     1.5  		B7D1EEC81E8BEC8D00F190E3 /* CollapsibleTableViewHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7D1EEC71E8BEC8D00F190E3 /* CollapsibleTableViewHeader.swift */; };
     1.6  		B7DB7FB522148585003968DA /* SecretUITestData.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7DB7FB422148585003968DA /* SecretUITestData.swift */; };
     1.7 +		B7DB7FC42215C4FF003968DA /* UINavigationController+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7DB7FC32215C4FF003968DA /* UINavigationController+Extensions.swift */; };
     1.8 +		B7DB7FC72215C57F003968DA /* UIView+Autolayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7DB7FC52215C57F003968DA /* UIView+Autolayout.swift */; };
     1.9 +		B7DB7FC82215C57F003968DA /* UIView+Util.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7DB7FC62215C57F003968DA /* UIView+Util.swift */; };
    1.10  		B7F4A793212DDFC500507B76 /* EmailListViewModelTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7F4A792212DDFC500507B76 /* EmailListViewModelTest.swift */; };
    1.11  		F73E4F72217F238300CCFFED /* FolderSectionViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F73E4F71217F238300CCFFED /* FolderSectionViewModelTests.swift */; };
    1.12  		F73E4F7A2180744700CCFFED /* FolderCellViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F73E4F792180744700CCFFED /* FolderCellViewModelTests.swift */; };
    1.13 @@ -1150,6 +1153,9 @@
    1.14  		B7911EC321F86D7900D7F66F /* pEpUtilities.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = pEpUtilities.framework; sourceTree = BUILT_PRODUCTS_DIR; };
    1.15  		B7D1EEC71E8BEC8D00F190E3 /* CollapsibleTableViewHeader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CollapsibleTableViewHeader.swift; path = Folder/CollapsibleTableViewHeader.swift; sourceTree = "<group>"; };
    1.16  		B7DB7FB422148585003968DA /* SecretUITestData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecretUITestData.swift; sourceTree = "<group>"; };
    1.17 +		B7DB7FC32215C4FF003968DA /* UINavigationController+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UINavigationController+Extensions.swift"; sourceTree = "<group>"; };
    1.18 +		B7DB7FC52215C57F003968DA /* UIView+Autolayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+Autolayout.swift"; sourceTree = "<group>"; };
    1.19 +		B7DB7FC62215C57F003968DA /* UIView+Util.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+Util.swift"; sourceTree = "<group>"; };
    1.20  		B7F4A792212DDFC500507B76 /* EmailListViewModelTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EmailListViewModelTest.swift; sourceTree = "<group>"; };
    1.21  		F73E4F71217F238300CCFFED /* FolderSectionViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FolderSectionViewModelTests.swift; sourceTree = "<group>"; };
    1.22  		F73E4F792180744700CCFFED /* FolderCellViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FolderCellViewModelTests.swift; sourceTree = "<group>"; };
    1.23 @@ -2295,13 +2301,12 @@
    1.24  		43AA82511E9B925000ABD5A8 /* Util */ = {
    1.25  			isa = PBXGroup;
    1.26  			children = (
    1.27 +				B7DB7FC22215C484003968DA /* Extensions */,
    1.28  				15D43998216E695500EB3933 /* AccountPicker */,
    1.29  				15265973216234C0006A78DF /* SuggestTableViewController */,
    1.30  				150DF6D12052A99800A9DCF7 /* SecureWebViewController */,
    1.31  				43AAC2281F7A5AED00F435F4 /* BaseTableViewController.swift */,
    1.32  				43AAC2291F7A5AEE00F435F4 /* BaseViewController.swift */,
    1.33 -				43293EFA1EB9DD6700EEE010 /* UIViewController+Extension.swift */,
    1.34 -				434AC3E220A450D700C11B7F /* UIAlertController+Extension.swift */,
    1.35  				43C322081EA90192005073FB /* PEP+UI.swift */,
    1.36  				4330278D1F7BABFF00D685F8 /* GradientView.swift */,
    1.37  				15B2204F1FBF5D6E00CA52BA /* InfoPlist.swift */,
    1.38 @@ -2826,6 +2831,18 @@
    1.39  			name = ViewModel;
    1.40  			sourceTree = "<group>";
    1.41  		};
    1.42 +		B7DB7FC22215C484003968DA /* Extensions */ = {
    1.43 +			isa = PBXGroup;
    1.44 +			children = (
    1.45 +				B7DB7FC62215C57F003968DA /* UIView+Util.swift */,
    1.46 +				B7DB7FC52215C57F003968DA /* UIView+Autolayout.swift */,
    1.47 +				B7DB7FC32215C4FF003968DA /* UINavigationController+Extensions.swift */,
    1.48 +				43293EFA1EB9DD6700EEE010 /* UIViewController+Extension.swift */,
    1.49 +				434AC3E220A450D700C11B7F /* UIAlertController+Extension.swift */,
    1.50 +			);
    1.51 +			path = Extensions;
    1.52 +			sourceTree = "<group>";
    1.53 +		};
    1.54  		F73E4F7B2180746400CCFFED /* Folder */ = {
    1.55  			isa = PBXGroup;
    1.56  			children = (
    1.57 @@ -3350,8 +3367,10 @@
    1.58  				15874BCC2127493E00A3A4A6 /* AccountSettingsViewModel.swift in Sources */,
    1.59  				436C232F1E02A52D00071430 /* LimitedOperationQueue.swift in Sources */,
    1.60  				434F40941EB0B173002FBF0D /* ObservableValue.swift in Sources */,
    1.61 +				B7DB7FC42215C4FF003968DA /* UINavigationController+Extensions.swift in Sources */,
    1.62  				15F0F7AD213594FC002BE853 /* Folder+Imap.swift in Sources */,
    1.63  				430D73651E9CBD4E00EA6FA9 /* AttachmentsViewOperation.swift in Sources */,
    1.64 +				B7DB7FC82215C57F003968DA /* UIView+Util.swift in Sources */,
    1.65  				495F607C20B564CD00F47BD6 /* EmailViewController+SizeClasses.swift in Sources */,
    1.66  				43313DFC1DEC7F6000C111C8 /* DeleteFoldersOperation.swift in Sources */,
    1.67  				152A39CC21905C3E00D9F8E4 /* MediaAttachmentPickerProvider.swift in Sources */,
    1.68 @@ -3479,6 +3498,7 @@
    1.69  				B722EC4D1E5B01B300A2B9D5 /* FolderCellViewModel.swift in Sources */,
    1.70  				15874BCF2127493E00A3A4A6 /* AccountSettingsTableViewController.swift in Sources */,
    1.71  				43122B3E1DF5BB6600610253 /* MySelfOperation.swift in Sources */,
    1.72 +				B7DB7FC72215C57F003968DA /* UIView+Autolayout.swift in Sources */,
    1.73  				15547572213FEC4B005A52D0 /* CdMessagePredicateFactory+Extension.swift in Sources */,
    1.74  				B71EBBBC1E55E4AE00150177 /* FolderTableViewController.swift in Sources */,
    1.75  				492EF92F20C699D0004EAE14 /* ThreadViewController+TableView.swift in Sources */,
     2.1 --- a/pEpForiOS/Base.lproj/AccountCreation.storyboard	Wed Feb 13 18:25:26 2019 +0100
     2.2 +++ b/pEpForiOS/Base.lproj/AccountCreation.storyboard	Thu Feb 14 17:58:10 2019 +0100
     2.3 @@ -566,7 +566,7 @@
     2.4                                              <view contentMode="scaleToFill" horizontalCompressionResistancePriority="749" verticalCompressionResistancePriority="749" translatesAutoresizingMaskIntoConstraints="NO" id="7IS-Mp-8VB">
     2.5                                                  <rect key="frame" x="243" y="153" width="250" height="152"/>
     2.6                                                  <subviews>
     2.7 -                                                    <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="line" placeholder="Username" textAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="mKi-gF-bu9" customClass="CredentialTextField" customModule="pEpUtilities">
     2.8 +                                                    <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="line" placeholder="Username" textAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="mKi-gF-bu9" customClass="CredentialTextField" customModule="pEpIOSToolbox">
     2.9                                                          <rect key="frame" x="0.0" y="0.0" width="250" height="28"/>
    2.10                                                          <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
    2.11                                                          <accessibility key="accessibilityConfiguration" identifier="username"/>
    2.12 @@ -591,7 +591,7 @@
    2.13                                                              </userDefinedRuntimeAttribute>
    2.14                                                          </userDefinedRuntimeAttributes>
    2.15                                                      </textField>
    2.16 -                                                    <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="line" placeholder="Email Address" textAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="36s-Iw-b58" customClass="CredentialTextField" customModule="pEpUtilities">
    2.17 +                                                    <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="line" placeholder="Email Address" textAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="36s-Iw-b58" customClass="CredentialTextField" customModule="pEpIOSToolbox">
    2.18                                                          <rect key="frame" x="0.0" y="62" width="250" height="28"/>
    2.19                                                          <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
    2.20                                                          <accessibility key="accessibilityConfiguration" identifier="email"/>
    2.21 @@ -616,7 +616,7 @@
    2.22                                                              <action selector="emailChanged:" destination="clh-8B-z2B" eventType="editingChanged" id="hsV-YG-JFW"/>
    2.23                                                          </connections>
    2.24                                                      </textField>
    2.25 -                                                    <textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="line" placeholder="Password" textAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="3wB-RC-5fz" customClass="CredentialTextField" customModule="pEpUtilities">
    2.26 +                                                    <textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="line" placeholder="Password" textAlignment="center" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="3wB-RC-5fz" customClass="CredentialTextField" customModule="pEpIOSToolbox">
    2.27                                                          <rect key="frame" x="0.0" y="124" width="250" height="28"/>
    2.28                                                          <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
    2.29                                                          <accessibility key="accessibilityConfiguration" identifier="password"/>
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/pEpForiOS/UI/Util/Extensions/UIAlertController+Extension.swift	Thu Feb 14 17:58:10 2019 +0100
     3.3 @@ -0,0 +1,33 @@
     3.4 +//
     3.5 +//  UIAlertController+Extension.swift
     3.6 +//  pEp
     3.7 +//
     3.8 +//  Created by Dirk Zimmermann on 10.05.18.
     3.9 +//  Copyright © 2018 p≡p Security S.A. All rights reserved.
    3.10 +//
    3.11 +
    3.12 +import Foundation
    3.13 +
    3.14 +import MessageModel
    3.15 +
    3.16 +extension UIAlertController {
    3.17 +    public func action(_ title: String,
    3.18 +                       _ style: UIAlertActionStyle = .default,
    3.19 +                       _ closure: Tasks.simple? = nil) ->  UIAlertAction {
    3.20 +        return UIAlertAction(title: title, style: style) { (action) in
    3.21 +            if let clos = closure {
    3.22 +                clos()
    3.23 +            }
    3.24 +        }
    3.25 +    }
    3.26 +
    3.27 +    public static func pEpAlertController(
    3.28 +        title: String? = nil,
    3.29 +        message: String? = nil,
    3.30 +        preferredStyle: UIAlertControllerStyle = .actionSheet) -> UIAlertController {
    3.31 +        let alertCtrl = UIAlertController(title: title, message: message,
    3.32 +                                          preferredStyle: preferredStyle)
    3.33 +        alertCtrl.view.tintColor = .pEpGreen
    3.34 +        return alertCtrl
    3.35 +    }
    3.36 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/pEpForiOS/UI/Util/Extensions/UINavigationController+Extensions.swift	Thu Feb 14 17:58:10 2019 +0100
     4.3 @@ -0,0 +1,15 @@
     4.4 +//
     4.5 +//  UINavigationController+Extensions.swift
     4.6 +//  pEpForiOS
     4.7 +//
     4.8 +//  Created by Andreas Buff on 23.08.17.
     4.9 +//  Copyright © 2017 p≡p Security S.A. All rights reserved.
    4.10 +//
    4.11 +
    4.12 +import UIKit
    4.13 +
    4.14 +extension UINavigationController {
    4.15 +    public var rootViewController : UIViewController? {
    4.16 +        return viewControllers.first
    4.17 +    }
    4.18 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/pEpForiOS/UI/Util/Extensions/UIView+Autolayout.swift	Thu Feb 14 17:58:10 2019 +0100
     5.3 @@ -0,0 +1,31 @@
     5.4 +//
     5.5 +//  UIView+Autolayout.swift
     5.6 +//  pEp
     5.7 +//
     5.8 +//  Created by Andreas Buff on 09.03.18.
     5.9 +//  Copyright © 2018 p≡p Security S.A. All rights reserved.
    5.10 +//
    5.11 +
    5.12 +import UIKit
    5.13 +
    5.14 +extension UIView {
    5.15 +    /// Sets up constraints to always stay the same size as the superview.
    5.16 +    public func fullSizeInSuperView() {
    5.17 +        guard let superview = self.superview else {
    5.18 +            Logger.frontendLogger.errorAndCrash("No superview")
    5.19 +            return
    5.20 +        }
    5.21 +
    5.22 +        self.translatesAutoresizingMaskIntoConstraints = false
    5.23 +        superview.addConstraints(NSLayoutConstraint.constraints(
    5.24 +            withVisualFormat: "H:|-0-[subview]-0-|",
    5.25 +            options: .directionLeadingToTrailing,
    5.26 +            metrics: nil,
    5.27 +            views: ["subview": self]))
    5.28 +        superview.addConstraints(NSLayoutConstraint.constraints(
    5.29 +            withVisualFormat: "V:|-0-[subview]-0-|",
    5.30 +            options: .directionLeadingToTrailing,
    5.31 +            metrics: nil,
    5.32 +            views: ["subview": self]))
    5.33 +    }
    5.34 +}
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/pEpForiOS/UI/Util/Extensions/UIView+Util.swift	Thu Feb 14 17:58:10 2019 +0100
     6.3 @@ -0,0 +1,61 @@
     6.4 +//
     6.5 +//  UIView+Util.swift
     6.6 +//  pEpForiOS
     6.7 +//
     6.8 +//  Created by Dirk Zimmermann on 10.04.17.
     6.9 +//  Copyright © 2017 p≡p Security S.A. All rights reserved.
    6.10 +//
    6.11 +
    6.12 +import UIKit
    6.13 +
    6.14 +/**
    6.15 + A piece of data for tracking the "busyness" of a view.
    6.16 + */
    6.17 +public struct ViewBusyState {
    6.18 +    let views: [UIView]
    6.19 +}
    6.20 +
    6.21 +extension UIView {
    6.22 +    func dumpConstraints(axis: NSLayoutConstraint.Axis) {
    6.23 +        let constrs = constraintsAffectingLayout(for: axis)
    6.24 +        if constrs.isEmpty {
    6.25 +            print("no constraints")
    6.26 +        }
    6.27 +        for con in constrs {
    6.28 +            print("\(con)")
    6.29 +        }
    6.30 +    }
    6.31 +
    6.32 +    /**
    6.33 +     Marks the view as busy, e.g. by adding some spinning animation view.
    6.34 +     */
    6.35 +    public func displayAsBusy() -> ViewBusyState {
    6.36 +        let darkView = UIView()
    6.37 +        darkView.translatesAutoresizingMaskIntoConstraints = false
    6.38 +        darkView.backgroundColor = .black
    6.39 +        darkView.alpha = 0.5
    6.40 +        addSubview(darkView)
    6.41 +        darkView.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true
    6.42 +        darkView.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
    6.43 +        darkView.widthAnchor.constraint(equalTo: widthAnchor).isActive = true
    6.44 +        darkView.heightAnchor.constraint(equalTo: heightAnchor).isActive = true
    6.45 +
    6.46 +        let activityView = UIActivityIndicatorView()
    6.47 +        activityView.style = .whiteLarge
    6.48 +        activityView.translatesAutoresizingMaskIntoConstraints = false
    6.49 +        darkView.addSubview(activityView)
    6.50 +        activityView.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true
    6.51 +        activityView.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
    6.52 +        activityView.startAnimating()
    6.53 +        return ViewBusyState(views: [darkView])
    6.54 +    }
    6.55 +
    6.56 +    /**
    6.57 +     Marks the given view as not busy anymore.
    6.58 +     */
    6.59 +    public func stopDisplayingAsBusy(viewBusyState: ViewBusyState) {
    6.60 +        for v in viewBusyState.views {
    6.61 +            v.removeFromSuperview()
    6.62 +        }
    6.63 +    }
    6.64 +}
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/pEpForiOS/UI/Util/Extensions/UIViewController+Extension.swift	Thu Feb 14 17:58:10 2019 +0100
     7.3 @@ -0,0 +1,42 @@
     7.4 +//
     7.5 +//  UIViewController+Extension.swift
     7.6 +//  pEpForiOS
     7.7 +//
     7.8 +//  Created by Dirk Zimmermann on 17/02/2017.
     7.9 +//  Copyright © 2017 p≡p Security S.A. All rights reserved.
    7.10 +//
    7.11 +
    7.12 +import Foundation
    7.13 +import UIKit
    7.14 +
    7.15 +extension UIViewController {
    7.16 +    var isModalViewCurrentlyShown: Bool {
    7.17 +        return presentedViewController != nil
    7.18 +    }
    7.19 +
    7.20 +    @discardableResult func showPepRating(pEpRating: PEP_rating?, pEpProtection: Bool = true) -> UIView? {
    7.21 +        if let img = pEpRating?.pEpColor().statusIcon(enabled: pEpProtection) {
    7.22 +            // according to apple's design guidelines ('Hit Targets'):
    7.23 +            // https://developer.apple.com/design/tips/
    7.24 +            let minimumHittestDimension: CGFloat = 44
    7.25 +
    7.26 +            let minimumImageWidth = max(minimumHittestDimension / 2, img.size.width)
    7.27 +            let img2 = img.resized(newWidth: minimumImageWidth)
    7.28 +            let v = UIImageView(image: img2)
    7.29 +            v.contentMode = .center // DON'T stretch the image, leave it at original size
    7.30 +
    7.31 +            // try to make the hit area of the icon a minimum of 44x44
    7.32 +            let desiredHittestDimension: CGFloat = min(
    7.33 +                minimumHittestDimension,
    7.34 +                navigationController?.navigationBar.frame.size.height ?? minimumHittestDimension)
    7.35 +            v.bounds.size = CGSize(width: desiredHittestDimension, height: desiredHittestDimension)
    7.36 +
    7.37 +            navigationItem.titleView = v
    7.38 +            v.isUserInteractionEnabled = true
    7.39 +            return v
    7.40 +        } else {
    7.41 +            navigationItem.titleView = nil
    7.42 +            return nil
    7.43 +        }
    7.44 +    }
    7.45 +}
     8.1 --- a/pEpForiOS/UI/Util/UIAlertController+Extension.swift	Wed Feb 13 18:25:26 2019 +0100
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,33 +0,0 @@
     8.4 -//
     8.5 -//  UIAlertController+Extension.swift
     8.6 -//  pEp
     8.7 -//
     8.8 -//  Created by Dirk Zimmermann on 10.05.18.
     8.9 -//  Copyright © 2018 p≡p Security S.A. All rights reserved.
    8.10 -//
    8.11 -
    8.12 -import Foundation
    8.13 -
    8.14 -import MessageModel
    8.15 -
    8.16 -extension UIAlertController {
    8.17 -    public func action(_ title: String,
    8.18 -                       _ style: UIAlertActionStyle = .default,
    8.19 -                       _ closure: Tasks.simple? = nil) ->  UIAlertAction {
    8.20 -        return UIAlertAction(title: title, style: style) { (action) in
    8.21 -            if let clos = closure {
    8.22 -                clos()
    8.23 -            }
    8.24 -        }
    8.25 -    }
    8.26 -
    8.27 -    public static func pEpAlertController(
    8.28 -        title: String? = nil,
    8.29 -        message: String? = nil,
    8.30 -        preferredStyle: UIAlertControllerStyle = .actionSheet) -> UIAlertController {
    8.31 -        let alertCtrl = UIAlertController(title: title, message: message,
    8.32 -                                          preferredStyle: preferredStyle)
    8.33 -        alertCtrl.view.tintColor = .pEpGreen
    8.34 -        return alertCtrl
    8.35 -    }
    8.36 -}
     9.1 --- a/pEpForiOS/UI/Util/UIViewController+Extension.swift	Wed Feb 13 18:25:26 2019 +0100
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,42 +0,0 @@
     9.4 -//
     9.5 -//  UIViewController+Extension.swift
     9.6 -//  pEpForiOS
     9.7 -//
     9.8 -//  Created by Dirk Zimmermann on 17/02/2017.
     9.9 -//  Copyright © 2017 p≡p Security S.A. All rights reserved.
    9.10 -//
    9.11 -
    9.12 -import Foundation
    9.13 -import UIKit
    9.14 -
    9.15 -extension UIViewController {
    9.16 -    var isModalViewCurrentlyShown: Bool {
    9.17 -        return presentedViewController != nil
    9.18 -    }
    9.19 -
    9.20 -    @discardableResult func showPepRating(pEpRating: PEP_rating?, pEpProtection: Bool = true) -> UIView? {
    9.21 -        if let img = pEpRating?.pEpColor().statusIcon(enabled: pEpProtection) {
    9.22 -            // according to apple's design guidelines ('Hit Targets'):
    9.23 -            // https://developer.apple.com/design/tips/
    9.24 -            let minimumHittestDimension: CGFloat = 44
    9.25 -
    9.26 -            let minimumImageWidth = max(minimumHittestDimension / 2, img.size.width)
    9.27 -            let img2 = img.resized(newWidth: minimumImageWidth)
    9.28 -            let v = UIImageView(image: img2)
    9.29 -            v.contentMode = .center // DON'T stretch the image, leave it at original size
    9.30 -
    9.31 -            // try to make the hit area of the icon a minimum of 44x44
    9.32 -            let desiredHittestDimension: CGFloat = min(
    9.33 -                minimumHittestDimension,
    9.34 -                navigationController?.navigationBar.frame.size.height ?? minimumHittestDimension)
    9.35 -            v.bounds.size = CGSize(width: desiredHittestDimension, height: desiredHittestDimension)
    9.36 -
    9.37 -            navigationItem.titleView = v
    9.38 -            v.isUserInteractionEnabled = true
    9.39 -            return v
    9.40 -        } else {
    9.41 -            navigationItem.titleView = nil
    9.42 -            return nil
    9.43 -        }
    9.44 -    }
    9.45 -}
    10.1 --- a/subModules/pEpIOSToolbox/pEpIOSToolbox.xcodeproj/project.pbxproj	Wed Feb 13 18:25:26 2019 +0100
    10.2 +++ b/subModules/pEpIOSToolbox/pEpIOSToolbox.xcodeproj/project.pbxproj	Thu Feb 14 17:58:10 2019 +0100
    10.3 @@ -23,9 +23,6 @@
    10.4  		B7465DE72211E969008A1708 /* CGRect+Util.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7465DE62211E969008A1708 /* CGRect+Util.swift */; };
    10.5  		B7465DE92212CCDB008A1708 /* UIButton+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7465DE82212CCDB008A1708 /* UIButton+Extension.swift */; };
    10.6  		B753907E2212D6B500B1FCF9 /* CGSize+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = B753907D2212D6B500B1FCF9 /* CGSize+Extension.swift */; };
    10.7 -		B75390802212DD0600B1FCF9 /* UIView+Util.swift in Sources */ = {isa = PBXBuildFile; fileRef = B753907F2212DD0600B1FCF9 /* UIView+Util.swift */; };
    10.8 -		B75390822212DFB600B1FCF9 /* UINavigationController+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = B75390812212DFB500B1FCF9 /* UINavigationController+Extensions.swift */; };
    10.9 -		B75390842212DFD800B1FCF9 /* UIView+Autolayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = B75390832212DFD800B1FCF9 /* UIView+Autolayout.swift */; };
   10.10  		B75390862212E20500B1FCF9 /* Collection+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = B75390852212E20500B1FCF9 /* Collection+Extensions.swift */; };
   10.11  		B7911EC221F8694100D7F66F /* UIColor+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7911EC121F8694000D7F66F /* UIColor+Extension.swift */; };
   10.12  		B7911EC621F88AF800D7F66F /* UIImage+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7911EC521F88AF800D7F66F /* UIImage+Extension.swift */; };
   10.13 @@ -74,9 +71,6 @@
   10.14  		B7465DE62211E969008A1708 /* CGRect+Util.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CGRect+Util.swift"; sourceTree = "<group>"; };
   10.15  		B7465DE82212CCDB008A1708 /* UIButton+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIButton+Extension.swift"; sourceTree = "<group>"; };
   10.16  		B753907D2212D6B500B1FCF9 /* CGSize+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CGSize+Extension.swift"; sourceTree = "<group>"; };
   10.17 -		B753907F2212DD0600B1FCF9 /* UIView+Util.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+Util.swift"; sourceTree = "<group>"; };
   10.18 -		B75390812212DFB500B1FCF9 /* UINavigationController+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UINavigationController+Extensions.swift"; sourceTree = "<group>"; };
   10.19 -		B75390832212DFD800B1FCF9 /* UIView+Autolayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+Autolayout.swift"; sourceTree = "<group>"; };
   10.20  		B75390852212E20500B1FCF9 /* Collection+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Collection+Extensions.swift"; sourceTree = "<group>"; };
   10.21  		B7911EB421F7358500D7F66F /* pEpIOSToolbox.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = pEpIOSToolbox.framework; sourceTree = BUILT_PRODUCTS_DIR; };
   10.22  		B7911EB821F7358500D7F66F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
   10.23 @@ -160,9 +154,6 @@
   10.24  				B7465DDE2211C6C8008A1708 /* UIBarButtonItem+Extension.swift */,
   10.25  				B7465DE02211C6E9008A1708 /* UIImage+GIF.swift */,
   10.26  				B7465DE42211E08A008A1708 /* UIImageView+Extension.swift */,
   10.27 -				B753907F2212DD0600B1FCF9 /* UIView+Util.swift */,
   10.28 -				B75390832212DFD800B1FCF9 /* UIView+Autolayout.swift */,
   10.29 -				B75390812212DFB500B1FCF9 /* UINavigationController+Extensions.swift */,
   10.30  				B75390852212E20500B1FCF9 /* Collection+Extensions.swift */,
   10.31  			);
   10.32  			path = UIKit;
   10.33 @@ -335,12 +326,10 @@
   10.34  				B70A3A7322006B9F00EDCE61 /* SystemUtils.swift in Sources */,
   10.35  				B7465DDF2211C6C8008A1708 /* UIBarButtonItem+Extension.swift in Sources */,
   10.36  				B7936E3D220DD8F5003B39E6 /* NSAttributedString+Extensions.swift in Sources */,
   10.37 -				B75390842212DFD800B1FCF9 /* UIView+Autolayout.swift in Sources */,
   10.38  				B75390862212E20500B1FCF9 /* Collection+Extensions.swift in Sources */,
   10.39  				B7465DE92212CCDB008A1708 /* UIButton+Extension.swift in Sources */,
   10.40  				B7911EC221F8694100D7F66F /* UIColor+Extension.swift in Sources */,
   10.41  				B753907E2212D6B500B1FCF9 /* CGSize+Extension.swift in Sources */,
   10.42 -				B75390802212DD0600B1FCF9 /* UIView+Util.swift in Sources */,
   10.43  				B7DB7F522213120B003968DA /* SortedSet.swift in Sources */,
   10.44  				B7911EC621F88AF800D7F66F /* UIImage+Extension.swift in Sources */,
   10.45  				B70A3A77220091D400EDCE61 /* Logger.swift in Sources */,
   10.46 @@ -352,7 +341,6 @@
   10.47  				B7DB7F5022130DE9003968DA /* Weak.swift in Sources */,
   10.48  				B7A46C52220C732E0027CCB5 /* Data+Extensions.swift in Sources */,
   10.49  				B7465DC82211A062008A1708 /* SegueHandlerType.swift in Sources */,
   10.50 -				B75390822212DFB600B1FCF9 /* UINavigationController+Extensions.swift in Sources */,
   10.51  				B7465DCA2211BB3C008A1708 /* CredentialTextField.swift in Sources */,
   10.52  				B7465DE32211C890008A1708 /* CGImageSource+Extension.swift in Sources */,
   10.53  				B7465DE12211C6E9008A1708 /* UIImage+GIF.swift in Sources */,
    11.1 --- a/subModules/pEpIOSToolbox/pEpIOSToolbox/UIKit/Collection+Extensions.swift	Wed Feb 13 18:25:26 2019 +0100
    11.2 +++ b/subModules/pEpIOSToolbox/pEpIOSToolbox/UIKit/Collection+Extensions.swift	Thu Feb 14 17:58:10 2019 +0100
    11.3 @@ -6,7 +6,7 @@
    11.4  //  Copyright © 2016 pEp Security S.A. All rights reserved.
    11.5  //
    11.6  
    11.7 -import UIKit
    11.8 +//import UIKit
    11.9  
   11.10  extension Collection {
   11.11      /*
    12.1 --- a/subModules/pEpIOSToolbox/pEpIOSToolbox/UIKit/UINavigationController+Extensions.swift	Wed Feb 13 18:25:26 2019 +0100
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,15 +0,0 @@
    12.4 -//
    12.5 -//  UINavigationController+Extensions.swift
    12.6 -//  pEpForiOS
    12.7 -//
    12.8 -//  Created by Andreas Buff on 23.08.17.
    12.9 -//  Copyright © 2017 p≡p Security S.A. All rights reserved.
   12.10 -//
   12.11 -
   12.12 -import UIKit
   12.13 -
   12.14 -extension UINavigationController {
   12.15 -    public var rootViewController : UIViewController? {
   12.16 -        return viewControllers.first
   12.17 -    }
   12.18 -}
    13.1 --- a/subModules/pEpIOSToolbox/pEpIOSToolbox/UIKit/UIView+Autolayout.swift	Wed Feb 13 18:25:26 2019 +0100
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,31 +0,0 @@
    13.4 -//
    13.5 -//  UIView+Autolayout.swift
    13.6 -//  pEp
    13.7 -//
    13.8 -//  Created by Andreas Buff on 09.03.18.
    13.9 -//  Copyright © 2018 p≡p Security S.A. All rights reserved.
   13.10 -//
   13.11 -
   13.12 -import UIKit
   13.13 -
   13.14 -extension UIView {
   13.15 -    /// Sets up constraints to always stay the same size as the superview.
   13.16 -    public func fullSizeInSuperView() {
   13.17 -        guard let superview = self.superview else {
   13.18 -            Logger.frontendLogger.errorAndCrash("No superview")
   13.19 -            return
   13.20 -        }
   13.21 -
   13.22 -        self.translatesAutoresizingMaskIntoConstraints = false
   13.23 -        superview.addConstraints(NSLayoutConstraint.constraints(
   13.24 -            withVisualFormat: "H:|-0-[subview]-0-|",
   13.25 -            options: .directionLeadingToTrailing,
   13.26 -            metrics: nil,
   13.27 -            views: ["subview": self]))
   13.28 -        superview.addConstraints(NSLayoutConstraint.constraints(
   13.29 -            withVisualFormat: "V:|-0-[subview]-0-|",
   13.30 -            options: .directionLeadingToTrailing,
   13.31 -            metrics: nil,
   13.32 -            views: ["subview": self]))
   13.33 -    }
   13.34 -}
    14.1 --- a/subModules/pEpIOSToolbox/pEpIOSToolbox/UIKit/UIView+Util.swift	Wed Feb 13 18:25:26 2019 +0100
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,61 +0,0 @@
    14.4 -//
    14.5 -//  UIView+Util.swift
    14.6 -//  pEpForiOS
    14.7 -//
    14.8 -//  Created by Dirk Zimmermann on 10.04.17.
    14.9 -//  Copyright © 2017 p≡p Security S.A. All rights reserved.
   14.10 -//
   14.11 -
   14.12 -import UIKit
   14.13 -
   14.14 -/**
   14.15 - A piece of data for tracking the "busyness" of a view.
   14.16 - */
   14.17 -public struct ViewBusyState {
   14.18 -    let views: [UIView]
   14.19 -}
   14.20 -
   14.21 -extension UIView {
   14.22 -    func dumpConstraints(axis: NSLayoutConstraint.Axis) {
   14.23 -        let constrs = constraintsAffectingLayout(for: axis)
   14.24 -        if constrs.isEmpty {
   14.25 -            print("no constraints")
   14.26 -        }
   14.27 -        for con in constrs {
   14.28 -            print("\(con)")
   14.29 -        }
   14.30 -    }
   14.31 -
   14.32 -    /**
   14.33 -     Marks the view as busy, e.g. by adding some spinning animation view.
   14.34 -     */
   14.35 -    public func displayAsBusy() -> ViewBusyState {
   14.36 -        let darkView = UIView()
   14.37 -        darkView.translatesAutoresizingMaskIntoConstraints = false
   14.38 -        darkView.backgroundColor = .black
   14.39 -        darkView.alpha = 0.5
   14.40 -        addSubview(darkView)
   14.41 -        darkView.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true
   14.42 -        darkView.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
   14.43 -        darkView.widthAnchor.constraint(equalTo: widthAnchor).isActive = true
   14.44 -        darkView.heightAnchor.constraint(equalTo: heightAnchor).isActive = true
   14.45 -
   14.46 -        let activityView = UIActivityIndicatorView()
   14.47 -        activityView.style = .whiteLarge
   14.48 -        activityView.translatesAutoresizingMaskIntoConstraints = false
   14.49 -        darkView.addSubview(activityView)
   14.50 -        activityView.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true
   14.51 -        activityView.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
   14.52 -        activityView.startAnimating()
   14.53 -        return ViewBusyState(views: [darkView])
   14.54 -    }
   14.55 -
   14.56 -    /**
   14.57 -     Marks the given view as not busy anymore.
   14.58 -     */
   14.59 -    public func stopDisplayingAsBusy(viewBusyState: ViewBusyState) {
   14.60 -        for v in viewBusyState.views {
   14.61 -            v.removeFromSuperview()
   14.62 -        }
   14.63 -    }
   14.64 -}