fix: hide overlay scrollbar unless content overflows
This commit is contained in:
@@ -16,6 +16,7 @@ final class VoiceWakeOverlayController: ObservableObject {
|
|||||||
var forwardEnabled: Bool = false
|
var forwardEnabled: Bool = false
|
||||||
var isSending: Bool = false
|
var isSending: Bool = false
|
||||||
var attributed: NSAttributedString = NSAttributedString(string: "")
|
var attributed: NSAttributedString = NSAttributedString(string: "")
|
||||||
|
var isOverflowing: Bool = false
|
||||||
}
|
}
|
||||||
|
|
||||||
private var window: NSPanel?
|
private var window: NSPanel?
|
||||||
@@ -209,6 +210,7 @@ final class VoiceWakeOverlayController: ObservableObject {
|
|||||||
|
|
||||||
let contentHeight = ceil(used.height + (textInset.height * 2))
|
let contentHeight = ceil(used.height + (textInset.height * 2))
|
||||||
let total = contentHeight + self.verticalPadding * 2
|
let total = contentHeight + self.verticalPadding * 2
|
||||||
|
self.model.isOverflowing = total > 400
|
||||||
return max(48, min(total, 400))
|
return max(48, min(total, 400))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,6 +260,7 @@ private struct VoiceWakeOverlayView: View {
|
|||||||
set: { self.controller.updateText($0) }),
|
set: { self.controller.updateText($0) }),
|
||||||
attributed: self.controller.model.attributed,
|
attributed: self.controller.model.attributed,
|
||||||
isFinal: self.controller.model.isFinal,
|
isFinal: self.controller.model.isFinal,
|
||||||
|
isOverflowing: self.controller.model.isOverflowing,
|
||||||
onBeginEditing: {
|
onBeginEditing: {
|
||||||
self.controller.userBeganEditing()
|
self.controller.userBeganEditing()
|
||||||
},
|
},
|
||||||
@@ -313,6 +316,7 @@ private struct TranscriptTextView: NSViewRepresentable {
|
|||||||
@Binding var text: String
|
@Binding var text: String
|
||||||
var attributed: NSAttributedString
|
var attributed: NSAttributedString
|
||||||
var isFinal: Bool
|
var isFinal: Bool
|
||||||
|
var isOverflowing: Bool
|
||||||
var onBeginEditing: () -> Void
|
var onBeginEditing: () -> Void
|
||||||
var onSend: () -> Void
|
var onSend: () -> Void
|
||||||
|
|
||||||
@@ -354,7 +358,9 @@ private struct TranscriptTextView: NSViewRepresentable {
|
|||||||
let scroll = NSScrollView()
|
let scroll = NSScrollView()
|
||||||
scroll.drawsBackground = false
|
scroll.drawsBackground = false
|
||||||
scroll.borderType = .noBorder
|
scroll.borderType = .noBorder
|
||||||
scroll.hasVerticalScroller = true
|
scroll.hasVerticalScroller = self.isOverflowing
|
||||||
|
scroll.autohidesScrollers = true
|
||||||
|
scroll.scrollerStyle = .overlay
|
||||||
scroll.hasHorizontalScroller = false
|
scroll.hasHorizontalScroller = false
|
||||||
scroll.documentView = textView
|
scroll.documentView = textView
|
||||||
return scroll
|
return scroll
|
||||||
|
|||||||
Reference in New Issue
Block a user