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
46 changes: 46 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,52 @@ jobs:
test -s "$RUNNER_TEMP/payload/out/apple-16k/linux.bin"
grep -q 'apple-16k kernel: its source key matches' build.log

# Every screen of the companion and the in-app installer at the size of every
# iPhone, iPod touch and iPad (companion/App/LayoutCheck.swift): fails on a
# width the layout leaves to iOS (iOS 12 drew such a page two letters wide),
# broken or cut-off text and anything off the screen. Only when their code or
# the fonts change.
ios-layout:
name: Check the iOS screens' layout
if: github.event_name == 'pull_request'
runs-on: macos-15-intel
timeout-minutes: 20
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
persist-credentials: false
fetch-depth: 0

- name: See whether the screens changed
id: changed
env:
BASE: ${{ github.event.pull_request.base.sha }}
run: |
if git diff --quiet "$BASE" HEAD -- companion ios-installer crates/app/assets/fonts; then
echo "run=false" >> "$GITHUB_OUTPUT"
else
echo "run=true" >> "$GITHUB_OUTPUT"
echo "commit=$(sed -n 's/^RESIZE_APFS_COMMIT=//p' ios-installer/build.sh)" >> "$GITHUB_OUTPUT"
fi

- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
if: steps.changed.outputs.run == 'true'
with:
repository: OrchardLinux/resize-apfs
ref: ${{ steps.changed.outputs.commit }}
path: resize-apfs
persist-credentials: false

- name: The companion
if: steps.changed.outputs.run == 'true'
run: companion/build.sh --check-layout

- name: The in-app installer
if: steps.changed.outputs.run == 'true'
env:
RESIZE_APFS: ${{ github.workspace }}/resize-apfs
run: ios-installer/build-simulator.sh --check-layout

companion:
name: Build the iPad companion
needs: plan
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ program it changes. To release, rename `[Unreleased]` to the version and
date and raise the version in Cargo.toml, in the same pull request: once it
is on main, the release is published with that section as its notes (AGENTS.md, Releasing).

## [Unreleased]

### Installer and launcher

- On iOS 12 the app on the iPad or iPhone shows its Storage access page as
designed: its text was a column a few letters wide that pushed Continue
off the screen. Every screen of the app on the device and of the in-app
installer now fits every iPhone, iPod touch and iPad upright and on its
side, scrolling where a screen is taller than the display.

## [0.3.19] - 2026-12-05

### Installer and launcher
Expand Down
160 changes: 109 additions & 51 deletions companion/App/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,8 @@ private func heading(_ title: String, _ text: String) -> UIView {
label(text, sans(17), .body, lineSpacing: 8.5, center: true),
])
stack.axis = .vertical
stack.alignment = .center
stack.alignment = .fill
stack.spacing = 12
stack.translatesAutoresizingMaskIntoConstraints = false
stack.widthAnchor.constraint(lessThanOrEqualToConstant: 500).isActive = true
return stack
}

Expand Down Expand Up @@ -157,30 +155,54 @@ private func row(_ views: [UIView], spacing: CGFloat) -> UIStackView {
return stack
}

/// The note under 2.7 and 2.7b.
/// The note under 2.7 and 2.7b: as wide as its line, or the column where that is less.
private func keepNote() -> UIView {
framed(row([icon("plug", 16), label("Keep this app open and the cable connected.", sans(15), .body)], spacing: 10),
UIColor(0x1d1f2b), UIColor(0x292e42), vertical: 10, horizontal: 16)
let text = label("Keep this app open and the cable connected.", sans(15), .body)
let line = ceil(text.attributedText!.size().width)
let box = framed(row([icon("plug", 16), text], spacing: 10), UIColor(0x1d1f2b), UIColor(0x292e42), vertical: 10, horizontal: 16)
box.translatesAutoresizingMaskIntoConstraints = false
let natural = box.widthAnchor.constraint(equalToConstant: line + 16 + 10 + 2 * 16)
natural.priority = .required - 1
natural.isActive = true
return centered(box)
}

/// `view` in the middle of a block as wide as the column; never wider than it.
private func centered(_ view: UIView) -> UIView {
let block = UIView()
view.translatesAutoresizingMaskIntoConstraints = false
block.addSubview(view)
NSLayoutConstraint.activate([
view.topAnchor.constraint(equalTo: block.topAnchor),
view.bottomAnchor.constraint(equalTo: block.bottomAnchor),
view.centerXAnchor.constraint(equalTo: block.centerXAnchor),
view.leadingAnchor.constraint(greaterThanOrEqualTo: block.leadingAnchor),
])
return block
}

