Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Put a wrapped Login Items value under its label from the leading edge

Țugui Dragoșcb25e96e1728
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 42230553..96c604ca 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -874,6 +874,8 @@ its changes the way [Keep a Changelog](https://keepachangelog.com/) suggests.
- A job turned off in System Settings > General > Login Items & Extensions, or waiting for approval there, is no
longer loaded, run, restarted, or disabled from here, which went over that choice: it can only be stopped, and its
page says why.
+- A Login Items & Extensions status too long to sit beside its label goes under it from the left, rather than broken
+ at the right.
#### Extensions
diff --git a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
index 34364b2f..e793a885 100644
--- a/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
+++ b/Peel/Views/BackgroundItems/BackgroundItemDetailView.swift
@@ -45,8 +45,9 @@ struct BackgroundItemDetailView: View {
}
if let status = item.loginItemsStatus {
LabeledContent("Login Items & Extensions") {
- HStack(spacing: 8) {
+ FlowLayout {
Text(status.words)
+ .foregroundStyle(.secondary)
Button {
PrivilegedHelper.openLoginItemsSettings()
} label: {
@@ -56,6 +57,7 @@ struct BackgroundItemDetailView: View {
.buttonStyle(.link)
}
}
+ .labeledContentStyle(.leadingWhenWrapped)
}
LabeledContent {
answer(item.runsAtLoad)
diff --git a/Peel/Views/LeadingWhenWrapped.swift b/Peel/Views/LeadingWhenWrapped.swift
new file mode 100644
index 00000000..127e9283
--- /dev/null
+++ b/Peel/Views/LeadingWhenWrapped.swift
@@ -0,0 +1,24 @@
+import SwiftUI
+
+extension LabeledContentStyle where Self == LeadingWhenWrapped {
+ static var leadingWhenWrapped: LeadingWhenWrapped { LeadingWhenWrapped() }
+}
+
+/// A value beside its label while it fits, else under it from the leading edge, where a grouped form puts it at the
+/// trailing one.
+struct LeadingWhenWrapped: LabeledContentStyle {
+ func makeBody(configuration: Configuration) -> some View {
+ ViewThatFits(in: .horizontal) {
+ HStack(alignment: .firstTextBaseline, spacing: 12) {
+ configuration.label
+ Spacer(minLength: 0)
+ configuration.content
+ }
+ VStack(alignment: .leading, spacing: 4) {
+ configuration.label
+ configuration.content
+ }
+ .frame(maxWidth: .infinity, alignment: .leading)
+ }
+ }
+}