瀏覽代碼

target some lint warnings

B. Petersen 6 年之前
父節點
當前提交
e9e6108da5

+ 1 - 0
.swiftlint.yml

@@ -5,6 +5,7 @@ opt_in_rules:
 disabled_rules:
 - trailing_comma
 - large_tuple
+- todo
 
 excluded:
 - Carthage

+ 1 - 3
deltachat-ios/Controller/AccountSetup/PortSettingsController.swift

@@ -8,7 +8,7 @@ class PortSettingsController: UITableViewController {
 
     var resetButton: UIBarButtonItem!
 
-    var onDismiss:((String)->Void)?
+    var onDismiss: ((String) -> Void)?
 
     var currentPort: Int {
         didSet {
@@ -159,5 +159,3 @@ class PortSettingsController: UITableViewController {
     }
 
 }
-
-

+ 1 - 1
deltachat-ios/Controller/AccountSetup/SecuritySettingsController.swift

@@ -117,7 +117,7 @@ class SecurityConverter {
                 return 0x400
             }
         case .SMTPSecurity:
-            switch value{
+            switch value {
             case .AUTO:
                 return 0x00000
             case .STARTTLS:

+ 6 - 2
deltachat-ios/Controller/AccountSetupController.swift

@@ -64,7 +64,9 @@ class AccountSetupController: UITableViewController {
     }()
 
     lazy var imapServerCell: TextFieldCell = {
-        let cell = TextFieldCell(descriptionID: "login_imap_server", placeholder: DCConfig.mailServer ?? DCConfig.configuredMailServer, delegate: self)
+        let cell = TextFieldCell(descriptionID: "login_imap_server",
+                                 placeholder: DCConfig.mailServer ?? DCConfig.configuredMailServer,
+                                 delegate: self)
         cell.accessibilityIdentifier = "IMAPServerCell"
         cell.textField.tag = 2
         cell.textField.autocorrectionType = .no
@@ -103,7 +105,9 @@ class AccountSetupController: UITableViewController {
     }()
 
     lazy var smtpServerCell: TextFieldCell = {
-        let cell = TextFieldCell(descriptionID: "login_smtp_server", placeholder: DCConfig.sendServer ?? DCConfig.configuredSendServer, delegate: self)
+        let cell = TextFieldCell(descriptionID: "login_smtp_server",
+                                 placeholder: DCConfig.sendServer ?? DCConfig.configuredSendServer,
+                                 delegate: self)
         cell.accessibilityIdentifier = "SMTPServerCell"
         cell.textField.tag = 4
         cell.textField.autocorrectionType = .no

+ 13 - 6
deltachat-ios/Controller/ChatViewController.swift

@@ -279,14 +279,19 @@ class ChatViewController: MessagesViewController {
 
         // Hide the outgoing avatar and adjust the label alignment to line up with the messages
         layout?.setMessageOutgoingAvatarSize(.zero)
-        layout?.setMessageOutgoingMessageTopLabelAlignment(LabelAlignment(textAlignment: .right, textInsets: UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 8)))
-        layout?.setMessageOutgoingMessageBottomLabelAlignment(LabelAlignment(textAlignment: .right, textInsets: UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 8)))
+        layout?.setMessageOutgoingMessageTopLabelAlignment(LabelAlignment(textAlignment: .right,
+            textInsets: UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 8)))
+        layout?.setMessageOutgoingMessageBottomLabelAlignment(LabelAlignment(textAlignment: .right,
+            textInsets: UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 8)))
 
         // Set outgoing avatar to overlap with the message bubble
-        layout?.setMessageIncomingMessageTopLabelAlignment(LabelAlignment(textAlignment: .left, textInsets: UIEdgeInsets(top: 0, left: 18, bottom: outgoingAvatarOverlap, right: 0)))
+        layout?.setMessageIncomingMessageTopLabelAlignment(LabelAlignment(textAlignment: .left,
+            textInsets: UIEdgeInsets(top: 0, left: 18, bottom: outgoingAvatarOverlap, right: 0)))
         layout?.setMessageIncomingAvatarSize(CGSize(width: 30, height: 30))
-        layout?.setMessageIncomingMessagePadding(UIEdgeInsets(top: -outgoingAvatarOverlap, left: -18, bottom: outgoingAvatarOverlap / 2, right: 18))
-        layout?.setMessageIncomingMessageBottomLabelAlignment(LabelAlignment(textAlignment: .left, textInsets: UIEdgeInsets(top: -7, left: 38, bottom: 0, right: 0)))
+        layout?.setMessageIncomingMessagePadding(UIEdgeInsets(
+            top: -outgoingAvatarOverlap, left: -18, bottom: outgoingAvatarOverlap / 2, right: 18))
+        layout?.setMessageIncomingMessageBottomLabelAlignment(LabelAlignment(textAlignment: .left,
+            textInsets: UIEdgeInsets(top: -7, left: 38, bottom: 0, right: 0)))
 
         layout?.setMessageIncomingAccessoryViewSize(CGSize(width: 30, height: 30))
         layout?.setMessageIncomingAccessoryViewPadding(HorizontalEdgeInsets(left: 8, right: 0))
@@ -655,7 +660,9 @@ extension ChatViewController: MessagesDisplayDelegate {
                 view.style = .none
                 view.backgroundColor = UIColor(alpha: 10, red: 0, green: 0, blue: 0)
                 let radius: CGFloat = 16
-                let path = UIBezierPath(roundedRect: view.bounds, byRoundingCorners: UIRectCorner.allCorners, cornerRadii: CGSize(width: radius, height: radius))
+                let path = UIBezierPath(roundedRect: view.bounds,
+                                        byRoundingCorners: UIRectCorner.allCorners,
+                                        cornerRadii: CGSize(width: radius, height: radius))
                 let mask = CAShapeLayer()
                 mask.path = path.cgPath
                 view.layer.mask = mask

+ 0 - 1
deltachat-ios/Controller/ContactDetailViewController.swift

@@ -147,4 +147,3 @@ class ContactDetailViewController: UITableViewController {
         coordinator?.showEditContact(contactId: contactId)
     }
 }
-

+ 1 - 1
deltachat-ios/Controller/NewProfileViewController.swift

@@ -241,7 +241,7 @@ class NewProfileViewController: UIViewController, QrCodeReaderDelegate {
         let btn = UIButton.init(type: UIButton.ButtonType.system)
         btn.translatesAutoresizingMaskIntoConstraints = false
         btn.setTitle(String.localized("qrscan_title"), for: .normal)
-        btn.addTarget(self, action:#selector(self.openQRCodeScanner), for: .touchUpInside)
+        btn.addTarget(self, action: #selector(self.openQRCodeScanner), for: .touchUpInside)
         return btn
     }
 

+ 22 - 8
deltachat-ios/Controller/SettingsController.swift

@@ -93,7 +93,7 @@ internal final class SettingsViewController: QuickTableViewController {
     }
 
     private func setTable() {
-        var backupRows = [
+        let backupRows = [
             TapActionRow(text: String.localized("create_backup"), action: { [weak self] in self?.createBackup($0) }),
         ]
 
@@ -116,13 +116,27 @@ internal final class SettingsViewController: QuickTableViewController {
             Section(
                 title: String.localized("flags"),
                 rows: [
-                    SwitchRow(text: String.localized("autocrypt_prefer_e2ee"), switchValue: DCConfig.e2eeEnabled, action: editCell(key: SVC.e2eeEnabled)),
-                    SwitchRow(text: String.localized("pref_read_receipts"), switchValue: DCConfig.mdnsEnabled, action: editCell(key: SVC.readReceipts)),
-                    SwitchRow(text: String.localized("pref_watch_inbox_folder"), switchValue: DCConfig.inboxWatch, action: editCell(key: SVC.watchMvBox)),
-                    SwitchRow(text: String.localized("pref_watch_sent_folder"), switchValue: DCConfig.sentboxWatch, action: editCell(key: SVC.watchSentbox)),
-                    SwitchRow(text: String.localized("pref_watch_mvbox_folder"), switchValue: DCConfig.mvboxWatch, action: editCell(key: SVC.watchMvBox)),
-                    SwitchRow(text: String.localized("pref_auto_folder_moves"), switchValue: DCConfig.mvboxMove, action: editCell(key: SVC.MvToMvbox)),
-                    SwitchRow(text: String.localized("save_mime_headers"), switchValue: DCConfig.saveMimeHeaders, action: editCell(key: SVC.SaveMimeHeaders))
+                    SwitchRow(text: String.localized("autocrypt_prefer_e2ee"),
+                              switchValue: DCConfig.e2eeEnabled,
+                              action: editCell(key: SVC.e2eeEnabled)),
+                    SwitchRow(text: String.localized("pref_read_receipts"),
+                              switchValue: DCConfig.mdnsEnabled,
+                              action: editCell(key: SVC.readReceipts)),
+                    SwitchRow(text: String.localized("pref_watch_inbox_folder"),
+                              switchValue: DCConfig.inboxWatch,
+                              action: editCell(key: SVC.watchMvBox)),
+                    SwitchRow(text: String.localized("pref_watch_sent_folder"),
+                              switchValue: DCConfig.sentboxWatch,
+                              action: editCell(key: SVC.watchSentbox)),
+                    SwitchRow(text: String.localized("pref_watch_mvbox_folder"),
+                              switchValue: DCConfig.mvboxWatch,
+                              action: editCell(key: SVC.watchMvBox)),
+                    SwitchRow(text: String.localized("pref_auto_folder_moves"),
+                              switchValue: DCConfig.mvboxMove,
+                              action: editCell(key: SVC.MvToMvbox)),
+                    SwitchRow(text: String.localized("save_mime_headers"),
+                              switchValue: DCConfig.saveMimeHeaders,
+                              action: editCell(key: SVC.SaveMimeHeaders))
                 ]
             ),
 

+ 10 - 6
deltachat-ios/Coordinator/AppCoordinator.swift

@@ -121,9 +121,9 @@ extension AppCoordinator: UITabBarControllerDelegate {
     func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
         if let dcNav = viewController as? DCNavigationController {
             switch tabBarController.selectedIndex {
-            case 0,3,4:
+            case 0, 3, 4:
                 dcNav.navigationBar.prefersLargeTitles = true
-            case 1,2:
+            case 1, 2:
                 dcNav.navigationBar.prefersLargeTitles = false
             default:
                 // should never get here
@@ -231,7 +231,7 @@ class ChatListCoordinator: Coordinator {
 class SettingsCoordinator: Coordinator {
     let navigationController: UINavigationController
 
-    var childCoordinators:[Coordinator] = []
+    var childCoordinators: [Coordinator] = []
 
     init(navigationController: UINavigationController) {
         self.navigationController = navigationController
@@ -271,7 +271,9 @@ class AccountSetupCoordinator: Coordinator {
     func showImapPortOptions() {
         let currentMailPort = DCConfig.mailPort ?? DCConfig.configuredMailPort
         let currentPort = Int(currentMailPort)
-        let portSettingsController = PortSettingsController(sectionTitle: String.localized("login_imap_port"), ports: [143, 993], currentPort: currentPort)
+        let portSettingsController = PortSettingsController(sectionTitle: String.localized("login_imap_port"),
+                                                            ports: [143, 993],
+                                                            currentPort: currentPort)
         portSettingsController.onDismiss = {
             port in
             DCConfig.mailPort = port
@@ -298,7 +300,9 @@ class AccountSetupCoordinator: Coordinator {
     func showSmtpPortsOptions() {
         let currentMailPort = DCConfig.sendPort ?? DCConfig.configuredSendPort
         let currentPort = Int(currentMailPort)
-        let portSettingsController = PortSettingsController(sectionTitle: String.localized("login_smtp_port"), ports: [25, 465, 587], currentPort: currentPort)
+        let portSettingsController = PortSettingsController(sectionTitle: String.localized("login_smtp_port"),
+                                                            ports: [25, 465, 587],
+                                                            currentPort: currentPort)
         portSettingsController.onDismiss = {
             port in
             DCConfig.sendPort = port
@@ -449,7 +453,7 @@ class ChatViewCoordinator: NSObject, Coordinator {
         // navigationController.present(nav, animated: true, completion: nil)
     }
 
-    private func sendImage(_ image:UIImage) {
+    private func sendImage(_ image: UIImage) {
         DispatchQueue.global().async {
             if let compressedImage = image.dcCompress() {
                 // at this point image is compressed by 85% by default

+ 1 - 2
deltachat-ios/DC/Wrapper.swift

@@ -110,7 +110,7 @@ class DcContext {
 
 
     func getSecurejoinQr (chatId: Int) -> String? {
-        if let cString = dc_get_securejoin_qr(self.contextPointer,  UInt32(chatId)) {
+        if let cString = dc_get_securejoin_qr(self.contextPointer, UInt32(chatId)) {
             return String(cString: cString)
         }
         return nil
@@ -991,4 +991,3 @@ class DCConfig {
         set {}
     }
 }
-

+ 1 - 2
deltachat-ios/Helper/Extensions.swift

@@ -63,7 +63,7 @@ extension String {
     static func localized(stringID: String, count: Int) -> String {
         let formatString: String = localized(stringID)
         let resultString: String = String.localizedStringWithFormat(formatString, count)
-        return resultString;
+        return resultString
     }
 }
 
@@ -238,4 +238,3 @@ extension UIColor {
 
 
 }
-

+ 0 - 1
deltachat-ios/Helper/Utils.swift

@@ -180,4 +180,3 @@ class DateUtils {
         }
     }
 }
-

+ 1 - 1
deltachat-ios/View/ContactCell.swift

@@ -184,7 +184,7 @@ class ContactCell: UITableViewCell {
             return
         }
 
-        var indicatorImage:UIImage?
+        var indicatorImage: UIImage?
         switch status {
         case .OUTPENDING, .OUTPAIRING:
             indicatorImage = #imageLiteral(resourceName: "ic_delivery_status_sending").withRenderingMode(.alwaysTemplate)

+ 0 - 2
deltachat-ios/View/CustomMessageCell.swift

@@ -36,5 +36,3 @@ open class CustomMessageCell: UICollectionViewCell {
         }
     }
 }
-
-

+ 1 - 1
deltachat-ios/View/TextFieldCell.swift

@@ -3,7 +3,7 @@ import UIKit
 class TextFieldCell: UITableViewCell {
     private let placeholder: String
 
-    var onTextFieldChange:((_:UITextField)->Void)?	// set this from outside to get notified about textfield changes
+    var onTextFieldChange:((_:UITextField) -> Void)?	// set this from outside to get notified about textfield changes
 
     lazy var textField: UITextField = {
         let textField = UITextField()