mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-28 23:50:08 +00:00
feat(native): a calmer watch map, whole street names, a today page that ends clean
The place map is flat and muted without points of interest, with the stop's own pin; the day timeline gives a street two lines; the today page puts what follows into the card instead of a list cut off at the fold, and its header opens the day. The screenshot mode takes the real clock, moved to the hour a screen needs through the app's time zone, so the clock in the corner agrees; the capture covers three watch sizes, three languages and every state.
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
#!/bin/bash
|
||||
# Captures the watch app's screens from watchOS simulators, in screenshot mode
|
||||
# (client/ios/App/TREKWatch/DemoMode.swift), for review and the App Store:
|
||||
# every screen in English and German on the largest and the smallest watch,
|
||||
# and the main screens in every language on the smallest, where text is
|
||||
# tightest. .github/workflows/native.yml runs it after building the app.
|
||||
# every screen and its states in English, German and Russian on the newest
|
||||
# Ultra, the largest other watch and the smallest one, and the main screens in
|
||||
# every language on the smallest, where text is tightest.
|
||||
# .github/workflows/native.yml runs it after building the app.
|
||||
#
|
||||
# watch-screens.sh <TREKWatch.app> <output directory>
|
||||
set -euo pipefail
|
||||
@@ -13,8 +14,9 @@ OUT="$2"
|
||||
BUNDLE=com.liketrek.trek.watchkitapp
|
||||
mkdir -p "$OUT"
|
||||
|
||||
# The newest watchOS runtime, its newest Ultra, and the smallest watch it still runs on.
|
||||
read -r RUNTIME LARGE SMALL < <(xcrun simctl list runtimes -j | python3 -c '
|
||||
# The newest watchOS runtime, its newest Ultra, the largest other watch and the
|
||||
# smallest one it still runs on.
|
||||
read -r RUNTIME LARGE MEDIUM SMALL < <(xcrun simctl list runtimes -j | python3 -c '
|
||||
import json, re, sys
|
||||
runtimes = [r for r in json.load(sys.stdin)["runtimes"] if r["platform"] == "watchOS" and r["isAvailable"]]
|
||||
runtime = sorted(runtimes, key=lambda r: [int(x) for x in r["version"].split(".")])[-1]
|
||||
@@ -24,48 +26,81 @@ def mm(n):
|
||||
def gen(n):
|
||||
m = re.search(r"(?:Series|Ultra|SE) ?(\d+)?", n); return int(m.group(1) or 1) if m else 0
|
||||
ultra = sorted([n for n in names if "Ultra" in n], key=gen)[-1]
|
||||
small = sorted([n for n in names if "Ultra" not in n], key=lambda n: (mm(n), -gen(n)))[0]
|
||||
print(runtime["identifier"], ultra.replace(" ", "_"), small.replace(" ", "_"))')
|
||||
echo "runtime $RUNTIME"
|
||||
rest = sorted([n for n in names if "Ultra" not in n], key=lambda n: (mm(n), gen(n)))
|
||||
print(runtime["identifier"], *[n.replace(" ", "_") for n in (ultra, rest[-1], rest[0])])')
|
||||
LARGE=${LARGE//_/ }
|
||||
MEDIUM=${MEDIUM//_/ }
|
||||
SMALL=${SMALL//_/ }
|
||||
echo "large: $LARGE, small: $SMALL"
|
||||
echo "runtime $RUNTIME; large: $LARGE, medium: $MEDIUM, small: $SMALL"
|
||||
|
||||
boot() {
|
||||
local udid
|
||||
udid=$(xcrun simctl create "$1" "$1" "$RUNTIME")
|
||||
xcrun simctl boot "$udid"
|
||||
xcrun simctl bootstatus "$udid" -b >/dev/null
|
||||
xcrun simctl status_bar "$udid" override --time "13:05" >/dev/null 2>&1 || true
|
||||
xcrun simctl install "$udid" "$APP"
|
||||
echo "$udid"
|
||||
}
|
||||
|
||||
# shot <udid> <file> <screen> <language> [extra launch arguments]
|
||||
# A fixed-offset zone in which it is now <hour> o'clock, so the clock the
|
||||
# watch draws in the corner agrees with the time the screen is about.
|
||||
zone_for() {
|
||||
local offset=$(( ($1 - 10#$(date -u +%H) + 36) % 24 - 12 ))
|
||||
if [ "$offset" -ge 0 ]; then echo "Etc/GMT-$offset"; else echo "Etc/GMT+$(( -offset ))"; fi
|
||||
}
|
||||
|
||||
# shot <udid> <file> <screen> <scenario> <hour> <language>
|
||||
shot() {
|
||||
local udid=$1 file=$2 screen=$3 lang=$4
|
||||
shift 4
|
||||
local udid=$1 file=$2 screen=$3 scenario=$4 hour=$5 lang=$6
|
||||
local locale=${lang//-/_}
|
||||
xcrun simctl launch --terminate-running-process "$udid" "$BUNDLE" \
|
||||
-AppleLanguages "($lang)" -AppleLocale "$locale" -TrekDemo "$screen" "$@" >/dev/null || { echo "could not launch $file"; return 0; }
|
||||
case "$screen" in place) sleep 9 ;; *) sleep 4 ;; esac
|
||||
SIMCTL_CHILD_TZ=$(zone_for "$hour") xcrun simctl launch --terminate-running-process "$udid" "$BUNDLE" \
|
||||
-AppleLanguages "($lang)" -AppleLocale "$locale" -TrekDemo "$screen" -TrekScenario "$scenario" >/dev/null \
|
||||
|| { echo "could not launch $file"; return 0; }
|
||||
case "$screen" in place) sleep 10 ;; *) sleep 4 ;; esac
|
||||
xcrun simctl io "$udid" screenshot --type=png "$file" >/dev/null 2>&1 || echo "could not capture $file"
|
||||
}
|
||||
|
||||
ALL="today day place booking bookings trip days packing todos lists countdown empty nosync faces"
|
||||
MAIN="today booking countdown trip lists packing"
|
||||
# name screen scenario hour: every screen, and the states a screen has.
|
||||
SHOTS="
|
||||
today today running 13
|
||||
today-travelday today travelday 10
|
||||
today-done today running 22
|
||||
day day running 13
|
||||
place place running 13
|
||||
booking booking travelday 10
|
||||
booking-dinner booking running 17
|
||||
bookings bookings travelday 10
|
||||
booking-detail booking-detail travelday 10
|
||||
trip trip running 13
|
||||
trip-upcoming trip upcoming 9
|
||||
days days running 13
|
||||
countdown countdown upcoming 9
|
||||
lists lists upcoming 19
|
||||
packing packing upcoming 19
|
||||
todos todos upcoming 19
|
||||
empty empty running 12
|
||||
nosync nosync running 12
|
||||
faces faces running 13
|
||||
"
|
||||
MAIN="today booking countdown trip lists packing day"
|
||||
LANGS="ar az ca cs de el en es et fr he hu id it ja ko nl pl pt-BR ru sk sv th tr uk vi zh-Hans zh-Hant"
|
||||
|
||||
run() {
|
||||
local size=$1 name=$2 udid
|
||||
udid=$(boot "$name" | tail -1)
|
||||
for lang in en de; do
|
||||
for screen in $ALL; do shot "$udid" "$OUT/$size-$lang-$screen.png" "$screen" "$lang"; done
|
||||
for lang in en de ru; do
|
||||
while read -r shotname screen scenario hour; do
|
||||
[ -n "$shotname" ] || continue
|
||||
shot "$udid" "$OUT/$size-$lang-$shotname.png" "$screen" "$scenario" "$hour" "$lang"
|
||||
done <<< "$SHOTS"
|
||||
done
|
||||
if [ "$size" = small ]; then
|
||||
for lang in $LANGS; do
|
||||
[ "$lang" = en ] || [ "$lang" = de ] && continue
|
||||
for screen in $MAIN; do shot "$udid" "$OUT/$size-$lang-$screen.png" "$screen" "$lang"; done
|
||||
case "$lang" in en|de|ru) continue ;; esac
|
||||
while read -r shotname screen scenario hour; do
|
||||
[ -n "$shotname" ] || continue
|
||||
case " $MAIN " in *" $shotname "*) shot "$udid" "$OUT/$size-$lang-$shotname.png" "$screen" "$scenario" "$hour" "$lang" ;; esac
|
||||
done <<< "$SHOTS"
|
||||
done
|
||||
fi
|
||||
xcrun simctl shutdown "$udid" || true
|
||||
@@ -73,10 +108,12 @@ run() {
|
||||
|
||||
run large "$LARGE" &
|
||||
large=$!
|
||||
run medium "$MEDIUM" &
|
||||
medium=$!
|
||||
run small "$SMALL" &
|
||||
small=$!
|
||||
wait "$large"
|
||||
wait "$medium"
|
||||
wait "$small"
|
||||
echo "$LARGE" > "$OUT/devices.txt"
|
||||
echo "$SMALL" >> "$OUT/devices.txt"
|
||||
printf '%s\n' "large: $LARGE" "medium: $MEDIUM" "small: $SMALL" > "$OUT/devices.txt"
|
||||
ls "$OUT" | wc -l
|
||||
|
||||
Reference in New Issue
Block a user