fix: bottom corner for last pick sever cell missing issue
This commit is contained in:
parent
5c6618f13e
commit
395f254f55
|
@ -6,6 +6,7 @@
|
|||
//
|
||||
|
||||
import Foundation
|
||||
import Combine
|
||||
import MastodonSDK
|
||||
|
||||
/// Note: update Equatable when change case
|
||||
|
@ -19,11 +20,11 @@ enum PickServerItem {
|
|||
|
||||
extension PickServerItem {
|
||||
final class ServerItemAttribute: Equatable, Hashable {
|
||||
var isLast: Bool
|
||||
var isLast: CurrentValueSubject<Bool, Never>
|
||||
var isExpand: Bool
|
||||
|
||||
init(isLast: Bool, isExpand: Bool) {
|
||||
self.isLast = isLast
|
||||
self.isLast = CurrentValueSubject(isLast)
|
||||
self.isExpand = isExpand
|
||||
}
|
||||
|
||||
|
|
|
@ -83,16 +83,24 @@ extension PickServerSection {
|
|||
|
||||
cell.updateExpandMode(mode: attribute.isExpand ? .expand : .collapse)
|
||||
|
||||
if attribute.isLast {
|
||||
cell.containerView.layer.maskedCorners = [
|
||||
.layerMinXMaxYCorner,
|
||||
.layerMaxXMaxYCorner
|
||||
]
|
||||
cell.containerView.layer.cornerCurve = .continuous
|
||||
cell.containerView.layer.cornerRadius = MastodonPickServerAppearance.tableViewCornerRadius
|
||||
} else {
|
||||
cell.containerView.layer.cornerRadius = 0
|
||||
}
|
||||
attribute.isLast
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak cell] isLast in
|
||||
guard let cell = cell else { return }
|
||||
if isLast {
|
||||
cell.containerView.layer.maskedCorners = [
|
||||
.layerMinXMaxYCorner,
|
||||
.layerMaxXMaxYCorner
|
||||
]
|
||||
cell.containerView.layer.cornerCurve = .continuous
|
||||
cell.containerView.layer.cornerRadius = MastodonPickServerAppearance.tableViewCornerRadius
|
||||
cell.containerView.layer.masksToBounds = true
|
||||
} else {
|
||||
cell.containerView.layer.cornerRadius = 0
|
||||
cell.containerView.layer.masksToBounds = false
|
||||
}
|
||||
}
|
||||
.store(in: &cell.disposeBag)
|
||||
|
||||
cell.expandMode
|
||||
.receive(on: DispatchQueue.main)
|
||||
|
@ -152,8 +160,10 @@ extension PickServerSection {
|
|||
]
|
||||
cell.containerView.layer.cornerCurve = .continuous
|
||||
cell.containerView.layer.cornerRadius = MastodonPickServerAppearance.tableViewCornerRadius
|
||||
cell.containerView.layer.masksToBounds = true
|
||||
} else {
|
||||
cell.containerView.layer.cornerRadius = 0
|
||||
cell.containerView.layer.masksToBounds = false
|
||||
}
|
||||
|
||||
attribute.isNoResult ? cell.stopAnimating() : cell.startAnimating()
|
||||
|
|
|
@ -109,7 +109,7 @@ extension MastodonPickServerViewModel {
|
|||
var serverItems: [PickServerItem] = []
|
||||
for server in indexedServers {
|
||||
let attribute = oldSnapshotServerItemAttributeDict[server.domain] ?? PickServerItem.ServerItemAttribute(isLast: false, isExpand: false)
|
||||
attribute.isLast = false
|
||||
attribute.isLast.value = false
|
||||
let item = PickServerItem.server(server: server, attribute: attribute)
|
||||
guard !serverItems.contains(item) else { continue }
|
||||
serverItems.append(item)
|
||||
|
@ -119,7 +119,7 @@ extension MastodonPickServerViewModel {
|
|||
if !unindexedServers.isEmpty {
|
||||
for server in unindexedServers {
|
||||
let attribute = oldSnapshotServerItemAttributeDict[server.domain] ?? PickServerItem.ServerItemAttribute(isLast: false, isExpand: false)
|
||||
attribute.isLast = false
|
||||
attribute.isLast.value = false
|
||||
let item = PickServerItem.server(server: server, attribute: attribute)
|
||||
guard !serverItems.contains(item) else { continue }
|
||||
serverItems.append(item)
|
||||
|
@ -134,7 +134,7 @@ extension MastodonPickServerViewModel {
|
|||
}
|
||||
|
||||
if case let .server(_, attribute) = serverItems.last {
|
||||
attribute.isLast = true
|
||||
attribute.isLast.value = true
|
||||
}
|
||||
if case let .loader(attribute) = serverItems.last {
|
||||
attribute.isLast = true
|
||||
|
|
Loading…
Reference in New Issue