Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CIS-1073] Change ContainerStackView assertions #1328

Merged
merged 1 commit into from
Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Fix hiding already hidden channels not working [#1327](https://github.com/GetStream/stream-chat-swift/issues/1327)

### 🔄 Changed
- `ContainerStackView` doesn't `assert` when trying to remove a subview, these operations are now no-op [#1328](https://github.com/GetStream/stream-chat-swift/issues/1328)

# [4.0.0-beta.8](https://github.com/GetStream/stream-chat-swift/releases/tag/4.0.0-beta.8)
_July 21, 2021_
Expand Down
19 changes: 17 additions & 2 deletions Sources/StreamChatUI/CommonViews/ContainerStackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright © 2021 Stream.io Inc. All rights reserved.
//

import StreamChat
import UIKit

extension ContainerStackView {
Expand Down Expand Up @@ -216,7 +217,14 @@ public class ContainerStackView: UIView {
/// Removes an arranged subview from the container.
/// - Parameter subview: The subview to be removed.
public func removeArrangedSubview(_ subview: UIView) {
assert(subviews.contains(subview))
guard subviews.contains(subview) else {
log.warning(
"Trying to remove subview \(subview) from ContainerStackView \(self)"
+ " but it wasn't added as a subview."
)
return
}

subview.removeFromSuperview()

// Reset hiding state from the removed view. This important especially if the view
Expand All @@ -240,7 +248,14 @@ public class ContainerStackView: UIView {
/// - spacing: The value of the spacing.
/// - subview: The subview that the spacing will be applied (after this subview).
func setCustomSpacing(_ spacing: Spacing, after subview: UIView) {
assert(subviews.contains(subview))
guard subviews.contains(subview) else {
log.warning(
"Trying to set custom spacing after subview \(subview) in ContainerStackView \(self)"
+ " but it wasn't added as a subview."
)
return
}

customSpacingByView[subview] = spacing.rawValue
invalidateConstraints()
}
Expand Down