How implement cell like TimeSeparator but with more complex layout
- Dominant language
- Swift
- Stars
- 4.6k
- Forks
- 588
- PR merge metrics
- No merged PRs in 30d
Description
I want create cell that placed in horizontal center of chat (content of cell can changes)
```swift
private func commonInit() {
//panelView - colored background view with rounded corners
self.panelView.add(subviews: [iconView, label])
self.contentView.add(subviews: [panelView])
}
```
```swift
override func layoutSubviews() {
super.layoutSubviews()
let maxSize = self.contentView.bounds.size
let iconViewBounds = CGRect(origin: CGPoint(x: VoipMessageCellUI.insets, y: VoipMessageCellUI.insets), size: VoipMessageCellUI.iconSize)
let maxLabelSize = CGSize(width: maxSize.width - (iconViewBounds.maxX + VoipMessageCellUI.insets),
height: maxSize.height - VoipMessageCellUI.insets * 2 )
let labelSize = self.label.sizeThatFits(maxLabelSize)
let labelOrigin = CGPoint(x: iconViewBounds.maxX + VoipMessageCellUI.insets, y: (maxSize.height - labelSize.height)/2)
let labelBounds = CGRect(origin: labelOrigin, size: labelSize)
self.iconView.bma_rect = iconViewBounds
self.label.bma_rect = labelBounds
let panelSize = CGSize(width: labelBounds.maxX + VoipMessageCellUI.insets, height: maxSize.height)
let panelBounds = CGRect (origin: CGPoint(x: (maxSize.width - panelSize.width), y: 0), size: panelSize )
self.panelView.bma_rect = panelBounds
self.panelView.center = self.contentView.center
// Code below i comment/uncomment withouth success
// self.panelView.layoutSubviews()
//
// self.panelView.bma_rect = panelBounds
// self.panelView.center = self.contentView.center
}
```
Some times after refreshing `panelView.bounds` become zero (((
Contributor guide
Research direction
Start by comparing the existing TimeSeparator cell with the shown commonInit() and layoutSubviews() entry points, then trace what happens during refresh when panelView.bounds becomes zero. Done means the new horizontally centered cell has the intended changing content and retains a nonzero panelView layout after refresh.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- mobile-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100