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.

The album's dashed lines answer Increase Contrast, and Home is drawn with it

Țugui Dragoș54466cf2c649
diff --git a/Peel/Assets.xcassets/CutLine.colorset/Contents.json b/Peel/Assets.xcassets/CutLine.colorset/Contents.json
new file mode 100644
index 00000000..da572966
--- /dev/null
+++ b/Peel/Assets.xcassets/CutLine.colorset/Contents.json
@@ -0,0 +1,78 @@
+{
+ "colors": [
+ {
+ "color": {
+ "color-space": "display-p3",
+ "components": {
+ "alpha": "0.110",
+ "red": "0.000",
+ "green": "0.000",
+ "blue": "0.000"
+ }
+ },
+ "idiom": "universal"
+ },
+ {
+ "color": {
+ "color-space": "display-p3",
+ "components": {
+ "alpha": "0.450",
+ "red": "0.000",
+ "green": "0.000",
+ "blue": "0.000"
+ }
+ },
+ "idiom": "universal",
+ "appearances": [
+ {
+ "appearance": "contrast",
+ "value": "high"
+ }
+ ]
+ },
+ {
+ "color": {
+ "color-space": "display-p3",
+ "components": {
+ "alpha": "0.110",
+ "red": "1.000",
+ "green": "1.000",
+ "blue": "1.000"
+ }
+ },
+ "idiom": "universal",
+ "appearances": [
+ {
+ "appearance": "luminosity",
+ "value": "dark"
+ }
+ ]
+ },
+ {
+ "color": {
+ "color-space": "display-p3",
+ "components": {
+ "alpha": "0.350",
+ "red": "1.000",
+ "green": "1.000",
+ "blue": "1.000"
+ }
+ },
+ "idiom": "universal",
+ "appearances": [
+ {
+ "appearance": "luminosity",
+ "value": "dark"
+ },
+ {
+ "appearance": "contrast",
+ "value": "high"
+ }
+ ]
+ }
+ ],
+ "info": {
+ "author": "xcode",
+ "version": 1
+ }
+}
diff --git a/Peel/Assets.xcassets/SlotEdge.colorset/Contents.json b/Peel/Assets.xcassets/SlotEdge.colorset/Contents.json
new file mode 100644
index 00000000..2b20020f
--- /dev/null
+++ b/Peel/Assets.xcassets/SlotEdge.colorset/Contents.json
@@ -0,0 +1,78 @@
+{
+ "colors": [
+ {
+ "color": {
+ "color-space": "display-p3",
+ "components": {
+ "alpha": "0.240",
+ "red": "0.000",
+ "green": "0.000",
+ "blue": "0.000"
+ }
+ },
+ "idiom": "universal"
+ },
+ {
+ "color": {
+ "color-space": "display-p3",
+ "components": {
+ "alpha": "0.500",
+ "red": "0.000",
+ "green": "0.000",
+ "blue": "0.000"
+ }
+ },
+ "idiom": "universal",
+ "appearances": [
+ {
+ "appearance": "contrast",
+ "value": "high"
+ }
+ ]
+ },
+ {
+ "color": {
+ "color-space": "display-p3",
+ "components": {
+ "alpha": "0.240",
+ "red": "1.000",
+ "green": "1.000",
+ "blue": "1.000"
+ }
+ },
+ "idiom": "universal",
+ "appearances": [
+ {
+ "appearance": "luminosity",
+ "value": "dark"
+ }
+ ]
+ },
+ {
+ "color": {
+ "color-space": "display-p3",
+ "components": {
+ "alpha": "0.500",
+ "red": "1.000",
+ "green": "1.000",
+ "blue": "1.000"
+ }
+ },
+ "idiom": "universal",
+ "appearances": [
+ {
+ "appearance": "luminosity",
+ "value": "dark"
+ },
+ {
+ "appearance": "contrast",
+ "value": "high"
+ }
+ ]
+ }
+ ],
+ "info": {
+ "author": "xcode",
+ "version": 1
+ }
+}
diff --git a/Peel/HomeSnapshot.swift b/Peel/HomeSnapshot.swift
index 99354423..afc747a1 100644
--- a/Peel/HomeSnapshot.swift
+++ b/Peel/HomeSnapshot.swift
@@ -2,8 +2,8 @@ import AppKit
import SwiftUI
#if DEBUG
-/// Renders Home, About and the menu bar panel to PNG files in light and dark when `PEEL_SNAPSHOT` names a folder,
-/// then quits. This lets their layouts be checked without a screenshot, in any language Peel runs in. Each view is
+/// Renders Home, About and the menu bar panel to PNG files in light and dark, each also with Increase Contrast, when
+/// `PEEL_SNAPSHOT` names a folder, then quits. This lets their layouts be checked without a screenshot, in any language Peel runs in. Each view is
/// drawn at the width the app gives it, on the background it has there: About on its paper, the menu bar panel on
/// the paper it draws itself, and Home on the window's plain color, since `ImageRenderer` does not draw glass.
enum HomeSnapshot {
@@ -16,22 +16,30 @@ enum HomeSnapshot {
await ExclusionsStore.shared.load()
let window = Color(nsColor: .windowBackgroundColor)
for scheme in [ColorScheme.light, .dark] {
- let name = scheme == .light ? "light" : "dark"
- render(HomeContent().environment(home).environment(helper).environment(stats), width: 360, height: 760, on: window, scheme: scheme, to: "\(directory)/home-content-\(name).png")
- // Home again with Show Borders on, for this image only. The stickers then outline their edges.
- render(HomeContent().environment(home).environment(helper).environment(stats).environment(\._accessibilityShowButtonShapes, true), width: 360, height: 760, on: window, scheme: scheme, to: "\(directory)/home-content-borders-\(name).png")
- // The permissions at their widest, and at their narrowest, where Home puts its two halves side by side.
- render(HomePermissionsContent().environment(home).environment(helper).environment(ExclusionsStore.shared), width: 720, height: 680, on: window, scheme: scheme, to: "\(directory)/home-detail-\(name).png")
- render(HomePermissionsContent().environment(home).environment(helper).environment(ExclusionsStore.shared), width: 480, height: 700, on: window, scheme: scheme, to: "\(directory)/detail-narrow-\(name).png")
- render(AboutContent().fixedSize(horizontal: false, vertical: true), width: 380, on: Album.sheet, scheme: scheme, to: "\(directory)/about-\(name).png")
- render(MenuBarPanel().environment(AppLibrary()).environment(stats), width: 320, scheme: scheme, to: "\(directory)/menu-bar-\(name).png")
+ for contrast in [ColorSchemeContrast.standard, .increased] {
+ let name = (scheme == .light ? "light" : "dark") + (contrast == .increased ? "-contrast" : "")
+ render(HomeContent().environment(home).environment(helper).environment(stats), width: 360, height: 760, on: window, scheme: scheme, contrast: contrast, to: "\(directory)/home-content-\(name).png")
+ // Home again with Show Borders on, for this image only. The stickers then outline their edges.
+ if contrast == .standard {
+ render(HomeContent().environment(home).environment(helper).environment(stats).environment(\._accessibilityShowButtonShapes, true), width: 360, height: 760, on: window, scheme: scheme, to: "\(directory)/home-content-borders-\(name).png")
+ }
+ // The permissions at their widest, and at their narrowest, where Home puts its two halves side by side.
+ render(HomePermissionsContent().environment(home).environment(helper).environment(ExclusionsStore.shared), width: 720, height: 680, on: window, scheme: scheme, contrast: contrast, to: "\(directory)/home-detail-\(name).png")
+ render(HomePermissionsContent().environment(home).environment(helper).environment(ExclusionsStore.shared), width: 480, height: 700, on: window, scheme: scheme, contrast: contrast, to: "\(directory)/detail-narrow-\(name).png")
+ render(AboutContent().fixedSize(horizontal: false, vertical: true), width: 380, on: Album.sheet, scheme: scheme, contrast: contrast, to: "\(directory)/about-\(name).png")
+ render(MenuBarPanel().environment(AppLibrary()).environment(stats), width: 320, scheme: scheme, contrast: contrast, to: "\(directory)/menu-bar-\(name).png")
+ }
}
NSApp.terminate(nil)
}
/// Saves `view` as a PNG at `path`, `width` wide and `height` tall, or as tall as it needs when `height` is nil.
- private static func render(_ view: some View, width: CGFloat, height: CGFloat? = nil, on backdrop: Color = .clear, scheme: ColorScheme, to path: String) {
- let renderer = ImageRenderer(content: view.frame(width: width, height: height).background(backdrop).environment(\.colorScheme, scheme))
+ /// Increase Contrast is set through `_colorSchemeContrast`, the setter SwiftUI keeps for previews.
+ private static func render(_ view: some View, width: CGFloat, height: CGFloat? = nil, on backdrop: Color = .clear, scheme: ColorScheme, contrast: ColorSchemeContrast = .standard, to path: String) {
+ let content = view.frame(width: width, height: height).background(backdrop)
+ .environment(\.colorScheme, scheme)
+ .environment(\._colorSchemeContrast, contrast)
+ let renderer = ImageRenderer(content: content)
renderer.scale = 2
guard let image = renderer.nsImage, let data = image.tiffRepresentation, let bitmap = NSBitmapImageRep(data: data) else { return }
try? bitmap.representation(using: .png, properties: [:])?.write(to: URL(filePath: path))
diff --git a/Peel/Views/Home/HomeDeviceCard.swift b/Peel/Views/Home/HomeDeviceCard.swift
index 20ae1e5a..4b766264 100644
--- a/Peel/Views/Home/HomeDeviceCard.swift
+++ b/Peel/Views/Home/HomeDeviceCard.swift
@@ -110,7 +110,7 @@ struct StorageStrip: View {
.fill(isAlbum ? AnyShapeStyle(Album.slot) : AnyShapeStyle(.quaternary))
if isAlbum {
RoundedRectangle(cornerRadius: 7, style: .continuous)
- .strokeBorder(Color.primary.opacity(0.28), style: StrokeStyle(lineWidth: 1.2, dash: [4, 3]))
+ .strokeBorder(Album.slotEdge, style: StrokeStyle(lineWidth: 1.2, dash: [4, 3]))
}
RoundedRectangle(cornerRadius: 5, style: .continuous)
.fill(isAlbum ? Album.orange : Color.accentColor)
diff --git a/Peel/Views/Stickers/StickerStyle.swift b/Peel/Views/Stickers/StickerStyle.swift
index 28e79a93..42fcf4cc 100644
--- a/Peel/Views/Stickers/StickerStyle.swift
+++ b/Peel/Views/Stickers/StickerStyle.swift
@@ -15,6 +15,10 @@ enum Album {
static let stickerEdge = Color(.stickerEdge)
static let ink = Color(.ink)
static let slot = Color(.slot)
+ /// The dashed edge of a slot, such as the storage bar's track. Increase Contrast darkens it to 3:1, as it does
+ /// `cutLine`, the dashed line between a sheet's rows.
+ static let slotEdge = Color(.slotEdge)
+ static let cutLine = Color(.cutLine)
static let shadow = Color(.stickerShadow)
static let quietFill = Color(.quietFill)
/// The red of words and marks for what is missing, readable on a sticker in every appearance, which the system
@@ -100,7 +104,7 @@ struct DieCut: View {
struct Perforation: View {
var body: some View {
Line()
- .stroke(Color.primary.opacity(0.13), style: StrokeStyle(lineWidth: 1, dash: [3, 3]))
+ .stroke(Album.cutLine, style: StrokeStyle(lineWidth: 1, dash: [3, 3]))
.frame(height: 1)
}