Clean up mini recorder components and fix sizing
This commit is contained in:
parent
501a97658c
commit
4a397a15c6
@ -12,35 +12,34 @@ class MiniRecorderPanel: NSPanel {
|
||||
backing: .buffered,
|
||||
defer: false
|
||||
)
|
||||
|
||||
self.isFloatingPanel = true
|
||||
self.level = .floating
|
||||
self.backgroundColor = .clear
|
||||
self.isOpaque = false
|
||||
self.hasShadow = false
|
||||
self.isMovableByWindowBackground = true
|
||||
self.hidesOnDeactivate = false
|
||||
self.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary]
|
||||
|
||||
self.titlebarAppearsTransparent = true
|
||||
self.titleVisibility = .hidden
|
||||
|
||||
self.standardWindowButton(.closeButton)?.isHidden = true
|
||||
|
||||
self.isMovable = true
|
||||
configurePanel()
|
||||
}
|
||||
|
||||
private func configurePanel() {
|
||||
isFloatingPanel = true
|
||||
level = .floating
|
||||
hidesOnDeactivate = false
|
||||
collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary]
|
||||
isMovable = true
|
||||
isMovableByWindowBackground = true
|
||||
backgroundColor = .clear
|
||||
isOpaque = false
|
||||
hasShadow = false
|
||||
titlebarAppearsTransparent = true
|
||||
titleVisibility = .hidden
|
||||
standardWindowButton(.closeButton)?.isHidden = true
|
||||
}
|
||||
|
||||
static func calculateWindowMetrics() -> NSRect {
|
||||
guard let screen = NSScreen.main else {
|
||||
return NSRect(x: 0, y: 0, width: 150, height: 34)
|
||||
return NSRect(x: 0, y: 0, width: 160, height: 34)
|
||||
}
|
||||
|
||||
let width: CGFloat = 150 // Adjusted for new spacing and negative padding
|
||||
let width: CGFloat = 160
|
||||
let height: CGFloat = 34
|
||||
let padding: CGFloat = 24
|
||||
|
||||
let visibleFrame = screen.visibleFrame
|
||||
|
||||
let xPosition = visibleFrame.midX - (width / 2)
|
||||
let yPosition = visibleFrame.minY + padding
|
||||
|
||||
|
||||
@ -4,11 +4,10 @@ struct MiniRecorderView: View {
|
||||
@ObservedObject var whisperState: WhisperState
|
||||
@ObservedObject var recorder: Recorder
|
||||
@EnvironmentObject var windowManager: MiniWindowManager
|
||||
@EnvironmentObject private var enhancementService: AIEnhancementService
|
||||
|
||||
@State private var showPowerModePopover = false
|
||||
@State private var showEnhancementPromptPopover = false
|
||||
@ObservedObject private var powerModeManager = PowerModeManager.shared
|
||||
|
||||
@EnvironmentObject private var enhancementService: AIEnhancementService
|
||||
|
||||
private var backgroundView: some View {
|
||||
ZStack {
|
||||
@ -34,8 +33,6 @@ struct MiniRecorderView: View {
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
var body: some View {
|
||||
Group {
|
||||
if windowManager.isVisible {
|
||||
@ -52,13 +49,12 @@ struct MiniRecorderView: View {
|
||||
|
||||
statusView
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.horizontal, 8)
|
||||
.padding(.horizontal, 6)
|
||||
|
||||
RecorderPowerModeButton(showPopover: $showPowerModePopover)
|
||||
}
|
||||
.padding(.vertical, 8)
|
||||
}
|
||||
.opacity(windowManager.isVisible ? 1 : 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,7 +11,14 @@ class MiniWindowManager: ObservableObject {
|
||||
init(whisperState: WhisperState, recorder: Recorder) {
|
||||
self.whisperState = whisperState
|
||||
self.recorder = recorder
|
||||
|
||||
setupNotifications()
|
||||
}
|
||||
|
||||
deinit {
|
||||
NotificationCenter.default.removeObserver(self)
|
||||
}
|
||||
|
||||
private func setupNotifications() {
|
||||
NotificationCenter.default.addObserver(
|
||||
self,
|
||||
selector: #selector(handleHideNotification),
|
||||
@ -20,14 +27,9 @@ class MiniWindowManager: ObservableObject {
|
||||
)
|
||||
}
|
||||
|
||||
deinit {
|
||||
NotificationCenter.default.removeObserver(self)
|
||||
}
|
||||
|
||||
@objc private func handleHideNotification() {
|
||||
hide()
|
||||
}
|
||||
|
||||
func show() {
|
||||
if isVisible { return }
|
||||
|
||||
|
||||
@ -128,7 +128,7 @@ struct RecorderPromptButton: View {
|
||||
let buttonSize: CGFloat
|
||||
let padding: EdgeInsets
|
||||
|
||||
init(showPopover: Binding<Bool>, buttonSize: CGFloat = 24, padding: EdgeInsets = EdgeInsets(top: 0, leading: 8, bottom: 0, trailing: 0)) {
|
||||
init(showPopover: Binding<Bool>, buttonSize: CGFloat = 24, padding: EdgeInsets = EdgeInsets(top: 0, leading: 6, bottom: 0, trailing: 0)) {
|
||||
self._showPopover = showPopover
|
||||
self.buttonSize = buttonSize
|
||||
self.padding = padding
|
||||
@ -163,7 +163,7 @@ struct RecorderPowerModeButton: View {
|
||||
let buttonSize: CGFloat
|
||||
let padding: EdgeInsets
|
||||
|
||||
init(showPopover: Binding<Bool>, buttonSize: CGFloat = 24, padding: EdgeInsets = EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 8)) {
|
||||
init(showPopover: Binding<Bool>, buttonSize: CGFloat = 24, padding: EdgeInsets = EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 6)) {
|
||||
self._showPopover = showPopover
|
||||
self.buttonSize = buttonSize
|
||||
self.padding = padding
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user