Ver código fonte

left align scaled preview image

cyberta 3 anos atrás
pai
commit
50839dede3

+ 1 - 0
deltachat-ios/Chat/Views/Cells/WebxdcCell.swift

@@ -16,6 +16,7 @@ public class WebxdcCell: BaseMessageCell {
         let spacerView = UIView()
         spacer = spacerView.constraintHeightTo(8, priority: .defaultHigh)
         spacer?.isActive = true
+        spacerView.constraintWidthTo(300, priority: UILayoutPriority(rawValue: 400)).isActive = true
         mainContentView.addArrangedSubview(webxdcView)
         mainContentView.addArrangedSubview(spacerView)
         mainContentView.addArrangedSubview(messageLabel)

+ 5 - 6
deltachat-ios/Chat/Views/WebxdcPreview.swift

@@ -3,12 +3,12 @@ import DcCore
 
 public class WebxdcPreview: UIView {
     
-    private var imageWidthConstraint: NSLayoutConstraint?
-    private var imageHeightConstraint: NSLayoutConstraint?
-    
     lazy var imagePreview: UIImageView = {
         let view = UIImageView()
+        view.contentMode = .left
         view.translatesAutoresizingMaskIntoConstraints = false
+        view.layer.cornerRadius = 8
+        view.clipsToBounds = true
         return view
     }()
     
@@ -34,6 +34,7 @@ public class WebxdcPreview: UIView {
     lazy var containerStackView: UIStackView = {
         let view = UIStackView(arrangedSubviews: [imagePreview, titleView, subtitleView])
         view.axis = .vertical
+        view.alignment = .leading
         view.spacing = 6
         view.translatesAutoresizingMaskIntoConstraints = false
         return view
@@ -56,12 +57,10 @@ public class WebxdcPreview: UIView {
     private func setupSubviews() {
         addSubview(containerStackView)
         containerStackView.fillSuperview()
-        imageWidthConstraint = imagePreview.constraintWidthTo(80)
-        imageHeightConstraint = imagePreview.constraintHeightTo(80, priority: .defaultLow)
     }
     
     public func configure(message: DcMsg) {
-        imagePreview.image = message.getWebxdcIcon()
+        imagePreview.image = message.getWebxdcIcon()?.sd_resizedImage(with: CGSize(width: 175, height: 175), scaleMode: .aspectFill)
         titleView.text = message.getWebxdcName()
         subtitleView.text = message.getWebxdcSummary()
     }