Browse Source

Fix font size inconsistencies

Signed-off-by: Henrik Storch <henrik.storch@nextcloud.com>
Henrik Storch 3 years ago
parent
commit
5f49f27e61

+ 11 - 12
iOSClient/Notification/NCNotification.storyboard

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="c26-Us-IIn">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19455" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="c26-Us-IIn">
     <device id="retina4_7" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19454"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <scenes>
@@ -17,7 +17,7 @@
                         <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                         <prototypes>
                             <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" rowHeight="187" id="R1c-h5-BOp" customClass="NCNotificationCell" customModule="Nextcloud" customModuleProvider="target">
-                                <rect key="frame" x="0.0" y="28" width="375" height="187"/>
+                                <rect key="frame" x="0.0" y="44.5" width="375" height="187"/>
                                 <autoresizingMask key="autoresizingMask"/>
                                 <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="R1c-h5-BOp" id="9Bv-1W-yVV">
                                     <rect key="frame" x="0.0" y="0.0" width="375" height="187"/>
@@ -28,7 +28,7 @@
                                             <constraints>
                                                 <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="23" id="HIf-ra-ApH"/>
                                             </constraints>
-                                            <fontDescription key="fontDescription" type="system" pointSize="16"/>
+                                            <fontDescription key="fontDescription" type="system" pointSize="15"/>
                                             <nil key="textColor"/>
                                             <nil key="highlightedColor"/>
                                         </label>
@@ -43,11 +43,11 @@
                                             <nil key="highlightedColor"/>
                                         </label>
                                         <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="9fz-sr-8Gv" userLabel="message">
-                                            <rect key="frame" x="50" y="73" width="315" height="73"/>
+                                            <rect key="frame" x="50" y="73" width="315" height="64"/>
                                             <constraints>
                                                 <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="5" id="w3S-Mr-J41"/>
                                             </constraints>
-                                            <fontDescription key="fontDescription" type="system" pointSize="16"/>
+                                            <fontDescription key="fontDescription" type="system" pointSize="15"/>
                                             <color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
                                             <nil key="highlightedColor"/>
                                         </label>
@@ -70,7 +70,7 @@
                                             </connections>
                                         </button>
                                         <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="sMh-G7-FLo">
-                                            <rect key="frame" x="245" y="147" width="120" height="30"/>
+                                            <rect key="frame" x="245" y="142" width="120" height="30"/>
                                             <constraints>
                                                 <constraint firstAttribute="height" constant="30" id="n50-CF-ODl"/>
                                                 <constraint firstAttribute="width" constant="120" id="tiI-55-Qu5"/>
@@ -81,7 +81,7 @@
                                             </connections>
                                         </button>
                                         <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="obR-h7-TUC">
-                                            <rect key="frame" x="115" y="147" width="120" height="30"/>
+                                            <rect key="frame" x="115" y="142" width="120" height="30"/>
                                             <constraints>
                                                 <constraint firstAttribute="height" constant="30" id="Vko-Ob-nuj"/>
                                                 <constraint firstAttribute="width" constant="120" id="sVc-6c-vO4"/>
@@ -104,22 +104,22 @@
                                         <constraint firstItem="j3P-Mn-NRk" firstAttribute="leading" secondItem="9Bv-1W-yVV" secondAttribute="leading" constant="10" id="05B-JK-v6T"/>
                                         <constraint firstAttribute="trailing" secondItem="sMh-G7-FLo" secondAttribute="trailing" constant="10" id="4W9-Xm-fxY"/>
                                         <constraint firstItem="9mD-Qe-1wu" firstAttribute="centerY" secondItem="YM1-uH-2Cz" secondAttribute="centerY" id="6VB-EF-GQs"/>
+                                        <constraint firstItem="sMh-G7-FLo" firstAttribute="top" secondItem="9fz-sr-8Gv" secondAttribute="bottom" constant="5" id="EOH-W7-TBv"/>
                                         <constraint firstItem="pg1-7p-7Rz" firstAttribute="leading" secondItem="j3P-Mn-NRk" secondAttribute="trailing" constant="15" id="FHX-rf-Z0E"/>
-                                        <constraint firstAttribute="bottomMargin" secondItem="9fz-sr-8Gv" secondAttribute="bottom" constant="30" id="FnM-0E-rXs"/>
                                         <constraint firstAttribute="trailing" secondItem="9mD-Qe-1wu" secondAttribute="trailing" constant="10" id="L9w-kA-Ypv"/>
                                         <constraint firstItem="sMh-G7-FLo" firstAttribute="leading" secondItem="obR-h7-TUC" secondAttribute="trailing" constant="10" id="MZG-Fc-cbL"/>
