Jotley / app · jotley.ai / macOS / Views / CustomOverlays.swift
| 1 | // |
| 2 | // CustomOverlays.swift |
| 3 | // Jotley |
| 4 | // |
| 5 | // Custom overlay components extracted from NoteDetailPlaceholderView+Body.swift |
| 6 | // |
| 7 | |
| 8 | import SwiftUI |
| 9 | |
| 10 | /// Custom overlay for the more menu |
| 11 | struct CustomMoreMenuOverlay<Content: View>: View { |
| 12 | @Binding var isPresented: Bool |
| 13 | let content: Content |
| 14 | |
| 15 | @State private var opacity: Double = 0 |
| 16 | @State private var scale: CGFloat = 0.92 |
| 17 | |
| 18 | var body: some View { |
| 19 | ZStack(alignment: .topTrailing) { |
| 20 | // Invisible background to capture clicks outside |
| 21 | Color.clear |
| 22 | .contentShape(Rectangle()) |
| 23 | .onTapGesture { |
| 24 | dismiss() |
| 25 | } |
| 26 | .ignoresSafeArea() |
| 27 | |
| 28 | // Position menu at top-right, below the button |
| 29 | content |
| 30 | .fixedSize() |
| 31 | .scaleEffect(scale, anchor: .topTrailing) |
| 32 | .opacity(opacity) |
| 33 | .padding(.top, MacNoteHeaderLayout.menuTopInset) |
| 34 | .padding(.trailing, 16) // Align with right edge |
| 35 | } |
| 36 | .zIndex(1000) |
| 37 | .onExitCommand { dismiss() } |
| 38 | .onAppear { |
| 39 | withAnimation(.easeOut(duration: 0.14)) { |
| 40 | opacity = 1 |
| 41 | scale = 1 |
| 42 | } |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | private func dismiss() { |
| 47 | withAnimation(.easeOut(duration: 0.15)) { |
| 48 | opacity = 0 |
| 49 | scale = 0.92 |
| 50 | } |
| 51 | DispatchQueue.main.asyncAfter(deadline: .now() + 0.15) { |
| 52 | isPresented = false |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | // MARK: - Transcript Button Indicator Wrapper |