mirror of
https://github.com/anomalyco/hex.git
synced 2026-12-05 10:45:15 +01:00
What: a full-height sheet over Home, "What's new in Hex", with the release's items in one vertical scroll (a cropped picture from the real app over a name and one sentence) and Continue kept at the bottom; Continue or a swipe down closes it. Home gets a What's new row under Run setup again that opens it any time. 1.0.5's six: Dutch, Swedish and Slovak; Emoji as you type; Word replacements; Kept when the screen locks; Key colors; Send feedback. English and Simplified Chinese for every string; the two pictures that show Hex's own words have a zh-Hans variant. When it shows (WhatsNew, WhatsNewMoment): the newest list at or below the app's version (TestFlight's 9.0.0 gets the newest list once), marked seen in Hex's UserDefaults (whatsNew.seen) as it appears. Never on a first run: a launch that opens onboarding marks the list seen. Only on a plain open over Home: 1 s after Hex comes to the front, and not if a link opened Hex since it was last in the background (keyboard hand-off, Open Hex, a words file, setup), a sheet, page or anything presented is showing, a dictation is recording or transcribing, Hex is asking for the microphone, or Hex isn't active. The keyboard never shows it; it downloads nothing. Why: Ryan asked for a short visual changelog shown only the first time the app opens after an update. Pictures: eight JPEGs at 3x in Assets.xcassets/WhatsNew (344 KB), cropped from iPhone 18 Pro simulator screenshots; scenes and crop boxes in docs/settings-and-home.md. Two picture scenes are new and debug builds only (#if DEBUG in FullKeyboardSnapshotStage): emoji-word and strip-stopped. Also new: --snap-state settings-whats-new. Verified (Mac Studio simbox, iPhone 18 Pro, iOS 27.2): - Real update: ios-beta-appstore-1.0.4's tree built as 1.0.4, onboarding finished in its UI, then this build stamped 1.0.5 installed over it. Opened by the keyboard's hand-off, Open Hex and the setup link: no sheet, nothing marked. First plain open: the sheet. Second open: none (seen 1.0.5). - A Hex words file opening Hex, and iOS's microphone prompt: no sheet. A fresh install: onboarding, then Home without it, and none on the next open. - iPhone SE (3rd generation) and landscape, English and Chinese: everything wraps; VoiceOver reads the title, then each name, sentence and picture label. - Release build: the debug-only scene strings are absent. - New tests in SettingsHierarchyTests (which list a version gets, first run, once after an update, each blocking moment, every picture present).
150 lines
6.7 KiB
Swift
150 lines
6.7 KiB
Swift
import SwiftUI
|
||
import UIKit
|
||
|
||
/// One release's What's new: the App Store version that brings it, and its items.
|
||
struct WhatsNewRelease: Identifiable, Equatable {
|
||
let version: String
|
||
let items: [WhatsNewItem]
|
||
|
||
var id: String { version }
|
||
}
|
||
|
||
/// A picture from the real app (Assets.xcassets › WhatsNew › `picture`), a name and a sentence.
|
||
struct WhatsNewItem: Identifiable, Equatable {
|
||
let picture: String
|
||
let title: LocalizedStringResource
|
||
let detail: LocalizedStringResource
|
||
/// What the picture shows, for VoiceOver.
|
||
let pictureLabel: LocalizedStringResource
|
||
|
||
var id: String { picture }
|
||
var imageName: String { "WhatsNew/\(picture)" }
|
||
|
||
static func == (lhs: WhatsNewItem, rhs: WhatsNewItem) -> Bool { lhs.picture == rhs.picture }
|
||
}
|
||
|
||
/// What else is going on when What's new could show.
|
||
struct WhatsNewMoment: Equatable {
|
||
/// A link opened Hex since it last came to the front: the keyboard's hand-off or Open Hex,
|
||
/// a words file, setup.
|
||
var openedByLink = false
|
||
var shownThisLaunch = false
|
||
var setupSheet = false
|
||
/// A Settings page over Home.
|
||
var settingsPage = false
|
||
/// Anything presented over Home: a words file's review, Safari, Send feedback.
|
||
var presenting = false
|
||
/// Recording, transcribing, or asking for the microphone.
|
||
var dictationBusy = false
|
||
var active = true
|
||
}
|
||
|
||
/// What's new, shown once in a sheet over Home on the first plain open after an update that
|
||
/// brings a list; never on a first run (onboarding is), never from a link, and never again
|
||
/// once it has shown. Home's What's new row opens it any time.
|
||
@MainActor
|
||
enum WhatsNew {
|
||
/// Newest first. A release with something to show adds its list at the top, with a
|
||
/// picture per item in Assets.xcassets › WhatsNew (docs/settings-and-home.md says how
|
||
/// they're made).
|
||
static let releases: [WhatsNewRelease] = [
|
||
WhatsNewRelease(version: "1.0.5", items: [
|
||
WhatsNewItem(
|
||
picture: "languages",
|
||
title: "Dutch, Swedish and Slovak",
|
||
detail: "Add one in Keyboard › Languages to type with its own letters, like å, ä and ö.",
|
||
pictureLabel: "Hex's Swedish keyboard, with the keys å, ä and ö."
|
||
),
|
||
WhatsNewItem(
|
||
picture: "emoji",
|
||
title: "Emoji as you type",
|
||
detail: "Type a word like “smile” and tap the 😊 above the keys to put it in its place.",
|
||
pictureLabel: "The keyboard offering 😊 above the keys while “smile” is typed."
|
||
),
|
||
WhatsNewItem(
|
||
picture: "replacements",
|
||
title: "Word replacements",
|
||
detail: "In Dictation › Custom vocabulary, tell Hex to write “GitHub” when it hears “jet hub”, and share your list as a file.",
|
||
pictureLabel: "Word replacements, with “jet hub” written as “GitHub”."
|
||
),
|
||
WhatsNewItem(
|
||
picture: "kept",
|
||
title: "Kept when the screen locks",
|
||
detail: "If your iPhone locks mid-dictation, what you said is kept: tap Paste in the keyboard to put it in.",
|
||
pictureLabel: "The keyboard saying the dictation stopped at 0:44, with Paste."
|
||
),
|
||
WhatsNewItem(
|
||
picture: "key-colors",
|
||
title: "Key colors",
|
||
detail: "Turn on Key colors in Labs, which used to be Experiments, and pick a color for the keys.",
|
||
pictureLabel: "Hex's keyboard with burgundy keys."
|
||
),
|
||
WhatsNewItem(
|
||
picture: "feedback",
|
||
title: "Send feedback",
|
||
detail: "Tap Send feedback at the bottom of Home to tell us what to fix or add, with a screenshot if it helps.",
|
||
pictureLabel: "The Send feedback form."
|
||
),
|
||
]),
|
||
]
|
||
|
||
/// The version of the last list that showed, in Hex's own `UserDefaults`.
|
||
static let seenKey = "whatsNew.seen"
|
||
|
||
/// The list for this version: the newest one at or below it, so TestFlight's 9.0.0 shows
|
||
/// the newest list once, and a version without a list of its own shows nothing new.
|
||
static func release(forAppVersion version: String, in releases: [WhatsNewRelease] = releases) -> WhatsNewRelease? {
|
||
releases
|
||
.filter { version.compare($0.version, options: .numeric) != .orderedAscending }
|
||
.max { $0.version.compare($1.version, options: .numeric) == .orderedAscending }
|
||
}
|
||
|
||
static var current: WhatsNewRelease? {
|
||
let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? ""
|
||
return release(forAppVersion: version)
|
||
}
|
||
|
||
/// The list due at this launch, decided once per process as Home first shows. A first run
|
||
/// (onboarding opened at launch, or resumed) marks the current list seen instead.
|
||
static let dueAtLaunch: WhatsNewRelease? = {
|
||
if snapshotShows { return current }
|
||
guard !OnboardingFixture.isSnapshot else { return nil }
|
||
return decideAtLaunch(current, defaults: .standard, firstRun: OnboardingProgress.launchPage != nil)
|
||
}()
|
||
|
||
static func decideAtLaunch(_ release: WhatsNewRelease?, defaults: UserDefaults, firstRun: Bool) -> WhatsNewRelease? {
|
||
guard let release else { return nil }
|
||
if firstRun {
|
||
markSeen(release, defaults: defaults)
|
||
return nil
|
||
}
|
||
return defaults.string(forKey: seenKey) == release.version ? nil : release
|
||
}
|
||
|
||
/// Only over Home itself, on an open no link asked for, with nothing else going on.
|
||
static func shows(_ due: WhatsNewRelease?, at moment: WhatsNewMoment) -> WhatsNewRelease? {
|
||
guard let due, moment.active, !moment.openedByLink, !moment.shownThisLaunch, !moment.setupSheet,
|
||
!moment.settingsPage, !moment.presenting, !moment.dictationBusy else { return nil }
|
||
return due
|
||
}
|
||
|
||
/// Seen as it shows, so a lock or a quit part-way never brings it back.
|
||
static func markSeen(_ release: WhatsNewRelease, defaults: UserDefaults = .standard) {
|
||
defaults.set(release.version, forKey: seenKey)
|
||
}
|
||
|
||
/// `--snap-state settings-whats-new`: Home with the sheet open.
|
||
static var snapshotShows: Bool { SettingsSnapshotFixture.scene == "settings-whats-new" }
|
||
|
||
/// This process's part of the moment: set by HEXMobileApp (links, back to the background)
|
||
/// and by Home as the sheet shows.
|
||
static var openedByLink = false
|
||
static var shownThisLaunch = false
|
||
|
||
static var somethingIsPresented: Bool {
|
||
UIApplication.shared.connectedScenes
|
||
.compactMap { $0 as? UIWindowScene }
|
||
.flatMap(\.windows)
|
||
.contains { $0.rootViewController?.presentedViewController != nil }
|
||
}
|
||
}
|