-                                        <constraint firstAttribute="bottom" secondItem="sMh-G7-FLo" secondAttribute="bottom" constant="10" id="RKX-zp-kja"/>
+                                        <constraint firstAttribute="bottom" secondItem="sMh-G7-FLo" secondAttribute="bottom" constant="15" id="RKX-zp-kja"/>
                                         <constraint firstItem="9fz-sr-8Gv" firstAttribute="leading" secondItem="9Bv-1W-yVV" secondAttribute="leading" constant="50" id="ZxC-VD-ZtU"/>
                                         <constraint firstAttribute="trailing" secondItem="pg1-7p-7Rz" secondAttribute="trailing" constant="10" id="bwL-co-8gM"/>
                                         <constraint firstAttribute="trailing" secondItem="9fz-sr-8Gv" secondAttribute="trailing" constant="10" id="d8l-vA-BmP"/>
                                         <constraint firstItem="9mD-Qe-1wu" firstAttribute="leading" secondItem="YPu-No-c8x" secondAttribute="trailing" constant="12" id="goU-TU-7Jd"/>
                                         <constraint firstItem="9fz-sr-8Gv" firstAttribute="top" secondItem="pg1-7p-7Rz" secondAttribute="bottom" constant="10" id="heM-QX-U30"/>
-                                        <constraint firstAttribute="bottom" secondItem="obR-h7-TUC" secondAttribute="bottom" constant="10" id="keX-xE-b77"/>
                                         <constraint firstItem="pg1-7p-7Rz" firstAttribute="top" secondItem="9Bv-1W-yVV" secondAttribute="top" constant="40" id="pcJ-Jy-HwJ"/>
                                         <constraint firstItem="YM1-uH-2Cz" firstAttribute="top" secondItem="9Bv-1W-yVV" secondAttribute="top" constant="10" id="vBN-K9-5xe"/>
                                         <constraint firstItem="YM1-uH-2Cz" firstAttribute="leading" secondItem="9Bv-1W-yVV" secondAttribute="leading" constant="10" id="xEL-jv-PCm"/>
                                         <constraint firstItem="j3P-Mn-NRk" firstAttribute="top" secondItem="9Bv-1W-yVV" secondAttribute="top" constant="40" id="xoc-tf-dh9"/>
                                         <constraint firstItem="YPu-No-c8x" firstAttribute="centerY" secondItem="YM1-uH-2Cz" secondAttribute="centerY" id="z8s-et-n4J"/>
+                                        <constraint firstItem="obR-h7-TUC" firstAttribute="firstBaseline" secondItem="sMh-G7-FLo" secondAttribute="firstBaseline" id="zHR-cX-8yQ"/>
                                     </constraints>
                                 </tableViewCellContentView>
                                 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
@@ -130,7 +130,6 @@
                                     <outlet property="date" destination="YPu-No-c8x" id="CfW-Pz-jdL"/>
                                     <outlet property="icon" destination="YM1-uH-2Cz" id="MPX-ZL-wVR"/>
                                     <outlet property="message" destination="9fz-sr-8Gv" id="3Zx-pz-gEK"/>
-                                    <outlet property="messageBottomMargin" destination="FnM-0E-rXs" id="Pf6-Au-H7E"/>
                                     <outlet property="primary" destination="sMh-G7-FLo" id="oyl-c8-sTP"/>
                                     <outlet property="primaryWidth" destination="tiI-55-Qu5" id="8H6-cf-vtP"/>
                                     <outlet property="remove" destination="9mD-Qe-1wu" id="r1h-mr-5U9"/>

+ 45 - 53
iOSClient/Notification/NCNotification.swift

@@ -6,6 +6,7 @@
 //  Copyright (c) 2017 Marino Faggiana. All rights reserved.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
+//  Henrik Storch <henrik.storch@nextcloud.com>
 //
 //  This program is free software: you can redistribute it and/or modify
 //  it under the terms of the GNU General Public License as published by
@@ -110,7 +111,7 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
     }
     
     override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
-    
+
         let cell = self.tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! NCNotificationCell
         cell.delegate = self
         
@@ -163,20 +164,20 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
         cell.subject.textColor = NCBrandColor.shared.label
         cell.message.text = notification.message.replacingOccurrences(of: "<br />", with: "\n")
         cell.message.textColor = .gray
-        
+
         cell.remove.setImage(UIImage(named: "xmark")!.image(color: .gray, size: 20), for: .normal)
-        
+
         cell.primary.isEnabled = false
         cell.primary.isHidden = true
-        cell.primary.titleLabel?.font = .systemFont(ofSize: 14)
+        cell.primary.titleLabel?.font = .systemFont(ofSize: 15)
         cell.primary.setTitleColor(.white, for: .normal)
         cell.primary.layer.cornerRadius = 15
         cell.primary.layer.masksToBounds = true
         cell.primary.layer.backgroundColor = NCBrandColor.shared.brandElement.cgColor
