#!/bin/bash
# Schermate grezze per gli store (impostazioni e luoghi, in italiano) dal
# simulatore: ./scripts/schermate-ios.sh <udid> <cartella>. Per le altre
# schermate si aggiungono flussi in maestro/schermate/.
# Simulatori propri: «STS iPhone 18 Pro Max» (1320×2868) e «STS iPad Pro 13».
# Sull'iPad iOS 27 mette nome dell'app e data nella barra: si incolla la
# striscia in alto (64 px) di una schermata vecchia.
set -e
U=$1; OUT=$2; M="$(dirname "$0")/../maestro/schermate"
APP=~/dev/spotthespy/build/sim/Build/Products/Release-iphonesimulator/SpotTheSpy.app
export JAVA_HOME=~/.jdks/jdk-17.0.20.1+1/Contents/Home
xcrun simctl boot $U 2>/dev/null || true
xcrun simctl bootstatus $U -b >/dev/null
xcrun simctl spawn $U defaults write -g AppleLanguages -array it
xcrun simctl spawn $U defaults write -g AppleLocale it_IT
xcrun simctl status_bar $U override --time "09:41" --batteryState discharging --batteryLevel 100 --cellularBars 4 --wifiBars 3
xcrun simctl install $U "$APP"
~/.maestro/bin/maestro --device $U test "$M/vai-impostazioni.yaml"
sleep 1; xcrun simctl io $U screenshot "$OUT/02-impostazioni.png"
~/.maestro/bin/maestro --device $U test "$M/vai-luoghi.yaml"
sleep 2; xcrun simctl io $U screenshot "$OUT/06-luoghi.png"
