Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow 0 height notch #359

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion boringNotch/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct ContentView: View {
.mask {
NotchShape(cornerRadius: ((vm.notchState == .open) && Defaults[.cornerRadiusScaling]) ? cornerRadiusInsets.opened : cornerRadiusInsets.closed).drawingGroup()
}
.padding(.bottom, vm.notchState == .open ? 30 : 0) // Safe area to ensure the notch does not close if the cursor is within 30px of the notch from the bottom.
.padding(.bottom, calculateBottomPadding())
.animation(.bouncy.speed(1.2), value: hoverAnimation)
.animation(.bouncy.speed(1.2), value: vm.notchState)
.animation(.smooth, value: gestureProgress)
Expand Down Expand Up @@ -396,6 +396,17 @@ struct ContentView: View {
vm.open()
}
}

private func calculateBottomPadding() -> CGFloat {
let safeAreaNotchHeight: CGFloat = 30 // Safe area to ensure the notch does not close if the cursor is within 30px of the notch from the bottom.

if vm.notchState == .open {
return safeAreaNotchHeight
}

let shouldExtendHover = vm.closedNotchSize.height == 0 && Defaults[.extendHoverArea]
return shouldExtendHover ? safeAreaNotchHeight : 0
}
}

struct FullScreenDropDelegate: DropDelegate {
Expand Down
3 changes: 2 additions & 1 deletion boringNotch/components/Settings/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ struct GeneralSettings: View {
NotificationCenter.default.post(name: Notification.Name.notchHeightChanged, object: nil)
}
if nonNotchHeightMode == .custom {
Slider(value: $nonNotchHeight, in: 10...40, step: 1) {
Slider(value: $nonNotchHeight, in: 0...40, step: 1) {
Text("Custom notch size - \(nonNotchHeight, specifier: "%.0f")")
}
.onChange(of: nonNotchHeight) {
Expand Down Expand Up @@ -291,6 +291,7 @@ struct GeneralSettings: View {
@ViewBuilder
func NotchBehaviour() -> some View {
Section {
Defaults.Toggle("Extend hover area", key: .extendHoverArea)
Defaults.Toggle("Enable haptics", key: .enableHaptics)
Defaults.Toggle("Open notch on hover", key: .openNotchOnHover)
Toggle("Remember last tab", isOn: $coordinator.openLastTabByDefault)
Expand Down
1 change: 1 addition & 0 deletions boringNotch/models/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ extension Defaults.Keys {
static let minimumHoverDuration = Key<TimeInterval>("minimumHoverDuration", default: 0.3)
static let enableHaptics = Key<Bool>("enableHaptics", default: true)
static let openNotchOnHover = Key<Bool>("openNotchOnHover", default: true)
static let extendHoverArea = Key<Bool>("extendHoverArea", default: false)
static let notchHeightMode = Key<WindowHeightMode>(
"notchHeightMode",
default: WindowHeightMode.matchRealNotchSize
Expand Down
Loading