-        
+
         cell.secondary.isEnabled = false
         cell.secondary.isHidden = true
-        cell.secondary.titleLabel?.font = .systemFont(ofSize: 14)
+        cell.secondary.titleLabel?.font = .systemFont(ofSize: 15)
         cell.secondary.setTitleColor(.gray, for: .normal)
         cell.secondary.layer.cornerRadius = 15
         cell.secondary.layer.masksToBounds = true
@@ -184,52 +185,41 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
         cell.secondary.layer.borderWidth = 0.3
         cell.secondary.layer.borderColor = UIColor.gray.cgColor
         
-        cell.messageBottomMargin.constant = 10
-        
         // Action
-        if let actions = notification.actions {
-            if let jsonActions = JSON(actions).array {
-                if jsonActions.count == 1 {
-                    let action = jsonActions[0]
-                    
-                    cell.primary.isEnabled = true
-                    cell.primary.isHidden = false
-                    cell.primary.setTitle(action["label"].stringValue, for: .normal)
-                    
-                } else if jsonActions.count == 2 {
+        if let actions = notification.actions,
+           let jsonActions = JSON(actions).array {
+            if jsonActions.count == 1 {
+                let action = jsonActions[0]
+                
+                cell.primary.isEnabled = true
+                cell.primary.isHidden = false
+                cell.primary.setTitle(action["label"].stringValue, for: .normal)
+                
+            } else if jsonActions.count == 2 {
+                
+                cell.primary.isEnabled = true
+                cell.primary.isHidden = false
+                
+                cell.secondary.isEnabled = true
+                cell.secondary.isHidden = false
+                
+                for action in jsonActions {
                     
-                    cell.primary.isEnabled = true
-                    cell.primary.isHidden = false
-                        
-                    cell.secondary.isEnabled = true
-                    cell.secondary.isHidden = false
+                    let label =  action["label"].stringValue
+                    let primary = action["primary"].boolValue
                     
-                    for action in jsonActions {
-                            
-                        let label =  action["label"].stringValue
-                        let primary = action["primary"].boolValue
-                            
-                        if primary {
-                            cell.primary.setTitle(label, for: .normal)
-                        } else {
-                            cell.secondary.setTitle(label, for: .normal)
-                        }
+                    if primary {
+                        cell.primary.setTitle(label, for: .normal)
+                    } else {
+                        cell.secondary.setTitle(label, for: .normal)
                     }
                 }
-                
-                let widthPrimary = cell.primary.intrinsicContentSize.width + 30;
-                let widthSecondary = cell.secondary.intrinsicContentSize.width + 30;
-                
-                if widthPrimary > widthSecondary {
-                    cell.primaryWidth.constant = widthPrimary
-                    cell.secondaryWidth.constant = widthPrimary
-                } else {
-                    cell.primaryWidth.constant = widthSecondary
-                    cell.secondaryWidth.constant = widthSecondary
-                }
-                
-                cell.messageBottomMargin.constant = 40
             }
+
+            var buttonWidth = max(cell.primary.intrinsicContentSize.width, cell.secondary.intrinsicContentSize.width)
+            buttonWidth += 30
+            cell.primaryWidth.constant = buttonWidth
+            cell.secondaryWidth.constant = buttonWidth
         }
         
         return cell
@@ -241,8 +231,9 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
            
         NCCommunication.shared.setNotification(serverUrl:nil, idNotification: notification!.idNotification , method: "DELETE") { (account, errorCode, errorDescription) in
             if errorCode == 0 && account == self.appDelegate.account {
-                                
-                if let index = self.notifications.firstIndex(where: {$0.idNotification == notification!.idNotification})  {
+
+                if let index = self.notifications
+                    .firstIndex(where: { $0.idNotification == notification!.idNotification })  {
                     self.notifications.remove(at: index)
                 }
                 
@@ -264,17 +255,18 @@ class NCNotification: UITableViewController, NCNotificationCellDelegate, NCEmpty
                     if action["label"].string == label {
                         let serverUrl = action["link"].stringValue
                         let method = action["type"].stringValue
-                            
+
                         if method == "WEB", let url = action["link"].url {
                             UIApplication.shared.open(url, options: [:], completionHandler: nil)
                             return
                         }
-                        
+
                         NCCommunication.shared.setNotification(serverUrl: serverUrl, idNotification: 0, method: method) { (account, errorCode, errorDescription) in
                             
                             if errorCode == 0 && account == self.appDelegate.account {
-                                                        
-                                if let index = self.notifications.firstIndex(where: {$0.idNotification == notification!.idNotification})  {
+
+                                if let index = self.notifications
+                                    .firstIndex(where: { $0.idNotification == notification!.idNotification })  {
                                     self.notifications.remove(at: index)
                                 }
                                 
@@ -333,7 +325,7 @@ class NCNotificationCell: UITableViewCell, NCCellProtocol {
     @IBOutlet weak var primary: UIButton!
     @IBOutlet weak var secondary: UIButton!
     @IBOutlet weak var avatarLeadingMargin: NSLayoutConstraint!
-    @IBOutlet weak var messageBottomMargin: NSLayoutConstraint!
+//    @IBOutlet weak var messageBottomMargin: NSLayoutConstraint!
     @IBOutlet weak var primaryWidth: NSLayoutConstraint!
     @IBOutlet weak var secondaryWidth: NSLayoutConstraint!
     

+ 15 - 27
iOSClient/Share/NCShareCommon.swift

@@ -61,11 +61,7 @@ class NCShareCommon: NSObject {
         var shareLinkMenuView: NCShareLinkMenuView
         let window = UIApplication.shared.keyWindow!
         let viewWindow = UIView(frame: window.bounds)
-//        let globalPoint = shareViewController.view.superview?.convert(shareViewController.view.frame.origin, to: nil)
-//        let constantTrailingAnchor = window.bounds.width - shareViewController.view.bounds.width - globalPoint!.x + 40
-//        var constantBottomAnchor: CGFloat = 10
-//        constantBottomAnchor = constantBottomAnchor + UIApplication.shared.keyWindow!.safeAreaInsets.bottom
-        
+
         window.addSubview(viewWindow)
         viewWindow.autoresizingMask = [.flexibleWidth, .flexibleHeight]
 
@@ -105,11 +101,7 @@ class NCShareCommon: NSObject {
         var shareUserMenuView: NCShareUserMenuView
         let window = UIApplication.shared.keyWindow!
         let viewWindow = UIView(frame: window.bounds)
-//        let globalPoint = shareViewController.view.superview?.convert(shareViewController.view.frame.origin, to: nil)
-//        let constantTrailingAnchor = window.bounds.width - shareViewController.view.bounds.width - globalPoint!.x + 40
-//        var constantBottomAnchor: CGFloat = 10
-//        constantBottomAnchor = constantBottomAnchor + UIApplication.shared.keyWindow!.safeAreaInsets.bottom
-        
+
         window.addSubview(viewWindow)
         viewWindow.autoresizingMask = [.flexibleWidth, .flexibleHeight]
 
@@ -174,10 +166,10 @@ class NCShareCommon: NSObject {
         calendar.appearance.headerTitleFont = UIFont.systemFont(ofSize: 13)
         
         calendar.appearance.weekdayTextColor = UIColor(red: 100/255, green: 100/255, blue: 100/255, alpha: 1)
-        calendar.appearance.weekdayFont = UIFont.systemFont(ofSize: 12)
+        calendar.appearance.weekdayFont = UIFont.systemFont(ofSize: 13)
         
         calendar.appearance.todayColor = NCBrandColor.shared.brandElement
-        calendar.appearance.titleFont = UIFont.systemFont(ofSize: 12)
+        calendar.appearance.titleFont = UIFont.systemFont(ofSize: 13)
         
         viewWindow.addSubview(calendar)
         
@@ -185,22 +177,18 @@ class NCShareCommon: NSObject {
     }
     
     func copyLink(link: String, viewController: UIViewController, sender: Any) {
-        //guard let tableShare = tableShare else { return }
-        
-        //if let name = URL(string: tableShare.url), !name.absoluteString.isEmpty {
-            let objectsToShare = [link]
-            
-            let activityViewController = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
-            
-            if UIDevice.current.userInterfaceIdiom == .pad {
-                if activityViewController.responds(to: #selector(getter: UIViewController.popoverPresentationController)) {
-                    activityViewController.popoverPresentationController?.sourceView = sender as? UIView
-                    activityViewController.popoverPresentationController?.sourceRect = (sender as AnyObject).bounds
-                }
+        let objectsToShare = [link]
+
+        let activityViewController = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
+
+        if UIDevice.current.userInterfaceIdiom == .pad {
+            if activityViewController.responds(to: #selector(getter: UIViewController.popoverPresentationController)) {
+                activityViewController.popoverPresentationController?.sourceView = sender as? UIView
+                activityViewController.popoverPresentationController?.sourceRect = (sender as AnyObject).bounds
             }
-            
-            viewController.present(activityViewController, animated: true, completion: nil)
-        //}
+        }
+
+        viewController.present(activityViewController, animated: true, completion: nil)
     }
     
     func getImageShareType(shareType: Int) -> UIImage? {