Skip to content
Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes to Pullo are listed here, newest first. The format follows [

## [Unreleased]

### Changed
- CI progress now shows below the notch, so it no longer covers the menu bar icons next to it. To keep it beside the notch, choose Beside the notch in Settings › Appearance.

### Fixed
- While checks are running, the notch no longer disappears for a second after you move the pointer away from the open panel.

Expand Down
2 changes: 1 addition & 1 deletion Sources/Pullo/Features/Notch/Header/TopBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ struct TopBar: View {
var body: some View {
let notchSize = notch.geometry.notchSize
ZStack {
if notch.state == .closed, let live = notch.liveCI {
if notch.state == .closed, let live = notch.liveCI, live.placement == .beside {
LiveCIView(live: live, notchWidth: notchSize.width)
.frame(width: notch.layout.size(for: .closed).width)
.transition(.opacity)
Expand Down
28 changes: 28 additions & 0 deletions Sources/Pullo/Features/Notch/LiveCI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Foundation

struct LiveCI: Equatable {
static let maxNameLength = 14
static let dropHeight: CGFloat = 24

let id: String
let name: String
Expand All @@ -11,6 +12,7 @@ struct LiveCI: Equatable {
var othersRunning = 0
var finished: CIState?
var label: LiveCILabel = .number
var placement: LiveCIPlacement = .below

init(pr: PullRequest, othersRunning: Int = 0, finished: CIState? = nil, label: LiveCILabel = .number) {
id = pr.id
Expand Down Expand Up @@ -46,6 +48,21 @@ struct LiveCI: Equatable {
return max(46, max(leading, trailing) + 20)
}

var belowWidth: CGFloat {
var width: CGFloat = 14
if showsNumberBeside { width += 5 + Self.width(of: name) }
if let trailingText { width += 5 + Self.width(of: trailingText) }
if let othersText { width += 5 + Self.width(of: othersText) + 8 }
return width + 28
}

func closedSize(around notch: CGSize) -> CGSize {
switch placement {
case .beside: CGSize(width: notch.width + wingWidth * 2, height: notch.height)
case .below: CGSize(width: max(notch.width, belowWidth), height: notch.height + Self.dropHeight)
}
}

private static func width(of text: String) -> CGFloat { CGFloat(text.count) * 7 }

private static func shortened(_ name: String) -> String {
Expand All @@ -64,3 +81,14 @@ enum LiveCILabel: String, CaseIterable {
}
}
}

enum LiveCIPlacement: String, CaseIterable {
case below, beside

var title: String {
switch self {
case .below: String(localized: "Below the notch")
case .beside: String(localized: "Beside the notch")
}
}
}
1 change: 1 addition & 0 deletions Sources/Pullo/Features/Notch/LiveCIModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ final class LiveCIModel {
var current: LiveCI? {
guard settings.showsLiveCI, var live = peeks.finishedCI ?? running else { return nil }
live.label = settings.liveCILabel
live.placement = settings.liveCIPlacement
return live
}

Expand Down
22 changes: 16 additions & 6 deletions Sources/Pullo/Features/Notch/LiveCIView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,22 @@ struct LiveCIView: View {
let notchWidth: CGFloat

var body: some View {
HStack(spacing: 0) {
leading
.frame(maxWidth: .infinity)
Color.clear.frame(width: notchWidth)
counter
.frame(maxWidth: .infinity)
Group {
switch live.placement {
case .beside:
HStack(spacing: 0) {
leading
.frame(maxWidth: .infinity)
Color.clear.frame(width: notchWidth)
counter
.frame(maxWidth: .infinity)
}
case .below:
HStack(spacing: 5) {
leading
counter
}
}
}
.accessibilityElement(children: .ignore)
.accessibilityLabel(accessibilityText)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Pullo/Features/Notch/NotchInteraction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ final class NotchInteraction {
peeks.host = self
}

var layout: NotchLayout { NotchLayout(geometry: geometry, closedWings: liveCI?.wingWidth ?? 0) }
var layout: NotchLayout { NotchLayout(geometry: geometry, live: liveCI) }

var liveCI: LiveCI? { liveCIModel.current }

Expand Down
4 changes: 2 additions & 2 deletions Sources/Pullo/Features/Notch/NotchLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ struct NotchLayout {
static let switcherSpace: CGFloat = 56

let geometry: NotchGeometry
var closedWings: CGFloat = 0
var live: LiveCI?

func size(for state: NotchState) -> CGSize {
let notch = geometry.notchSize
switch state {
case .closed:
return CGSize(width: notch.width + closedWings * 2, height: notch.height)
return live?.closedSize(around: notch) ?? notch
case .peek:
return CGSize(width: max(notch.width + 200, 400), height: notch.height + 54)
case .open:
Expand Down
5 changes: 5 additions & 0 deletions Sources/Pullo/Features/Notch/NotchRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ struct NotchRootView: View {
private func panel(state: NotchState, size: CGSize, radii: (top: CGFloat, bottom: CGFloat), shape: NotchShape) -> some View {
VStack(spacing: 0) {
TopBar()
if state == .closed, let live = notch.liveCI, live.placement == .below {
LiveCIView(live: live, notchWidth: notch.geometry.notchSize.width)
.frame(height: LiveCI.dropHeight)
.transition(.opacity)
}
if state == .peek, let alert = notch.peekAlert {
PeekView(alert: alert) { notch.tapPeek(alert) }
.id(alert.id)
Expand Down
3 changes: 3 additions & 0 deletions Sources/Pullo/Features/Settings/AppSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ final class AppSettings {
var panelStyle: PanelStyle { didSet { save() } }
var showsLiveCI: Bool { didSet { save() } }
var liveCILabel: LiveCILabel { didSet { save() } }
var liveCIPlacement: LiveCIPlacement { didSet { save() } }
var display: DisplayChoice { didSet { save() } }
var shortcut: ShortcutChoice { didSet { save() } }
var holdsAlertsInFullScreen: Bool { didSet { save() } }
Expand All @@ -38,6 +39,7 @@ final class AppSettings {
panelStyle = (defaults.object(for: .panelStyle) as? String).flatMap(PanelStyle.init(rawValue:)) ?? .solid
showsLiveCI = defaults.object(for: .liveCI) as? Bool ?? true
liveCILabel = (defaults.object(for: .liveCILabel) as? String).flatMap(LiveCILabel.init(rawValue:)) ?? .number
liveCIPlacement = (defaults.object(for: .liveCIPlacement) as? String).flatMap(LiveCIPlacement.init(rawValue:)) ?? .below
display = (defaults.object(for: .display) as? String).flatMap(DisplayChoice.init(rawValue:)) ?? .builtIn
shortcut = (defaults.object(for: .shortcut) as? String).flatMap(ShortcutChoice.init(rawValue:)) ?? .optionCommandP
holdsAlertsInFullScreen = defaults.object(for: .holdInFullScreen) as? Bool ?? false
Expand Down Expand Up @@ -89,6 +91,7 @@ final class AppSettings {
defaults.set(panelStyle.rawValue, for: .panelStyle)
defaults.set(showsLiveCI, for: .liveCI)
defaults.set(liveCILabel.rawValue, for: .liveCILabel)
defaults.set(liveCIPlacement.rawValue, for: .liveCIPlacement)
defaults.set(display.rawValue, for: .display)
defaults.set(shortcut.rawValue, for: .shortcut)
defaults.set(holdsAlertsInFullScreen, for: .holdInFullScreen)
Expand Down
9 changes: 7 additions & 2 deletions Sources/Pullo/Features/Settings/AppearancePage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@ struct AppearancePage: View {
Toggle("Show CI progress on the notch", isOn: $settings.showsLiveCI)
.toggleStyle(.switch)
if settings.showsLiveCI {
PreviewPicker(options: LiveCIPlacement.allCases, selection: $settings.liveCIPlacement, title: \.title) { placement in
LiveCIPreview(label: settings.liveCILabel, placement: placement)
}
PreviewPicker(options: LiveCILabel.allCases, selection: $settings.liveCILabel, title: \.title) { label in
LiveCIPreview(label: label)
LiveCIPreview(label: label, placement: settings.liveCIPlacement)
}
}
} footer: {
Text("While checks run on your pull requests, the notch widens to show their progress.")
Text(
"While checks run on your pull requests, the notch shows their progress. Below the notch keeps the menu bar icons beside it visible."
)
}
}
}
Expand Down
26 changes: 20 additions & 6 deletions Sources/Pullo/Features/Settings/LiveCIPreview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,38 @@ import SwiftUI

struct LiveCIPreview: View {
let label: LiveCILabel
let placement: LiveCIPlacement

private static let notchWidth: CGFloat = 30
private static let notchHeight: CGFloat = 32

private var live: LiveCI {
var pr = PullRequest.sample
pr.checks = CheckProgress(done: 2, total: 3)
return LiveCI(pr: pr, othersRunning: 0, label: label)
var live = LiveCI(pr: pr, othersRunning: 0, label: label)
live.placement = placement
return live
}

var body: some View {
let width = Self.notchWidth + live.wingWidth * 2
let live = live
let size = live.closedSize(around: CGSize(width: Self.notchWidth, height: Self.notchHeight))
ZStack(alignment: .top) {
PreviewWallpaper()
LiveCIView(live: live, notchWidth: Self.notchWidth)
.frame(width: width, height: Self.notchHeight)
.background(NotchShape(topRadius: 6, bottomRadius: 12).fill(Color.black))
.scaleEffect(0.7, anchor: .top)
VStack(spacing: 0) {
switch placement {
case .beside:
LiveCIView(live: live, notchWidth: Self.notchWidth)
.frame(height: Self.notchHeight)
case .below:
Color.clear.frame(height: Self.notchHeight)
LiveCIView(live: live, notchWidth: Self.notchWidth)
.frame(height: LiveCI.dropHeight)
}
}
.frame(width: size.width, height: size.height)
.background(NotchShape(topRadius: 6, bottomRadius: 12).fill(Color.black))
.scaleEffect(0.7, anchor: .top)
}
}
}
64 changes: 48 additions & 16 deletions Sources/Pullo/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -4352,22 +4352,6 @@
}
}
},
"While checks run on your pull requests, the notch widens to show their progress.": {
"localizations": {
"es": {
"stringUnit": {
"state": "translated",
"value": "Mientras se ejecutan los checks de tus pull requests, el notch se ensancha para mostrar su progreso."
}
},
"pt-BR": {
"stringUnit": {
"state": "translated",
"value": "Enquanto os checks rodam nos seus pull requests, o notch se alarga para mostrar o progresso."
}
}
}
},
"While you were in Focus": {
"localizations": {
"es": {
Expand Down Expand Up @@ -5797,6 +5781,54 @@
}
}
}
},
"Below the notch": {
"localizations": {
"es": {
"stringUnit": {
"state": "translated",
"value": "Debajo del notch"
}
},
"pt-BR": {
"stringUnit": {
"state": "translated",
"value": "Embaixo do notch"
}
}
}
},
"Beside the notch": {
"localizations": {
"es": {
"stringUnit": {
"state": "translated",
"value": "Junto al notch"
}
},
"pt-BR": {
"stringUnit": {
"state": "translated",
"value": "Ao lado do notch"
}
}
}
},
"While checks run on your pull requests, the notch shows their progress. Below the notch keeps the menu bar icons beside it visible.": {
"localizations": {
"es": {
"stringUnit": {
"state": "translated",
"value": "Mientras se ejecutan los checks de tus pull requests, el notch muestra su progreso. Debajo del notch deja a la vista los iconos de la barra de menús que tiene al lado."
}
},
"pt-BR": {
"stringUnit": {
"state": "translated",
"value": "Enquanto os checks rodam nos seus pull requests, o notch mostra o progresso. Embaixo do notch deixa visíveis os ícones da barra de menus ao lado dele."
}
}
}
}
},
"version": "1.0"
Expand Down
2 changes: 1 addition & 1 deletion Sources/Pullo/Support/DefaultsKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation

enum DefaultsKey: String {
case accounts, tabs, runTabs, unreadableTabs, unreadableRunTabs
case mutedCategories, mutedAccounts, haptics, sound, categorySounds, panelStyle, liveCI, liveCILabel
case mutedCategories, mutedAccounts, haptics, sound, categorySounds, panelStyle, liveCI, liveCILabel, liveCIPlacement
case display, shortcut, holdInFullScreen
case readBaselines, readKnownAccounts
case betaUpdates
Expand Down
7 changes: 7 additions & 0 deletions Tests/PulloTests/AppSettingsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ struct AppSettingsTests {
#expect(AppSettings(defaults: scratch.defaults).liveCILabel == .both)
}

@Test func ciProgressShowsBelowTheNotchUntilBesideIsChosen() {
let scratch = ScratchDefaults()
#expect(AppSettings(defaults: scratch.defaults).liveCIPlacement == .below)
AppSettings(defaults: scratch.defaults).liveCIPlacement = .beside
#expect(AppSettings(defaults: scratch.defaults).liveCIPlacement == .beside)
}

@Test func soundsChosenPerKindAreRemembered() {
let scratch = ScratchDefaults()
AppSettings(defaults: scratch.defaults).categorySounds = [.ciFailed: "Basso", .ciPassed: ""]
Expand Down
2 changes: 1 addition & 1 deletion Tests/PulloTests/FirstRunTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ extension NotchBehavior {
hasNotch: false
)
#expect(h.notch.liveCI?.id == "PR_1")
#expect(h.notch.layout.size(for: .closed).width > NotchGeometry.pillWidth)
#expect(h.notch.layout.size(for: .closed).height > 24)
}
}
}
Expand Down
24 changes: 22 additions & 2 deletions Tests/PulloTests/LiveCITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,33 @@ extension NotchBehavior {
#expect(h.notch.liveCI?.othersRunning == 1)
}

@Test func widensTheClosedNotchWhileChecksRun() async {
@Test func dropsBelowTheClosedNotchWhileChecksRun() async {
let idle = await NotchHarness()
let busy = await NotchHarness(mine: [Self.running("PR_1", minutesAgo: 1)])
#expect(idle.notch.liveCI == nil)
#expect(busy.notch.layout.size(for: .closed).width > idle.notch.layout.size(for: .closed).width)
let closed = busy.notch.layout.size(for: .closed)
#expect(closed.width == idle.notch.layout.size(for: .closed).width)
#expect(closed.height == idle.notch.layout.size(for: .closed).height + LiveCI.dropHeight)
#expect(busy.notch.layout.hitRect(for: .closed).height > idle.notch.layout.hitRect(for: .closed).height)
}

@Test func widensTheClosedNotchWhenShownBesideIt() async {
let idle = await NotchHarness()
let busy = await NotchHarness(mine: [Self.running("PR_1", minutesAgo: 1)])
busy.settings.liveCIPlacement = .beside
let closed = busy.notch.layout.size(for: .closed)
#expect(closed.width > idle.notch.layout.size(for: .closed).width)
#expect(closed.height == idle.notch.layout.size(for: .closed).height)
#expect(busy.notch.layout.hitRect(for: .closed).width > idle.notch.layout.hitRect(for: .closed).width)
}

@Test func growsWiderBelowANarrowNotchWhenTheLabelDoesNotFit() async {
let h = await NotchHarness(mine: [Self.running("PR_1", minutesAgo: 1)])
h.notch.geometry.notchSize.width = 60
h.settings.liveCILabel = .both
#expect(h.notch.layout.size(for: .closed).width > 60)
}

@Test func staysHiddenWhenTurnedOffOrTheAccountIsMuted() async {
let h = await NotchHarness(accounts: ["me", "work"], mine: [Self.running("PR_1", minutesAgo: 1, account: "work")])
#expect(h.notch.liveCI != nil)
Expand All @@ -45,6 +64,7 @@ extension NotchBehavior {

@Test func followsTheChosenLabel() async {
let h = await NotchHarness(mine: [Self.running("PR_1", minutesAgo: 1)])
h.settings.liveCIPlacement = .beside
#expect(h.notch.liveCI?.trailingText == "#383")
h.settings.liveCILabel = .checks
#expect(h.notch.liveCI?.trailingText == "3/5")
Expand Down
Loading