diff --git a/enzevalos_iphone/Base.lproj/Main.storyboard b/enzevalos_iphone/Base.lproj/Main.storyboard index 5e8bac37d3d60d6a38ca66c97e249a1746e54eda..fea1ca5e10fc1e8835543bf4a99a9c3250dd9b68 100644 --- a/enzevalos_iphone/Base.lproj/Main.storyboard +++ b/enzevalos_iphone/Base.lproj/Main.storyboard @@ -540,16 +540,16 @@ <autoresizingMask key="autoresizingMask"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4I7-Ir-fwz"> - <rect key="frame" x="44" y="14" width="42" height="23"/> + <rect key="frame" x="44" y="14" width="42" height="22"/> <constraints> - <constraint firstAttribute="height" constant="22.5" id="29r-eG-9RK"/> + <constraint firstAttribute="height" constant="22" id="29r-eG-9RK"/> </constraints> <fontDescription key="fontDescription" type="system" pointSize="17"/> <nil key="textColor"/> <nil key="highlightedColor"/> </label> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="Subject" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="TWB-SA-V9M"> - <rect key="frame" x="44" y="44" width="58.5" height="22"/> + <rect key="frame" x="44" y="43" width="58.5" height="22"/> <constraints> <constraint firstAttribute="height" constant="22" id="Gcf-vv-aPr"/> </constraints> @@ -558,20 +558,20 @@ <nil key="highlightedColor"/> </label> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="753" verticalCompressionResistancePriority="753" text="Date" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="OLU-yz-VZh"> - <rect key="frame" x="271.5" y="18.5" width="32.5" height="18"/> + <rect key="frame" x="271.5" y="17.5" width="32.5" height="18"/> <fontDescription key="fontDescription" type="system" pointSize="15"/> <color key="textColor" cocoaTouchSystemColor="scrollViewTexturedBackgroundColor"/> <nil key="highlightedColor"/> </label> <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="nRP-yN-8GZ"> - <rect key="frame" x="16" y="18.5" width="23" height="15"/> + <rect key="frame" x="16" y="18" width="23" height="15"/> <constraints> <constraint firstAttribute="height" constant="15" id="TgY-wB-hul"/> <constraint firstAttribute="width" constant="23" id="XaP-6s-BLv"/> </constraints> </imageView> <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="equalCentering" alignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="CZD-9d-nBt"> - <rect key="frame" x="21" y="39" width="15" height="32.5"/> + <rect key="frame" x="21" y="38.5" width="15" height="31.5"/> <subviews> <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="lfd-QR-eFB"> <rect key="frame" x="0.0" y="0.0" width="15" height="15"/> @@ -581,7 +581,7 @@ </constraints> </imageView> <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="sfv-2Q-95I"> - <rect key="frame" x="0.0" y="17.5" width="15" height="15"/> + <rect key="frame" x="0.0" y="16.5" width="15" height="15"/> <constraints> <constraint firstAttribute="height" constant="15" id="SmT-9e-ovi"/> <constraint firstAttribute="width" constant="15" id="uKU-PK-flD"/> @@ -590,7 +590,7 @@ </subviews> </stackView> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="249" verticalHuggingPriority="249" horizontalCompressionResistancePriority="749" verticalCompressionResistancePriority="749" text="Body" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="aMi-fS-0nq"> - <rect key="frame" x="110" y="49" width="153" height="16"/> + <rect key="frame" x="110" y="48" width="153" height="16"/> <fontDescription key="fontDescription" type="system" pointSize="13"/> <color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/> <nil key="highlightedColor"/> @@ -632,6 +632,13 @@ <outlet property="delegate" destination="eRp-By-lS3" id="uzM-L0-alX"/> </connections> </tableView> + <toolbarItems> + <barButtonItem style="plain" systemItem="flexibleSpace" id="6J0-Tr-Tgj"/> + <barButtonItem enabled="NO" title="last Update" id="ZNc-Kc-oC1"> + <color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> + </barButtonItem> + <barButtonItem style="plain" systemItem="flexibleSpace" id="LhP-ZB-o4i"/> + </toolbarItems> <navigationItem key="navigationItem" id="qTG-y6-efi"> <barButtonItem key="rightBarButtonItem" title="Über uns" id="vnz-ap-Ddb"> <connections> @@ -639,11 +646,13 @@ </connections> </barButtonItem> </navigationItem> + <simulatedToolbarMetrics key="simulatedBottomBarMetrics"/> <refreshControl key="refreshControl" opaque="NO" multipleTouchEnabled="YES" contentMode="center" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" id="i7r-Oq-y5T"> <rect key="frame" x="0.0" y="0.0" width="1000" height="1000"/> <autoresizingMask key="autoresizingMask"/> </refreshControl> <connections> + <outlet property="lastUpdateButton" destination="ZNc-Kc-oC1" id="ZUS-YO-vnu"/> <segue destination="TFs-eK-jti" kind="show" identifier="showInboxSegue" id="Qjs-MH-bHU"/> <segue destination="Ouw-WD-EV6" kind="show" identifier="readFolderMailSegue" id="6Ug-AV-lba"/> </connections> @@ -1848,8 +1857,8 @@ Um deine sicheren E-Mails auch auf einem anderen Gerät lesen zu können, muss d </scene> </scenes> <inferredMetricsTieBreakers> - <segue reference="rhW-cI-4c4"/> - <segue reference="hSn-Um-hji"/> + <segue reference="3Wb-uL-BB5"/> + <segue reference="td8-VW-Wrt"/> <segue reference="btx-4o-o0r"/> <segue reference="TgN-rB-esa"/> <segue reference="6Ug-AV-lba"/> diff --git a/enzevalos_iphone/FolderViewController.swift b/enzevalos_iphone/FolderViewController.swift index e94c50f9b4d0c7007ae16c274d952d8b13144318..fa2b3cd21fac28cd8c47c9f61d6f58c684114a41 100644 --- a/enzevalos_iphone/FolderViewController.swift +++ b/enzevalos_iphone/FolderViewController.swift @@ -15,9 +15,22 @@ class FolderViewController: UITableViewController { var isFirstFolderViewController = true var presentedFolder: Folder? = nil + @IBOutlet weak var lastUpdateButton: UIBarButtonItem! + var lastUpdateLabel = UILabel(frame: CGRect.zero) + var lastUpdateText: String? { + didSet { + lastUpdateLabel.text = lastUpdateText + lastUpdateLabel.sizeToFit() + } + } + + var lastUpdate: Date? = Date() + let dateFormatter = DateFormatter() + override func viewDidLoad() { self.refreshControl?.addTarget(self, action: #selector(FolderViewController.refresh), for: UIControlEvents.valueChanged) self.refreshControl?.attributedTitle = NSAttributedString(string: NSLocalizedString("PullToRefresh", comment: "Pull to refresh")) + lastUpdateText = NSLocalizedString("Updating", comment: "Getting new data") if isFirstFolderViewController { folders = DataHandler.handler.allRootFolders.sorted().filter { $0.path != UserManager.backendInboxFolderPath } @@ -34,8 +47,19 @@ class FolderViewController: UITableViewController { } NotificationCenter.default.addObserver(forName: Notification.Name.NSManagedObjectContextDidSave, object: nil, queue: nil, using: { [weak self] _ in + self?.lastUpdate = Date() self?.tableView.reloadData() }) + + dateFormatter.locale = Locale.current + dateFormatter.timeStyle = .medium + + lastUpdateLabel.sizeToFit() + lastUpdateLabel.backgroundColor = UIColor.clear + lastUpdateLabel.textAlignment = .center + lastUpdateLabel.font = UIFont.systemFont(ofSize: 13) + lastUpdateLabel.textColor = UIColor.black + lastUpdateButton.customView = lastUpdateLabel } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) @@ -164,6 +188,7 @@ class FolderViewController: UITableViewController { } func refresh() { + lastUpdateText = NSLocalizedString("Updating", comment: "Getting new data") if let thisFolder = presentedFolder { refreshControl?.beginRefreshing() AppDelegate.getAppDelegate().mailHandler.updateFolder(folder: thisFolder, newMailCallback: newMails, completionCallback: endRefreshing(_:)) @@ -181,6 +206,7 @@ class FolderViewController: UITableViewController { } tableView.reloadData() refreshControl?.endRefreshing() + lastUpdateText = lastUpdate != nil ? "\(NSLocalizedString("LastUpdate", comment: "When the last update occured")): \(dateFormatter.string(from: lastUpdate!))" : NSLocalizedString("NeverUpdated", comment: "No internet connection since last launch") } func newMails(mail: PersistentMail?) { }