TDKCandidates // Fix calculation mistakes in horizontal layout.
This commit is contained in:
parent
aa99475645
commit
ad1a96160b
|
@ -31,10 +31,9 @@ public struct CandidatePool {
|
|||
|
||||
// MARK: - 動態變數
|
||||
|
||||
public var maxRowWidth: Int { Int(Double(maxRowCapacity + 3) * 2) * Int(ceil(CandidateCellData.unifiedSize)) }
|
||||
public var maxRowWidth: Int { Int(ceil((Double(maxRowCapacity + 3) * 2 - 0.5) * CandidateCellData.unifiedSize)) }
|
||||
public var maxWindowWidth: Double {
|
||||
let testCell = CandidateCellData(key: "XX", displayedText: "XX", isSelected: false)
|
||||
return Double(maxRowCapacity) * (testCell.minWidthToDrawInSwiftUI + ceil(CandidateCellData.unifiedSize * 0.5))
|
||||
Double(maxRowCapacity) * (blankCell.minWidthToDrawInSwiftUI + ceil(CandidateCellData.unifiedSize * 0.5))
|
||||
}
|
||||
|
||||
public var currentLineNumber: Int {
|
||||
|
|
|
@ -66,10 +66,7 @@ public struct VwrCandidateHorizontal: View {
|
|||
ForEach(Array(thePool.candidateLines[rowIndex]), id: \.self) { currentCandidate in
|
||||
currentCandidate.attributedStringForSwiftUI.fixedSize()
|
||||
.contentShape(Rectangle())
|
||||
.frame(
|
||||
maxWidth: .infinity,
|
||||
alignment: .topLeading
|
||||
)
|
||||
.frame(alignment: .topLeading)
|
||||
.onTapGesture { didSelectCandidateAt(currentCandidate.index) }
|
||||
.contextMenu {
|
||||
if controller?.delegate?.isCandidateContextMenuEnabled ?? false {
|
||||
|
@ -91,7 +88,7 @@ public struct VwrCandidateHorizontal: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
Spacer(minLength: Double.infinity)
|
||||
Spacer()
|
||||
}.frame(
|
||||
minWidth: 0,
|
||||
maxWidth: .infinity,
|
||||
|
@ -104,7 +101,7 @@ public struct VwrCandidateHorizontal: View {
|
|||
HStack(spacing: 0) {
|
||||
thePool.blankCell.attributedStringForSwiftUI
|
||||
.contentShape(Rectangle())
|
||||
.frame(maxWidth: .infinity, alignment: .topLeading)
|
||||
.frame(alignment: .topLeading)
|
||||
Spacer()
|
||||
}.frame(
|
||||
minWidth: 0,
|
||||
|
|
|
@ -67,10 +67,7 @@ public struct VwrCandidateHorizontalBackports: View {
|
|||
ForEach(Array(thePool.candidateLines[rowIndex]), id: \.self) { currentCandidate in
|
||||
currentCandidate.attributedStringForSwiftUIBackports.fixedSize()
|
||||
.contentShape(Rectangle())
|
||||
.frame(
|
||||
maxWidth: .infinity,
|
||||
alignment: .topLeading
|
||||
)
|
||||
.frame(alignment: .topLeading)
|
||||
.onTapGesture { didSelectCandidateAt(currentCandidate.index) }
|
||||
.contextMenu {
|
||||
if controller?.delegate?.isCandidateContextMenuEnabled ?? false {
|
||||
|
@ -92,7 +89,7 @@ public struct VwrCandidateHorizontalBackports: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
Spacer(minLength: Double.infinity)
|
||||
Spacer()
|
||||
}.frame(
|
||||
minWidth: 0,
|
||||
maxWidth: .infinity,
|
||||
|
@ -105,7 +102,7 @@ public struct VwrCandidateHorizontalBackports: View {
|
|||
HStack(spacing: 0) {
|
||||
thePool.blankCell.attributedStringForSwiftUIBackports
|
||||
.contentShape(Rectangle())
|
||||
.frame(maxWidth: .infinity, alignment: .topLeading)
|
||||
.frame(alignment: .topLeading)
|
||||
Spacer()
|
||||
}.frame(
|
||||
minWidth: 0,
|
||||
|
|
Loading…
Reference in New Issue