diff --git a/Loop/AppDelegate.swift b/Loop/AppDelegate.swift index 78ed0204..eb36304e 100644 --- a/Loop/AppDelegate.swift +++ b/Loop/AppDelegate.swift @@ -27,16 +27,6 @@ class AppDelegate: NSObject, NSApplicationDelegate { await Defaults.iCloud.waitForSyncCompletion() } - // Check & ask for accessibility access - AccessibilityManager.requestAccess() - UNUserNotificationCenter.current().delegate = self - - AppDelegate.requestNotificationAuthorization() - - IconManager.refreshCurrentAppIcon() - AppDelegate.loopManager.start() - AppDelegate.windowDragManager.addObservers() - if !launchedAsLoginItem { LuminareManager.open() } else { @@ -45,6 +35,17 @@ class AppDelegate: NSObject, NSApplicationDelegate { NSApp.setActivationPolicy(.accessory) } } + + IconManager.refreshCurrentAppIcon() + AppDelegate.loopManager.start() + AppDelegate.windowDragManager.addObservers() + + UNUserNotificationCenter.current().delegate = self + AppDelegate.requestNotificationAuthorization() + + DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { + AccessibilityManager.requestAccess() + } } func applicationShouldTerminateAfterLastWindowClosed(_: NSApplication) -> Bool { diff --git a/Loop/Luminare/Settings/Keybindings/CustomActionConfigurationView.swift b/Loop/Luminare/Settings/Keybindings/CustomActionConfigurationView.swift index 66fa5846..32d5fa8c 100644 --- a/Loop/Luminare/Settings/Keybindings/CustomActionConfigurationView.swift +++ b/Loop/Luminare/Settings/Keybindings/CustomActionConfigurationView.swift @@ -43,19 +43,19 @@ struct CustomActionConfigurationView: View { } var body: some View { - ScreenView { + ScreenView(blurred: .constant(action.sizeMode != .custom)) { GeometryReader { geo in - let frame = action.getFrame(window: nil, bounds: CGRect(origin: .zero, size: geo.size), disablePadding: true) - let _ = print(frame) ZStack { if action.sizeMode == .custom { + let frame = action.getFrame(window: nil, bounds: CGRect(origin: .zero, size: geo.size), disablePadding: true) + blurredWindow() .frame(width: frame.width, height: frame.height) .offset(x: frame.origin.x, y: frame.origin.y) + .animation(LuminareSettingsWindow.animation, value: frame) } } .frame(width: geo.size.width, height: geo.size.height, alignment: .topLeading) - .animation(LuminareSettingsWindow.animation, value: frame) } } .onChange(of: action) { windowAction = $0 } @@ -303,9 +303,9 @@ struct CustomActionConfigurationView: View { @ViewBuilder private func blurredWindow() -> some View { VisualEffectView(material: .hudWindow, blendingMode: .withinWindow) .overlay { - RoundedRectangle(cornerRadius: 5) - .strokeBorder(.white.opacity(0.1), lineWidth: 2) + RoundedRectangle(cornerRadius: 12 - 5) + .strokeBorder(Color.getLoopAccent(tone: .normal), lineWidth: 2) } - .clipShape(RoundedRectangle(cornerRadius: 5)) + .clipShape(RoundedRectangle(cornerRadius: 12 - 5)) } } diff --git a/Loop/Luminare/Settings/Keybindings/KeybindingItem.swift b/Loop/Luminare/Settings/Keybindings/KeybindingItem.swift index cb3bb19b..ed46a8e8 100644 --- a/Loop/Luminare/Settings/Keybindings/KeybindingItem.swift +++ b/Loop/Luminare/Settings/Keybindings/KeybindingItem.swift @@ -94,11 +94,6 @@ struct KeybindingItemView: View { } .help("Customize what this keybind cycles through.") } - - if isHovering { - directionPicker() - .help("Customize this keybind's action.") - } } .font(.title3) .foregroundStyle(isHovering ? .primary : .secondary) @@ -137,6 +132,7 @@ struct KeybindingItemView: View { .fixedSize() } } + .animation(LuminareSettingsWindow.animation, value: keybind) .padding(.horizontal, 12) .onAppear { computeSearchResults() @@ -163,21 +159,26 @@ struct KeybindingItemView: View { } func label() -> some View { - HStack(spacing: 0) { - HStack(spacing: 8) { - IconView(action: $keybind) - - Text(keybind.getName()) - .lineLimit(1) - .contentTransition(.numericText()) - .animation(LuminareSettingsWindow.animation, value: keybind) - } + Button { + isPresented.toggle() + } label: { + HStack(spacing: 0) { + HStack(spacing: 8) { + IconView(action: $keybind) + + Text(keybind.getName()) + .lineLimit(1) + .contentTransition(.numericText()) + } - if let info = keybind.direction.infoView { - info + if let info = keybind.direction.infoView { + info + } } + .fixedSize(horizontal: false, vertical: true) } - .fixedSize(horizontal: false, vertical: true) + .buttonStyle(CompactButtonStyle()) + .help("Customize this keybind's action.") } func directionPicker() -> some View { @@ -225,3 +226,42 @@ struct KeybindingItemView: View { } } } + +private struct CompactButtonStyle: ButtonStyle { + @Environment(\.hoveringOverLuminareItem) var hoveringOverLuminareItem + @Environment(\.isEnabled) private var isEnabled: Bool + let elementMinHeight: CGFloat = 25 + @State var isHovering: Bool = false + let cornerRadius: CGFloat = 6 + + public func makeBody(configuration: Configuration) -> some View { + configuration.label + .background { + if configuration.isPressed || isHovering || hoveringOverLuminareItem { + backgroundForState(isPressed: configuration.isPressed) + .background { + RoundedRectangle(cornerRadius: cornerRadius) + .strokeBorder(.quaternary, lineWidth: 1) + } + .clipShape(.rect(cornerRadius: cornerRadius)) + .padding(-4) + } + } + .onHover { isHovering = $0 } + .animation(LuminareSettingsWindow.fastAnimation, value: [isHovering, hoveringOverLuminareItem]) + .frame(minHeight: elementMinHeight) + .opacity(isEnabled ? 1 : 0.5) + } + + private func backgroundForState(isPressed: Bool) -> some View { + Group { + if isPressed { + Rectangle().foregroundStyle(.quaternary) + } else if isHovering { + Rectangle().foregroundStyle(.quaternary.opacity(0.6)) + } else { + Rectangle().foregroundStyle(.quinary.opacity(0.5)) + } + } + } +} diff --git a/Loop/Window Management/WindowAction+Image.swift b/Loop/Window Management/WindowAction+Image.swift index 3543a536..8e428b8d 100644 --- a/Loop/Window Management/WindowAction+Image.swift +++ b/Loop/Window Management/WindowAction+Image.swift @@ -70,16 +70,6 @@ struct IconView: View { .font(.system(size: 8)) .fontWeight(.bold) .frame(width: size.width, height: size.height) - } else if action.direction == .cycle, action.cycle?.first == nil { - Image(._18PxRepeat4) - .resizable() - .aspectRatio(contentMode: .fit) - .frame(width: size.width, height: size.height) - } else if action.direction == .custom, frame == .zero { - Image(._18PxSliders) - .resizable() - .aspectRatio(contentMode: .fit) - .frame(width: size.width, height: size.height) } else { ZStack { RoundedRectangle(cornerRadius: outerCornerRadius - inset) diff --git a/Loop/Window Management/WindowEngine.swift b/Loop/Window Management/WindowEngine.swift index 817bde91..3d6246bf 100644 --- a/Loop/Window Management/WindowEngine.swift +++ b/Loop/Window Management/WindowEngine.swift @@ -63,8 +63,8 @@ enum WindowEngine { let animate = Defaults[.animateWindowResizes] && !enhancedUI WindowRecords.record(window, action) - if window.nsRunningApplication == NSRunningApplication.current, - let window = NSApp.keyWindow { + if window.nsRunningApplication?.bundleIdentifier == Bundle.main.bundleIdentifier, + let window = NSApp.keyWindow ?? NSApp.windows.first { var newFrame = targetFrame newFrame.size = window.frame.size