cyBerta пре 4 година
родитељ
комит
47047612b5

+ 2 - 2
DcCore/DcCore/Extensions/UIImage+Extensions.swift

@@ -11,12 +11,12 @@ public extension UIImage {
         let maxRatio: Float = maxWidth / maxHeight
         if actualHeight > maxHeight || actualWidth > maxWidth {
             if imgRatio < maxRatio {
-                //adjust width according to maxHeight
+                // adjust width according to maxHeight
                 imgRatio = maxHeight / actualHeight
                 actualWidth = imgRatio * actualWidth
                 actualHeight = maxHeight
             } else if imgRatio > maxRatio {
-                //adjust height according to maxWidth
+                // adjust height according to maxWidth
                 imgRatio = maxWidth / actualWidth
                 actualHeight = imgRatio * actualHeight
                 actualWidth = maxWidth

+ 3 - 3
DcCore/DcCore/Views/InitialsBadge.swift

@@ -31,13 +31,13 @@ public class InitialsBadge: UIView {
     }()
 
     public var cornerRadius: CGFloat {
+        get {
+            return layer.cornerRadius
+        }
         set {
             layer.cornerRadius = newValue
             imageView.layer.cornerRadius = newValue
         }
-        get {
-            return layer.cornerRadius
-        }
     }
 
     public convenience init(name: String, color: UIColor, size: CGFloat, accessibilityLabel: String? = nil) {

+ 1 - 1
DcShare/Controller/ChatListController.swift

@@ -12,7 +12,7 @@ class ChatListController: UITableViewController {
     let contactCellReuseIdentifier = "contactCellReuseIdentifier"
     weak var chatListDelegate: ChatListDelegate?
 
-    /// MARK - search
+    // MARK: - search
 
     private lazy var searchController: UISearchController = {
         let searchController = UISearchController(searchResultsController: nil)

+ 12 - 12
deltachat-ios/Chat/Views/Cells/BaseMessageCell.swift

@@ -17,17 +17,20 @@ public class BaseMessageCell: UITableViewCell {
     private var fullMessageZeroHeightConstraint: NSLayoutConstraint?
 
     public var mainContentViewHorizontalPadding: CGFloat {
+        get {
+            return mainContentViewLeadingConstraint?.constant ?? 0
+        }
         set {
             mainContentViewLeadingConstraint?.constant = newValue
             mainContentViewTrailingConstraint?.constant = -newValue
         }
-        get {
-            return mainContentViewLeadingConstraint?.constant ?? 0
-        }
     }
 
     // if set to true topLabel overlaps the main content
     public var topCompactView: Bool {
+        get {
+            return mainContentUnderTopLabelConstraint?.isActive ?? false
+        }
         set {
             mainContentBelowTopLabelConstraint?.isActive = !newValue
             mainContentUnderTopLabelConstraint?.isActive = newValue
@@ -35,13 +38,13 @@ public class BaseMessageCell: UITableViewCell {
                 UIColor(alpha: 200, red: 20, green: 20, blue: 20) :
                 UIColor(alpha: 0, red: 0, green: 0, blue: 0)
         }
-        get {
-            return mainContentUnderTopLabelConstraint?.isActive ?? false
-        }
     }
 
     // if set to true bottomLabel overlaps the main content
     public var bottomCompactView: Bool {
+        get {
+            return mainContentUnderBottomLabelConstraint?.isActive ?? false
+        }
         set {
             mainContentAboveFullMessageBtnConstraint?.isActive = !newValue
             mainContentUnderBottomLabelConstraint?.isActive = newValue
@@ -49,21 +52,18 @@ public class BaseMessageCell: UITableViewCell {
                 UIColor(alpha: 200, red: 50, green: 50, blue: 50) :
                 UIColor(alpha: 0, red: 0, green: 0, blue: 0)
         }
-        get {
-            return mainContentUnderBottomLabelConstraint?.isActive ?? false
-        }
     }
 
     public var isFullMessageButtonHidden: Bool {
+        get {
+            return fullMessageButton.isHidden
+        }
         set {
             mainContentAboveFullMessageBtnConstraint?.constant = newValue ? -2 : 8
             fullMessageButton.setTitle(newValue ? "" : String.localized("show_full_message"), for: .normal)
             fullMessageZeroHeightConstraint?.isActive = newValue
             fullMessageButton.isHidden = newValue
         }
-        get {
-            return fullMessageButton.isHidden
-        }
     }
 
     public weak var baseDelegate: BaseMessageCellDelegate?

+ 1 - 1
deltachat-ios/Chat/Views/Cells/ImageTextCell.swift

@@ -134,7 +134,7 @@ class ImageTextCell: BaseMessageCell {
         } else {
             // show image in aspect ratio for landscape images
             if orientation.isLandscape && height > UIScreen.main.bounds.height * 5 / 8 {
-                //shrink landscape image in landscape device orientation if image height is too big
+                // shrink landscape image in landscape device orientation if image height is too big
                 self.imageHeightConstraint = self.contentImageView.heightAnchor.constraint(lessThanOrEqualToConstant: UIScreen.main.bounds.height * 5 / 8)
                 self.imageWidthConstraint = self.contentImageView.widthAnchor.constraint(lessThanOrEqualTo: self.contentImageView.heightAnchor,
                                                                                          multiplier: width/height)

+ 1 - 1
deltachat-ios/Chat/Views/DetectorType.swift

@@ -57,7 +57,7 @@ public enum DetectorType: Hashable {
         }
     }
 
-    ///The hashValue of the `DetectorType` so we can conform to `Hashable` and be sorted.
+    /// The hashValue of the `DetectorType` so we can conform to `Hashable` and be sorted.
     public func hash(into: inout Hasher) {
         into.combine(toInt())
     }

+ 4 - 4
deltachat-ios/Chat/Views/DraftArea.swift

@@ -11,14 +11,14 @@ public class DraftArea: UIView, InputItem {
     public func keyboardEditingBeginsAction() {}
 
     var delegate: DraftPreviewDelegate? {
+        get {
+            return quotePreview.delegate
+        }
         set {
             quotePreview.delegate = newValue
             mediaPreview.delegate = newValue
             documentPreview.delegate = newValue
         }
-        get {
-            return quotePreview.delegate
-        }
     }
 
     lazy var mainContentView: UIStackView = {
@@ -80,7 +80,7 @@ public class DraftArea: UIView, InputItem {
     /// reload cleans caches containing the drafted attachment so that the UI will update correctly
     public func reload(draft: DraftModel) {
         mediaPreview.reload(draft: draft)
-        ///TODO: add document reloading when document editing was added
+        // TODO: add document reloading when document editing was added
     }
 
     public func cancel() {

+ 3 - 3
deltachat-ios/Chat/Views/FileView.swift

@@ -6,6 +6,9 @@ public class FileView: UIView {
     private var imageHeightConstraint: NSLayoutConstraint?
 
     public var horizontalLayout: Bool {
+        get {
+            return fileStackView.axis == .horizontal
+        }
         set {
             if newValue {
                 fileStackView.axis = .horizontal
@@ -19,9 +22,6 @@ public class FileView: UIView {
                 fileStackView.alignment = .leading
             }
         }
-        get {
-            return fileStackView.axis == .horizontal
-        }
     }
 
     // allow to automatically switch between small and large preview of a file,

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

@@ -788,7 +788,7 @@ class AccountSetupController: UITableViewController, ProgressAlertHandler {
 
     private func handleLoginSuccess() {
         // used when login hud successfully went through
-        let appDelegate = UIApplication.shared.delegate as! AppDelegate
+        guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
 
         if !UserDefaults.standard.bool(forKey: "notifications_disabled") {
             appDelegate.registerForNotifications()

+ 2 - 2
deltachat-ios/Controller/AddGroupMembersViewController.swift

@@ -56,7 +56,7 @@ class AddGroupMembersViewController: GroupMembersViewController {
         return button
     }()
 
-    //add members of new group, no chat object yet
+    // add members of new group, no chat object yet
     init(preselected: Set<Int>, isVerified: Bool) {
         super.init()
         isVerifiedGroup = isVerified
@@ -64,7 +64,7 @@ class AddGroupMembersViewController: GroupMembersViewController {
         selectedContactIds = preselected
     }
 
-    //add members of existing group
+    // add members of existing group
     init(chatId: Int) {
         self.chatId = chatId
         super.init()

+ 3 - 3
deltachat-ios/Controller/AudioRecorderController.swift

@@ -10,14 +10,14 @@ class AudioRecorderController: UIViewController, AVAudioRecorderDelegate {
 
     weak var delegate: AudioRecorderControllerDelegate?
 
-    //Recording...
+    // Recording...
     var meterUpdateDisplayLink: CADisplayLink?
     var isRecordingPaused: Bool = false
 
     // maximumRecordDuration > 0 -> restrict max time period for one take
     var maximumRecordDuration = 0.0
 
-    //Private variables
+    // Private variables
     var oldSessionCategory: AVAudioSession.Category?
     var wasIdleTimerDisabled: Bool = false
 
@@ -125,7 +125,7 @@ class AudioRecorderController: UIViewController, AVAudioRecorderDelegate {
         self.navigationController?.navigationBar.isTranslucent = true
         self.navigationController?.toolbar.isTranslucent = true
 
-        //Define the recorder setting
+        // Define the recorder setting
         let recordSettings = [AVFormatIDKey: kAudioFormatMPEG4AAC,
                               AVSampleRateKey: 44100.0,
                               AVNumberOfChannelsKey: 1] as [String: Any]

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

@@ -144,7 +144,7 @@ class ContextMenuProvider {
         var children: [UIMenuElement] = []
 
         for item in menu {
-            //we only support 1 submenu layer for now
+            // we only support 1 submenu layer for now
             if let subMenus = item.children {
                 var submenuChildren: [UIMenuElement] = []
                 for submenuItem in subMenus {

+ 2 - 2
deltachat-ios/Controller/GroupChatDetailViewController.swift

@@ -207,7 +207,7 @@ class GroupChatDetailViewController: UIViewController {
 
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
-        //update chat object, maybe chat name was edited
+        // update chat object, maybe chat name was edited
         updateGroupMembers()
         tableView.reloadData() // to display updates
         editBarButtonItem.isEnabled = currentUser != nil
@@ -255,7 +255,7 @@ class GroupChatDetailViewController: UIViewController {
 
     private func toggleArchiveChat() {
         let archivedBefore = chat.isArchived
-        if (!archivedBefore) {
+        if !archivedBefore {
             NotificationManager.removeNotificationsForChat(chatId: chatId)
         }
         dcContext.archiveChat(chatId: chat.id, archive: !archivedBefore)

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

@@ -189,7 +189,7 @@ extension GroupMembersViewController: UISearchResultsUpdating {
 
     override func viewDidLayoutSubviews() {
         super.viewDidLayoutSubviews()
-        //ensure the empty search state message can be fully read
+        // ensure the empty search state message can be fully read
         if searchController.isActive && filteredContactIds.isEmpty {
             tableView.scrollRectToVisible(emptySearchStateLabel.frame, animated: false)
         }

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

@@ -13,7 +13,7 @@ class MediaQualityController: UITableViewController {
             cell.selectionStyle = .none
             return cell
         })
-    } ()
+    }()
 
     init(dcContext: DcContext) {
         self.dcContext = dcContext

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

@@ -301,7 +301,7 @@ class NewChatViewController: UITableViewController {
 
     override func viewDidLayoutSubviews() {
         super.viewDidLayoutSubviews()
-        //ensure the empty search state message can be fully read
+        // ensure the empty search state message can be fully read
         if searchController.isActive && filteredContactIds.isEmpty {
             tableView.scrollRectToVisible(emptySearchStateLabel.frame, animated: false)
         }

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

@@ -234,7 +234,7 @@ class NewGroupController: UITableViewController, MediaPickerDelegate {
         let section = indexPath.section
         let row = indexPath.row
 
-        //swipe by delete
+        // swipe by delete
         if section == sectionGroupMembers, groupContactIds[row] != DC_CONTACT_ID_SELF {
             let delete = UITableViewRowAction(style: .destructive, title: String.localized("remove_desktop")) { [weak self] _, indexPath in
                 guard let self = self else { return }

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

@@ -405,7 +405,7 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
                                               preferredStyle: .alert)
                 alert.addAction(UIAlertAction(title: String.localized("ok"), style: .default, handler: nil))
                 self.navigationController?.present(alert, animated: true, completion: nil)
-            } else if (self.dcContext.isSendingLocationsToChat(chatId: 0)) {
+            } else if self.dcContext.isSendingLocationsToChat(chatId: 0) {
                 guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {
                     return
                 }

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

@@ -123,7 +123,7 @@ class WelcomeViewController: UIViewController, ProgressAlertHandler {
     }
 
     private func handleLoginSuccess() {
-        let appDelegate = UIApplication.shared.delegate as! AppDelegate
+        guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
         if !UserDefaults.standard.bool(forKey: "notifications_disabled") {
             appDelegate.registerForNotifications()
         }

+ 4 - 5
deltachat-ios/Helper/MediaPicker.swift

@@ -48,7 +48,7 @@ class MediaPicker: NSObject, UINavigationControllerDelegate, AudioRecorderContro
     func showVoiceRecorder() {
         let audioRecorderController = AudioRecorderController()
         audioRecorderController.delegate = self
-        //audioRecorderController.maximumRecordDuration = 1200
+        // audioRecorderController.maximumRecordDuration = 1200
         let audioRecorderNavController = UINavigationController(rootViewController: audioRecorderController)
 
         navigationController?.present(audioRecorderNavController, animated: true, completion: nil)
@@ -57,8 +57,7 @@ class MediaPicker: NSObject, UINavigationControllerDelegate, AudioRecorderContro
     func showPhotoVideoLibrary() {
         if PHPhotoLibrary.authorizationStatus() != .authorized {
             PHPhotoLibrary.requestAuthorization { status in
-                DispatchQueue.main.async {
-                    [weak self] in
+                DispatchQueue.main.async { [weak self] in
                     switch status {
                     case  .denied, .notDetermined, .restricted:
                         print("denied")
@@ -158,10 +157,10 @@ extension MediaPicker: UIImagePickerControllerDelegate {
                     //  selected from camera and edtied
                     self.delegate?.onImageSelected(image: image)
                 } else if let imageURL = info[.imageURL] as? NSURL {
-                    //selected from gallery
+                    // selected from gallery
                     self.delegate?.onImageSelected(url: imageURL)
                 } else if let image = info[.originalImage] as? UIImage {
-                    //selected from camera
+                    // selected from camera
                     self.delegate?.onImageSelected(image: image)
                 }
             }

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

@@ -53,7 +53,7 @@ struct Utils {
     }
 
     static func hasAudioSuffix(url: URL) -> Bool {
-        ///TODO: add more file suffixes
+        // TODO: add more file suffixes
         return url.absoluteString.hasSuffix("wav")
     }
 }

+ 7 - 7
deltachat-ios/View/PaddingTextView.swift

@@ -40,38 +40,38 @@ public class PaddingTextView: UIView {
     }()
 
     public var text: String? {
-        set { label.text = newValue }
         get { return label.text }
+        set { label.text = newValue }
     }
 
     public var attributedText: NSAttributedString? {
-        set { label.attributedText = newValue }
         get { return label.attributedText }
+        set { label.attributedText = newValue }
     }
 
     public var numberOfLines: Int {
-        set { label.numberOfLines = newValue }
         get { return label.numberOfLines }
+        set { label.numberOfLines = newValue }
     }
 
     public var font: UIFont {
-        set { label.font = newValue }
         get { return label.font }
+        set { label.font = newValue }
     }
 
     public var textColor: UIColor {
-        set { label.textColor = newValue }
         get { return label.textColor }
+        set { label.textColor = newValue }
     }
 
     public var enabledDetectors: [DetectorType] {
-        set { label.enabledDetectors = newValue }
         get { return label.enabledDetectors }
+        set { label.enabledDetectors = newValue }
     }
 
     public var delegate: MessageLabelDelegate? {
-        set { label.delegate = newValue }
         get { return label.delegate }
+        set { label.delegate = newValue }
     }
 
     init() {

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

@@ -7,13 +7,13 @@ class TextFieldCell: UITableViewCell {
 
     private var placeholderVal: String
     var placeholder: String? {
+        get {
+            return placeholderVal
+        }
         set {
             placeholderVal = newValue ?? ""
             configureTextFieldPlaceholder()
         }
-        get {
-            return placeholderVal
-        }
     }
 
     private var fontSize: CGFloat {
@@ -21,13 +21,13 @@ class TextFieldCell: UITableViewCell {
     }
 
     private var preferValue: Bool {
+        get {
+            textField.contentCompressionResistancePriority(for: .horizontal) == .defaultHigh
+        }
         set {
             textField.setContentCompressionResistancePriority( newValue ? .defaultHigh : .defaultLow, for: .horizontal)
             title.setContentCompressionResistancePriority( newValue ? .defaultLow : .defaultHigh, for: .horizontal)
         }
-        get {
-            textField.contentCompressionResistancePriority(for: .horizontal) == .defaultHigh
-        }
     }
 
     private var customConstraints: [NSLayoutConstraint] = []

+ 1 - 1
deltachat-ios/ViewModel/ChatListViewModel.swift

@@ -183,7 +183,7 @@ class ChatListViewModel: NSObject {
     func archiveChatToggle(chatId: Int) {
         let chat = dcContext.getChat(chatId: chatId)
         let isArchivedBefore = chat.isArchived
-        if (!isArchivedBefore) {
+        if !isArchivedBefore {
             NotificationManager.removeNotificationsForChat(chatId: chatId)
         }
         dcContext.archiveChat(chatId: chatId, archive: !isArchivedBefore)