diff --git a/Stepic/Images.xcassets/New placeholders/new-empty-noconnection.imageset/new-empty-noconnection.pdf b/Stepic/Images.xcassets/New placeholders/new-empty-noconnection.imageset/new-empty-noconnection.pdf index 6499247c40..e08483bbe6 100644 Binary files a/Stepic/Images.xcassets/New placeholders/new-empty-noconnection.imageset/new-empty-noconnection.pdf and b/Stepic/Images.xcassets/New placeholders/new-empty-noconnection.imageset/new-empty-noconnection.pdf differ diff --git a/Stepic/StepikPlaceholderStyle+Placeholders.swift b/Stepic/StepikPlaceholderStyle+Placeholders.swift index 1a3744ebb0..765567070e 100644 --- a/Stepic/StepikPlaceholderStyle+Placeholders.swift +++ b/Stepic/StepikPlaceholderStyle+Placeholders.swift @@ -14,7 +14,7 @@ extension StepikPlaceholder.Style { text: NSLocalizedString("PlaceholderEmptyText", comment: ""), buttonTitle: NSLocalizedString("PlaceholderEmptyButton", comment: "")) static let noConnection = StepikPlaceholderStyle(id: "noConnection", - image: PlaceholderImage(image: #imageLiteral(resourceName: "new-empty-noconnection"), scale: 0.35), + image: PlaceholderImage(image: #imageLiteral(resourceName: "new-empty-noconnection"), scale: 0.49), text: NSLocalizedString("PlaceholderNoConnectionText", comment: ""), buttonTitle: NSLocalizedString("PlaceholderNoConnectionButton", comment: "")) static let emptyDownloads = StepikPlaceholderStyle(id: "emptyDownloads", @@ -28,7 +28,7 @@ extension StepikPlaceholder.Style { static let emptyNotifications = StepikPlaceholderStyle(id: "emptyNotifications", image: PlaceholderImage(image: #imageLiteral(resourceName: "new-empty-notifications"), scale: 0.48), text: NSLocalizedString("PlaceholderEmptyNotificationsText", comment: ""), - buttonTitle: NSLocalizedString("PlaceholderEmptyNotificationsButton", comment: "")) + buttonTitle: nil) static let emptyNotificationsLoading = StepikPlaceholderStyle(id: "emptyNotificationsLoading", image: PlaceholderImage(image: #imageLiteral(resourceName: "new-empty-notifications"), scale: 0.48), text: NSLocalizedString("Refreshing", comment: ""), diff --git a/Stepic/StepikPlaceholderView.swift b/Stepic/StepikPlaceholderView.swift index 11080d504a..167342949d 100644 --- a/Stepic/StepikPlaceholderView.swift +++ b/Stepic/StepikPlaceholderView.swift @@ -63,7 +63,7 @@ class StepikPlaceholderView: NibInitializableView { actionButton.layer.borderWidth = 0.5 actionButton.layer.borderColor = UIColor(red: 204 / 255, green: 204 / 255, blue: 204 / 255, alpha: 1.0).cgColor - actionButton.contentEdgeInsets = UIEdgeInsets(top: 14.0, left: 25.0, bottom: 14.0, right: 25.0) + actionButton.contentEdgeInsets = UIEdgeInsets(top: 12.0, left: 23.0, bottom: 12.0, right: 23.0) actionButton.setTitleColor(UIColor(red: 83 / 255, green: 83 / 255, blue: 102 / 255, alpha: 1.0), for: .normal) } @@ -111,29 +111,43 @@ class StepikPlaceholderView: NibInitializableView { if isVertical { stackView.axis = .vertical stackView.distribution = .equalCentering + stackView.alignment = .fill } else { stackView.axis = .horizontal stackView.distribution = .fillEqually + stackView.alignment = .center + } + } + + override func updateConstraints() { + super.updateConstraints() + if let currentPlaceholder = self.currentPlaceholder { + self.rebuildConstraints(for: currentPlaceholder) } } override func layoutSubviews() { super.layoutSubviews() - DispatchQueue.main.async { [weak self] in - if let currentPlaceholder = self?.currentPlaceholder { - self?.rebuildConstraints(for: currentPlaceholder) - } - } + setNeedsUpdateConstraints() + updateConstraintsIfNeeded() } func set(placeholder: StepikPlaceholderStyle) { - currentPlaceholder = placeholder - imageView.image = placeholder.image?.image textLabel.text = placeholder.text - actionButton.setTitle(placeholder.buttonTitle, for: .normal) + // If it's first load prevent button title change animation + if currentPlaceholder == nil { + UIView.performWithoutAnimation { + self.actionButton.setTitle(placeholder.buttonTitle, for: .normal) + self.actionButton.layoutIfNeeded() + } + } else { + actionButton.setTitle(placeholder.buttonTitle, for: .normal) + } + + currentPlaceholder = placeholder rebuildConstraints(for: placeholder) } } diff --git a/Stepic/StepikPlaceholderView.xib b/Stepic/StepikPlaceholderView.xib index dab64f3cfb..33f3f69ef2 100644 --- a/Stepic/StepikPlaceholderView.xib +++ b/Stepic/StepikPlaceholderView.xib @@ -1,15 +1,14 @@ - + - - + - + @@ -26,14 +25,14 @@ - - + + - + - + @@ -50,19 +49,22 @@ - + - + -