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