← All repositories

reportage

A life-logging app for iPhone

git clone https://code.inqk.net/reportage.git


Reportage/Views/LockView.swift (1606B)

1import SwiftUI
2
3/// What covers the app: the lock screen while it's locked, and otherwise a
4/// blur of the app itself, which is what the app switcher shows.
5struct CoverView: View {
6    let lock: AppLock
7
8    var body: some View {
9        if lock.isLocked {
10            LockView(lock: lock)
11        } else {
12            Rectangle()
13                .fill(.ultraThickMaterial)
14                .ignoresSafeArea()
15        }
16    }
17}
18
19/// The lock screen: the app's name and a button to unlock it.
20struct LockView: View {
21    let lock: AppLock
22
23    var body: some View {
24        VStack(spacing: Theme.promptGap) {
25            Spacer()
26            Text("Reportage\(Text(".").foregroundStyle(Theme.mark))", comment: "The app's name on the lock screen, with a coloured full stop")
27                .screenTitle()
28                .accessibilityLabel(Text("Reportage"))
29            Spacer()
30            Button {
31                Task { await lock.unlock() }
32            } label: {
33                Text("Unlock with \(Text(lock.methodName))", comment: "Unlocks the app; the method is Face ID, Touch ID or Passcode")
34                    .font(.body.weight(.semibold))
35                    .foregroundStyle(Theme.onAccent)
36                    .frame(maxWidth: .infinity, minHeight: 52)
37                    .background(Theme.accent, in: .capsule)
38            }
39            .buttonStyle(.plain)
40            .padding(.horizontal, Theme.margin)
41            .padding(.vertical, 12)
42        }
43        .frame(maxWidth: .infinity, maxHeight: .infinity)
44        .background(Theme.paper)
45        .foregroundStyle(Theme.ink)
46    }
47}