/// A screen's blocks, each exactly as wide as the column (StatusController gives it its
/// width): no text is left to pick its own width, which iOS versions pick differently
/// (iOS 12 made the Storage access page two letters wide). Blocks narrower than the
/// column go through `centered`. LayoutCheck.swift holds every screen to this.
private func column(_ views: [UIView]) -> UIStackView {
let stack = UIStackView(arrangedSubviews: views)
stack.axis = .vertical
stack.alignment = .center
stack.alignment = .fill
stack.spacing = 28
return stack
}

/// 2.7b: the computer hasn't connected yet.
private func waiting() -> UIView {
column([badge(.accent, 0.08, fixed(Spinner(), 40, 40)),
column([centered(badge(.accent, 0.08, fixed(Spinner(), 40, 40))),
heading("Waiting for your computer", "Orchard Installer continues once it reaches this iPad."),
keepNote()])
}

/// 2.7: the computer is connected and the split hasn't started.
private func before(system: String) -> UIView {
column([badge(.accent, 0.12, icon("laptop", 38)),
column([centered(badge(.accent, 0.12, icon("laptop", 38))),
heading("Continue on your computer", "Your iPad is connected to Orchard Installer. Choose how much space \(system) gets there."),
keepNote()])
}
Expand All @@ -195,22 +217,18 @@ private func splitting(minutes: UILabel) -> UIView {
label("Your iPad may freeze or look idle for a while. That's normal, and it doesn't mean anything went wrong.", sans(14), .body, lineSpacing: 7),
])
rules.axis = .vertical
rules.alignment = .leading
rules.alignment = .fill
rules.spacing = 16
let box = framed(rules, UIColor.amber.withAlphaComponent(0.05), UIColor.amber.withAlphaComponent(0.32), vertical: 24, horizontal: 24)
box.translatesAutoresizingMaskIntoConstraints = false
// 500 wide where the screen has the room.
let width = box.widthAnchor.constraint(equalToConstant: 500)
width.priority = .defaultHigh
width.isActive = true
return column([badge(.accent, 0.08, fixed(Spinner(), 40, 40)),
minutes.textAlignment = .center
return column([centered(badge(.accent, 0.08, fixed(Spinner(), 40, 40))),
heading("Splitting the storage", "This can take around 30 minutes. Your computer shows how it's going."),
minutes, box])
}

/// 2.9: done.
private func done() -> UIView {
column([badge(.ok, 0.12, icon("check", 38)),
column([centered(badge(.ok, 0.12, icon("check", 38))),
heading("Done on your iPad", "The storage is split. Continue on your computer.")])
}

Expand All @@ -231,15 +249,6 @@ private final class ActionButton: UIButton {
@objc private func tapped() { action() }
}

/// The width of the Storage access page's steps and notice (9.1): 500, or what a
/// narrower screen leaves.
private func wide(_ view: UIView) {
view.widthAnchor.constraint(lessThanOrEqualToConstant: 500).isActive = true
let wanted = view.widthAnchor.constraint(equalToConstant: 500)
wanted.priority = .defaultHigh
wanted.isActive = true
}

/// Some devices restart their screen once before access; nothing can open the app again
/// then, and what that restart was for holds only about 20 seconds. In Amethyst (iOS 12
/// and 13) the first run restarts the whole device instead, and the app is opened again
Expand All @@ -250,10 +259,7 @@ private func reopenNotice(_ restartsDevice: Bool) -> UIView {
let text = label(line, sans(16, semibold: true), .rule, lineSpacing: 4)
text.numberOfLines = 0
let content = row([icon("timer", 18), text], spacing: 14)
let box = framed(content, UIColor.amber.withAlphaComponent(0.05), UIColor.amber.withAlphaComponent(0.32), vertical: 18, horizontal: 24)
box.translatesAutoresizingMaskIntoConstraints = false
wide(box)
return box
return framed(content, UIColor.amber.withAlphaComponent(0.05), UIColor.amber.withAlphaComponent(0.32), vertical: 18, horizontal: 24)
}

/// Storage access (the app inside Dopamine, 9.1 and 9.2): with Continue, then with the
Expand All @@ -264,22 +270,20 @@ private func storageAccess(working: Bool, restartsDevice: Bool, proceed: @escapi
row([icon("arrow-right", 18), label($0, sans(16), .rule)], spacing: 14)
})
steps.axis = .vertical
steps.alignment = .leading
steps.alignment = .fill
steps.spacing = 12
steps.translatesAutoresizingMaskIntoConstraints = false
wide(steps)
var views = [working ? badge(.accent, 0.08, fixed(Spinner(), 40, 40)) : badge(.accent, 0.12, icon("hard-drive", 38)),
var views = [centered(working ? badge(.accent, 0.08, fixed(Spinner(), 40, 40)) : badge(.accent, 0.12, icon("hard-drive", 38))),
heading("Storage access", "Orchard Installer needs access to your device’s storage. This takes about a minute."),
steps, reopenNotice(restartsDevice)]
if !working { views.append(ActionButton("Continue", action: proceed)) }
if !working { views.append(centered(ActionButton("Continue", action: proceed))) }
return column(views)
}

/// 9.3.
private func accessFailed(restartsDevice: Bool, retry: @escaping () -> Void) -> UIView {
column([badge(.red, 0.12, icon("x", 38)),
column([centered(badge(.red, 0.12, icon("x", 38))),
heading("Couldn’t get storage access", "Your storage was not changed."),
reopenNotice(restartsDevice), ActionButton("Try again", action: retry)])
reopenNotice(restartsDevice), centered(ActionButton("Try again", action: retry))])
}

/// Shows the screen for the helper's status, read every second. Inside the Dopamine app
Expand All @@ -306,7 +310,16 @@ final class StatusController: UIViewController {
private let reading = DispatchQueue(label: "org.orchardlinux.companion.status")
private var status: Status?
private var shown: String?
/// The screen and the footer under it, in a scroll view for screens taller than the
/// window (phones on their side): the footer is at the bottom where there is room
/// and follows the screen where there isn't, never over it.
private let scroll = UIScrollView()
private let content = UIView()
/// The room above the footer, which the screen is centred in.
private let area = UIView()
/// The screen shown now, in the content beside the footer.
private var screenView: UIView?
private var margins: [NSLayoutConstraint] = []
private let minutes = label("", mono(14), .faint)
private var timer: Timer?

Expand All @@ -323,17 +336,40 @@ final class StatusController: UIViewController {
super.viewDidLoad()
view.backgroundColor = .background
let footer = label("Orchard Installer", mono(12), .faint, center: true)
// A phone's screen has no room for the iPad's margin.
let margin: CGFloat = min(UIScreen.main.bounds.width, UIScreen.main.bounds.height) < 600 ? 24 : 72
for v in [content, footer] { v.translatesAutoresizingMaskIntoConstraints = false; view.addSubview(v) }
footer.numberOfLines = 1
scroll.contentInsetAdjustmentBehavior = .never
scroll.alwaysBounceVertical = false
scroll.showsHorizontalScrollIndicator = false
scroll.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(scroll)
content.translatesAutoresizingMaskIntoConstraints = false
scroll.addSubview(content)
footer.translatesAutoresizingMaskIntoConstraints = false
content.addSubview(footer)
area.translatesAutoresizingMaskIntoConstraints = false
content.addSubview(area)
// The content is as wide as the window and at least as high; higher scrolls.
let fit = content.heightAnchor.constraint(equalTo: scroll.frameLayoutGuide.heightAnchor)
fit.priority = .defaultLow
NSLayoutConstraint.activate([
content.topAnchor.constraint(equalTo: view.topAnchor),
content.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: margin),
content.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -margin),
content.bottomAnchor.constraint(equalTo: footer.topAnchor),
footer.centerXAnchor.constraint(equalTo: view.centerXAnchor),
scroll.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
scroll.leadingAnchor.constraint(equalTo: view.leadingAnchor),
scroll.trailingAnchor.constraint(equalTo: view.trailingAnchor),
scroll.bottomAnchor.constraint(equalTo: view.bottomAnchor),
content.topAnchor.constraint(equalTo: scroll.contentLayoutGuide.topAnchor),
content.bottomAnchor.constraint(equalTo: scroll.contentLayoutGuide.bottomAnchor),
content.leadingAnchor.constraint(equalTo: scroll.contentLayoutGuide.leadingAnchor),
content.trailingAnchor.constraint(equalTo: scroll.contentLayoutGuide.trailingAnchor),
content.widthAnchor.constraint(equalTo: scroll.frameLayoutGuide.widthAnchor),
content.heightAnchor.constraint(greaterThanOrEqualTo: scroll.frameLayoutGuide.heightAnchor),
fit,
area.topAnchor.constraint(equalTo: content.topAnchor),
area.leadingAnchor.constraint(equalTo: content.leadingAnchor),
area.trailingAnchor.constraint(equalTo: content.trailingAnchor),
area.bottomAnchor.constraint(equalTo: footer.topAnchor),
footer.centerXAnchor.constraint(equalTo: content.centerXAnchor),
footer.heightAnchor.constraint(equalToConstant: 72),
footer.bottomAnchor.constraint(equalTo: view.bottomAnchor),
footer.bottomAnchor.constraint(equalTo: content.bottomAnchor),
])
render()
refresh()
Expand All @@ -343,6 +379,13 @@ final class StatusController: UIViewController {
}
}

/// A phone's screen has no room for the iPad's margin.
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
let margin: CGFloat = min(view.bounds.width, view.bounds.height) < 600 ? 24 : 72
for m in margins { m.constant = margin }
}

/// Reads the status and shows its screen when it changed.
private func refresh() {
guard gate == .open else { return }
Expand Down Expand Up @@ -375,9 +418,16 @@ final class StatusController: UIViewController {
case (.open, "idle"?, true?), (.open, "failed"?, true?): screen = "before"
default: screen = "waiting"
}
show(screen)
}

/// The screens `show` knows (the layout check goes through all of them).
static let screens = ["access", "access-working", "access-failed", "waiting", "before", "splitting", "done"]

func show(_ screen: String) {
guard screen != shown else { return }
shown = screen
content.subviews.forEach { $0.removeFromSuperview() }
screenView?.removeFromSuperview()
let view: UIView
switch screen {
case "access": view = storageAccess(working: false, restartsDevice: restartsDevice) { [weak self] in self?.proceed() }
Expand All @@ -390,11 +440,19 @@ final class StatusController: UIViewController {
}
view.translatesAutoresizingMaskIntoConstraints = false
content.addSubview(view)
NSLayoutConstraint.activate([
screenView = view
// The column: 500 wide, or what the margins leave.
let wanted = view.widthAnchor.constraint(equalTo: content.widthAnchor)
wanted.priority = .required - 1
let margin: CGFloat = min(self.view.bounds.width, self.view.bounds.height) < 600 ? 24 : 72
margins = [view.leadingAnchor.constraint(greaterThanOrEqualTo: content.leadingAnchor, constant: margin),
view.topAnchor.constraint(greaterThanOrEqualTo: area.topAnchor, constant: margin),
area.bottomAnchor.constraint(greaterThanOrEqualTo: view.bottomAnchor, constant: margin)]
NSLayoutConstraint.activate(margins + [
view.centerXAnchor.constraint(equalTo: content.centerXAnchor),
view.centerYAnchor.constraint(equalTo: content.centerYAnchor),
view.leadingAnchor.constraint(greaterThanOrEqualTo: content.leadingAnchor),
view.trailingAnchor.constraint(lessThanOrEqualTo: content.trailingAnchor),
view.centerYAnchor.constraint(equalTo: area.centerYAnchor),
view.widthAnchor.constraint(lessThanOrEqualToConstant: 500),
wanted,
])
}
}
Expand Down
27 changes: 26 additions & 1 deletion companion/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@
import UIKit

private func makeWindow(_ window: UIWindow) -> UIWindow {
let window = companionWindow(window, StatusController())
#if targetEnvironment(simulator)
// The simulator shows the Storage access pages too, to check them.
let gates: [String: StatusController.Gate] = ["ask": .ask, "working": .working, "failed": .failed, "checking": .checking]
let env = ProcessInfo.processInfo.environment
let controller = StatusController(gate: env["ORCHARD_COMPANION_GATE"].flatMap { gates[$0] } ?? .open)
controller.restartsDevice = env["ORCHARD_COMPANION_RESTARTS"] != nil
#else
let controller = StatusController()
#endif
let window = companionWindow(window, controller)
window.makeKeyAndVisible()
return window
}
Expand All @@ -23,6 +32,22 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
#if targetEnvironment(simulator)
if ProcessInfo.processInfo.environment["ORCHARD_LAYOUT_CHECK"] != nil {
LayoutCheck.start { [false, true].flatMap { restarts in
StatusController.screens.flatMap { screen in
LayoutCheck.problems(screen + (restarts ? " (restarts)" : "")) { _ in
let controller = StatusController(gate: .open) { nil }
controller.restartsDevice = restarts
controller.loadViewIfNeeded()
controller.show(screen)
return controller
}
}
}}
return true
}
#endif
application.isIdleTimerDisabled = true
// iOS 12 has no scenes: the window is the app's own.
if #available(iOS 13, *) {} else { window = makeWindow(UIWindow(frame: UIScreen.main.bounds)) }
Expand Down
Loading
Loading