浏览代码

fix indentation in ProfileView

cyberta 6 年之前
父节点
当前提交
0f2a253b7b
共有 2 个文件被更改,包括 180 次插入180 次删除
  1. 1 1
      deltachat-ios.xcodeproj/project.pbxproj
  2. 179 179
      deltachat-ios/View/ProfileView.swift

+ 1 - 1
deltachat-ios.xcodeproj/project.pbxproj

@@ -147,7 +147,7 @@
 		306011C722E5E82E00C1CE6F /* lt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = lt; path = lt.lproj/Localizable.stringsdict; sourceTree = "<group>"; };
 		306011C722E5E82E00C1CE6F /* lt */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = lt; path = lt.lproj/Localizable.stringsdict; sourceTree = "<group>"; };
 		306011C822E5E83100C1CE6F /* zh-Hant-TW */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = "zh-Hant-TW"; path = "zh-Hant-TW.lproj/Localizable.stringsdict"; sourceTree = "<group>"; };
 		306011C822E5E83100C1CE6F /* zh-Hant-TW */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = "zh-Hant-TW"; path = "zh-Hant-TW.lproj/Localizable.stringsdict"; sourceTree = "<group>"; };
 		306011C922E5E83500C1CE6F /* uk */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = uk; path = uk.lproj/Localizable.stringsdict; sourceTree = "<group>"; };
 		306011C922E5E83500C1CE6F /* uk */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = uk; path = uk.lproj/Localizable.stringsdict; sourceTree = "<group>"; };
-		30BD261322F8679200F399DF /* ProfileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileView.swift; sourceTree = "<group>"; };
+		30BD261322F8679200F399DF /* ProfileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileView.swift; sourceTree = "<group>"; usesTabs = 0; };
 		30BD261522F8812700F399DF /* UIView+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Extension.swift"; sourceTree = "<group>"; usesTabs = 0; };
 		30BD261522F8812700F399DF /* UIView+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Extension.swift"; sourceTree = "<group>"; usesTabs = 0; };
 		6241BE1534A653E79AD5D01D /* Pods_deltachat_ios.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_deltachat_ios.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		6241BE1534A653E79AD5D01D /* Pods_deltachat_ios.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_deltachat_ios.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 		7070FB9A2101ECBB000DC258 /* GroupNameController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupNameController.swift; sourceTree = "<group>"; };
 		7070FB9A2101ECBB000DC258 /* GroupNameController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupNameController.swift; sourceTree = "<group>"; };

+ 179 - 179
deltachat-ios/View/ProfileView.swift

@@ -2,183 +2,183 @@ import UIKit
 
 
 class ProfileView: UIView {
 class ProfileView: UIView {
 
 
-	private let initialsLabelSize: CGFloat = 54
-	private let imgSize: CGFloat = 25
-	
-	override init(frame: CGRect) {
-		super.init(frame: frame)
-		translatesAutoresizingMaskIntoConstraints = false
-		setupSubviews()
-	}
-	
-	required init?(coder _: NSCoder) {
-		fatalError("init(coder:) has not been implemented")
-	}
-
-	let avatar: UIView = {
-		let avatar = UIView()
-		return avatar
-	}()
-	
-	lazy var imgView: UIImageView = {
-		let imgView = UIImageView()
-		let img = UIImage(named: "approval")!.withRenderingMode(.alwaysTemplate)
-		imgView.isHidden = true
-		imgView.image = img
-		imgView.bounds = CGRect(
-			x: 0,
-			y: 0,
-			width: imgSize, height: imgSize
-		)
-		return imgView
-	}()
-	
-	lazy var initialsLabel: UILabel = {
-		let initialsLabel = UILabel()
-		initialsLabel.textAlignment = NSTextAlignment.center
-		initialsLabel.textColor = UIColor.white
-		initialsLabel.font = UIFont.systemFont(ofSize: 22)
-		initialsLabel.backgroundColor = UIColor.green
-		let initialsLabelCornerRadius = (initialsLabelSize - 6) / 2
-		initialsLabel.layer.cornerRadius = initialsLabelCornerRadius
-		initialsLabel.clipsToBounds = true
-		return initialsLabel
-	}()
-	
-	let nameLabel: UILabel = {
-		let label = UILabel()
-		label.font = UIFont.systemFont(ofSize: 16, weight: .medium)
-		label.lineBreakMode = .byTruncatingTail
-		label.textColor = UIColor(hexString: "2f3944")
-		// label.makeBorder()
-		return label
-		
-	}()
-	
-	let emailLabel: UILabel = {
-		let label = UILabel()
-		label.font = UIFont.systemFont(ofSize: 14)
-		label.textColor = UIColor(hexString: "848ba7")
-		label.lineBreakMode = .byTruncatingTail
-		return label
-	}()
-	
-	/*private let timeLabel: UILabel = {
-		let label = UILabel()
-		label.font = UIFont.systemFont(ofSize: 14)
-		label.textColor = UIColor(hexString: "848ba7")
-		label.textAlignment = .right
-		// label.makeBorder()
-		return label
-	}()*/
-	
-	/*private let deliveryStatusIndicator: UIImageView = {
-		let view = UIImageView()
-		view.tintColor = UIColor.green
-		view.isHidden = true
-		return view
-	}()*/
-	
-	var darkMode: Bool = false {
-		didSet {
-			if darkMode {
-				self.backgroundColor = UIColor.darkGray
-				nameLabel.textColor = UIColor.white
-				emailLabel.textColor = UIColor.white
-			}
-		}
-	}
-	
-	
-	
-	private func setupSubviews() {
-		let margin: CGFloat = 10
-		
-		initialsLabel.translatesAutoresizingMaskIntoConstraints = false
-		avatar.translatesAutoresizingMaskIntoConstraints = false
-		initialsLabel.widthAnchor.constraint(equalToConstant: initialsLabelSize - 6).isActive = true
-		initialsLabel.heightAnchor.constraint(equalToConstant: initialsLabelSize - 6).isActive = true
-		// avatar.backgroundColor = .red
-		
-		avatar.widthAnchor.constraint(equalToConstant: initialsLabelSize).isActive = true
-		avatar.heightAnchor.constraint(equalToConstant: initialsLabelSize).isActive = true
-		
-		avatar.addSubview(initialsLabel)
-		self.addSubview(avatar)
-		
-		initialsLabel.topAnchor.constraint(equalTo: avatar.topAnchor, constant: 3).isActive = true
-		initialsLabel.leadingAnchor.constraint(equalTo: avatar.leadingAnchor, constant: 3).isActive = true
-		initialsLabel.trailingAnchor.constraint(equalTo: avatar.trailingAnchor, constant: -3).isActive = true
-		
-		avatar.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: margin).isActive = true
-		avatar.center.y = self.center.y
-		avatar.center.x += initialsLabelSize / 2
-		avatar.topAnchor.constraint(equalTo: self.topAnchor, constant: margin).isActive = true
-		avatar.bottomAnchor.constraint(lessThanOrEqualTo: self.bottomAnchor, constant: -margin).isActive = true
-		initialsLabel.center = avatar.center
-		
-		//deliveryStatusIndicator.translatesAutoresizingMaskIntoConstraints = false
-		//deliveryStatusIndicator.heightAnchor.constraint(equalToConstant: 25).isActive = true
-		//deliveryStatusIndicator.widthAnchor.constraint(equalToConstant: 25).isActive = true
-		
-		let myStackView = UIStackView()
-		myStackView.translatesAutoresizingMaskIntoConstraints = false
-		myStackView.clipsToBounds = true
-		
-		let toplineStackView = UIStackView()
-		toplineStackView.axis = .horizontal
-		
-		let bottomLineStackView = UIStackView()
-		bottomLineStackView.axis = .horizontal
-		
-		toplineStackView.addArrangedSubview(nameLabel)
-		//toplineStackView.addArrangedSubview(timeLabel)
-		
-		bottomLineStackView.addArrangedSubview(emailLabel)
-		//bottomLineStackView.addArrangedSubview(deliveryStatusIndicator)
-		
-		self.addSubview(myStackView)
-		myStackView.leadingAnchor.constraint(equalTo: avatar.trailingAnchor, constant: margin).isActive = true
-		myStackView.centerYAnchor.constraint(equalTo: avatar.centerYAnchor).isActive = true
-		myStackView.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -margin).isActive = true
-		myStackView.axis = .vertical
-		myStackView.addArrangedSubview(toplineStackView)
-		myStackView.addArrangedSubview(bottomLineStackView)
-		
-		imgView.tintColor = DCColors.primary
-		
-		avatar.addSubview(imgView)
-		
-		imgView.center.x = avatar.center.x + (avatar.frame.width / 2) + imgSize - 5
-		imgView.center.y = avatar.center.y + (avatar.frame.height / 2) + imgSize - 5
-	}
-
-	func setBackgroundColor(_ color: UIColor) {
-		self.backgroundColor = color
-	}
-	
-	func setColor(_ color: UIColor) {
-		initialsLabel.backgroundColor = color
-	}
-	
-	func setVerified(isVerified: Bool) {
-		imgView.isHidden = !isVerified
-	}
-	
-	func setImage(_ img: UIImage) {
-		let attachment = NSTextAttachment()
-		attachment.image = img
-		initialsLabel.attributedText = NSAttributedString(attachment: attachment)
-	}
-	
-	func setBackupImage(name: String, color: UIColor) {
-		let text = Utils.getInitials(inputName: name)
-		
-		initialsLabel.textAlignment = .center
-		initialsLabel.text = text
-		
-		setColor(color)
-	}
-
-	
+    private let initialsLabelSize: CGFloat = 54
+    private let imgSize: CGFloat = 25
+
+    override init(frame: CGRect) {
+        super.init(frame: frame)
+        translatesAutoresizingMaskIntoConstraints = false
+        setupSubviews()
+    }
+
+    required init?(coder _: NSCoder) {
+        fatalError("init(coder:) has not been implemented")
+    }
+
+    let avatar: UIView = {
+        let avatar = UIView()
+        return avatar
+    }()
+
+    lazy var imgView: UIImageView = {
+        let imgView = UIImageView()
+        let img = UIImage(named: "approval")!.withRenderingMode(.alwaysTemplate)
+        imgView.isHidden = true
+        imgView.image = img
+        imgView.bounds = CGRect(
+            x: 0,
+            y: 0,
+            width: imgSize, height: imgSize
+        )
+        return imgView
+    }()
+
+    lazy var initialsLabel: UILabel = {
+        let initialsLabel = UILabel()
+        initialsLabel.textAlignment = NSTextAlignment.center
+        initialsLabel.textColor = UIColor.white
+        initialsLabel.font = UIFont.systemFont(ofSize: 22)
+        initialsLabel.backgroundColor = UIColor.green
+        let initialsLabelCornerRadius = (initialsLabelSize - 6) / 2
+        initialsLabel.layer.cornerRadius = initialsLabelCornerRadius
+        initialsLabel.clipsToBounds = true
+        return initialsLabel
+    }()
+
+    let nameLabel: UILabel = {
+        let label = UILabel()
+        label.font = UIFont.systemFont(ofSize: 16, weight: .medium)
+        label.lineBreakMode = .byTruncatingTail
+        label.textColor = UIColor(hexString: "2f3944")
+        // label.makeBorder()
+        return label
+
+    }()
+
+    let emailLabel: UILabel = {
+        let label = UILabel()
+        label.font = UIFont.systemFont(ofSize: 14)
+        label.textColor = UIColor(hexString: "848ba7")
+        label.lineBreakMode = .byTruncatingTail
+        return label
+    }()
+
+    /*private let timeLabel: UILabel = {
+     let label = UILabel()
+     label.font = UIFont.systemFont(ofSize: 14)
+     label.textColor = UIColor(hexString: "848ba7")
+     label.textAlignment = .right
+     // label.makeBorder()
+     return label
+     }()*/
+
+    /*private let deliveryStatusIndicator: UIImageView = {
+     let view = UIImageView()
+     view.tintColor = UIColor.green
+     view.isHidden = true
+     return view
+     }()*/
+
+    var darkMode: Bool = false {
+        didSet {
+            if darkMode {
+                self.backgroundColor = UIColor.darkGray
+                nameLabel.textColor = UIColor.white
+                emailLabel.textColor = UIColor.white
+            }
+        }
+    }
+
+
+
+    private func setupSubviews() {
+        let margin: CGFloat = 10
+
+        initialsLabel.translatesAutoresizingMaskIntoConstraints = false
+        avatar.translatesAutoresizingMaskIntoConstraints = false
+        initialsLabel.widthAnchor.constraint(equalToConstant: initialsLabelSize - 6).isActive = true
+        initialsLabel.heightAnchor.constraint(equalToConstant: initialsLabelSize - 6).isActive = true
+        // avatar.backgroundColor = .red
+
+        avatar.widthAnchor.constraint(equalToConstant: initialsLabelSize).isActive = true
+        avatar.heightAnchor.constraint(equalToConstant: initialsLabelSize).isActive = true
+
+        avatar.addSubview(initialsLabel)
+        self.addSubview(avatar)
+
+        initialsLabel.topAnchor.constraint(equalTo: avatar.topAnchor, constant: 3).isActive = true
+        initialsLabel.leadingAnchor.constraint(equalTo: avatar.leadingAnchor, constant: 3).isActive = true
+        initialsLabel.trailingAnchor.constraint(equalTo: avatar.trailingAnchor, constant: -3).isActive = true
+
+        avatar.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: margin).isActive = true
+        avatar.center.y = self.center.y
+        avatar.center.x += initialsLabelSize / 2
+        avatar.topAnchor.constraint(equalTo: self.topAnchor, constant: margin).isActive = true
+        avatar.bottomAnchor.constraint(lessThanOrEqualTo: self.bottomAnchor, constant: -margin).isActive = true
+        initialsLabel.center = avatar.center
+
+        //deliveryStatusIndicator.translatesAutoresizingMaskIntoConstraints = false
+        //deliveryStatusIndicator.heightAnchor.constraint(equalToConstant: 25).isActive = true
+        //deliveryStatusIndicator.widthAnchor.constraint(equalToConstant: 25).isActive = true
+
+        let myStackView = UIStackView()
+        myStackView.translatesAutoresizingMaskIntoConstraints = false
+        myStackView.clipsToBounds = true
+
+        let toplineStackView = UIStackView()
+        toplineStackView.axis = .horizontal
+
+        let bottomLineStackView = UIStackView()
+        bottomLineStackView.axis = .horizontal
+
+        toplineStackView.addArrangedSubview(nameLabel)
+        //toplineStackView.addArrangedSubview(timeLabel)
+
+        bottomLineStackView.addArrangedSubview(emailLabel)
+        //bottomLineStackView.addArrangedSubview(deliveryStatusIndicator)
+
+        self.addSubview(myStackView)
+        myStackView.leadingAnchor.constraint(equalTo: avatar.trailingAnchor, constant: margin).isActive = true
+        myStackView.centerYAnchor.constraint(equalTo: avatar.centerYAnchor).isActive = true
+        myStackView.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: -margin).isActive = true
+        myStackView.axis = .vertical
+        myStackView.addArrangedSubview(toplineStackView)
+        myStackView.addArrangedSubview(bottomLineStackView)
+
+        imgView.tintColor = DCColors.primary
+
+        avatar.addSubview(imgView)
+
+        imgView.center.x = avatar.center.x + (avatar.frame.width / 2) + imgSize - 5
+        imgView.center.y = avatar.center.y + (avatar.frame.height / 2) + imgSize - 5
+    }
+
+    func setBackgroundColor(_ color: UIColor) {
+        self.backgroundColor = color
+    }
+
+    func setColor(_ color: UIColor) {
+        initialsLabel.backgroundColor = color
+    }
+
+    func setVerified(isVerified: Bool) {
+        imgView.isHidden = !isVerified
+    }
+
+    func setImage(_ img: UIImage) {
+        let attachment = NSTextAttachment()
+        attachment.image = img
+        initialsLabel.attributedText = NSAttributedString(attachment: attachment)
+    }
+
+    func setBackupImage(name: String, color: UIColor) {
+        let text = Utils.getInitials(inputName: name)
+
+        initialsLabel.textAlignment = .center
+        initialsLabel.text = text
+
+        setColor(color)
+    }
+
+
 }
 }