Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.
Swift apple-siliconcustom-formathomebrewiosipaipadipadosiphonemetalnative-portnintendo-switchnxnativeromfsswitch-games
iOS shell views: art-led library, Cover Flow and settings for iPhone and iPad
v0lumehib37e6b78461b
diff --git a/frontend-ios/.gitignore b/frontend-ios/.gitignorenew file mode 100644index 00000000..308fb0ab--- /dev/null+++ b/frontend-ios/.gitignore@@ -0,0 +1,6 @@+.build/+.swiftpm/+DerivedData/+*.xcresult/+xcuserdata/+QA/diff --git a/frontend-ios/Demo/ShellDemo.xcodeproj/project.pbxproj b/frontend-ios/Demo/ShellDemo.xcodeproj/project.pbxprojnew file mode 100644index 00000000..dd4ed636--- /dev/null+++ b/frontend-ios/Demo/ShellDemo.xcodeproj/project.pbxproj@@ -0,0 +1,486 @@+// !$*UTF8*$!+{+ archiveVersion = 1;+ classes = {+ };+ objectVersion = 77;+ objects = {++/* Begin PBXBuildFile section */+ 2861C1407044359116FE0A66 /* ShellCaptureTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8694319745E3759D50772855 /* ShellCaptureTests.swift */; };+ 3E143B39E0F97A669D2F6EFF /* ShellAdditionalTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DF3DBBE6BC067DDD34E3560C /* ShellAdditionalTests.swift */; };+ 44E0EBFDB9557A0C8BB741BE /* ShellUI in Frameworks */ = {isa = PBXBuildFile; productRef = 7F6858A53523100F9E10590E /* ShellUI */; };+ 4749F987D74B27CAA0E02480 /* ShellDemoApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 59E0A7AE45425C5BA9689FE4 /* ShellDemoApp.swift */; };+ D94D715334EE4F5E0CCBA788 /* SampleArt.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39DB78D11BCF59879A3712F5 /* SampleArt.swift */; };+ DF097C40B129901722DD4DF3 /* ShellDemoUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 916109EC3198FC9C0E9D655B /* ShellDemoUITests.swift */; };+ E305EAC2B52CE23FC907C7C7 /* DemoControllerInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = 779E0E026682ED6CDDF647C6 /* DemoControllerInput.swift */; };+ E71FEFEAE303CA4343BBDE2E /* SampleData.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBE23919FFDC3D06EF0D3065 /* SampleData.swift */; };+ F15D381F62331B5172AD6D22 /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = D1591481D38DDC20A1A9B215 /* Localizable.xcstrings */; };+/* End PBXBuildFile section */++/* Begin PBXContainerItemProxy section */+ A478FB37CABC371EA8134656 /* PBXContainerItemProxy */ = {+ isa = PBXContainerItemProxy;+ containerPortal = D41A7603C6BA5BB604CCFDE4 /* Project object */;+ proxyType = 1;+ remoteGlobalIDString = 85AF0342F954D1F33C949240;+ remoteInfo = ShellDemoApp;+ };+/* End PBXContainerItemProxy section */++/* Begin PBXFileReference section */+ 39DB78D11BCF59879A3712F5 /* SampleArt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleArt.swift; sourceTree = "<group>"; };+ 59E0A7AE45425C5BA9689FE4 /* ShellDemoApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShellDemoApp.swift; sourceTree = "<group>"; };+ 779E0E026682ED6CDDF647C6 /* DemoControllerInput.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoControllerInput.swift; sourceTree = "<group>"; };+ 8694319745E3759D50772855 /* ShellCaptureTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShellCaptureTests.swift; sourceTree = "<group>"; };+ 916109EC3198FC9C0E9D655B /* ShellDemoUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShellDemoUITests.swift; sourceTree = "<group>"; };+ B1D199F3FD9C677BD245559E /* ShellDemoApp.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; path = ShellDemoApp.app; sourceTree = BUILT_PRODUCTS_DIR; };+ B88394C7E11B302B2B420DF2 /* frontend-ios */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "frontend-ios"; path = ..; sourceTree = SOURCE_ROOT; };+ CBE23919FFDC3D06EF0D3065 /* SampleData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleData.swift; sourceTree = "<group>"; };+ CEB77983EFFD9EA46FE3DFDF /* ShellDemoUITests.xctest */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.cfbundle; path = ShellDemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };+ D1591481D38DDC20A1A9B215 /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = "<group>"; };+ DF3DBBE6BC067DDD34E3560C /* ShellAdditionalTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShellAdditionalTests.swift; sourceTree = "<group>"; };+/* End PBXFileReference section */++/* Begin PBXFrameworksBuildPhase section */+ 1BD5DBF0EF5C005698AA1F08 /* Frameworks */ = {+ isa = PBXFrameworksBuildPhase;+ buildActionMask = 2147483647;+ files = (+ 44E0EBFDB9557A0C8BB741BE /* ShellUI in Frameworks */,+ );+ runOnlyForDeploymentPostprocessing = 0;+ };+/* End PBXFrameworksBuildPhase section */++/* Begin PBXGroup section */+ 2152F5714F5AA74B9FBBB0F0 /* Packages */ = {+ isa = PBXGroup;+ children = (+ B88394C7E11B302B2B420DF2 /* frontend-ios */,+ );+ name = Packages;+ sourceTree = "<group>";+ };+ 5928E24F76B598AD8FD0D1AB /* ShellDemo */ = {+ isa = PBXGroup;+ children = (+ 779E0E026682ED6CDDF647C6 /* DemoControllerInput.swift */,+ 39DB78D11BCF59879A3712F5 /* SampleArt.swift */,+ CBE23919FFDC3D06EF0D3065 /* SampleData.swift */,+ 59E0A7AE45425C5BA9689FE4 /* ShellDemoApp.swift */,+ DAD47348DC7356A3CEDE7BE1 /* Resources */,+ );+ name = ShellDemo;+ path = ../Sources/ShellDemo;+ sourceTree = "<group>";+ };+ B149173B288581EEEA22408A /* UITests */ = {+ isa = PBXGroup;+ children = (+ DF3DBBE6BC067DDD34E3560C /* ShellAdditionalTests.swift */,+ 8694319745E3759D50772855 /* ShellCaptureTests.swift */,+ 916109EC3198FC9C0E9D655B /* ShellDemoUITests.swift */,+ );+ name = UITests;+ path = ../UITests;+ sourceTree = "<group>";+ };+ BCC2A2B39C0D1F8C141AEED5 /* Products */ = {+ isa = PBXGroup;+ children = (+ B1D199F3FD9C677BD245559E /* ShellDemoApp.app */,+ CEB77983EFFD9EA46FE3DFDF /* ShellDemoUITests.xctest */,+ );+ name = Products;+ sourceTree = "<group>";+ };+ DAD47348DC7356A3CEDE7BE1 /* Resources */ = {+ isa = PBXGroup;+ children = (+ D1591481D38DDC20A1A9B215 /* Localizable.xcstrings */,+ );+ path = Resources;+ sourceTree = "<group>";+ };+ E65C041019EAFE79D28C3E4E = {+ isa = PBXGroup;+ children = (+ 2152F5714F5AA74B9FBBB0F0 /* Packages */,+ 5928E24F76B598AD8FD0D1AB /* ShellDemo */,+ B149173B288581EEEA22408A /* UITests */,+ BCC2A2B39C0D1F8C141AEED5 /* Products */,+ );+ sourceTree = "<group>";+ };+/* End PBXGroup section */++/* Begin PBXNativeTarget section */+ 85AF0342F954D1F33C949240 /* ShellDemoApp */ = {+ isa = PBXNativeTarget;+ buildConfigurationList = 6661A7253C258D435E406EBE /* Build configuration list for PBXNativeTarget "ShellDemoApp" */;+ buildPhases = (+ 536BC63D68A4CE4BF976542B /* Sources */,+ 935E6F65D1EC83E09A8C1441 /* Resources */,+ 1BD5DBF0EF5C005698AA1F08 /* Frameworks */,+ );+ buildRules = (+ );+ dependencies = (+ );+ name = ShellDemoApp;+ packageProductDependencies = (+ 7F6858A53523100F9E10590E /* ShellUI */,+ );+ productName = ShellDemoApp;+ productReference = B1D199F3FD9C677BD245559E /* ShellDemoApp.app */;+ productType = "com.apple.product-type.application";+ };+ BBE3C0425143E6EB56C6DE55 /* ShellDemoUITests */ = {+ isa = PBXNativeTarget;+ buildConfigurationList = 0B7286BAE8C77C9BA63AD93C /* Build configuration list for PBXNativeTarget "ShellDemoUITests" */;+ buildPhases = (+ 5EE547D3477141577E328902 /* Sources */,+ );+ buildRules = (+ );+ dependencies = (+ B47C14E4357B7410B62D3A8F /* PBXTargetDependency */,+ );+ name = ShellDemoUITests;+ packageProductDependencies = (+ );+ productName = ShellDemoUITests;+ productReference = CEB77983EFFD9EA46FE3DFDF /* ShellDemoUITests.xctest */;+ productType = "com.apple.product-type.bundle.ui-testing";+ };+/* End PBXNativeTarget section */++/* Begin PBXProject section */+ D41A7603C6BA5BB604CCFDE4 /* Project object */ = {+ isa = PBXProject;+ attributes = {+ BuildIndependentTargetsInParallel = YES;+ LastUpgradeCheck = 1430;+ TargetAttributes = {+ BBE3C0425143E6EB56C6DE55 = {+ TestTargetID = 85AF0342F954D1F33C949240;+ };+ };+ };+ buildConfigurationList = AA82EEAB83FEAB5062E81055 /* Build configuration list for PBXProject "ShellDemo" */;+ developmentRegion = en;+ hasScannedForEncodings = 0;+ knownRegions = (+ Base,+ en,+ );+ mainGroup = E65C041019EAFE79D28C3E4E;+ minimizedProjectReferenceProxies = 1;+ packageReferences = (+ 1929FA0375E6966DA0CB3064 /* XCLocalSwiftPackageReference ".." */,+ );+ preferredProjectObjectVersion = 77;+ productRefGroup = BCC2A2B39C0D1F8C141AEED5 /* Products */;+ projectDirPath = "";+ projectRoot = "";+ targets = (+ 85AF0342F954D1F33C949240 /* ShellDemoApp */,+ BBE3C0425143E6EB56C6DE55 /* ShellDemoUITests */,+ );+ };+/* End PBXProject section */++/* Begin PBXResourcesBuildPhase section */+ 935E6F65D1EC83E09A8C1441 /* Resources */ = {+ isa = PBXResourcesBuildPhase;+ buildActionMask = 2147483647;+ files = (+ F15D381F62331B5172AD6D22 /* Localizable.xcstrings in Resources */,+ );+ runOnlyForDeploymentPostprocessing = 0;+ };+/* End PBXResourcesBuildPhase section */++/* Begin PBXSourcesBuildPhase section */+ 536BC63D68A4CE4BF976542B /* Sources */ = {+ isa = PBXSourcesBuildPhase;+ buildActionMask = 2147483647;+ files = (+ E305EAC2B52CE23FC907C7C7 /* DemoControllerInput.swift in Sources */,+ D94D715334EE4F5E0CCBA788 /* SampleArt.swift in Sources */,+ E71FEFEAE303CA4343BBDE2E /* SampleData.swift in Sources */,+ 4749F987D74B27CAA0E02480 /* ShellDemoApp.swift in Sources */,+ );+ runOnlyForDeploymentPostprocessing = 0;+ };+ 5EE547D3477141577E328902 /* Sources */ = {+ isa = PBXSourcesBuildPhase;+ buildActionMask = 2147483647;+ files = (+ 3E143B39E0F97A669D2F6EFF /* ShellAdditionalTests.swift in Sources */,+ 2861C1407044359116FE0A66 /* ShellCaptureTests.swift in Sources */,+ DF097C40B129901722DD4DF3 /* ShellDemoUITests.swift in Sources */,+ );+ runOnlyForDeploymentPostprocessing = 0;+ };+/* End PBXSourcesBuildPhase section */++/* Begin PBXTargetDependency section */+ B47C14E4357B7410B62D3A8F /* PBXTargetDependency */ = {+ isa = PBXTargetDependency;+ target = 85AF0342F954D1F33C949240 /* ShellDemoApp */;+ targetProxy = A478FB37CABC371EA8134656 /* PBXContainerItemProxy */;+ };+/* End PBXTargetDependency section */++/* Begin XCBuildConfiguration section */+ 073F03F5C7D2C0957D216254 /* Release */ = {+ isa = XCBuildConfiguration;+ buildSettings = {+ ALWAYS_SEARCH_USER_PATHS = NO;+ CLANG_ANALYZER_NONNULL = YES;+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";+ CLANG_CXX_LIBRARY = "libc++";+ CLANG_ENABLE_MODULES = YES;+ CLANG_ENABLE_OBJC_ARC = YES;+ CLANG_ENABLE_OBJC_WEAK = YES;+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;+ CLANG_WARN_BOOL_CONVERSION = YES;+ CLANG_WARN_COMMA = YES;+ CLANG_WARN_CONSTANT_CONVERSION = YES;+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;+ CLANG_WARN_EMPTY_BODY = YES;+ CLANG_WARN_ENUM_CONVERSION = YES;+ CLANG_WARN_INFINITE_RECURSION = YES;+ CLANG_WARN_INT_CONVERSION = YES;+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;+ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;+ CLANG_WARN_STRICT_PROTOTYPES = YES;+ CLANG_WARN_SUSPICIOUS_MOVE = YES;+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;+ CLANG_WARN_UNREACHABLE_CODE = YES;+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;+ CODE_SIGNING_ALLOWED = NO;+ COPY_PHASE_STRIP = NO;+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";+ ENABLE_NS_ASSERTIONS = NO;+ ENABLE_STRICT_OBJC_MSGSEND = YES;+ GCC_C_LANGUAGE_STANDARD = gnu11;+ GCC_NO_COMMON_BLOCKS = YES;+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;+ GCC_WARN_UNDECLARED_SELECTOR = YES;+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;+ GCC_WARN_UNUSED_FUNCTION = YES;+ GCC_WARN_UNUSED_VARIABLE = YES;+ GENERATE_INFOPLIST_FILE = YES;+ INFOPLIST_KEY_CFBundleDisplayName = "Shell Demo";+ INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;+ INFOPLIST_KEY_UILaunchScreen_Generation = YES;+ INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortraitUpsideDown";+ INFOPLIST_KEY_UIUserInterfaceStyle = Dark;+ IPHONEOS_DEPLOYMENT_TARGET = 26.0;+ MTL_ENABLE_DEBUG_INFO = NO;+ MTL_FAST_MATH = YES;+ PRODUCT_NAME = "$(TARGET_NAME)";+ SDKROOT = iphoneos;+ SUPPORTS_MACCATALYST = NO;+ SWIFT_COMPILATION_MODE = wholemodule;+ SWIFT_EMIT_LOC_STRINGS = YES;+ SWIFT_OPTIMIZATION_LEVEL = "-O";+ SWIFT_VERSION = 6.0;+ TARGETED_DEVICE_FAMILY = "1,2";+ };+ name = Release;+ };+ 1B3011F907AA12EB1C214CAB /* Debug */ = {+ isa = XCBuildConfiguration;+ buildSettings = {+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;+ CODE_SIGN_IDENTITY = "iPhone Developer";+ LD_RUNPATH_SEARCH_PATHS = (+ "$(inherited)",+ "@executable_path/Frameworks",+ );+ PRODUCT_BUNDLE_IDENTIFIER = dev.shellui.ShellDemoApp;+ SDKROOT = iphoneos;+ TARGETED_DEVICE_FAMILY = "1,2";+ };+ name = Debug;+ };+ 1DADDAC25FD575CDBD49469A /* Release */ = {+ isa = XCBuildConfiguration;+ buildSettings = {+ BUNDLE_LOADER = "$(TEST_HOST)";+ LD_RUNPATH_SEARCH_PATHS = (+ "$(inherited)",+ "@executable_path/Frameworks",+ "@loader_path/Frameworks",+ );+ PRODUCT_BUNDLE_IDENTIFIER = dev.shellui.ShellDemoUITests;+ SDKROOT = iphoneos;+ TARGETED_DEVICE_FAMILY = "1,2";+ TEST_TARGET_NAME = ShellDemoApp;+ };+ name = Release;+ };+ 4B96CA7B30D2B36B6369F0DE /* Release */ = {+ isa = XCBuildConfiguration;+ buildSettings = {+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;+ CODE_SIGN_IDENTITY = "iPhone Developer";+ LD_RUNPATH_SEARCH_PATHS = (+ "$(inherited)",+ "@executable_path/Frameworks",+ );+ PRODUCT_BUNDLE_IDENTIFIER = dev.shellui.ShellDemoApp;+ SDKROOT = iphoneos;+ TARGETED_DEVICE_FAMILY = "1,2";+ };+ name = Release;+ };+ B1AA224613E947AA9CA7C2E3 /* Debug */ = {+ isa = XCBuildConfiguration;+ buildSettings = {+ ALWAYS_SEARCH_USER_PATHS = NO;+ CLANG_ANALYZER_NONNULL = YES;+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";+ CLANG_CXX_LIBRARY = "libc++";+ CLANG_ENABLE_MODULES = YES;+ CLANG_ENABLE_OBJC_ARC = YES;+ CLANG_ENABLE_OBJC_WEAK = YES;+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;+ CLANG_WARN_BOOL_CONVERSION = YES;+ CLANG_WARN_COMMA = YES;+ CLANG_WARN_CONSTANT_CONVERSION = YES;+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;+ CLANG_WARN_EMPTY_BODY = YES;+ CLANG_WARN_ENUM_CONVERSION = YES;+ CLANG_WARN_INFINITE_RECURSION = YES;+ CLANG_WARN_INT_CONVERSION = YES;+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;+ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;+ CLANG_WARN_STRICT_PROTOTYPES = YES;+ CLANG_WARN_SUSPICIOUS_MOVE = YES;+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;+ CLANG_WARN_UNREACHABLE_CODE = YES;+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;+ CODE_SIGNING_ALLOWED = NO;+ COPY_PHASE_STRIP = NO;+ DEBUG_INFORMATION_FORMAT = dwarf;+ ENABLE_STRICT_OBJC_MSGSEND = YES;+ ENABLE_TESTABILITY = YES;+ GCC_C_LANGUAGE_STANDARD = gnu11;+ GCC_DYNAMIC_NO_PIC = NO;+ GCC_NO_COMMON_BLOCKS = YES;+ GCC_OPTIMIZATION_LEVEL = 0;+ GCC_PREPROCESSOR_DEFINITIONS = (+ "$(inherited)",+ "DEBUG=1",+ );+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;+ GCC_WARN_UNDECLARED_SELECTOR = YES;+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;+ GCC_WARN_UNUSED_FUNCTION = YES;+ GCC_WARN_UNUSED_VARIABLE = YES;+ GENERATE_INFOPLIST_FILE = YES;+ INFOPLIST_KEY_CFBundleDisplayName = "Shell Demo";+ INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;+ INFOPLIST_KEY_UILaunchScreen_Generation = YES;+ INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortraitUpsideDown";+ INFOPLIST_KEY_UIUserInterfaceStyle = Dark;+ IPHONEOS_DEPLOYMENT_TARGET = 26.0;+ MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;+ MTL_FAST_MATH = YES;+ ONLY_ACTIVE_ARCH = YES;+ PRODUCT_NAME = "$(TARGET_NAME)";+ SDKROOT = iphoneos;+ SUPPORTS_MACCATALYST = NO;+ SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;+ SWIFT_EMIT_LOC_STRINGS = YES;+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";+ SWIFT_VERSION = 6.0;+ TARGETED_DEVICE_FAMILY = "1,2";+ };+ name = Debug;+ };+ CC69F74A268055276006EE97 /* Debug */ = {+ isa = XCBuildConfiguration;+ buildSettings = {+ BUNDLE_LOADER = "$(TEST_HOST)";+ LD_RUNPATH_SEARCH_PATHS = (+ "$(inherited)",+ "@executable_path/Frameworks",+ "@loader_path/Frameworks",+ );+ PRODUCT_BUNDLE_IDENTIFIER = dev.shellui.ShellDemoUITests;+ SDKROOT = iphoneos;+ TARGETED_DEVICE_FAMILY = "1,2";+ TEST_TARGET_NAME = ShellDemoApp;+ };+ name = Debug;+ };+/* End XCBuildConfiguration section */++/* Begin XCConfigurationList section */+ 0B7286BAE8C77C9BA63AD93C /* Build configuration list for PBXNativeTarget "ShellDemoUITests" */ = {+ isa = XCConfigurationList;+ buildConfigurations = (+ CC69F74A268055276006EE97 /* Debug */,+ 1DADDAC25FD575CDBD49469A /* Release */,+ );+ defaultConfigurationIsVisible = 0;+ defaultConfigurationName = Debug;+ };+ 6661A7253C258D435E406EBE /* Build configuration list for PBXNativeTarget "ShellDemoApp" */ = {+ isa = XCConfigurationList;+ buildConfigurations = (+ 1B3011F907AA12EB1C214CAB /* Debug */,+ 4B96CA7B30D2B36B6369F0DE /* Release */,+ );+ defaultConfigurationIsVisible = 0;+ defaultConfigurationName = Debug;+ };+ AA82EEAB83FEAB5062E81055 /* Build configuration list for PBXProject "ShellDemo" */ = {+ isa = XCConfigurationList;+ buildConfigurations = (+ B1AA224613E947AA9CA7C2E3 /* Debug */,+ 073F03F5C7D2C0957D216254 /* Release */,+ );+ defaultConfigurationIsVisible = 0;+ defaultConfigurationName = Debug;+ };+/* End XCConfigurationList section */++/* Begin XCLocalSwiftPackageReference section */+ 1929FA0375E6966DA0CB3064 /* XCLocalSwiftPackageReference ".." */ = {+ isa = XCLocalSwiftPackageReference;+ relativePath = ..;+ };+/* End XCLocalSwiftPackageReference section */++/* Begin XCSwiftPackageProductDependency section */+ 7F6858A53523100F9E10590E /* ShellUI */ = {+ isa = XCSwiftPackageProductDependency;+ productName = ShellUI;+ };+/* End XCSwiftPackageProductDependency section */+ };+ rootObject = D41A7603C6BA5BB604CCFDE4 /* Project object */;+}diff --git a/frontend-ios/Demo/ShellDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/frontend-ios/Demo/ShellDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedatanew file mode 100644index 00000000..919434a6--- /dev/null+++ b/frontend-ios/Demo/ShellDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata@@ -0,0 +1,7 @@+<?xml version="1.0" encoding="UTF-8"?>+<Workspace+ version = "1.0">+ <FileRef+ location = "self:">+ </FileRef>+</Workspace>diff --git a/frontend-ios/Demo/ShellDemo.xcodeproj/xcshareddata/xcschemes/ShellDemo.xcscheme b/frontend-ios/Demo/ShellDemo.xcodeproj/xcshareddata/xcschemes/ShellDemo.xcschemenew file mode 100644index 00000000..62a40f3f--- /dev/null+++ b/frontend-ios/Demo/ShellDemo.xcodeproj/xcshareddata/xcschemes/ShellDemo.xcscheme@@ -0,0 +1,102 @@+<?xml version="1.0" encoding="UTF-8"?>+<Scheme+ LastUpgradeVersion = "1430"+ version = "1.7">+ <BuildAction+ parallelizeBuildables = "YES"+ buildImplicitDependencies = "YES"+ runPostActionsOnFailure = "NO">+ <BuildActionEntries>+ <BuildActionEntry+ buildForTesting = "YES"+ buildForRunning = "YES"+ buildForProfiling = "YES"+ buildForArchiving = "YES"+ buildForAnalyzing = "YES">+ <BuildableReference+ BuildableIdentifier = "primary"+ BlueprintIdentifier = "85AF0342F954D1F33C949240"+ BuildableName = "ShellDemoApp.app"+ BlueprintName = "ShellDemoApp"+ ReferencedContainer = "container:ShellDemo.xcodeproj">+ </BuildableReference>+ </BuildActionEntry>+ </BuildActionEntries>+ </BuildAction>+ <TestAction+ buildConfiguration = "Debug"+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"+ shouldUseLaunchSchemeArgsEnv = "YES"+ onlyGenerateCoverageForSpecifiedTargets = "NO">+ <MacroExpansion>+ <BuildableReference+ BuildableIdentifier = "primary"+ BlueprintIdentifier = "85AF0342F954D1F33C949240"+ BuildableName = "ShellDemoApp.app"+ BlueprintName = "ShellDemoApp"+ ReferencedContainer = "container:ShellDemo.xcodeproj">+ </BuildableReference>+ </MacroExpansion>+ <Testables>+ <TestableReference+ skipped = "NO"+ parallelizable = "NO">+ <BuildableReference+ BuildableIdentifier = "primary"+ BlueprintIdentifier = "BBE3C0425143E6EB56C6DE55"+ BuildableName = "ShellDemoUITests.xctest"+ BlueprintName = "ShellDemoUITests"+ ReferencedContainer = "container:ShellDemo.xcodeproj">+ </BuildableReference>+ </TestableReference>+ </Testables>+ <CommandLineArguments>+ </CommandLineArguments>+ </TestAction>+ <LaunchAction+ buildConfiguration = "Debug"+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"+ launchStyle = "0"+ useCustomWorkingDirectory = "NO"+ ignoresPersistentStateOnLaunch = "NO"+ debugDocumentVersioning = "YES"+ debugServiceExtension = "internal"+ allowLocationSimulation = "YES">+ <BuildableProductRunnable+ runnableDebuggingMode = "0">+ <BuildableReference+ BuildableIdentifier = "primary"+ BlueprintIdentifier = "85AF0342F954D1F33C949240"+ BuildableName = "ShellDemoApp.app"+ BlueprintName = "ShellDemoApp"+ ReferencedContainer = "container:ShellDemo.xcodeproj">+ </BuildableReference>+ </BuildableProductRunnable>+ </LaunchAction>+ <ProfileAction+ buildConfiguration = "Release"+ shouldUseLaunchSchemeArgsEnv = "YES"+ savedToolIdentifier = ""+ useCustomWorkingDirectory = "NO"+ debugDocumentVersioning = "YES">+ <BuildableProductRunnable+ runnableDebuggingMode = "0">+ <BuildableReference+ BuildableIdentifier = "primary"+ BlueprintIdentifier = "85AF0342F954D1F33C949240"+ BuildableName = "ShellDemoApp.app"+ BlueprintName = "ShellDemoApp"+ ReferencedContainer = "container:ShellDemo.xcodeproj">+ </BuildableReference>+ </BuildableProductRunnable>+ </ProfileAction>+ <AnalyzeAction+ buildConfiguration = "Debug">+ </AnalyzeAction>+ <ArchiveAction+ buildConfiguration = "Release"+ revealArchiveInOrganizer = "YES">+ </ArchiveAction>+</Scheme>diff --git a/frontend-ios/Demo/project.yml b/frontend-ios/Demo/project.ymlnew file mode 100644index 00000000..d3899b0e--- /dev/null+++ b/frontend-ios/Demo/project.yml@@ -0,0 +1,45 @@+name: ShellDemo+options:+ bundleIdPrefix: dev.shellui+ deploymentTarget:+ iOS: '26.0'+packages:+ ShellUI:+ path: ..+settings:+ base:+ SWIFT_VERSION: '6.0'+ CODE_SIGNING_ALLOWED: NO+ GENERATE_INFOPLIST_FILE: YES+ TARGETED_DEVICE_FAMILY: '1,2'+ SUPPORTS_MACCATALYST: NO+ INFOPLIST_KEY_UILaunchScreen_Generation: YES+ INFOPLIST_KEY_UIApplicationSceneManifest_Generation: YES+ INFOPLIST_KEY_UISupportedInterfaceOrientations: 'UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortraitUpsideDown'+ INFOPLIST_KEY_UIUserInterfaceStyle: Dark+ INFOPLIST_KEY_CFBundleDisplayName: Shell Demo+ SWIFT_EMIT_LOC_STRINGS: YES+targets:+ ShellDemoApp:+ type: application+ platform: iOS+ sources:+ - ../Sources/ShellDemo+ dependencies:+ - package: ShellUI+ product: ShellUI+ ShellDemoUITests:+ type: bundle.ui-testing+ platform: iOS+ sources:+ - ../UITests+ dependencies:+ - target: ShellDemoApp+schemes:+ ShellDemo:+ build:+ targets:+ ShellDemoApp: all+ test:+ targets:+ - ShellDemoUITestsdiff --git a/frontend-ios/Package.swift b/frontend-ios/Package.swiftnew file mode 100644index 00000000..6499bf61--- /dev/null+++ b/frontend-ios/Package.swift@@ -0,0 +1,16 @@+// swift-tools-version: 6.2+import PackageDescription++let package = Package(+ name: "ShellUI",+ platforms: [.iOS(.v26), .macOS(.v26)],+ products: [+ .library(name: "ShellUI", targets: ["ShellUI"]),+ .executable(name: "ShellDemo", targets: ["ShellDemo"])+ ],+ targets: [+ .target(name: "ShellUI", resources: [.process("Resources")]),+ .executableTarget(name: "ShellDemo", dependencies: ["ShellUI"], resources: [.process("Resources")]),+ .testTarget(name: "ShellUITests", dependencies: ["ShellUI"])+ ]+)diff --git a/frontend-ios/README.md b/frontend-ios/README.mdnew file mode 100644index 00000000..c9e5bffb--- /dev/null+++ b/frontend-ios/README.md@@ -0,0 +1,66 @@+# iOS shell views++A Swift 6 package for iOS and iPadOS 26 and later. `ShellUI` is the view layer of the multi-game shell described in Route C (#144). It renders what it is given and reports what the player does. It has no engine dependency, game launching, storage, document picker, networking or game-file access.++## Run++```sh+swift build --package-path frontend-ios+swift test --package-path frontend-ios+open frontend-ios/Demo/ShellDemo.xcodeproj+```++Select the `ShellDemo` scheme and an iOS Simulator. After changing targets, regenerate the project with `xcodegen generate --spec frontend-ios/Demo/project.yml`. A command-line build:++```sh+xcodebuild -project frontend-ios/Demo/ShellDemo.xcodeproj -scheme ShellDemo \+ -destination 'generic/platform=iOS Simulator' -derivedDataPath /tmp/shell-demo build+```++`ShellDemo` is also an executable package target for previews on the Mac. The Xcode app target is `ShellDemoApp`.++## Integrate++All boundary types are in `Sources/ShellUI/ShellInputs.swift` and `ShellArtwork.swift`:++- `GameTile` and `GameDetail`: title, a short subtitle, the cover, optional wider hero art, state, recent-play text, settings, game-data source, cloud saves and additional content.+- `Artwork`: a picture decoded once by the host, from the NACP icon's bytes (`Artwork(id:data:)`) or a `CGImage`. The views draw it and make their blurred backdrops from a small copy. Without one, a calm placeholder is drawn from the title.+- `GameState`: playable, needs game data, needs an app update, or broken with a reason.+- `SettingSection`, `SettingRow`, `SettingKind`, `SettingOption`: ordered toggle, choice and range rows with string values, as in launcher.json. The caller resolves dependencies, defaults and locked rows (`enabled`).+- `ControllerInfo`: a connected controller, its player and an optional battery level.+- `ShellActions`: selection, Play, setting changes, game-data and cloud-folder requests, reset, log, app update and Back. The game ID is always passed.+- `ShellInput`: an optional semantic controller event with an increasing sequence. Hardware belongs to the caller. The demo's `DemoControllerInput` is one such adapter.++```swift+LibraryView(+ games: details,+ controllers: controllers,+ actions: ShellActions(onPlay: { id in /* launch */ },+ onChange: { gameID, settingID, value in /* store */ }),+ input: latestInput+)+```++The caller returns changed values through `games`. The views keep no second copy.++## Layouts++Only the available size decides, never the device model, idiom or orientation (`ShellLayout` in `LibraryView.swift`):++| Size | Layout |+| --- | --- |+| Compact, taller than wide (iPhone portrait, a folded foldable, Split View) | One column: the chosen game's art as a full-bleed hero with the title over it, a row of covers, recently played, Play and settings at the bottom for the thumb. Settings push over the library. |+| Regular width and height, not wide (iPad portrait, an unfolded foldable held like a book) | Two panes: the same library with a cover grid and Play in the hero, settings inline beside it. |+| Wider than tall (iPhone and iPad landscape, an unfolded foldable on its side) | Cover Flow over the blurred cover. Settings open as a panel on the right (regular) or over the library (compact). |++The settings pane is one view in one place for every layout, so the selected game, open settings and both scroll positions survive a fold, a rotation or a Stage Manager resize.++Controller first: the D-pad and stick move a cream focus ring, A activates, B backs out, X opens settings, Y opens controllers. In Cover Flow, left and right move the carousel by one cover and the focused cover is always the middle one. Keyboard arrows, Return and Escape take the same path. Touch and pointer use ordinary controls.++Manrope and its SIL OFL licence are bundled and registered at runtime, with the system font as fallback. Reduce Motion turns the Cover Flow tilt and the slides into plain crossfades. Shell strings are in `Resources/Localizable.xcstrings`.++## Demo++Seven fictional games with their own drawn cover art (`Sources/ShellDemo/SampleArt.swift`, rendered to images at launch so the views get them exactly as real icons). Launch arguments: `--screen library|settings|needs-data|needs-update|broken|empty|controllers|controllers-empty|focus`, `--games <n>`, `--select <id>`, `--input-test` (on-screen controller buttons) and `--fold-test` (the foldable stand-in: the running shell in a frame that switches between a 1.4:1 folded size and a larger unfolded one).++`UITests/` checks navigation, controller input, setting edits, rotation and the fold. `ShellCaptureTests` captures every screen. With `TEST_RUNNER_SHOT_DIR` set it also writes the PNGs to that folder.diff --git a/frontend-ios/Sources/ShellDemo/DemoControllerInput.swift b/frontend-ios/Sources/ShellDemo/DemoControllerInput.swiftnew file mode 100644index 00000000..e6f00280--- /dev/null+++ b/frontend-ios/Sources/ShellDemo/DemoControllerInput.swift@@ -0,0 +1,64 @@+#if os(iOS)+import GameController+import ShellUI++/// Hardware adapter belongs to the demo, never ShellUI. The real shell can use its own adapter.+@MainActor final class DemoControllerInput {+ private var observers: [NSObjectProtocol] = []+ private var send: ((ShellInput.Action) -> Void)?+ private var heldDirection: ShellInput.Action?+ private var repeatTask: Task<Void, Never>?++ func start(send: @escaping (ShellInput.Action) -> Void) {+ stop()+ self.send = send+ observers.append(NotificationCenter.default.addObserver(forName: .GCControllerDidConnect, object: nil, queue: .main) { [weak self] _ in+ MainActor.assumeIsolated { self?.bind() }+ })+ observers.append(NotificationCenter.default.addObserver(forName: .GCControllerDidDisconnect, object: nil, queue: .main) { [weak self] _ in+ MainActor.assumeIsolated { self?.direction(nil) }+ })+ bind()+ }+ func stop() {+ for observer in observers { NotificationCenter.default.removeObserver(observer) }+ observers.removeAll()+ for controller in GCController.controllers() { controller.extendedGamepad?.valueChangedHandler = nil }+ repeatTask?.cancel()+ heldDirection = nil+ send = nil+ }+ private func bind() {+ for controller in GCController.controllers() {+ controller.extendedGamepad?.valueChangedHandler = { [weak self] pad, element in+ // GameController may call on its handler queue. Cross to the UI actor explicitly.+ let x = abs(pad.dpad.xAxis.value) > 0.4 ? pad.dpad.xAxis.value : pad.leftThumbstick.xAxis.value+ let y = abs(pad.dpad.yAxis.value) > 0.4 ? pad.dpad.yAxis.value : pad.leftThumbstick.yAxis.value+ let direction: ShellInput.Action? = abs(x) > abs(y) && abs(x) > 0.5 ? (x > 0 ? .right : .left) : abs(y) > 0.5 ? (y > 0 ? .up : .down) : nil+ let action: ShellInput.Action? = element == pad.buttonA && pad.buttonA.isPressed ? .activate+ : element == pad.buttonB && pad.buttonB.isPressed ? .back+ : element == pad.buttonX && pad.buttonX.isPressed ? .settings+ : element == pad.buttonY && pad.buttonY.isPressed ? .controllers : nil+ Task { @MainActor in+ self?.direction(direction)+ if let action { self?.send?(action) }+ }+ }+ }+ }+ private func direction(_ action: ShellInput.Action?) {+ guard action != heldDirection else { return }+ repeatTask?.cancel()+ heldDirection = action+ guard let action else { return }+ send?(action)+ repeatTask = Task { [weak self] in+ try? await Task.sleep(for: .milliseconds(350))+ while !Task.isCancelled {+ self?.send?(action)+ try? await Task.sleep(for: .milliseconds(140))+ }+ }+ }+}+#endifdiff --git a/frontend-ios/Sources/ShellDemo/Resources/Localizable.xcstrings b/frontend-ios/Sources/ShellDemo/Resources/Localizable.xcstringsnew file mode 100644index 00000000..ccbe8a07--- /dev/null+++ b/frontend-ios/Sources/ShellDemo/Resources/Localizable.xcstrings@@ -0,0 +1,476 @@+{+ "sourceLanguage": "en",+ "strings": {+ "2 additional content packs": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "2 additional content packs"+ }+ }+ }+ },+ "30 fps": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "30 fps"+ }+ }+ }+ },+ "60 fps": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "60 fps"+ }+ }+ }+ },+ "All controllers are player 1": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "All controllers are player 1"+ }+ }+ }+ },+ "App update requested. The host supplies update instructions.": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "App update requested. The host supplies update instructions."+ }+ }+ }+ },+ "Back requested.": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Back requested."+ }+ }+ }+ },+ "Choose a RomFS folder or romfs.img on this device, an external drive, or iCloud Drive.": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Choose a RomFS folder or romfs.img on this device, an external drive, or iCloud Drive."+ }+ }+ }+ },+ "Choose cloud folder requested. The host supplies the picker.": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Choose cloud folder requested. The host supplies the picker."+ }+ }+ }+ },+ "Choose game data requested. The host supplies the picker.": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Choose game data requested. The host supplies the picker."+ }+ }+ }+ },+ "Controls": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Controls"+ }+ }+ }+ },+ "Demo action": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Demo action"+ }+ }+ }+ },+ "Docked": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Docked"+ }+ }+ }+ },+ "Fold": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Fold"+ }+ }+ }+ },+ "Frame rate": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Frame rate"+ }+ }+ }+ },+ "Game": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Game"+ }+ }+ }+ },+ "Handheld": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Handheld"+ }+ }+ }+ },+ "No additional content": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "No additional content"+ }+ }+ }+ },+ "OK": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "OK"+ }+ }+ }+ },+ "Performance": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Performance"+ }+ }+ }+ },+ "Play mode": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Play mode"+ }+ }+ }+ },+ "Play requested. The demo does not launch games.": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Play requested. The demo does not launch games."+ }+ }+ }+ },+ "Played today": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Played today"+ }+ }+ }+ },+ "Played yesterday": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Played yesterday"+ }+ }+ }+ },+ "Player 1": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Player 1"+ }+ }+ }+ },+ "Player 2": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Player 2"+ }+ }+ }+ },+ "Player 3": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Player 3"+ }+ }+ }+ },+ "Pro Controller": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Pro Controller"+ }+ }+ }+ },+ "Render scale": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Render scale"+ }+ }+ }+ },+ "Scale the game's 3D resolution.": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Scale the game's 3D resolution."+ }+ }+ }+ },+ "Show frame rate": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Show frame rate"+ }+ }+ }+ },+ "Show log requested. The host supplies the log.": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Show log requested. The host supplies the log."+ }+ }+ }+ },+ "The game's display and performance profile.": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "The game's display and performance profile."+ }+ }+ }+ },+ "This app's folder": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "This app's folder"+ }+ }+ }+ },+ "This game's bundled files could not be verified. Rebuild the app to restore them.": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "This game's bundled files could not be verified. Rebuild the app to restore them."+ }+ }+ }+ },+ "USB Controller": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "USB Controller"+ }+ }+ }+ },+ "Unfold": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Unfold"+ }+ }+ }+ },+ "Use app data requested.": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Use app data requested."+ }+ }+ }+ },+ "Use more than one controller for the same player.": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Use more than one controller for the same player."+ }+ }+ }+ },+ "Version 1.0.0": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Version 1.0.0"+ }+ }+ }+ },+ "Version 1.0.2": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Version 1.0.2"+ }+ }+ }+ },+ "Version 1.1.0": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Version 1.1.0"+ }+ }+ }+ },+ "Version 1.2.0": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Version 1.2.0"+ }+ }+ }+ },+ "Version 1.4.0": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Version 1.4.0"+ }+ }+ }+ },+ "Version 2.0.1": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Version 2.0.1"+ }+ }+ }+ },+ "Version 3.1.0": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Version 3.1.0"+ }+ }+ }+ },+ "Wireless Controller": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Wireless Controller"+ }+ }+ }+ },+ "iCloud Drive / Game Saves": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "iCloud Drive / Game Saves"+ }+ }+ }+ }+ },+ "version": "1.0"+}diff --git a/frontend-ios/Sources/ShellDemo/SampleArt.swift b/frontend-ios/Sources/ShellDemo/SampleArt.swiftnew file mode 100644index 00000000..988b640d--- /dev/null+++ b/frontend-ios/Sources/ShellDemo/SampleArt.swift@@ -0,0 +1,351 @@+import SwiftUI+import ShellUI++/// Cover art for the fictional sample games, drawn here and rendered to images at launch. The views receive them+/// exactly as they will receive a real game's icon. Each game has its own palette, composition and lettering, so the+/// library reads as a shelf of different games. Nothing here is taken from a real game.+@MainActor enum SampleArt {+ private static var cache: [String: Artwork] = [:]++ /// The square icon, with the game's lettering, as a NACP icon has it.+ static func cover(_ id: String) -> Artwork? { render(id, lettering: true) }+ /// Key art: the same picture without lettering, for the hero.+ static func keyArt(_ id: String) -> Artwork? { render(id, lettering: false) }++ private static func render(_ id: String, lettering: Bool) -> Artwork? {+ let key = "\(id).\(lettering)"+ if let art = cache[key] { return art }+ _ = ShellFonts.font(12) // registers Manrope before the first render+ let renderer = ImageRenderer(content: composition(id).environment(\.lettering, lettering).frame(width: 384, height: 384))+ renderer.scale = 2.5+ guard let image = renderer.cgImage else { return nil }+ let art = Artwork(id: "sample.\(key)", image: image)+ cache[key] = art+ return art+ }++ @ViewBuilder static func composition(_ id: String) -> some View {+ switch id {+ case "orbit": OrbitValleyArt()+ case "tide": QuietTideArt()+ case "paper": PaperTrailsArt()+ case "moon": MoonlitExpressArt()+ case "wild": WildGardensArt()+ case "drift": DriftAtlasArt()+ case "amber": AmberHoursArt()+ default: Color.gray+ }+ }+}++/// Off for the key art: the same picture without the game's lettering, as a hero behind the shell's own title.+private struct LetteringKey: EnvironmentKey { static let defaultValue = true }+private extension EnvironmentValues {+ var lettering: Bool {+ get { self[LetteringKey.self] }+ set { self[LetteringKey.self] = newValue }+ }+}++private func rgb(_ r: Double, _ g: Double, _ b: Double) -> Color { Color(red: r, green: g, blue: b) }+private func manrope(_ size: CGFloat, _ weight: Font.Weight) -> Font { .custom("Manrope", fixedSize: size).weight(weight) }++/// A repeatable sequence, so the scattered stars and leaves land in the same places on every launch.+private struct Scatter {+ private var state: UInt64+ init(_ seed: UInt64) { state = seed }+ mutating func next() -> CGFloat {+ state = state &* 6364136223846793005 &+ 1442695040888963407+ return CGFloat((state >> 33) % 10_000) / 10_000+ }+}++/// A band of land or water: a sine line across, filled down to the bottom edge.+private struct Wave: Shape {+ var baseline: CGFloat+ var amplitude: CGFloat+ var frequency: CGFloat+ var phase: CGFloat+ var filled = true+ func path(in rect: CGRect) -> Path {+ var path = Path()+ let steps = 80+ for step in 0...steps {+ let x = rect.width * CGFloat(step) / CGFloat(steps)+ let y = rect.height * baseline + sin(x / rect.width * .pi * 2 * frequency + phase) * rect.height * amplitude+ if step == 0 { path.move(to: CGPoint(x: x, y: y)) } else { path.addLine(to: CGPoint(x: x, y: y)) }+ }+ if filled {+ path.addLine(to: CGPoint(x: rect.width, y: rect.height))+ path.addLine(to: CGPoint(x: 0, y: rect.height))+ path.closeSubpath()+ }+ return path+ }+}++// MARK: Orbit Valley: warm dusk over teal hills, a planet on its rings++private struct OrbitValleyArt: View {+ @Environment(\.lettering) private var lettering+ var body: some View {+ GeometryReader { g in+ let s = g.size.width+ ZStack(alignment: .topLeading) {+ LinearGradient(colors: [rgb(0.06, 0.19, 0.24), rgb(0.52, 0.46, 0.40), rgb(0.97, 0.64, 0.44)],+ startPoint: .top, endPoint: .bottom)+ Circle().fill(rgb(1, 0.87, 0.64)).frame(width: s * 0.36).position(x: s * 0.42, y: s * 0.66)+ ForEach(0..<3, id: \.self) { ring in+ Ellipse().stroke(rgb(1, 0.95, 0.86).opacity(0.55 - Double(ring) * 0.15), lineWidth: s * 0.006)+ .frame(width: s * (0.62 + CGFloat(ring) * 0.26), height: s * (0.16 + CGFloat(ring) * 0.07))+ .rotationEffect(.degrees(-14)).position(x: s * 0.6, y: s * 0.4)+ }+ Circle().fill(rgb(0.98, 0.95, 0.9)).frame(width: s * 0.075).position(x: s * 0.9, y: s * 0.29)+ Circle().fill(rgb(0.98, 0.95, 0.9)).frame(width: s * 0.13).position(x: s * 0.6, y: s * 0.4)+ .shadow(color: rgb(1, 0.8, 0.6).opacity(0.6), radius: s * 0.03)+ Wave(baseline: 0.70, amplitude: 0.035, frequency: 1.3, phase: 0.6).fill(rgb(0.10, 0.31, 0.31))+ Wave(baseline: 0.78, amplitude: 0.04, frequency: 1.1, phase: 2.4).fill(rgb(0.06, 0.22, 0.23))+ Wave(baseline: 0.88, amplitude: 0.03, frequency: 1.6, phase: 4.0).fill(rgb(0.03, 0.12, 0.13))+ Text("ORBIT\nVALLEY").font(manrope(s * 0.105, .heavy)).tracking(s * 0.012).lineSpacing(-s * 0.03)+ .foregroundStyle(rgb(1, 0.97, 0.9)).padding(s * 0.075).opacity(lettering ? 1 : 0)+ }+ }+ }+}++// MARK: The Quiet Tide: a navy sea under a pale moon, set in a serif italic++private struct QuietTideArt: View {+ @Environment(\.lettering) private var lettering+ var body: some View {+ GeometryReader { g in+ let s = g.size.width+ ZStack(alignment: .bottomLeading) {+ LinearGradient(colors: [rgb(0.03, 0.06, 0.13), rgb(0.06, 0.13, 0.23)], startPoint: .top, endPoint: .bottom)+ RadialGradient(colors: [rgb(0.9, 0.92, 1).opacity(0.22), .clear], center: UnitPoint(x: 0.68, y: 0.28),+ startRadius: 0, endRadius: s * 0.45)+ Circle().fill(rgb(0.94, 0.92, 0.85)).frame(width: s * 0.25).position(x: s * 0.68, y: s * 0.28)+ ForEach(0..<7, id: \.self) { index in+ Capsule().fill(rgb(0.94, 0.92, 0.85).opacity(0.5 - Double(index) * 0.06))+ .frame(width: s * (0.22 - CGFloat(index) * 0.022), height: s * 0.008)+ .position(x: s * 0.68, y: s * (0.58 + CGFloat(index) * 0.035))+ }+ ForEach(0..<9, id: \.self) { index in+ Wave(baseline: 0.56 + CGFloat(index) * 0.045, amplitude: 0.006 + CGFloat(index) * 0.002,+ frequency: 2.5 + CGFloat(index) * 0.3, phase: CGFloat(index) * 1.7, filled: false)+ .stroke(rgb(0.55, 0.72, 0.88).opacity(0.18 + Double(index) * 0.04), lineWidth: s * 0.005)+ }+ VStack(alignment: .leading, spacing: s * 0.01) {+ Text("THE").font(manrope(s * 0.035, .bold)).tracking(s * 0.02)+ Text("Quiet Tide").font(.system(size: s * 0.11, weight: .regular, design: .serif).italic())+ }.foregroundStyle(rgb(0.95, 0.93, 0.86)).padding(s * 0.08).opacity(lettering ? 1 : 0)+ }+ }+ }+}++// MARK: Paper Trails: a folded map on cream paper, a red dashed route, heavy ink lettering++private struct PaperTrailsArt: View {+ @Environment(\.lettering) private var lettering+ var body: some View {+ GeometryReader { g in+ let s = g.size.width+ ZStack(alignment: .topLeading) {+ rgb(0.95, 0.92, 0.85)+ Path { p in+ p.move(to: CGPoint(x: s * 0.34, y: 0)); p.addLine(to: CGPoint(x: s * 0.66, y: 0))+ p.addLine(to: CGPoint(x: s * 0.66, y: s)); p.addLine(to: CGPoint(x: s * 0.34, y: s))+ }.fill(.black.opacity(0.045))+ Path { p in+ p.move(to: CGPoint(x: s * 0.66, y: 0)); p.addLine(to: CGPoint(x: s, y: 0))+ p.addLine(to: CGPoint(x: s, y: s)); p.addLine(to: CGPoint(x: s * 0.66, y: s))+ }.fill(.black.opacity(0.02))+ Path { p in+ p.move(to: CGPoint(x: s * 0.08, y: s * 0.9))+ p.addCurve(to: CGPoint(x: s * 0.5, y: s * 0.62), control1: CGPoint(x: s * 0.35, y: s * 0.95), control2: CGPoint(x: s * 0.2, y: s * 0.6))+ p.addCurve(to: CGPoint(x: s * 0.82, y: s * 0.36), control1: CGPoint(x: s * 0.8, y: s * 0.64), control2: CGPoint(x: s * 0.62, y: s * 0.38))+ }.stroke(rgb(0.86, 0.27, 0.2), style: StrokeStyle(lineWidth: s * 0.016, lineCap: .round, dash: [s * 0.035, s * 0.03]))+ ForEach([45.0, -45.0], id: \.self) { angle in+ Capsule().fill(rgb(0.86, 0.27, 0.2)).frame(width: s * 0.09, height: s * 0.022)+ .rotationEffect(.degrees(angle)).position(x: s * 0.86, y: s * 0.32)+ }+ Path { p in+ p.move(to: CGPoint(x: s * 0.05, y: s * 0.97)); p.addLine(to: CGPoint(x: s * 0.2, y: s * 0.86))+ p.addLine(to: CGPoint(x: s * 0.1, y: s * 0.83)); p.closeSubpath()+ }.fill(rgb(0.99, 0.99, 0.97)).shadow(color: .black.opacity(0.15), radius: s * 0.01, y: s * 0.006)+ Text("PAPER\nTRAILS").font(manrope(s * 0.15, .heavy)).tracking(-s * 0.004).lineSpacing(-s * 0.045)+ .foregroundStyle(rgb(0.14, 0.13, 0.13)).padding(s * 0.075).opacity(lettering ? 1 : 0)+ }+ }+ }+}++// MARK: Moonlit Express: a night train on a viaduct, gold windows, monospaced lettering++private struct MoonlitExpressArt: View {+ @Environment(\.lettering) private var lettering+ var body: some View {+ GeometryReader { g in+ let s = g.size.width+ let gold = rgb(0.96, 0.80, 0.46)+ ZStack(alignment: .bottomLeading) {+ LinearGradient(colors: [rgb(0.03, 0.06, 0.09), rgb(0.07, 0.15, 0.17)], startPoint: .top, endPoint: .bottom)+ Canvas { context, size in+ var scatter = Scatter(7)+ for _ in 0..<46 {+ let x = scatter.next() * size.width, y = scatter.next() * size.height * 0.55+ let r = 0.6 + scatter.next() * 1.6+ context.fill(Path(ellipseIn: CGRect(x: x, y: y, width: r, height: r)), with: .color(.white.opacity(0.3 + scatter.next() * 0.6)))+ }+ }+ Circle().fill(gold)+ .overlay(Circle().fill(.black).offset(x: s * 0.055, y: -s * 0.035).blendMode(.destinationOut))+ .compositingGroup()+ .frame(width: s * 0.2).position(x: s * 0.76, y: s * 0.22)+ // The viaduct: a deck and its arches, slightly uphill to the right.+ ZStack(alignment: .topLeading) {+ Rectangle().fill(rgb(0.02, 0.04, 0.05)).frame(width: s * 1.3, height: s * 0.035)+ HStack(spacing: s * 0.05) {+ ForEach(0..<8, id: \.self) { _ in+ Rectangle().fill(rgb(0.02, 0.04, 0.05)).frame(width: s * 0.035, height: s * 0.5)+ }+ }.padding(.leading, s * 0.03)+ HStack(spacing: s * 0.012) {+ ForEach(0..<4, id: \.self) { car in+ RoundedRectangle(cornerRadius: s * 0.015).fill(rgb(0.13, 0.16, 0.18))+ .frame(width: s * 0.2, height: s * 0.065)+ .overlay {+ HStack(spacing: s * 0.018) {+ ForEach(0..<4, id: \.self) { _ in+ RoundedRectangle(cornerRadius: s * 0.004).fill(gold).frame(width: s * 0.022, height: s * 0.022)+ }+ }+ }+ .shadow(color: gold.opacity(car == 0 ? 0.5 : 0.25), radius: s * 0.02)+ }+ }.offset(x: s * 0.2, y: -s * 0.07)+ }+ .rotationEffect(.degrees(-8), anchor: .topLeading)+ .position(x: s * 0.62, y: s * 0.9)+ Text("MOONLIT\nEXPRESS").font(.system(size: s * 0.07, weight: .semibold, design: .monospaced))+ .tracking(s * 0.018).foregroundStyle(gold).padding(s * 0.075).opacity(lettering ? 1 : 0)+ .frame(maxHeight: .infinity, alignment: .topLeading)+ }+ }+ }+}++// MARK: Wild Gardens: dense leaves, pink flowers, a rounded heavy wordmark++private struct WildGardensArt: View {+ @Environment(\.lettering) private var lettering+ var body: some View {+ GeometryReader { g in+ let s = g.size.width+ let greens = [rgb(0.16, 0.45, 0.25), rgb(0.25, 0.58, 0.30), rgb(0.10, 0.33, 0.20), rgb(0.45, 0.68, 0.32)]+ ZStack(alignment: .bottomLeading) {+ rgb(0.05, 0.19, 0.12)+ Canvas { context, size in+ var scatter = Scatter(31)+ for index in 0..<34 {+ let x = scatter.next() * size.width, y = scatter.next() * size.height+ var leaf = context+ leaf.translateBy(x: x, y: y)+ leaf.rotate(by: .radians(Double(scatter.next()) * .pi))+ let w = size.width * (0.22 + scatter.next() * 0.16)+ leaf.fill(Path(ellipseIn: CGRect(x: -w / 2, y: -w * 0.18, width: w, height: w * 0.36)), with: .color(greens[index % 4]))+ leaf.stroke(Path { p in p.move(to: CGPoint(x: -w / 2, y: 0)); p.addLine(to: CGPoint(x: w / 2, y: 0)) },+ with: .color(.black.opacity(0.18)), lineWidth: 1.2)+ }+ for _ in 0..<6 {+ let x = scatter.next() * size.width, y = scatter.next() * size.height * 0.7+ let petal = size.width * 0.045+ for k in 0..<5 {+ let a = Double(k) / 5 * 2 * .pi+ let px = x + CGFloat(cos(a)) * petal, py = y + CGFloat(sin(a)) * petal+ context.fill(Path(ellipseIn: CGRect(x: px - petal * 0.8, y: py - petal * 0.8, width: petal * 1.6, height: petal * 1.6)),+ with: .color(rgb(0.93, 0.36, 0.53)))+ }+ context.fill(Path(ellipseIn: CGRect(x: x - petal * 0.6, y: y - petal * 0.6, width: petal * 1.2, height: petal * 1.2)),+ with: .color(rgb(0.99, 0.83, 0.32)))+ }+ }+ LinearGradient(colors: [.clear, rgb(0.03, 0.12, 0.08).opacity(0.92)], startPoint: UnitPoint(x: 0.5, y: 0.5), endPoint: .bottom)+ Text("Wild\nGardens").font(.system(size: s * 0.13, weight: .heavy, design: .rounded)).lineSpacing(-s * 0.04)+ .foregroundStyle(rgb(1, 0.95, 0.86)).padding(s * 0.075).opacity(lettering ? 1 : 0)+ }+ }+ }+}++// MARK: Drift Atlas: contour lines on sand, a compass, wide-tracked capitals++private struct DriftAtlasArt: View {+ @Environment(\.lettering) private var lettering+ var body: some View {+ GeometryReader { g in+ let s = g.size.width+ let ink = rgb(0.42, 0.29, 0.18)+ ZStack(alignment: .topLeading) {+ rgb(0.87, 0.79, 0.63)+ Canvas { context, size in+ func contours(cx: CGFloat, cy: CGFloat, count: Int, step: CGFloat, seed: Double) {+ for ring in 0..<count {+ let base = size.width * (0.05 + CGFloat(ring) * step)+ var path = Path()+ for k in 0...96 {+ let a = Double(k) / 96 * 2 * .pi+ let r = base * (1 + 0.13 * CGFloat(sin(3 * a + seed + Double(ring) * 0.4)) + 0.05 * CGFloat(sin(5 * a + seed)))+ let point = CGPoint(x: cx + CGFloat(cos(a)) * r, y: cy + CGFloat(sin(a)) * r * 0.85)+ if k == 0 { path.move(to: point) } else { path.addLine(to: point) }+ }+ path.closeSubpath()+ context.stroke(path, with: .color(ink.opacity(ring % 3 == 2 ? 0.75 : 0.42)), lineWidth: ring % 3 == 2 ? 1.6 : 1)+ }+ }+ contours(cx: size.width * 0.6, cy: size.height * 0.58, count: 9, step: 0.052, seed: 0.3)+ contours(cx: size.width * 0.16, cy: size.height * 0.34, count: 3, step: 0.05, seed: 2.1)+ }+ ZStack {+ Circle().stroke(ink, lineWidth: s * 0.005).frame(width: s * 0.17)+ Path { p in+ p.move(to: CGPoint(x: 0, y: -s * 0.07)); p.addLine(to: CGPoint(x: s * 0.018, y: 0)); p.addLine(to: CGPoint(x: -s * 0.018, y: 0))+ }.fill(rgb(0.76, 0.26, 0.18)).offset(x: s * 0.085, y: s * 0.085)+ Path { p in+ p.move(to: CGPoint(x: 0, y: s * 0.07)); p.addLine(to: CGPoint(x: s * 0.018, y: 0)); p.addLine(to: CGPoint(x: -s * 0.018, y: 0))+ }.fill(ink).offset(x: s * 0.085, y: s * 0.085)+ }.frame(width: s * 0.17, height: s * 0.17).rotationEffect(.degrees(18)).position(x: s * 0.2, y: s * 0.8)+ Text("DRIFT ATLAS").font(manrope(s * 0.068, .bold)).tracking(s * 0.03)+ .foregroundStyle(rgb(0.25, 0.17, 0.10)).padding(s * 0.075).opacity(lettering ? 1 : 0)+ }+ }+ }+}++// MARK: Amber Hours: a sundial in amber, a light wordmark++private struct AmberHoursArt: View {+ @Environment(\.lettering) private var lettering+ var body: some View {+ GeometryReader { g in+ let s = g.size.width+ ZStack(alignment: .topLeading) {+ LinearGradient(colors: [rgb(0.99, 0.68, 0.27), rgb(0.62, 0.21, 0.08)], startPoint: .top, endPoint: .bottom)+ ForEach(0..<7, id: \.self) { ring in+ Circle().stroke(rgb(1, 0.93, 0.8).opacity(0.16 + Double(ring) * 0.04), lineWidth: s * 0.01)+ .frame(width: s * (0.4 + CGFloat(ring) * 0.26))+ .position(x: s * 0.08, y: s * 0.96)+ }+ Circle().fill(rgb(1, 0.93, 0.78)).frame(width: s * 0.2).position(x: s * 0.74, y: s * 0.34)+ .shadow(color: rgb(1, 0.85, 0.5), radius: s * 0.05)+ Capsule().fill(rgb(0.33, 0.09, 0.04)).frame(width: s * 0.82, height: s * 0.022)+ .rotationEffect(.degrees(-38), anchor: .leading)+ .position(x: s * 0.49, y: s * 0.96)+ Circle().fill(rgb(0.33, 0.09, 0.04)).frame(width: s * 0.07).position(x: s * 0.08, y: s * 0.96)+ Text("Amber\nHours").font(manrope(s * 0.15, .light)).tracking(-s * 0.004).lineSpacing(-s * 0.05)+ .foregroundStyle(rgb(1, 0.97, 0.92)).padding(s * 0.075).opacity(lettering ? 1 : 0)+ }+ }+ }+}diff --git a/frontend-ios/Sources/ShellDemo/SampleData.swift b/frontend-ios/Sources/ShellDemo/SampleData.swiftnew file mode 100644index 00000000..38d5f9fc--- /dev/null+++ b/frontend-ios/Sources/ShellDemo/SampleData.swift@@ -0,0 +1,47 @@+import ShellUI+import Foundation++func demoText(_ key: String.LocalizationValue) -> String {+ #if SWIFT_PACKAGE+ String(localized: key, bundle: .module)+ #else+ String(localized: key)+ #endif+}++/// Fictional fixtures. Only the demo and previews reference this file.+@MainActor enum SampleData {+ static var games: [GameDetail] {+ let tiles: [GameTile] = [+ GameTile(id: "orbit", title: "Orbit Valley", subtitle: demoText("Version 1.4.0"), cover: SampleArt.cover("orbit"), heroArt: SampleArt.keyArt("orbit"), recentlyPlayed: demoText("Played today")),+ GameTile(id: "tide", title: "The Quiet Tide", subtitle: demoText("Version 2.0.1"), cover: SampleArt.cover("tide"), heroArt: SampleArt.keyArt("tide"), recentlyPlayed: demoText("Played yesterday")),+ GameTile(id: "paper", title: "Paper Trails", subtitle: demoText("Version 1.0.0"), cover: SampleArt.cover("paper"), heroArt: SampleArt.keyArt("paper"), state: .needsGameData),+ GameTile(id: "moon", title: "Moonlit Express", subtitle: demoText("Version 3.1.0"), cover: SampleArt.cover("moon"), heroArt: SampleArt.keyArt("moon"), state: .needsAppUpdate),+ GameTile(id: "wild", title: "Wild Gardens", subtitle: demoText("Version 1.2.0"), cover: SampleArt.cover("wild"), heroArt: SampleArt.keyArt("wild"), state: .broken(reason: demoText("This game's bundled files could not be verified. Rebuild the app to restore them."))),+ GameTile(id: "drift", title: "Drift Atlas", subtitle: demoText("Version 1.1.0"), cover: SampleArt.cover("drift"), heroArt: SampleArt.keyArt("drift")),+ GameTile(id: "amber", title: "Amber Hours", subtitle: demoText("Version 1.0.2"), cover: SampleArt.cover("amber"))+ ]+ return tiles.map { tile in+ GameDetail(game: tile, sections: [+ SettingSection(id: "game", title: demoText("Game"), rows: [+ SettingRow(id: "DM_OPERATION_MODE", label: demoText("Play mode"), note: demoText("The game's display and performance profile."), kind: .choice([SettingOption("handheld", demoText("Handheld")), SettingOption("docked", demoText("Docked"))]), value: "handheld"),+ SettingRow(id: "DM_SHOW_FPS", label: demoText("Show frame rate"), kind: .toggle(on: "1", off: "0"), value: "0")+ ]),+ SettingSection(id: "controls", title: demoText("Controls"), rows: [+ SettingRow(id: "DM_PAD_MERGE", label: demoText("All controllers are player 1"), note: demoText("Use more than one controller for the same player."), kind: .toggle(on: "1", off: "0"), value: "0")+ ]),+ SettingSection(id: "performance", title: demoText("Performance"), rows: [+ SettingRow(id: "DM_RENDER_SCALE", label: demoText("Render scale"), note: demoText("Scale the game's 3D resolution."), kind: .range(min: 0.5, max: 1.5, step: 0.05, unit: "×"), value: "1"),+ SettingRow(id: "DM_FPS_TARGET", label: demoText("Frame rate"), kind: .choice([SettingOption("30", demoText("30 fps")), SettingOption("60", demoText("60 fps"))]), value: "60")+ ])+ ], dataSource: tile.state == .needsGameData ? "" : demoText("This app's folder"), dataNote: demoText("Choose a RomFS folder or romfs.img on this device, an external drive, or iCloud Drive."),+ cloudSaves: tile.id == "orbit" ? demoText("iCloud Drive / Game Saves") : nil,+ dlc: tile.id == "orbit" ? demoText("2 additional content packs") : demoText("No additional content"), hasModifiedSettings: true)+ }+ }+ static let controllers = [+ ControllerInfo(id: "one", name: demoText("Pro Controller"), player: demoText("Player 1"), batteryPercent: 78),+ ControllerInfo(id: "two", name: demoText("Wireless Controller"), player: demoText("Player 2"), batteryPercent: 16, charging: true),+ ControllerInfo(id: "three", name: demoText("USB Controller"), player: demoText("Player 3"))+ ]+}diff --git a/frontend-ios/Sources/ShellDemo/ShellDemoApp.swift b/frontend-ios/Sources/ShellDemo/ShellDemoApp.swiftnew file mode 100644index 00000000..ed705f16--- /dev/null+++ b/frontend-ios/Sources/ShellDemo/ShellDemoApp.swift@@ -0,0 +1,149 @@+import SwiftUI+import ShellUI++@main struct ShellDemoApp: App {+ var body: some Scene { WindowGroup { DemoScreen() } }+}++/// The demo owns sample values. None of this state or callback simulation is part of ShellUI.+struct DemoScreen: View {+ @State private var games = SampleData.games+ @State private var notice: String?+ @State private var input: ShellInput?+ @State private var unfolded = ProcessInfo.processInfo.arguments.contains("--unfolded")+ #if os(iOS)+ @State private var controller = DemoControllerInput()+ #endif+ private var args: [String] { ProcessInfo.processInfo.arguments }+ private func value(_ flag: String) -> String? {+ guard let i = args.firstIndex(of: flag), args.indices.contains(i + 1) else { return nil }+ return args[i + 1]+ }+ private var scenario: String { value("--screen") ?? "library" }+ /// `--games 3` shows the first three sample games, for the short shelf.+ private var shown: [GameDetail] {+ guard scenario != "empty" else { return [] }+ return value("--games").flatMap(Int.init).map { Array(games.prefix($0)) } ?? games+ }+ private var initialSelection: String {+ switch scenario {+ case "needs-data": "paper"+ case "needs-update": "moon"+ case "broken": "wild"+ default: value("--select") ?? "orbit"+ }+ }++ var body: some View {+ Group {+ if args.contains("--fold-test") { foldHarness } else { shell }+ }+ .background(ShellPalette.background)+ // QA only: on-screen stand-ins for controller buttons, above everything so the art never takes their taps.+ .overlay(alignment: .bottom) {+ if args.contains("--input-test") {+ HStack {+ ForEach(["left", "right", "down", "up", "activate", "back", "settings"], id: \.self) { name in+ Button(name) { send(qaAction(name)) }.accessibilityIdentifier("qa.input.\(name)").frame(minHeight: 44)+ }+ }+ .font(.caption).padding(.horizontal, 12)+ .background(.black.opacity(0.8), in: Capsule())+ .padding(.bottom, 2)+ }+ }+ .alert("Demo action", isPresented: Binding(get: { notice != nil }, set: { if !$0 { notice = nil } })) {+ Button("OK") { notice = nil }+ } message: { Text(notice ?? "") }+ #if os(iOS)+ .onAppear { controller.start { action in send(action) } }+ .onDisappear { controller.stop() }+ #endif+ }++ private var shell: some View {+ LibraryView(games: shown,+ controllers: scenario == "controllers-empty" ? [] : SampleData.controllers,+ actions: actions, input: input, initialSelection: initialSelection,+ initialDetailOpen: scenario == "settings",+ initialControllersOpen: scenario.hasPrefix("controllers"),+ initialFocusVisible: scenario == "focus")+ }++ /// A stand-in for the foldable while no Simulator runtime for it is installed: the same running shell in a frame+ /// that switches between a short 1.4:1 phone screen (folded) and a larger, nearly square one (unfolded).+ /// The sizes are only this harness's. ShellUI decides from whatever size it gets.+ private var foldHarness: some View {+ GeometryReader { geometry in+ let landscape = geometry.size.width > geometry.size.height+ let folded = landscape ? CGSize(width: 525, height: 375) : CGSize(width: 375, height: 525)+ let open = landscape ? CGSize(width: 890, height: 626) : CGSize(width: 626, height: 890)+ let size = unfolded ? open : folded+ VStack(spacing: 14) {+ Button(unfolded ? "Fold" : "Unfold") {+ withAnimation(.smooth(duration: 0.45)) { unfolded.toggle() }+ }+ .accessibilityIdentifier("qa.fold").frame(minHeight: 44)+ shell+ .frame(width: size.width, height: size.height)+ .clipShape(RoundedRectangle(cornerRadius: 28))+ .overlay(RoundedRectangle(cornerRadius: 28).strokeBorder(.white.opacity(0.25)))+ }+ .frame(maxWidth: .infinity, maxHeight: .infinity)+ }+ .background(Color.black.ignoresSafeArea())+ }++ private func qaAction(_ name: String) -> ShellInput.Action {+ switch name {+ case "left": .left+ case "right": .right+ case "down": .down+ case "up": .up+ case "activate": .activate+ case "back": .back+ default: .settings+ }+ }+ private func send(_ action: ShellInput.Action) { input = ShellInput(sequence: (input?.sequence ?? 0) + 1, action: action) }+ private var actions: ShellActions {+ ShellActions(onPlay: { _ in notice = demoText("Play requested. The demo does not launch games.") },+ onChange: { game, row, value in+ guard let g = games.firstIndex(where: { $0.id == game }) else { return }+ for section in games[g].sections.indices {+ if let index = games[g].sections[section].rows.firstIndex(where: { $0.id == row }) {+ games[g].sections[section].rows[index].value = value+ games[g].hasModifiedSettings = true+ }+ }+ }, onPickGameData: { _ in notice = demoText("Choose game data requested. The host supplies the picker.") },+ onUseAppData: { _ in notice = demoText("Use app data requested.") },+ onPickCloudSaves: { _ in notice = demoText("Choose cloud folder requested. The host supplies the picker.") },+ onDisableCloudSaves: { id in if let i = games.firstIndex(where: { $0.id == id }) { games[i].cloudSaves = nil } },+ onResetDefaults: { id in+ if let i = games.firstIndex(where: { $0.id == id }), let original = SampleData.games.first(where: { $0.id == id }) {+ games[i].sections = original.sections+ games[i].hasModifiedSettings = false+ }+ }, onShowLog: { _ in notice = demoText("Show log requested. The host supplies the log.") },+ onAppUpdate: { notice = demoText("App update requested. The host supplies update instructions.") },+ onBack: { notice = demoText("Back requested.") })+ }+}++#Preview("Library") { DemoScreen() }+#Preview("Cover Flow", traits: .landscapeLeft) { DemoScreen() }+#Preview("Game settings") {+ ScrollView { GameDetailView(detail: SampleData.games[0]).padding(24) }.background(ShellPalette.background).preferredColorScheme(.dark)+}+#Preview("Ready to play") { GameStateView(game: SampleData.games[0].game).padding().background(ShellPalette.background) }+#Preview("Needs game data") { GameStateView(game: SampleData.games[2].game).padding().background(ShellPalette.background) }+#Preview("Needs app update") { GameStateView(game: SampleData.games[3].game).padding().background(ShellPalette.background) }+#Preview("Broken") { GameStateView(game: SampleData.games[4].game).padding().background(ShellPalette.background) }+#Preview("Empty library") { LibraryView(games: []) }+#Preview("Controllers") { ControllersView(controllers: SampleData.controllers).background(ShellPalette.background) }+#Preview("No controllers") { ControllersView(controllers: []).background(ShellPalette.background) }+#Preview("Two panes", traits: .fixedLayout(width: 834, height: 1194)) { DemoScreen() }+#Preview("Folded", traits: .fixedLayout(width: 375, height: 525)) { DemoScreen() }+#Preview("Unfolded", traits: .fixedLayout(width: 626, height: 890)) { DemoScreen() }+#Preview("Largest text") { DemoScreen().environment(\.dynamicTypeSize, .accessibility5) }diff --git a/frontend-ios/Sources/ShellUI/ControllersView.swift b/frontend-ios/Sources/ShellUI/ControllersView.swiftnew file mode 100644index 00000000..99ede869--- /dev/null+++ b/frontend-ios/Sources/ShellUI/ControllersView.swift@@ -0,0 +1,128 @@+import SwiftUI++/// Connected controllers with their player and battery, and the buttons the shell listens to.+public struct ControllersView: View {+ public var controllers: [ControllerInfo]+ public var onBack: () -> Void+ public init(controllers: [ControllerInfo], onBack: @escaping () -> Void = {}) {+ self.controllers = controllers+ self.onBack = onBack+ }+ public var body: some View {+ ScrollView {+ VStack(alignment: .leading, spacing: 30) {+ HStack(alignment: .center) {+ Text(ShellStrings.text("Controllers")).shellText(30, .heavy, relativeTo: .title).tracking(-0.8)+ .lineLimit(1).minimumScaleFactor(0.7).accessibilityAddTraits(.isHeader)+ Spacer(minLength: 8)+ Button(action: onBack) { Image(systemName: "xmark") }+ .buttonStyle(RoundIconButtonStyle(size: 44))+ .accessibilityLabel(ShellStrings.text("Close controllers"))+ .accessibilityIdentifier("controllers.close")+ .shellTarget("ctl.close", radius: 22, action: onBack)+ }+ if controllers.isEmpty {+ VStack(alignment: .leading, spacing: 12) {+ Image(systemName: "gamecontroller").font(.system(size: 30, weight: .light))+ .foregroundStyle(ShellPalette.cream).accessibilityHidden(true).padding(.bottom, 4)+ Text(ShellStrings.text("No controllers connected")).shellText(19, .bold)+ Text(ShellStrings.text("Connect a controller in Bluetooth settings. Touch controls are always available in the library."))+ .shellText(14.5).foregroundStyle(.white.opacity(0.6)).fixedSize(horizontal: false, vertical: true)+ }.frame(maxWidth: .infinity, alignment: .leading).shellCard(padding: 20)+ } else {+ VStack(spacing: 0) {+ ForEach(controllers) { controller in+ ControllerRow(controller: controller)+ if controller.id != controllers.last?.id {+ Rectangle().fill(ShellPalette.hairline).frame(height: 1).padding(.leading, 64)+ }+ }+ }.padding(.horizontal, 16).padding(.vertical, 4)+ .background(ShellPalette.surface, in: RoundedRectangle(cornerRadius: 16))+ .overlay(RoundedRectangle(cornerRadius: 16).strokeBorder(ShellPalette.hairline))+ }+ VStack(alignment: .leading, spacing: 14) {+ SectionHeading(title: ShellStrings.text("On a controller"))+ hint(Image(systemName: "dpad"), ShellStrings.text("Move between controls"))+ hint(ButtonGlyph(letter: "A"), ShellStrings.text("Select"))+ hint(ButtonGlyph(letter: "B"), ShellStrings.text("Back"))+ hint(ButtonGlyph(letter: "X"), ShellStrings.text("Game settings"))+ hint(ButtonGlyph(letter: "Y"), ShellStrings.text("Controllers"))+ }.padding(.horizontal, 4)+ }.padding(24).frame(maxWidth: 640)+ .frame(maxWidth: .infinity, alignment: .leading)+ }+ .scrollIndicators(.hidden)+ .foregroundStyle(.white).preferredColorScheme(.dark)+ }+ private func hint(_ icon: some View, _ label: String) -> some View {+ HStack(spacing: 14) {+ icon.frame(width: 22).foregroundStyle(.white.opacity(0.75))+ Text(label).shellText(14.5).foregroundStyle(.white.opacity(0.7))+ }.accessibilityElement(children: .combine)+ }+}++private struct ControllerRow: View {+ let controller: ControllerInfo+ @Environment(\.dynamicTypeSize) private var typeSize+ var body: some View {+ let layout = typeSize.isAccessibilitySize ? AnyLayout(VStackLayout(alignment: .leading, spacing: 10)) : AnyLayout(HStackLayout(spacing: 16))+ layout {+ Image(systemName: "gamecontroller.fill").font(.system(size: 20))+ .frame(width: 48, height: 48)+ .background(.white.opacity(0.07), in: Circle())+ .foregroundStyle(.white.opacity(0.9))+ .accessibilityHidden(true)+ VStack(alignment: .leading, spacing: 4) {+ Text(controller.player.uppercased()).shellText(10.5, .bold, relativeTo: .caption2).tracking(1.4)+ .foregroundStyle(ShellPalette.cream.opacity(0.8))+ Text(controller.name).shellText(16, .semibold).fixedSize(horizontal: false, vertical: true)+ }+ if !typeSize.isAccessibilitySize { Spacer(minLength: 8) }+ BatteryChip(controller: controller)+ }+ .frame(maxWidth: .infinity, minHeight: 76, alignment: .leading)+ .padding(.vertical, typeSize.isAccessibilitySize ? 12 : 0)+ .accessibilityElement(children: .combine)+ }+}++/// The Mac console's battery chip: an outline battery with its fill, and the percentage. Low is amber.+struct BatteryChip: View {+ let controller: ControllerInfo+ var body: some View {+ let low = (controller.batteryPercent ?? 100) < 20 && !controller.charging+ let tint: Color = low ? ShellPalette.attention : controller.charging ? ShellPalette.ready : .white.opacity(0.75)+ HStack(spacing: 7) {+ if let percent = controller.batteryPercent {+ BatteryShape(fraction: Double(percent) / 100).foregroundStyle(tint)+ Text("\(percent)%").monospacedDigit()+ if controller.charging {+ Image(systemName: "bolt.fill").font(.system(size: 10)).accessibilityLabel(ShellStrings.text("Charging"))+ }+ } else {+ Text(ShellStrings.text("No battery level"))+ }+ }+ .lineLimit(1).fixedSize()+ .shellText(12.5, .semibold, relativeTo: .footnote)+ .foregroundStyle(controller.batteryPercent == nil ? .white.opacity(0.45) : tint)+ .padding(.horizontal, 10).frame(minHeight: 28)+ .background(.white.opacity(0.06), in: Capsule())+ }+}++private struct BatteryShape: View {+ let fraction: Double+ var body: some View {+ HStack(spacing: 1) {+ ZStack(alignment: .leading) {+ RoundedRectangle(cornerRadius: 3).strokeBorder(lineWidth: 1.2).opacity(0.7)+ RoundedRectangle(cornerRadius: 1.5).padding(2.5)+ .frame(width: max(7, 22 * min(1, max(0, fraction))))+ }.frame(width: 22, height: 11)+ RoundedRectangle(cornerRadius: 1).frame(width: 1.5, height: 4).opacity(0.7)+ }.accessibilityHidden(true)+ }+}diff --git a/frontend-ios/Sources/ShellUI/CoverFlowView.swift b/frontend-ios/Sources/ShellUI/CoverFlowView.swiftnew file mode 100644index 00000000..45f8d008--- /dev/null+++ b/frontend-ios/Sources/ShellUI/CoverFlowView.swift@@ -0,0 +1,247 @@+import SwiftUI++/// The library when it is wider than it is tall: one cover in the middle, its neighbours turned back, the title,+/// state and primary action underneath. The backdrop (the blurred cover) is drawn by the library behind the safe area.+struct CoverFlowView: View {+ let games: [GameDetail]+ let selected: GameDetail+ let controllers: Int+ let showsHints: Bool+ let select: (String) -> Void+ let primary: (GameDetail) -> Void+ let openSettings: () -> Void+ let openControllers: () -> Void+ @State private var centredID: String?+ /// How far the carousel is scrolled: 0 with the first cover in the middle.+ @State private var scrolled: CGFloat = 0+ @State private var userScrolling = false+ @Environment(\.accessibilityReduceMotion) private var reduceMotion+ @Environment(\.dynamicTypeSize) private var typeSize++ var body: some View {+ GeometryReader { geometry in+ let short = geometry.size.height < 520+ // The cover takes what the height allows, and never so much that no neighbour shows.+ let cover = max(110, min(geometry.size.height * (short ? 0.50 : 0.44), geometry.size.width * 0.34, 400))+ VStack(spacing: 0) {+ topBar.padding(.horizontal, 24).padding(.top, short ? 4 : 16)+ Spacer(minLength: short ? 4 : 12)+ Group {+ if games.count <= 3 { shelf(cover: cover) } else { carousel(width: geometry.size.width, cover: cover) }+ }.frame(height: cover * 1.04)+ info(short: short, width: geometry.size.width)+ .padding(.top, short ? 14 : 28).padding(.horizontal, 24)+ Spacer(minLength: short ? 4 : 12)+ if showsHints && !short {+ hints.padding(.bottom, 20)+ }+ }+ }+ .sensoryFeedback(.selection, trigger: selected.id)+ .onAppear { centredID = selected.id }+ .onChange(of: centredID) { _, id in+ // Only a scroll the player makes chooses a game. A scroll this view animates (after the D-pad or a tap)+ // passes other covers on the way and must not choose them.+ if userScrolling, let id, id != selected.id { select(id) }+ }+ .onChange(of: selected.id) { _, id in+ guard centredID != id else { return }+ withAnimation(reduceMotion ? nil : .smooth(duration: 0.32)) { centredID = id }+ }+ }++ private var topBar: some View {+ HStack(alignment: .center) {+ SectionHeading(title: ShellStrings.text("Your games"))+ Text(ShellStrings.text("\(position) of \(games.count)")).shellText(12, .medium, relativeTo: .caption)+ .monospacedDigit().foregroundStyle(.white.opacity(0.45)).padding(.leading, 6)+ Spacer(minLength: 12)+ ControllerChip(count: controllers, action: openControllers)+ }+ }+ private var position: Int { (games.firstIndex { $0.id == selected.id } ?? 0) + 1 }++ /// More than three games: a snapping carousel with the neighbours turned toward the middle.+ private func carousel(width: CGFloat, cover: CGFloat) -> some View {+ let spacing = cover * 0.06+ let stride = cover + spacing+ return ScrollView(.horizontal) {+ LazyHStack(spacing: spacing) {+ ForEach(Array(games.enumerated()), id: \.element.id) { index, detail in+ // Places from the middle: -1 is the neighbour on the left, 1 the one on the right.+ coverButton(detail, cover: cover)+ .modifier(FlowTilt(place: CGFloat(index) - scrolled / stride, cover: cover, flat: reduceMotion))+ .id(detail.id)+ }+ }.scrollTargetLayout()+ }+ .scrollTargetBehavior(.viewAligned)+ .scrollPosition(id: $centredID, anchor: .center)+ .contentMargins(.horizontal, max(0, (width - cover) / 2), for: .scrollContent)+ .onScrollGeometryChange(for: CGFloat.self) { $0.contentOffset.x + $0.contentInsets.leading } action: { _, offset in+ scrolled = offset+ }+ .onScrollPhaseChange { _, phase in+ switch phase {+ case .interacting, .decelerating: userScrolling = true+ case .idle:+ if userScrolling, let id = centredID, id != selected.id { select(id) }+ userScrolling = false+ default: userScrolling = false+ }+ }+ .scrollIndicators(.hidden)+ .scrollClipDisabled()+ }++ /// One to three games: they sit together in the middle, the chosen one larger. No empty track.+ private func shelf(cover: CGFloat) -> some View {+ HStack(spacing: cover * 0.12) {+ ForEach(games) { detail in+ let chosen = detail.id == selected.id+ coverButton(detail, cover: cover)+ .scaleEffect(chosen ? 1 : 0.8)+ .brightness(chosen ? 0 : -0.18)+ }+ }+ .animation(reduceMotion ? nil : .smooth(duration: 0.3), value: selected.id)+ .frame(maxWidth: .infinity)+ }++ private func coverButton(_ detail: GameDetail, cover: CGFloat) -> some View {+ let chosen = detail.id == selected.id+ return Button {+ if chosen { return }+ withAnimation(reduceMotion ? nil : .smooth(duration: 0.32)) { centredID = detail.id }+ select(detail.id)+ } label: {+ CoverView(game: detail.game, radius: cover * 0.06)+ .frame(width: cover, height: cover)+ .shadow(color: .black.opacity(0.45), radius: cover * 0.08, y: cover * 0.05)+ }+ .buttonStyle(.plain)+ .shellTarget("lib.tile.\(detail.id)", radius: cover * 0.06) { primary(detail) }+ .accessibilityLabel(detail.game.title + ", " + detail.game.state.title)+ .accessibilityAddTraits(chosen ? .isSelected : [])+ .accessibilityIdentifier("tile.\(detail.id)")+ }++ @ViewBuilder private func info(short: Bool, width: CGFloat) -> some View {+ let game = selected.game+ if short {+ // A phone on its side: one line of title and state beside the buttons, so the cover keeps the height.+ HStack(spacing: 28) {+ VStack(alignment: .leading, spacing: 5) {+ title(game, size: 22).lineLimit(1)+ StatusLabel(state: game.state)+ }.frame(maxWidth: min(340, width * 0.4), alignment: .leading).fixedSize(horizontal: true, vertical: true)+ actions(game)+ }+ .frame(maxWidth: .infinity)+ .dynamicTypeSize(...DynamicTypeSize.xxLarge)+ } else {+ VStack(spacing: 12) {+ title(game, size: 30).lineLimit(2).multilineTextAlignment(.center)+ StatusLabel(state: game.state, prominent: true)+ if !game.state.explanation.isEmpty {+ Text(game.state.explanation).shellText(14).foregroundStyle(.white.opacity(0.68))+ .multilineTextAlignment(.center).frame(maxWidth: 440).fixedSize(horizontal: false, vertical: true)+ }+ actions(game).padding(.top, 6)+ }+ .dynamicTypeSize(...DynamicTypeSize.accessibility1)+ }+ }++ private func title(_ game: GameTile, size: CGFloat) -> some View {+ Text(game.title).shellText(size, .heavy, relativeTo: .title).tracking(-size * 0.025)+ .shadow(color: .black.opacity(0.35), radius: 10)+ .accessibilityAddTraits(.isHeader).accessibilityIdentifier("hero.title")+ .id("title.\(game.id)").transition(.opacity)+ .animation(reduceMotion ? nil : .easeOut(duration: 0.2), value: game.id)+ }++ private func actions(_ game: GameTile) -> some View {+ HStack(spacing: 12) {+ Button { primary(selected) } label: { Label(game.state.actionTitle, systemImage: game.state.actionSymbol) }+ .buttonStyle(PrimaryPillStyle())+ .accessibilityLabel(game.state.actionTitle + ", " + game.title)+ .accessibilityIdentifier("state.action")+ .shellTarget("lib.play", radius: 25) { primary(selected) }+ Button(action: openSettings) { Image(systemName: "slider.horizontal.3") }+ .buttonStyle(RoundIconButtonStyle())+ .accessibilityLabel(ShellStrings.text("Game settings"))+ .accessibilityIdentifier("settings.open")+ .shellTarget("lib.settings", radius: 25, action: openSettings)+ }+ }++ private var hints: some View {+ HStack(spacing: 24) {+ GlyphHint(letter: "A", label: selected.game.state.actionTitle)+ GlyphHint(letter: "X", label: ShellStrings.text("Game settings"))+ GlyphHint(letter: "Y", label: ShellStrings.text("Controllers"))+ }.accessibilityHidden(true)+ }+}++/// A cover's turn by its place: up to 40 degrees back, a little smaller and darker, the farther ones closer together.+/// Reduced motion keeps them flat.+private struct FlowTilt: ViewModifier {+ let place: CGFloat+ let cover: CGFloat+ let flat: Bool+ func body(content: Content) -> some View {+ let near = max(-1, min(1, place))+ let far = place > 1 ? place - 1 : place < -1 ? place + 1 : 0+ content+ .rotation3DEffect(.degrees(flat ? 0 : -near * 40), axis: (x: 0, y: 1, z: 0), perspective: 0.45)+ .scaleEffect(1 - abs(near) * (flat ? 0.10 : 0.16))+ .offset(x: -near * cover * 0.10 - far * cover * (flat ? 0.2 : 0.34))+ .brightness(-abs(near) * 0.18)+ }+}++/// The blurred cover behind Cover Flow. It crossfades as the middle cover changes.+struct CoverFlowBackdrop: View {+ let game: GameTile+ @Environment(\.accessibilityReduceMotion) private var reduceMotion+ var body: some View {+ ZStack {+ ShellPalette.background+ ArtView(art: game.cover, title: game.title, seed: game.id, backdrop: true)+ .scaleEffect(1.3)+ .blur(radius: 60, opaque: true)+ .saturation(1.25)+ .opacity(0.75)+ .id(game.id)+ .transition(.opacity)+ // Darker toward the edges and the bottom, so the type and the covers keep their contrast.+ RadialGradient(colors: [.clear, ShellPalette.background.opacity(0.75)], center: .init(x: 0.5, y: 0.4),+ startRadius: 80, endRadius: 900)+ LinearGradient(colors: [.black.opacity(0.25), .clear, ShellPalette.background.opacity(0.85)],+ startPoint: .top, endPoint: .bottom)+ }+ .animation(reduceMotion ? .linear(duration: 0.2) : .easeInOut(duration: 0.45), value: game.id)+ .ignoresSafeArea()+ .accessibilityHidden(true)+ }+}++/// The controller count on top of art, which opens Controllers.+struct ControllerChip: View {+ let count: Int+ let action: () -> Void+ var body: some View {+ Button(action: action) {+ HStack(spacing: 8) {+ Image(systemName: count == 0 ? "gamecontroller" : "gamecontroller.fill")+ Text("\(count)").monospacedDigit()+ }+ }+ .buttonStyle(ChipButtonStyle())+ .accessibilityLabel(ShellStrings.text("Controllers") + ", \(count)")+ .accessibilityIdentifier("controllers.open")+ .shellTarget("lib.controllers", radius: 22, action: action)+ }+}diff --git a/frontend-ios/Sources/ShellUI/GameDetailView.swift b/frontend-ios/Sources/ShellUI/GameDetailView.swiftnew file mode 100644index 00000000..9a4f92a4--- /dev/null+++ b/frontend-ios/Sources/ShellUI/GameDetailView.swift@@ -0,0 +1,238 @@+import SwiftUI++/// One game's settings: what it is and its state, then the setting groups, game data, cloud saves and the reset.+/// The library supplies the scrolling container. Values come in through `detail` and leave through `actions`.+public struct GameDetailView: View {+ public let detail: GameDetail+ public var actions: ShellActions+ /// Off where the screen shows the primary action already, as beside the library's hero.+ public var showsPrimaryAction: Bool+ /// Off where the game's cover and title are already in view, as beside the library's hero.+ public var showsHeader: Bool+ public init(detail: GameDetail, actions: ShellActions = ShellActions(), showsPrimaryAction: Bool = true, showsHeader: Bool = true) {+ self.detail = detail+ self.actions = actions+ self.showsPrimaryAction = showsPrimaryAction+ self.showsHeader = showsHeader+ }+ public var body: some View {+ VStack(alignment: .leading, spacing: 30) {+ if showsHeader { header }+ ForEach(detail.sections) { section in+ group(section.title) {+ ForEach(section.rows) { row in+ SettingControl(row: row) { actions.onChange(detail.id, row.id, $0) }+ if row.id != section.rows.last?.id { divider }+ }+ }+ }+ group(ShellStrings.text("Game data")) {+ SourceRow(symbol: "folder",+ title: detail.dataSource.isEmpty ? ShellStrings.text("No data selected") : detail.dataSource,+ note: detail.dataNote) {+ Button(ShellStrings.text("Choose…")) { actions.onPickGameData(detail.id) }+ .buttonStyle(ShellButtonStyle()).accessibilityLabel(ShellStrings.text("Choose game data…"))+ .shellTarget("set.data") { actions.onPickGameData(detail.id) }+ if !detail.dataSource.isEmpty {+ Button(ShellStrings.text("Use app data")) { actions.onUseAppData(detail.id) }+ .buttonStyle(ShellButtonStyle()).shellTarget("set.appdata") { actions.onUseAppData(detail.id) }+ }+ }+ divider+ Label(detail.dlc.isEmpty ? ShellStrings.text("No additional content") : detail.dlc, systemImage: "square.stack.3d.up")+ .shellText(14).foregroundStyle(.white.opacity(0.72)).frame(minHeight: 32)+ }+ group(ShellStrings.text("Cloud saves")) {+ SourceRow(symbol: detail.cloudSaves == nil ? "icloud.slash" : "icloud",+ title: detail.cloudSaves ?? ShellStrings.text("Off"),+ note: detail.cloudNote.isEmpty ? ShellStrings.text("Choose the same iCloud Drive folder you use on your Mac.") : detail.cloudNote) {+ Button(ShellStrings.text("Choose folder…")) { actions.onPickCloudSaves(detail.id) }+ .buttonStyle(ShellButtonStyle()).shellTarget("set.cloud") { actions.onPickCloudSaves(detail.id) }+ if detail.cloudSaves != nil {+ Button(ShellStrings.text("Turn off")) { actions.onDisableCloudSaves(detail.id) }+ .buttonStyle(ShellButtonStyle()).accessibilityLabel(ShellStrings.text("Turn off cloud saves"))+ .shellTarget("set.cloud.off") { actions.onDisableCloudSaves(detail.id) }+ }+ }+ }+ VStack(alignment: .leading, spacing: 10) {+ Button(ShellStrings.text("Reset to tested defaults")) { actions.onResetDefaults(detail.id) }+ .buttonStyle(ShellButtonStyle())+ .disabled(!detail.hasModifiedSettings)+ .shellTarget("set.reset", enabled: detail.hasModifiedSettings) { actions.onResetDefaults(detail.id) }+ Text(ShellStrings.text("Brings back the settings this game was tested with."))+ .shellText(12.5).foregroundStyle(.white.opacity(0.45)).fixedSize(horizontal: false, vertical: true)+ }+ }.foregroundStyle(.white)+ }++ private var header: some View {+ VStack(alignment: .leading, spacing: 16) {+ HStack(alignment: .center, spacing: 16) {+ CoverView(game: detail.game, radius: 10).frame(width: 64, height: 64)+ VStack(alignment: .leading, spacing: 6) {+ Text(detail.game.title).shellText(24, .heavy, relativeTo: .title).tracking(-0.6)+ .fixedSize(horizontal: false, vertical: true)+ .accessibilityAddTraits(.isHeader).accessibilityIdentifier("detail.title")+ ViewThatFits(in: .horizontal) {+ HStack(spacing: 10) { status }+ VStack(alignment: .leading, spacing: 4) { status }+ }+ }+ }+ if showsPrimaryAction {+ if !detail.game.state.explanation.isEmpty {+ Text(detail.game.state.explanation).shellText(14).foregroundStyle(.white.opacity(0.72))+ .fixedSize(horizontal: false, vertical: true)+ }+ GameStateView(game: detail.game, actions: actions, showsExplanation: false)+ }+ }+ }++ @ViewBuilder private var status: some View {+ StatusLabel(state: detail.game.state).fixedSize()+ if !detail.game.subtitle.isEmpty {+ Text(detail.game.subtitle).shellText(12.5).foregroundStyle(.white.opacity(0.45)).fixedSize()+ }+ }++ private var divider: some View { Rectangle().fill(.white.opacity(0.06)).frame(height: 1) }++ private func group<Content: View>(_ title: String, @ViewBuilder content: () -> Content) -> some View {+ VStack(alignment: .leading, spacing: 12) {+ SectionHeading(title: title).padding(.leading, 4)+ VStack(alignment: .leading, spacing: 14) { content() }+ .frame(maxWidth: .infinity, alignment: .leading)+ .shellCard()+ }+ }+}++/// Where something comes from (game data, a cloud folder) and the buttons that change it.+private struct SourceRow<Buttons: View>: View {+ let symbol: String+ let title: String+ let note: String+ @ViewBuilder let buttons: () -> Buttons+ var body: some View {+ VStack(alignment: .leading, spacing: 12) {+ HStack(alignment: .firstTextBaseline, spacing: 12) {+ Image(systemName: symbol).foregroundStyle(ShellPalette.cream.opacity(0.8)).frame(width: 20).accessibilityHidden(true)+ VStack(alignment: .leading, spacing: 5) {+ Text(title).shellText(15, .semibold).fixedSize(horizontal: false, vertical: true)+ if !note.isEmpty {+ Text(note).shellText(12.5).foregroundStyle(.white.opacity(0.5)).fixedSize(horizontal: false, vertical: true)+ }+ }+ }+ ViewThatFits(in: .horizontal) {+ HStack(spacing: 10) { buttons() }+ VStack(alignment: .leading, spacing: 10) { buttons() }+ }.padding(.leading, 32)+ }+ }+}++private struct SettingControl: View {+ let row: SettingRow+ let change: (String) -> Void+ @Environment(\.dynamicTypeSize) private var typeSize+ var body: some View {+ VStack(alignment: .leading, spacing: 12) {+ switch row.kind {+ case .toggle(let on, let off):+ Toggle(isOn: Binding(get: { row.value == on }, set: { change($0 ? on : off) })) { label }+ .toggleStyle(CreamToggleStyle())+ .shellTarget("set.row.\(row.id)", enabled: row.enabled) { change(row.value == on ? off : on) }+ case .choice(let options):+ label+ if options.count <= 3 && !typeSize.isAccessibilitySize {+ ViewThatFits(in: .horizontal) {+ segmented(options)+ list(options)+ }+ } else {+ list(options)+ }+ case .range(let min, let max, let step, let unit):+ HStack(alignment: .firstTextBaseline) {+ label+ Spacer(minLength: 8)+ Text((Double(row.value) ?? min).formatted(.number.precision(.fractionLength(0...2))) + unit)+ .shellText(15, .bold).monospacedDigit().foregroundStyle(ShellPalette.cream)+ }+ HStack(spacing: 10) {+ rangeButton("minus", min: min, max: max, delta: -step)+ if min < max && step > 0 {+ Slider(value: Binding(get: { Double(row.value) ?? min }, set: { change(String($0)) }), in: min...max, step: step)+ .frame(minHeight: 44).tint(ShellPalette.cream).accessibilityLabel(row.label)+ }+ rangeButton("plus", min: min, max: max, delta: step)+ }+ }+ }.frame(maxWidth: .infinity, alignment: .leading)+ .disabled(!row.enabled).opacity(row.enabled ? 1 : 0.45)+ .accessibilityIdentifier("setting.\(row.id)")+ }+ private var label: some View {+ VStack(alignment: .leading, spacing: 4) {+ Text(row.label).shellText(15, .semibold).fixedSize(horizontal: false, vertical: true)+ if !row.note.isEmpty { Text(row.note).shellText(12.5).foregroundStyle(.white.opacity(0.5)).fixedSize(horizontal: false, vertical: true) }+ }+ }+ /// The Mac's segmented choice: a dim track, the chosen value in cream.+ private func segmented(_ options: [SettingOption]) -> some View {+ HStack(spacing: 2) {+ ForEach(options) { option in+ let chosen = row.value == option.id+ Button { change(option.id) } label: {+ Text(option.label).shellText(13.5, chosen ? .bold : .medium).lineLimit(1)+ .padding(.horizontal, 16).frame(minHeight: 40)+ .foregroundStyle(chosen ? .black : .white.opacity(0.75))+ .background(chosen ? ShellPalette.cream : .clear, in: RoundedRectangle(cornerRadius: 8))+ .contentShape(RoundedRectangle(cornerRadius: 8))+ }+ .buttonStyle(.plain).fixedSize()+ .accessibilityLabel(row.label + ", " + option.label)+ .accessibilityAddTraits(chosen ? .isSelected : [])+ .shellTarget("set.row.\(row.id).\(option.id)", enabled: row.enabled, radius: 8) { change(option.id) }+ }+ }+ .padding(3)+ .background(.white.opacity(0.055), in: RoundedRectangle(cornerRadius: 11))+ .overlay(RoundedRectangle(cornerRadius: 11).strokeBorder(.white.opacity(0.08)))+ }+ private func list(_ options: [SettingOption]) -> some View {+ VStack(alignment: .leading, spacing: 4) {+ ForEach(options) { option in+ let chosen = row.value == option.id+ Button { change(option.id) } label: {+ HStack {+ Text(option.label).shellText(14, chosen ? .bold : .medium)+ Spacer()+ if chosen { Image(systemName: "checkmark").font(.system(size: 13, weight: .bold)) }+ }+ .padding(.horizontal, 14).frame(minHeight: 44)+ .foregroundStyle(chosen ? ShellPalette.cream : .white.opacity(0.75))+ .background(.white.opacity(chosen ? 0.08 : 0.03), in: RoundedRectangle(cornerRadius: 9))+ .contentShape(RoundedRectangle(cornerRadius: 9))+ }+ .buttonStyle(.plain)+ .accessibilityLabel(row.label + ", " + option.label)+ .accessibilityAddTraits(chosen ? .isSelected : [])+ .shellTarget("set.row.\(row.id).\(option.id)", enabled: row.enabled, radius: 9) { change(option.id) }+ }+ }+ }+ private func rangeButton(_ symbol: String, min: Double, max: Double, delta: Double) -> some View {+ let action = { change(String(Swift.min(max, Swift.max(min, (Double(row.value) ?? min) + delta)))) }+ return Button(action: action) {+ Image(systemName: symbol).font(.system(size: 14, weight: .semibold)).frame(width: 44, height: 44)+ }+ .buttonStyle(.plain).background(.white.opacity(0.055), in: Circle())+ .overlay(Circle().strokeBorder(.white.opacity(0.10)))+ .accessibilityLabel(ShellStrings.text(symbol == "minus" ? "Decrease" : "Increase") + " " + row.label)+ .shellTarget("set.row.\(row.id).\(symbol)", enabled: row.enabled, radius: 22, action: action)+ }+}diff --git a/frontend-ios/Sources/ShellUI/GameStateView.swift b/frontend-ios/Sources/ShellUI/GameStateView.swiftnew file mode 100644index 00000000..1404904a--- /dev/null+++ b/frontend-ios/Sources/ShellUI/GameStateView.swift@@ -0,0 +1,60 @@+import SwiftUI++/// A game's state and the one thing to do about it: Play, choose game data, update the app, or read the log.+public struct GameStateView: View {+ public let game: GameTile+ public var actions: ShellActions+ public var showsExplanation: Bool+ public init(game: GameTile, actions: ShellActions = ShellActions(), showsExplanation: Bool = true) {+ self.game = game+ self.actions = actions+ self.showsExplanation = showsExplanation+ }+ public var body: some View {+ VStack(alignment: .leading, spacing: 14) {+ if showsExplanation {+ StatusLabel(state: game.state, prominent: true)+ if !game.state.explanation.isEmpty {+ Text(game.state.explanation).shellText(14.5).foregroundStyle(.white.opacity(0.72))+ .fixedSize(horizontal: false, vertical: true)+ }+ }+ Button(action: perform) { Label(game.state.actionTitle, systemImage: game.state.actionSymbol) }+ .buttonStyle(PrimaryPillStyle())+ .accessibilityIdentifier("state.action")+ .accessibilityLabel(game.state.actionTitle + ", " + game.title)+ .shellTarget("set.play", radius: 25, action: perform)+ }+ }+ private func perform() {+ switch game.state {+ case .playable: actions.onPlay(game.id)+ case .needsGameData: actions.onPickGameData(game.id)+ case .needsAppUpdate: actions.onAppUpdate()+ case .broken: actions.onShowLog(game.id)+ }+ }+}++/// No game in the app yet: an empty shelf, said plainly.+public struct EmptyLibraryView: View {+ public init() {}+ public var body: some View {+ VStack(alignment: .leading, spacing: 18) {+ HStack(spacing: 14) {+ ForEach(0..<3, id: \.self) { index in+ RoundedRectangle(cornerRadius: 12)+ .strokeBorder(.white.opacity(0.16 - Double(index) * 0.045), style: StrokeStyle(lineWidth: 1.2, dash: [5, 5]))+ .frame(width: 76, height: 76)+ }+ }.padding(.bottom, 14).accessibilityHidden(true)+ SectionHeading(title: ShellStrings.text("Your games"))+ Text(ShellStrings.text("A little room for adventure")).shellText(30, .heavy, relativeTo: .title).tracking(-0.8)+ .fixedSize(horizontal: false, vertical: true)+ Text(ShellStrings.text("Your games will appear here when they are included in this app."))+ .shellText(15).foregroundStyle(.white.opacity(0.6)).fixedSize(horizontal: false, vertical: true)+ }+ .padding(28).frame(maxWidth: 460, alignment: .leading)+ .frame(maxWidth: .infinity, maxHeight: .infinity)+ }+}diff --git a/frontend-ios/Sources/ShellUI/LibraryView.swift b/frontend-ios/Sources/ShellUI/LibraryView.swiftnew file mode 100644index 00000000..bfc95dbc--- /dev/null+++ b/frontend-ios/Sources/ShellUI/LibraryView.swift@@ -0,0 +1,277 @@+import SwiftUI++/// How the library arranges itself. Only the available size decides, never the device model or orientation,+/// so a Stage Manager window, Split View and a foldable opening while the app runs all follow the same rules.+enum ShellLayout: Equatable {+ /// Compact and taller than wide: one column, settings pushed over the library.+ case column+ /// Regular width and height, not wide: the library beside the settings pane.+ case split+ /// Wider than tall: Cover Flow. Settings open as a panel on the right (regular) or over the library (compact).+ case coverFlow(regular: Bool)++ static func resolve(_ size: CGSize, accessibilityText: Bool) -> ShellLayout {+ let regular = size.width >= 600 && size.height >= 500+ if size.width > size.height * 1.2 { return .coverFlow(regular: regular) }+ return regular && !accessibilityText ? .split : .column+ }++ /// The settings pane's width: the whole width where it covers the library.+ func paneWidth(_ width: CGFloat) -> CGFloat {+ switch self {+ case .column, .coverFlow(regular: false): width+ case .split: min(460, max(320, width * 0.46))+ case .coverFlow(regular: true): min(520, max(380, width * 0.42))+ }+ }+ var isCoverFlow: Bool { if case .coverFlow = self { true } else { false } }+}++/// A presentation-only shell. Selection, focus, navigation and scroll positions are local UI state.+/// All game effects are supplied by the host through actions.+public struct LibraryView: View {+ public let games: [GameDetail]+ public let controllers: [ControllerInfo]+ public var actions: ShellActions+ public var input: ShellInput?+ @State private var selectedID: String?+ @State private var settingsOpen: Bool+ @State private var controllersOpen: Bool+ @State private var focus: FocusAppearance+ @State private var targets = FocusTargetBuffer()+ @State private var settingsPosition = ScrollPosition()+ @State private var libraryPosition = ScrollPosition()+ @State private var layout: ShellLayout = .column+ @Environment(\.accessibilityReduceMotion) private var reduceMotion+ @Environment(\.dynamicTypeSize) private var typeSize++ public init(games: [GameDetail], controllers: [ControllerInfo] = [], actions: ShellActions = ShellActions(),+ input: ShellInput? = nil, initialSelection: String? = nil, initialDetailOpen: Bool = false,+ initialControllersOpen: Bool = false, initialFocusVisible: Bool = false) {+ self.games = games+ self.controllers = controllers+ self.actions = actions+ self.input = input+ let first = initialSelection ?? games.first?.id+ _selectedID = State(initialValue: first)+ _settingsOpen = State(initialValue: initialDetailOpen)+ _controllersOpen = State(initialValue: initialControllersOpen)+ _focus = State(initialValue: FocusAppearance(id: initialFocusVisible ? "lib.tile.\(first ?? "")" : nil, visible: initialFocusVisible))+ }+ private var selected: GameDetail? { games.first { $0.id == selectedID } ?? games.first }++ public var body: some View {+ GeometryReader { geometry in+ let insets = geometry.safeAreaInsets+ let whole = CGSize(width: geometry.size.width + insets.leading + insets.trailing,+ height: geometry.size.height + insets.top + insets.bottom)+ let layout = ShellLayout.resolve(whole, accessibilityText: typeSize.isAccessibilitySize)+ let width = geometry.size.width+ let pane = layout.paneWidth(width)+ let paneShown = layout == .split || settingsOpen+ // Where the pane is as wide as the screen, the library underneath steps out of the way.+ let paneCovers = settingsOpen && pane >= width+ let panelOverLibrary = settingsOpen && layout == .coverFlow(regular: true)+ ZStack(alignment: .topLeading) {+ if layout.isCoverFlow, let selected { CoverFlowBackdrop(game: selected.game) } else { ShellPalette.background.ignoresSafeArea() }+ if games.isEmpty {+ EmptyLibraryView()+ .overlay(alignment: .topTrailing) {+ ControllerChip(count: controllers.count, action: openControllers).padding(.top, 6).padding(.trailing, 16)+ }+ } else if let selected {+ library(selected, layout: layout,+ size: CGSize(width: layout == .split ? width - pane : width, height: geometry.size.height),+ topInset: insets.top)+ .frame(width: layout == .split ? width - pane : width, height: geometry.size.height)+ .opacity(paneCovers ? 0 : 1)+ .allowsHitTesting(!paneCovers && !panelOverLibrary)+ .accessibilityHidden(paneCovers || panelOverLibrary)+ .transformPreference(FocusTargets.self) { if paneCovers || panelOverLibrary { $0.removeAll() } }+ if panelOverLibrary {+ Color.black.opacity(0.45).ignoresSafeArea()+ .onTapGesture { closeSettings() }+ .accessibilityHidden(true)+ .transition(.opacity)+ }+ // One settings pane in one place for every layout, so its scroll position and focus survive+ // a fold, a rotation or a Stage Manager resize.+ settingsPane(selected, layout: layout)+ .frame(width: pane, height: geometry.size.height)+ .background {+ (paneCovers ? ShellPalette.background : Color(red: 0.075, green: 0.075, blue: 0.082))+ .ignoresSafeArea()+ .overlay(alignment: .leading) {+ if !paneCovers { Rectangle().fill(ShellPalette.hairline).frame(width: 1).ignoresSafeArea() }+ }+ }+ .offset(x: paneShown ? 0 : pane + 24)+ .opacity(paneShown ? 1 : 0)+ .frame(maxWidth: .infinity, alignment: .trailing)+ .allowsHitTesting(paneShown)+ .accessibilityHidden(!paneShown)+ .transformPreference(FocusTargets.self) { if !paneShown { $0.removeAll() } }+ }+ if controllersOpen {+ Color.black.opacity(0.55).ignoresSafeArea().accessibilityHidden(true)+ .onTapGesture { back() }+ ControllersView(controllers: controllers, onBack: back)+ .frame(width: min(width, 520))+ .frame(maxHeight: .infinity)+ .background { ShellPalette.background.ignoresSafeArea() }+ .overlay(alignment: .leading) { Rectangle().fill(ShellPalette.hairline).frame(width: 1).ignoresSafeArea() }+ .frame(maxWidth: .infinity, alignment: .trailing)+ .accessibilityAddTraits(.isModal)+ .transition(.move(edge: .trailing).combined(with: .opacity))+ }+ }+ .transformPreference(FocusTargets.self) { values in+ values = values.filter { controllersOpen ? $0.id.hasPrefix("ctl.") : !$0.id.hasPrefix("ctl.") }+ }+ .coordinateSpace(name: "shell")+ .onPreferenceChange(FocusTargets.self) { all in targets.values = all.filter { $0.frame.width > 1 } }+ .onAppear { self.layout = layout }+ .onChange(of: layout) { _, new in self.layout = new }+ }+ .animation(reduceMotion ? nil : .smooth(duration: 0.35), value: layout)+ .animation(reduceMotion ? nil : .smooth(duration: 0.3), value: settingsOpen)+ .animation(reduceMotion ? nil : .smooth(duration: 0.3), value: controllersOpen)+ .environment(\.shellFocus, focus)+ .foregroundStyle(.white)+ .font(ShellFonts.font(15)).tint(ShellPalette.cream).preferredColorScheme(.dark)+ .onChange(of: input) { _, event in if let event { handle(event.action) } }+ .focusable().focusEffectDisabled()+ .onKeyPress(.leftArrow) { handle(.left); return .handled }+ .onKeyPress(.rightArrow) { handle(.right); return .handled }+ .onKeyPress(.upArrow) { handle(.up); return .handled }+ .onKeyPress(.downArrow) { handle(.down); return .handled }+ .onKeyPress(.return) { handle(.activate); return .handled }+ .onKeyPress(.escape) { handle(.back); return .handled }+ .onDisappear { targets.values.removeAll() }+ .onChange(of: games.map(\.id)) { _, ids in+ if !ids.contains(selectedID ?? "") { selectedID = ids.first; settingsOpen = false }+ }+ }++ @ViewBuilder private func library(_ selected: GameDetail, layout: ShellLayout, size: CGSize, topInset: CGFloat) -> some View {+ if layout.isCoverFlow {+ CoverFlowView(games: games, selected: selected, controllers: controllers.count, showsHints: !controllers.isEmpty,+ select: select, primary: primary, openSettings: openSettings, openControllers: openControllers)+ .transition(.opacity)+ } else {+ PortraitLibrary(games: games, selected: selected, twoPanes: layout == .split, size: size, topInset: topInset,+ controllers: controllers.count, select: select, primary: primary,+ openSettings: openSettings, openControllers: openControllers, position: $libraryPosition)+ .transition(.opacity)+ }+ }++ private func settingsPane(_ selected: GameDetail, layout: ShellLayout) -> some View {+ let closable = layout != .split+ return VStack(spacing: 0) {+ HStack(spacing: 12) {+ if closable {+ Button(action: closeSettings) {+ if typeSize.isAccessibilitySize { Image(systemName: "chevron.left").frame(minWidth: 24) }+ else { Label(ShellStrings.text("Library"), systemImage: "chevron.left") }+ }+ .buttonStyle(ShellButtonStyle())+ .accessibilityLabel(ShellStrings.text("Library"))+ .accessibilityIdentifier("library.back")+ .shellTarget("set.back", action: closeSettings)+ }+ SectionHeading(title: ShellStrings.text("Game settings"))+ .padding(.leading, closable ? 4 : 0)+ Spacer(minLength: 0)+ }+ .padding(.horizontal, 24).padding(.top, 10).padding(.bottom, 4).frame(minHeight: 56)+ ScrollViewReader { proxy in+ ScrollView {+ GameDetailView(detail: selected, actions: actions, showsPrimaryAction: layout != .split, showsHeader: layout != .split)+ .padding(.horizontal, 24).padding(.top, 12).padding(.bottom, 32)+ // A phone on its side: a readable column, not rows stretched across the whole width.+ .frame(maxWidth: 640, alignment: .leading)+ .frame(maxWidth: .infinity, alignment: .leading)+ }+ .scrollPosition($settingsPosition)+ .scrollIndicators(.hidden)+ .onChange(of: focus.id) { _, id in+ guard let id, id.hasPrefix("set."), id != "set.back" else { return }+ withAnimation(reduceMotion ? nil : .easeOut(duration: 0.18)) { proxy.scrollTo(id, anchor: .center) }+ }+ }+ }+ }++ // MARK: Actions and focus++ private func primary(_ detail: GameDetail) {+ switch detail.game.state {+ case .playable: actions.onPlay(detail.id)+ case .needsGameData: actions.onPickGameData(detail.id)+ case .needsAppUpdate: actions.onAppUpdate()+ case .broken: actions.onShowLog(detail.id)+ }+ }+ private func select(_ id: String) {+ guard id != selectedID else { return }+ selectedID = id+ actions.onSelect(id)+ settingsPosition.scrollTo(edge: .top)+ }+ private func openSettings() {+ if layout == .split {+ // The pane is already there: move into it.+ focus.id = targets.values.first { $0.id.hasPrefix("set.row.") }?.id ?? focus.id+ return+ }+ settingsOpen = true+ focus.id = "set.back"+ }+ private func closeSettings() {+ settingsOpen = false+ focus.id = "lib.settings"+ }+ private func openControllers() { controllersOpen = true; focus.id = "ctl.close" }+ private func back() {+ if controllersOpen { controllersOpen = false; focus.id = "lib.controllers" }+ else if settingsOpen && layout != .split { closeSettings() }+ else if let id = focus.id, id.hasPrefix("set.") { focus.id = selected.map { "lib.tile.\($0.id)" } }+ else { actions.onBack() }+ }+ private func handle(_ action: ShellInput.Action) {+ focus.visible = true+ if focus.id == nil || !targets.values.contains(where: { $0.id == focus.id }) {+ focus.id = defaultFocus+ if action != .activate && action != .back && action != .settings && action != .controllers { return }+ }+ switch action {+ case .activate: targets.values.first { $0.id == focus.id }?.activate()+ case .back: back()+ case .settings: openSettings()+ case .controllers: openControllers()+ case .left, .right:+ // In Cover Flow the focused cover is always the middle one: left and right move the carousel by one.+ if layout.isCoverFlow, let id = focus.id, id.hasPrefix("lib.tile."), let index = games.firstIndex(where: { $0.id == selected?.id }) {+ let next = min(games.count - 1, max(0, index + (action == .left ? -1 : 1)))+ select(games[next].id)+ focus.id = "lib.tile.\(games[next].id)"+ return+ }+ move(action)+ default: move(action)+ }+ }+ private func move(_ action: ShellInput.Action) {+ let candidates = layout.isCoverFlow+ ? targets.values.filter { !$0.id.hasPrefix("lib.tile.") || $0.id == "lib.tile.\(selected?.id ?? "")" }+ : targets.values+ focus.id = FocusNavigation.next(from: focus.id, action: action, targets: candidates)+ if let id = focus.id, id.hasPrefix("lib.tile.") { select(String(id.dropFirst("lib.tile.".count))) }+ }+ private var defaultFocus: String? {+ if controllersOpen { return "ctl.close" }+ if settingsOpen && layout != .split { return "set.back" }+ return selected.map { "lib.tile.\($0.id)" } ?? "lib.controllers"+ }+}diff --git a/frontend-ios/Sources/ShellUI/PortraitLibrary.swift b/frontend-ios/Sources/ShellUI/PortraitLibrary.swiftnew file mode 100644index 00000000..681b8a4c--- /dev/null+++ b/frontend-ios/Sources/ShellUI/PortraitLibrary.swift@@ -0,0 +1,230 @@+import SwiftUI++/// The library when it is taller than it is wide: the chosen game's art as a full-bleed hero with the title over it,+/// then the collection, then recently played. In one column the primary action sits at the bottom for the thumb.+/// Beside the settings pane (two panes) the collection becomes a grid and Play moves into the hero.+struct PortraitLibrary: View {+ let games: [GameDetail]+ let selected: GameDetail+ let twoPanes: Bool+ let size: CGSize+ let topInset: CGFloat+ let controllers: Int+ let select: (String) -> Void+ let primary: (GameDetail) -> Void+ let openSettings: () -> Void+ let openControllers: () -> Void+ @Binding var position: ScrollPosition+ @Environment(\.shellFocus) private var focus+ @Environment(\.accessibilityReduceMotion) private var reduceMotion+ @Environment(\.dynamicTypeSize) private var typeSize++ /// A short screen (the folded foldable is about 1.4:1) gets a smaller hero and smaller covers, so the hero,+ /// the row and Play all fit without scrolling.+ private var short: Bool { size.height + topInset < 700 }+ private var heroHeight: CGFloat {+ let tall = size.height + topInset+ return twoPanes ? min(size.width * 0.95, tall * 0.5) : min(size.width * 1.02, tall * (short ? 0.44 : 0.52))+ }+ /// Whole covers and a third of the next one: the row shows it scrolls, and the edge cuts through a cover,+ /// never through a name or a status.+ private var coverSize: CGFloat {+ let target: CGFloat = typeSize.isAccessibilitySize ? 170 : short ? 100 : 128+ let available = size.width - 24+ let whole = max(1, ((available + 16) / (target + 16)).rounded(.down))+ return available / (whole + 0.34) - 16+ }++ var body: some View {+ ScrollViewReader { proxy in+ ScrollView {+ VStack(alignment: .leading, spacing: 0) {+ HeroView(game: selected.game, height: heroHeight, topInset: topInset,+ titleSize: twoPanes ? 36 : short ? 28 : 34) {+ if twoPanes {+ Button { primary(selected) } label: {+ Label(selected.game.state.actionTitle, systemImage: selected.game.state.actionSymbol)+ }+ .buttonStyle(PrimaryPillStyle())+ .accessibilityLabel(selected.game.state.actionTitle + ", " + selected.game.title)+ .accessibilityIdentifier("state.action")+ .shellTarget("lib.play", radius: 25) { primary(selected) }+ .padding(.top, 8)+ }+ }+ collection.padding(.top, short ? 6 : 14)+ recent.padding(.top, 34)+ }.padding(.bottom, 28)+ }+ .scrollPosition($position)+ .scrollIndicators(.hidden)+ .ignoresSafeArea(edges: .top)+ .safeAreaInset(edge: .bottom, spacing: 0) { if !twoPanes { bottomBar } }+ .overlay(alignment: .topTrailing) {+ ControllerChip(count: controllers, action: openControllers).padding(.top, 6).padding(.trailing, 16)+ }+ .onChange(of: focus.id) { _, id in+ guard let id, id.hasPrefix("lib.tile.") || id.hasPrefix("lib.recent.") else { return }+ let target = id.hasPrefix("lib.tile.") ? String(id.dropFirst("lib.tile.".count)) : id+ withAnimation(reduceMotion ? nil : .easeOut(duration: 0.18)) { proxy.scrollTo(target, anchor: .center) }+ }+ }+ }++ private var collection: some View {+ VStack(alignment: .leading, spacing: 14) {+ SectionHeading(title: ShellStrings.text("Your games"), trailing: "\(games.count)").padding(.horizontal, 24)+ if twoPanes {+ LazyVGrid(columns: [GridItem(.adaptive(minimum: 116, maximum: 180), spacing: 18, alignment: .top)],+ alignment: .leading, spacing: 24) {+ ForEach(games) { tile($0) }+ }.padding(.horizontal, 24)+ } else {+ ScrollView(.horizontal) {+ // Not lazy: every cover is a focus target, so the D-pad can reach the ones still off screen.+ HStack(alignment: .top, spacing: 16) {+ ForEach(games) { tile($0).frame(width: coverSize) }+ }.scrollTargetLayout().padding(.horizontal, 24).padding(.vertical, 6)+ }+ .scrollIndicators(.hidden)+ .scrollTargetBehavior(.viewAligned)+ .mask {+ LinearGradient(stops: [.init(color: .black, location: 0), .init(color: .black, location: 0.92),+ .init(color: .black.opacity(0), location: 1)], startPoint: .leading, endPoint: .trailing)+ }+ .padding(.vertical, -6)+ }+ }+ }++ private func tile(_ detail: GameDetail) -> some View {+ let chosen = detail.id == selected.id+ return Button { select(detail.id) } label: {+ VStack(alignment: .leading, spacing: 0) {+ CoverView(game: detail.game)+ .shellTarget("lib.tile.\(detail.id)") { primary(detail) }+ Text(detail.game.title).shellText(13.5, .semibold).lineLimit(typeSize.isAccessibilitySize ? 3 : 1)+ .foregroundStyle(.white.opacity(chosen ? 1 : 0.86))+ .frame(maxWidth: .infinity, alignment: .leading).padding(.top, 10)+ StatusLabel(state: detail.game.state).padding(.top, 4)+ // The Mac's selection mark: a cream bar under the chosen game.+ Capsule().fill(ShellPalette.cream).frame(height: 3).padding(.top, 10).opacity(chosen ? 1 : 0)+ }.contentShape(Rectangle())+ }+ .buttonStyle(.plain)+ .accessibilityLabel(detail.game.title + ", " + detail.game.state.title)+ .accessibilityAddTraits(chosen ? .isSelected : [])+ .accessibilityIdentifier("tile.\(detail.id)")+ .id(detail.id)+ }++ @ViewBuilder private var recent: some View {+ let recent = games.filter { $0.game.recentlyPlayed != nil }+ if !recent.isEmpty {+ VStack(alignment: .leading, spacing: 0) {+ SectionHeading(title: ShellStrings.text("Recently played")).padding(.bottom, 8)+ ForEach(recent) { detail in+ Button { select(detail.id) } label: {+ HStack(spacing: 14) {+ CoverView(game: detail.game, radius: 8).frame(width: 44, height: 44)+ VStack(alignment: .leading, spacing: 3) {+ Text(detail.game.title).shellText(15, .semibold).multilineTextAlignment(.leading)+ Text(detail.game.recentlyPlayed ?? "").shellText(12.5).foregroundStyle(.white.opacity(0.5))+ }+ Spacer(minLength: 8)+ Image(systemName: "chevron.right").font(.system(size: 12, weight: .semibold))+ .foregroundStyle(.white.opacity(0.28)).accessibilityHidden(true)+ }.frame(minHeight: 60).contentShape(Rectangle())+ }+ .buttonStyle(.plain)+ .shellTarget("lib.recent.\(detail.id)") { select(detail.id) }+ .id("lib.recent.\(detail.id)")+ if detail.id != recent.last?.id { Rectangle().fill(ShellPalette.hairline).frame(height: 1).padding(.leading, 58) }+ }+ }.padding(.horizontal, 24)+ }+ }++ private var bottomBar: some View {+ HStack(spacing: 12) {+ Button { primary(selected) } label: {+ Label(selected.game.state.actionTitle, systemImage: selected.game.state.actionSymbol)+ }+ .buttonStyle(PrimaryPillStyle(expands: true))+ .accessibilityLabel(selected.game.state.actionTitle + ", " + selected.game.title)+ .accessibilityIdentifier("state.action")+ .shellTarget("lib.play", radius: 25) { primary(selected) }+ Button(action: openSettings) { Image(systemName: "slider.horizontal.3") }+ .buttonStyle(RoundIconButtonStyle())+ .accessibilityLabel(ShellStrings.text("Game settings"))+ .accessibilityIdentifier("settings.open")+ .shellTarget("lib.settings", radius: 25, action: openSettings)+ }+ .padding(.horizontal, 24).padding(.top, 22).padding(.bottom, 8)+ .background {+ LinearGradient(stops: [.init(color: ShellPalette.background.opacity(0), location: 0),+ .init(color: ShellPalette.background, location: 0.4)],+ startPoint: .top, endPoint: .bottom)+ .ignoresSafeArea(edges: .bottom)+ }+ }+}++/// The chosen game's art edge to edge, darkened toward the type, with the state, the title and what to do next.+struct HeroView<Accessory: View>: View {+ let game: GameTile+ let height: CGFloat+ let topInset: CGFloat+ var titleSize: CGFloat = 34+ @ViewBuilder let accessory: () -> Accessory+ @Environment(\.accessibilityReduceMotion) private var reduceMotion++ var body: some View {+ VStack(alignment: .leading, spacing: 10) {+ StatusLabel(state: game.state, prominent: true)+ Text(game.title).shellText(titleSize, .heavy, relativeTo: .largeTitle).tracking(-titleSize * 0.03)+ .lineLimit(3).minimumScaleFactor(0.75).fixedSize(horizontal: false, vertical: true)+ .shadow(color: .black.opacity(0.35), radius: 14)+ .accessibilityAddTraits(.isHeader).accessibilityIdentifier("hero.title")+ if !meta.isEmpty {+ Text(meta).shellText(13).foregroundStyle(.white.opacity(0.62))+ }+ if !game.state.explanation.isEmpty {+ Text(game.state.explanation).shellText(14.5).foregroundStyle(.white.opacity(0.78))+ .fixedSize(horizontal: false, vertical: true).padding(.top, 2)+ }+ accessory()+ }+ .padding(.horizontal, 24).padding(.top, topInset + 64).padding(.bottom, 14)+ .frame(maxWidth: .infinity, minHeight: height, alignment: .bottomLeading)+ .background {+ ZStack {+ // Key art is made to sit behind a title. An icon carries its own lettering, which must not compete+ // with the shell's title: it is softened, enlarged and darkened further.+ ArtView(art: game.heroArt ?? game.cover, title: game.title, seed: game.id, lettering: false)+ .blur(radius: iconOnly ? 14 : 0, opaque: true)+ .scaleEffect(iconOnly ? 1.15 : 1)+ .overlay { if iconOnly { Color.black.opacity(0.22) } }+ .id(game.id).transition(.opacity)+ // Clear only in the upper part: the type below must win over whatever lettering the art has.+ LinearGradient(stops: [.init(color: .black.opacity(0.55), location: 0),+ .init(color: .clear, location: 0.2),+ .init(color: .clear, location: 0.32),+ .init(color: .black.opacity(0.55), location: 0.58),+ .init(color: ShellPalette.background.opacity(0.94), location: 0.82),+ .init(color: ShellPalette.background, location: 1)],+ startPoint: .top, endPoint: .bottom)+ LinearGradient(colors: [.black.opacity(0.28), .clear], startPoint: .leading, endPoint: .trailing)+ }+ .animation(reduceMotion ? .linear(duration: 0.15) : .easeInOut(duration: 0.35), value: game.id)+ .accessibilityHidden(true)+ }+ .clipped()+ }++ private var iconOnly: Bool { game.heroArt == nil && game.cover != nil }++ private var meta: String {+ [game.subtitle, game.recentlyPlayed ?? ""].filter { !$0.isEmpty }.joined(separator: " · ")+ }+}diff --git a/frontend-ios/Sources/ShellUI/Resources/Localizable.xcstrings b/frontend-ios/Sources/ShellUI/Resources/Localizable.xcstringsnew file mode 100644index 00000000..c43688a7--- /dev/null+++ b/frontend-ios/Sources/ShellUI/Resources/Localizable.xcstrings@@ -0,0 +1,436 @@+{+ "sourceLanguage": "en",+ "strings": {+ "%lld of %lld": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "%lld of %lld"+ }+ }+ }+ },+ "A little room for adventure": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "A little room for adventure"+ }+ }+ }+ },+ "App update needed": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "App update needed"+ }+ }+ }+ },+ "Back": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Back"+ }+ }+ }+ },+ "Brings back the settings this game was tested with.": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Brings back the settings this game was tested with."+ }+ }+ }+ },+ "Charging": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Charging"+ }+ }+ }+ },+ "Choose folder…": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Choose folder…"+ }+ }+ }+ },+ "Choose game data…": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Choose game data…"+ }+ }+ }+ },+ "Choose the same iCloud Drive folder you use on your Mac.": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Choose the same iCloud Drive folder you use on your Mac."+ }+ }+ }+ },+ "Choose this game's data to get ready to play.": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Choose this game's data to get ready to play."+ }+ }+ }+ },+ "Choose…": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Choose…"+ }+ }+ }+ },+ "Close controllers": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Close controllers"+ }+ }+ }+ },+ "Cloud saves": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Cloud saves"+ }+ }+ }+ },+ "Connect a controller in Bluetooth settings. Touch controls are always available in the library.": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Connect a controller in Bluetooth settings. Touch controls are always available in the library."+ }+ }+ }+ },+ "Controllers": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Controllers"+ }+ }+ }+ },+ "Decrease": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Decrease"+ }+ }+ }+ },+ "Game data": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Game data"+ }+ }+ }+ },+ "Game settings": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Game settings"+ }+ }+ }+ },+ "Increase": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Increase"+ }+ }+ }+ },+ "Install a newer version of this app to play this game.": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Install a newer version of this app to play this game."+ }+ }+ }+ },+ "Library": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Library"+ }+ }+ }+ },+ "Move between controls": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Move between controls"+ }+ }+ }+ },+ "Needs game data": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Needs game data"+ }+ }+ }+ },+ "No additional content": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "No additional content"+ }+ }+ }+ },+ "No battery level": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "No battery level"+ }+ }+ }+ },+ "No controllers connected": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "No controllers connected"+ }+ }+ }+ },+ "No data selected": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "No data selected"+ }+ }+ }+ },+ "Off": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Off"+ }+ }+ }+ },+ "On": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "On"+ }+ }+ }+ },+ "On a controller": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "On a controller"+ }+ }+ }+ },+ "Play": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Play"+ }+ }+ }+ },+ "Ready to play": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Ready to play"+ }+ }+ }+ },+ "Recently played": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Recently played"+ }+ }+ }+ },+ "Reset to tested defaults": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Reset to tested defaults"+ }+ }+ }+ },+ "Select": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Select"+ }+ }+ }+ },+ "Show log": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Show log"+ }+ }+ }+ },+ "Turn off": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Turn off"+ }+ }+ }+ },+ "Turn off cloud saves": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Turn off cloud saves"+ }+ }+ }+ },+ "Unavailable": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Unavailable"+ }+ }+ }+ },+ "Update app": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Update app"+ }+ }+ }+ },+ "Use app data": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Use app data"+ }+ }+ }+ },+ "Your games": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Your games"+ }+ }+ }+ },+ "Your games will appear here when they are included in this app.": {+ "localizations": {+ "en": {+ "stringUnit": {+ "state": "translated",+ "value": "Your games will appear here when they are included in this app."+ }+ }+ }+ }+ },+ "version": "1.0"+}diff --git a/frontend-ios/Sources/ShellUI/Resources/Manrope-OFL.txt b/frontend-ios/Sources/ShellUI/Resources/Manrope-OFL.txtnew file mode 100644index 00000000..e271172a--- /dev/null+++ b/frontend-ios/Sources/ShellUI/Resources/Manrope-OFL.txt@@ -0,0 +1,93 @@+Copyright 2018 The Manrope Project Authors (https://github.com/googlefonts/manrope)++This Font Software is licensed under the SIL Open Font License, Version 1.1.+This license is copied below, and is also available with a FAQ at:+http://scripts.sil.org/OFL+++-----------------------------------------------------------+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007+-----------------------------------------------------------++PREAMBLE+The goals of the Open Font License (OFL) are to stimulate worldwide+development of collaborative font projects, to support the font creation+efforts of academic and linguistic communities, and to provide a free and+open framework in which fonts may be shared and improved in partnership+with others.++The OFL allows the licensed fonts to be used, studied, modified and+redistributed freely as long as they are not sold by themselves. The+fonts, including any derivative works, can be bundled, embedded,+redistributed and/or sold with any software provided that any reserved+names are not used by derivative works. The fonts and derivatives,+however, cannot be released under any other type of license. The+requirement for fonts to remain under this license does not apply+to any document created using the fonts or their derivatives.++DEFINITIONS+"Font Software" refers to the set of files released by the Copyright+Holder(s) under this license and clearly marked as such. This may+include source files, build scripts and documentation.++"Reserved Font Name" refers to any names specified as such after the+copyright statement(s).++"Original Version" refers to the collection of Font Software components as+distributed by the Copyright Holder(s).++"Modified Version" refers to any derivative made by adding to, deleting,+or substituting -- in part or in whole -- any of the components of the+Original Version, by changing formats or by porting the Font Software to a+new environment.++"Author" refers to any designer, engineer, programmer, technical+writer or other person who contributed to the Font Software.++PERMISSION & CONDITIONS+Permission is hereby granted, free of charge, to any person obtaining+a copy of the Font Software, to use, study, copy, merge, embed, modify,+redistribute, and sell modified and unmodified copies of the Font+Software, subject to the following conditions:++1) Neither the Font Software nor any of its individual components,+in Original or Modified Versions, may be sold by itself.++2) Original or Modified Versions of the Font Software may be bundled,+redistributed and/or sold with any software, provided that each copy+contains the above copyright notice and this license. These can be+included either as stand-alone text files, human-readable headers or+in the appropriate machine-readable metadata fields within text or+binary files as long as those fields can be easily viewed by the user.++3) No Modified Version of the Font Software may use the Reserved Font+Name(s) unless explicit written permission is granted by the corresponding+Copyright Holder. This restriction only applies to the primary font name as+presented to the users.++4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font+Software shall not be used to promote, endorse or advertise any+Modified Version, except to acknowledge the contribution(s) of the+Copyright Holder(s) and the Author(s) or with their explicit written+permission.++5) The Font Software, modified or unmodified, in part or in whole,+must be distributed entirely under this license, and must not be+distributed under any other license. The requirement for fonts to+remain under this license does not apply to any document created+using the Font Software.++TERMINATION+This license becomes null and void if any of the above conditions are+not met.++DISCLAIMER+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM+OTHER DEALINGS IN THE FONT SOFTWARE.diff --git a/frontend-ios/Sources/ShellUI/Resources/Manrope.ttf b/frontend-ios/Sources/ShellUI/Resources/Manrope.ttfnew file mode 100644index 00000000..75274da5Binary files /dev/null and b/frontend-ios/Sources/ShellUI/Resources/Manrope.ttf differdiff --git a/frontend-ios/Sources/ShellUI/ShellArtwork.swift b/frontend-ios/Sources/ShellUI/ShellArtwork.swiftnew file mode 100644index 00000000..cd82e79c--- /dev/null+++ b/frontend-ios/Sources/ShellUI/ShellArtwork.swift@@ -0,0 +1,60 @@+import CoreGraphics+import Foundation+import ImageIO++/// A game's picture, decoded once by the host: the square NACP icon, or wider key art when there is some.+/// The views only draw it. A tiny copy and the mean colour are made here, so the blurred backgrounds stay cheap.+public struct Artwork: Equatable, @unchecked Sendable {+ public let id: String+ let image: CGImage+ /// About 48 px across. Scaled up and blurred, it gives the same backdrop as the full picture for a fraction of the work.+ let thumbnail: CGImage+ /// The picture's mean colour in sRGB, 0 to 1.+ let tone: (red: Double, green: Double, blue: Double)++ public init(id: String, image: CGImage) {+ self.id = id+ self.image = image+ thumbnail = Self.redraw(image, width: 48, height: max(1, Int(48 / max(0.25, CGFloat(image.width) / CGFloat(max(1, image.height)))))) ?? image+ tone = Self.meanColour(of: thumbnail)+ }++ /// PNG, JPEG or HEIC bytes, as the NACP icon comes. Nil when ImageIO cannot read them.+ public init?(id: String, data: Data) {+ guard let source = CGImageSourceCreateWithData(data as CFData, nil),+ let image = CGImageSourceCreateImageAtIndex(source, 0, nil) else { return nil }+ self.init(id: id, image: image)+ }++ public static func == (lhs: Self, rhs: Self) -> Bool { lhs.id == rhs.id && lhs.image === rhs.image }++ var aspectRatio: CGFloat { CGFloat(image.width) / CGFloat(max(1, image.height)) }++ private static func redraw(_ image: CGImage, width: Int, height: Int) -> CGImage? {+ guard let space = CGColorSpace(name: CGColorSpace.sRGB),+ let context = CGContext(data: nil, width: width, height: height, bitsPerComponent: 8, bytesPerRow: 0, space: space,+ bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue) else { return nil }+ context.interpolationQuality = .medium+ context.draw(image, in: CGRect(x: 0, y: 0, width: width, height: height))+ return context.makeImage()+ }++ private static func meanColour(of image: CGImage) -> (red: Double, green: Double, blue: Double) {+ var pixel = [UInt8](repeating: 0, count: 4)+ let drawn: Bool = pixel.withUnsafeMutableBytes { buffer in+ guard let space = CGColorSpace(name: CGColorSpace.sRGB),+ let context = CGContext(data: buffer.baseAddress, width: 1, height: 1, bitsPerComponent: 8, bytesPerRow: 4, space: space,+ bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue) else { return false }+ context.interpolationQuality = .medium+ context.draw(image, in: CGRect(x: 0, y: 0, width: 1, height: 1))+ return true+ }+ guard drawn else { return (0.2, 0.2, 0.22) }+ return (Double(pixel[0]) / 255, Double(pixel[1]) / 255, Double(pixel[2]) / 255)+ }+}++/// A stable number from a string. `hashValue` changes with every launch, and a placeholder should not.+func stableHash(_ text: String) -> UInt64 {+ text.utf8.reduce(UInt64(5381)) { ($0 &* 33) ^ UInt64($1) }+}diff --git a/frontend-ios/Sources/ShellUI/ShellFocus.swift b/frontend-ios/Sources/ShellUI/ShellFocus.swiftnew file mode 100644index 00000000..5d92f9b6--- /dev/null+++ b/frontend-ios/Sources/ShellUI/ShellFocus.swift@@ -0,0 +1,101 @@+import SwiftUI++/// Focus geometry and activation are transient UI state. Hardware belongs to the caller.+struct FocusTarget: Equatable {+ let id: String+ let frame: CGRect+ let activate: () -> Void+ // A new render can change an activation closure without changing its frame or ID.+ private let generation = UUID()+ init(id: String, frame: CGRect, activate: @escaping () -> Void) {+ self.id = id+ self.frame = frame+ self.activate = activate+ }+ static func == (lhs: Self, rhs: Self) -> Bool {+ lhs.id == rhs.id && lhs.frame == rhs.frame && lhs.generation == rhs.generation+ }+}++/// A non-observed UI registry avoids feeding preference updates back into view rendering.+/// It holds only the latest focus geometry and actions, never game or settings state.+@MainActor final class FocusTargetBuffer {+ var values: [FocusTarget] = []+}+struct FocusTargets: PreferenceKey {+ static var defaultValue: [FocusTarget] { [] }+ static func reduce(value: inout [FocusTarget], nextValue: () -> [FocusTarget]) { value += nextValue() }+}+struct FocusAppearance: Equatable {+ var id: String?+ var visible = false+}+private struct FocusAppearanceKey: EnvironmentKey {+ static var defaultValue: FocusAppearance { FocusAppearance() }+}+extension EnvironmentValues {+ var shellFocus: FocusAppearance {+ get { self[FocusAppearanceKey.self] }+ set { self[FocusAppearanceKey.self] = newValue }+ }+}+struct ShellFocusTarget: ViewModifier {+ let id: String+ let enabled: Bool+ /// The ring follows the control's shape: 12 for covers and cards, a large value for capsules and circles.+ let radius: CGFloat+ let action: () -> Void+ @Environment(\.shellFocus) private var focus+ func body(content: Content) -> some View {+ content+ .overlay {+ if focus.visible && focus.id == id {+ RoundedRectangle(cornerRadius: radius + 5).strokeBorder(ShellPalette.cream, lineWidth: 3)+ .padding(-5).allowsHitTesting(false).accessibilityHidden(true)+ }+ }+ .background {+ if enabled {+ GeometryReader { geometry in+ Color.clear.preference(key: FocusTargets.self, value: [+ FocusTarget(id: id, frame: geometry.frame(in: .named("shell")), activate: action)+ ])+ }+ }+ }+ .id(id)+ }+}+extension View {+ func shellTarget(_ id: String, enabled: Bool = true, radius: CGFloat = 12, action: @escaping () -> Void) -> some View {+ modifier(ShellFocusTarget(id: id, enabled: enabled, radius: radius, action: action))+ }+}++/// Pure spatial focus selection shared by the UI and its navigation tests.+enum FocusNavigation {+ static func next(from id: String?, action: ShellInput.Action, targets: [FocusTarget]) -> String? {+ guard let origin = targets.first(where: { $0.id == id }) else { return targets.first?.id }+ let candidates = targets.filter { target in+ guard target.id != origin.id else { return false }+ let dx = target.frame.midX - origin.frame.midX+ let dy = target.frame.midY - origin.frame.midY+ switch action {+ case .left: return dx < -8+ case .right: return dx > 8+ case .up: return dy < -8+ case .down: return dy > 8+ default: return false+ }+ }+ func score(_ target: FocusTarget) -> CGFloat {+ let dx = abs(target.frame.midX - origin.frame.midX)+ let dy = abs(target.frame.midY - origin.frame.midY)+ switch action {+ case .left, .right: return dx + dy * 3+ default: return dy + dx * 3+ }+ }+ return candidates.min(by: { score($0) < score($1) })?.id ?? id+ }+}diff --git a/frontend-ios/Sources/ShellUI/ShellInputs.swift b/frontend-ios/Sources/ShellUI/ShellInputs.swiftnew file mode 100644index 00000000..ec23aaef--- /dev/null+++ b/frontend-ios/Sources/ShellUI/ShellInputs.swift@@ -0,0 +1,150 @@+import Foundation++/// The caller supplies display data. These types never load, validate, or store game data.+public enum GameState: Equatable, Sendable {+ case playable+ case needsGameData+ case needsAppUpdate+ case broken(reason: String)+}++public struct GameTile: Identifiable, Equatable, Sendable {+ public var id: String+ public var title: String+ /// One short line under the title, such as the version.+ public var subtitle: String+ /// The square cover, normally the game's NACP icon. Nil draws a calm placeholder from the title.+ public var cover: Artwork?+ /// Wider key art for the hero, when the game data has some. Nil uses the cover.+ public var heroArt: Artwork?+ public var state: GameState+ /// Already localized, such as "Played today". Nil leaves the game out of Recently played.+ public var recentlyPlayed: String?+ public init(id: String, title: String, subtitle: String = "", cover: Artwork? = nil, heroArt: Artwork? = nil,+ state: GameState = .playable, recentlyPlayed: String? = nil) {+ self.id = id+ self.title = title+ self.subtitle = subtitle+ self.cover = cover+ self.heroArt = heroArt+ self.state = state+ self.recentlyPlayed = recentlyPlayed+ }+}++public struct SettingOption: Identifiable, Equatable, Sendable {+ public var id: String+ public var label: String+ public init(_ value: String, _ label: String) { id = value; self.label = label }+}++public enum SettingKind: Equatable, Sendable {+ case toggle(on: String, off: String)+ case choice([SettingOption])+ case range(min: Double, max: Double, step: Double, unit: String)+}++public struct SettingRow: Identifiable, Equatable, Sendable {+ public var id: String+ public var label: String+ public var note: String+ public var kind: SettingKind+ public var value: String+ /// The caller resolves dependencies and locks before supplying rows.+ public var enabled: Bool+ public init(id: String, label: String, note: String = "", kind: SettingKind, value: String, enabled: Bool = true) {+ self.id = id+ self.label = label+ self.note = note+ self.kind = kind+ self.value = value+ self.enabled = enabled+ }+}++public struct SettingSection: Identifiable, Equatable, Sendable {+ public var id: String+ public var title: String+ public var rows: [SettingRow]+ public init(id: String, title: String, rows: [SettingRow]) { self.id = id; self.title = title; self.rows = rows }+}++public struct GameDetail: Identifiable, Equatable, Sendable {+ public var id: String { game.id }+ public var game: GameTile+ public var sections: [SettingSection]+ public var dataSource: String+ public var dataNote: String+ public var cloudSaves: String?+ public var cloudNote: String+ public var dlc: String+ public var hasModifiedSettings: Bool+ public init(game: GameTile, sections: [SettingSection] = [], dataSource: String = "", dataNote: String = "",+ cloudSaves: String? = nil, cloudNote: String = "", dlc: String = "", hasModifiedSettings: Bool = false) {+ self.game = game+ self.sections = sections+ self.dataSource = dataSource+ self.dataNote = dataNote+ self.cloudSaves = cloudSaves+ self.cloudNote = cloudNote+ self.dlc = dlc+ self.hasModifiedSettings = hasModifiedSettings+ }+}++public struct ControllerInfo: Identifiable, Equatable, Sendable {+ public var id: String+ public var name: String+ public var player: String+ /// Nil means the controller does not report battery level.+ public var batteryPercent: Int?+ public var charging: Bool+ public init(id: String, name: String, player: String, batteryPercent: Int? = nil, charging: Bool = false) {+ self.id = id+ self.name = name+ self.player = player+ self.batteryPercent = batteryPercent+ self.charging = charging+ }+}++/// An optional event supplied by the host's input adapter. Increment sequence for repeated presses.+public struct ShellInput: Equatable, Sendable {+ public enum Action: Sendable { case up, down, left, right, activate, back, settings, controllers }+ public var sequence: Int+ public var action: Action+ public init(sequence: Int, action: Action) { self.sequence = sequence; self.action = action }+}++/// All effects leave the package through these closures. The game ID is always explicit.+public struct ShellActions {+ public var onSelect: (String) -> Void+ public var onPlay: (String) -> Void+ public var onChange: (_ gameID: String, _ settingID: String, _ value: String) -> Void+ public var onPickGameData: (String) -> Void+ public var onUseAppData: (String) -> Void+ public var onPickCloudSaves: (String) -> Void+ public var onDisableCloudSaves: (String) -> Void+ public var onResetDefaults: (String) -> Void+ public var onShowLog: (String) -> Void+ public var onAppUpdate: () -> Void+ public var onBack: () -> Void+ public init(onSelect: @escaping (String) -> Void = { _ in }, onPlay: @escaping (String) -> Void = { _ in },+ onChange: @escaping (String, String, String) -> Void = { _, _, _ in },+ onPickGameData: @escaping (String) -> Void = { _ in }, onUseAppData: @escaping (String) -> Void = { _ in },+ onPickCloudSaves: @escaping (String) -> Void = { _ in }, onDisableCloudSaves: @escaping (String) -> Void = { _ in },+ onResetDefaults: @escaping (String) -> Void = { _ in }, onShowLog: @escaping (String) -> Void = { _ in },+ onAppUpdate: @escaping () -> Void = {}, onBack: @escaping () -> Void = {}) {+ self.onSelect = onSelect+ self.onPlay = onPlay+ self.onChange = onChange+ self.onPickGameData = onPickGameData+ self.onUseAppData = onUseAppData+ self.onPickCloudSaves = onPickCloudSaves+ self.onDisableCloudSaves = onDisableCloudSaves+ self.onResetDefaults = onResetDefaults+ self.onShowLog = onShowLog+ self.onAppUpdate = onAppUpdate+ self.onBack = onBack+ }+}diff --git a/frontend-ios/Sources/ShellUI/ShellStyle.swift b/frontend-ios/Sources/ShellUI/ShellStyle.swiftnew file mode 100644index 00000000..13a33313--- /dev/null+++ b/frontend-ios/Sources/ShellUI/ShellStyle.swift@@ -0,0 +1,283 @@+import SwiftUI+import CoreText++public enum ShellPalette {+ public static let background = Color(red: 0.055, green: 0.055, blue: 0.06)+ public static let surface = Color(red: 0.10, green: 0.10, blue: 0.11)+ public static let cream = Color(red: 1, green: 0.94, blue: 0.84)+ public static let ready = Color(red: 0.25, green: 0.84, blue: 0.47)+ public static let attention = Color(red: 1, green: 0.78, blue: 0.24)+ public static let muted = Color(red: 0.57, green: 0.58, blue: 0.61)+ /// Hairlines between rows and around cards.+ static let hairline = Color.white.opacity(0.08)+}++enum ShellStrings {+ static func text(_ key: String.LocalizationValue) -> String { String(localized: key, bundle: .module) }+}++@MainActor public enum ShellFonts {+ /// Register just the bundled font. No game or user files are accessed.+ private static let registered: Bool = {+ guard let url = Bundle.module.url(forResource: "Manrope", withExtension: "ttf") else { return false }+ var error: Unmanaged<CFError>?+ if CTFontManagerRegisterFontsForURL(url as CFURL, .process, &error) { return true }+ return (CTFontManagerCopyAvailablePostScriptNames() as? [String])?.contains("Manrope") == true+ }()+ /// Manrope that follows Dynamic Type.+ public static func font(_ size: CGFloat, weight: Font.Weight = .regular, relativeTo: Font.TextStyle = .body) -> Font {+ if registered { return .custom("Manrope", size: size, relativeTo: relativeTo).weight(weight) }+ return .system(relativeTo).weight(weight)+ }+ /// Manrope at a fixed size, for lettering that belongs to a picture rather than to the interface.+ static func fixed(_ size: CGFloat, weight: Font.Weight = .regular) -> Font {+ if registered { return .custom("Manrope", fixedSize: size).weight(weight) }+ return .system(size: size, weight: weight)+ }+}++extension View {+ func shellText(_ size: CGFloat = 15, _ weight: Font.Weight = .regular, relativeTo: Font.TextStyle = .body) -> some View {+ font(ShellFonts.font(size, weight: weight, relativeTo: relativeTo))+ }+ /// A settings group: the surface colour with a 1 pt hairline, as on the Mac.+ func shellCard(padding: CGFloat = 18) -> some View {+ self.padding(padding)+ .background(ShellPalette.surface, in: RoundedRectangle(cornerRadius: 16))+ .overlay(RoundedRectangle(cornerRadius: 16).strokeBorder(ShellPalette.hairline, lineWidth: 1))+ }+}++/// The small cream capitals that open a section, such as YOUR GAMES.+struct SectionHeading: View {+ let title: String+ var trailing: String? = nil+ var body: some View {+ HStack(alignment: .firstTextBaseline) {+ Text(title.uppercased()).shellText(11, .bold, relativeTo: .caption).tracking(1.8)+ .foregroundStyle(ShellPalette.cream.opacity(0.72)).accessibilityAddTraits(.isHeader)+ if let trailing {+ Spacer(minLength: 8)+ Text(trailing).shellText(12, .medium, relativeTo: .caption).monospacedDigit().foregroundStyle(.white.opacity(0.4))+ }+ }+ }+}++/// The Mac's secondary button: white 0.055, a 0.10 hairline, radius 9.+struct ShellButtonStyle: ButtonStyle {+ @Environment(\.isEnabled) private var enabled+ func makeBody(configuration: Configuration) -> some View {+ configuration.label.shellText(14, .semibold)+ .frame(minHeight: 44).padding(.horizontal, 14)+ .foregroundStyle(.white.opacity(0.92))+ .background(.white.opacity(configuration.isPressed ? 0.13 : 0.055), in: RoundedRectangle(cornerRadius: 9))+ .overlay(RoundedRectangle(cornerRadius: 9).strokeBorder(.white.opacity(0.10)))+ .opacity(enabled ? 1 : 0.4)+ .contentShape(RoundedRectangle(cornerRadius: 9))+ }+}++/// The one primary action of a screen: a cream capsule with black type, as the Mac hero's Play.+struct PrimaryPillStyle: ButtonStyle {+ var expands = false+ func makeBody(configuration: Configuration) -> some View {+ configuration.label.shellText(17, .bold)+ .lineLimit(1).minimumScaleFactor(0.8)+ .padding(.horizontal, 26).frame(minHeight: 50)+ .frame(maxWidth: expands ? .infinity : nil)+ .foregroundStyle(.black)+ .background(ShellPalette.cream, in: Capsule())+ .opacity(configuration.isPressed ? 0.78 : 1)+ .scaleEffect(configuration.isPressed ? 0.98 : 1)+ .contentShape(Capsule())+ }+}++/// A round icon button beside the primary action, such as game settings.+struct RoundIconButtonStyle: ButtonStyle {+ var size: CGFloat = 50+ var active = false+ func makeBody(configuration: Configuration) -> some View {+ configuration.label.font(.system(size: 17, weight: .medium))+ .frame(width: size, height: size)+ .foregroundStyle(active ? .black : .white)+ .background(active ? ShellPalette.cream : .white.opacity(configuration.isPressed ? 0.2 : 0.10), in: Circle())+ .overlay(Circle().strokeBorder(.white.opacity(active ? 0 : 0.14)))+ .contentShape(Circle())+ }+}++/// A small capsule that sits on top of art, such as the controller count.+struct ChipButtonStyle: ButtonStyle {+ func makeBody(configuration: Configuration) -> some View {+ configuration.label.shellText(13, .semibold, relativeTo: .footnote)+ .padding(.horizontal, 14).frame(minHeight: 44)+ .foregroundStyle(.white)+ .background(.black.opacity(configuration.isPressed ? 0.55 : 0.38), in: Capsule())+ .overlay(Capsule().strokeBorder(.white.opacity(0.14)))+ .contentShape(Capsule())+ }+}++struct CreamToggleStyle: ToggleStyle {+ @Environment(\.accessibilityReduceMotion) private var reduceMotion+ func makeBody(configuration: Configuration) -> some View {+ Button {+ withAnimation(reduceMotion ? nil : .spring(response: 0.25, dampingFraction: 0.8)) { configuration.isOn.toggle() }+ } label: {+ HStack(spacing: 16) {+ configuration.label.frame(maxWidth: .infinity, alignment: .leading)+ ZStack(alignment: configuration.isOn ? .trailing : .leading) {+ Capsule().fill(configuration.isOn ? ShellPalette.cream : .white.opacity(0.14))+ Circle().fill(configuration.isOn ? ShellPalette.background : .white.opacity(0.85)).padding(3)+ }.frame(width: 46, height: 28)+ }.frame(minHeight: 44).contentShape(Rectangle())+ }.buttonStyle(.plain)+ .accessibilityValue(ShellStrings.text(configuration.isOn ? "On" : "Off"))+ .accessibilityAddTraits(configuration.isOn ? .isSelected : [])+ }+}++/// A game's picture filling whatever frame it gets, or the placeholder when there is none.+struct ArtView: View {+ let art: Artwork?+ let title: String+ let seed: String+ /// Draw from the small copy, for a backdrop that is blurred anyway.+ var backdrop = false+ /// The placeholder's lettering. Off where the title is set beside the art already, as in the hero.+ var lettering = true+ var body: some View {+ Color.clear.overlay {+ if let art {+ Image(decorative: backdrop ? art.thumbnail : art.image, scale: 1)+ .resizable().interpolation(backdrop ? .medium : .high).scaledToFill()+ } else {+ PlaceholderArt(title: title, seed: seed, lettering: lettering && !backdrop)+ }+ }.clipped()+ }+}++/// For a game without a picture: a deep tone from its name, a soft disc and the title set like a book cover.+/// It has to read as a deliberate cover, not as missing data.+struct PlaceholderArt: View {+ let title: String+ let seed: String+ var lettering = true+ var body: some View {+ let hash = stableHash(seed)+ let hue = Double(hash % 360) / 360+ GeometryReader { geometry in+ let side = min(geometry.size.width, geometry.size.height)+ ZStack(alignment: .bottomLeading) {+ LinearGradient(colors: [Color(hue: hue, saturation: 0.42, brightness: 0.36),+ Color(hue: hue, saturation: 0.55, brightness: 0.13)],+ startPoint: .topTrailing, endPoint: .bottomLeading)+ Circle().fill(Color(hue: hue, saturation: 0.30, brightness: 0.62).opacity(0.30))+ .frame(width: side * 0.95, height: side * 0.95)+ .position(x: geometry.size.width * 0.78, y: geometry.size.height * 0.24)+ if lettering {+ Text(title).font(ShellFonts.fixed(max(9, side * 0.12), weight: .heavy)).tracking(-side * 0.003)+ .foregroundStyle(ShellPalette.cream.opacity(0.92))+ .lineLimit(3).minimumScaleFactor(0.5).multilineTextAlignment(.leading)+ .padding(side * 0.09)+ }+ }+ }+ }+}++/// A square cover with the hairline every picture gets, so dark art keeps its edge on the dark page.+struct CoverView: View {+ let game: GameTile+ var radius: CGFloat = 12+ var body: some View {+ ArtView(art: game.cover, title: game.title, seed: game.id)+ .aspectRatio(1, contentMode: .fit)+ .clipShape(RoundedRectangle(cornerRadius: radius))+ .overlay(RoundedRectangle(cornerRadius: radius).strokeBorder(.white.opacity(0.10)))+ .accessibilityHidden(true)+ }+}++extension GameState {+ var title: String {+ switch self {+ case .playable: ShellStrings.text("Ready to play")+ case .needsGameData: ShellStrings.text("Needs game data")+ case .needsAppUpdate: ShellStrings.text("App update needed")+ case .broken: ShellStrings.text("Unavailable")+ }+ }+ var color: Color {+ switch self {+ case .playable: ShellPalette.ready+ case .needsGameData, .needsAppUpdate: ShellPalette.attention+ case .broken: ShellPalette.muted+ }+ }+ var explanation: String {+ switch self {+ case .playable: ""+ case .needsGameData: ShellStrings.text("Choose this game's data to get ready to play.")+ case .needsAppUpdate: ShellStrings.text("Install a newer version of this app to play this game.")+ case .broken(let reason): reason+ }+ }+ var actionTitle: String {+ switch self {+ case .playable: ShellStrings.text("Play")+ case .needsGameData: ShellStrings.text("Choose game data…")+ case .needsAppUpdate: ShellStrings.text("Update app")+ case .broken: ShellStrings.text("Show log")+ }+ }+ var actionSymbol: String {+ switch self {+ case .playable: "play.fill"+ case .needsGameData: "folder"+ case .needsAppUpdate: "arrow.up.circle"+ case .broken: "doc.text"+ }+ }+}++/// The Mac's status: a small coloured dot and the words. Prominent is the hero's capitals.+struct StatusLabel: View {+ let state: GameState+ var prominent = false+ var body: some View {+ HStack(spacing: prominent ? 8 : 6) {+ Circle().fill(state.color).frame(width: prominent ? 7 : 6, height: prominent ? 7 : 6)+ Text(prominent ? state.title.uppercased() : state.title)+ .shellText(prominent ? 11.5 : 12, prominent ? .bold : .medium, relativeTo: .caption)+ .tracking(prominent ? 1.4 : 0)+ .foregroundStyle(state.color)+ .lineLimit(prominent ? 2 : 1)+ }.accessibilityElement(children: .combine)+ }+}++/// A controller button as the Mac console draws it: the letter in a small rounded square.+struct ButtonGlyph: View {+ let letter: String+ var body: some View {+ Text(letter).font(ShellFonts.fixed(11, weight: .bold))+ .frame(width: 20, height: 20)+ .overlay(RoundedRectangle(cornerRadius: 5).strokeBorder(.white.opacity(0.45), lineWidth: 1.2))+ .accessibilityHidden(true)+ }+}++struct GlyphHint: View {+ let letter: String+ let label: String+ var body: some View {+ HStack(spacing: 8) {+ ButtonGlyph(letter: letter)+ Text(label).shellText(13, .medium, relativeTo: .footnote)+ }.foregroundStyle(.white.opacity(0.6))+ }+}diff --git a/frontend-ios/Tests/ShellUITests/FocusNavigationTests.swift b/frontend-ios/Tests/ShellUITests/FocusNavigationTests.swiftnew file mode 100644index 00000000..b8c11145--- /dev/null+++ b/frontend-ios/Tests/ShellUITests/FocusNavigationTests.swift@@ -0,0 +1,17 @@+import XCTest+@testable import ShellUI++final class FocusNavigationTests: XCTestCase {+ private func target(_ id: String, _ x: CGFloat, _ y: CGFloat) -> FocusTarget {+ FocusTarget(id: id, frame: CGRect(x: x, y: y, width: 44, height: 44), activate: {})+ }+ func testDirectionalNavigationPrefersSameRowAndDoesNotWrap() {+ let targets = [target("a", 0, 0), target("b", 80, 0), target("c", 0, 100), target("d", 80, 100)]+ XCTAssertEqual(FocusNavigation.next(from: "a", action: .right, targets: targets), "b")+ XCTAssertEqual(FocusNavigation.next(from: "b", action: .down, targets: targets), "d")+ XCTAssertEqual(FocusNavigation.next(from: "d", action: .left, targets: targets), "c")+ XCTAssertEqual(FocusNavigation.next(from: "c", action: .left, targets: targets), "c")+ XCTAssertEqual(FocusNavigation.next(from: "missing", action: .down, targets: targets), "a")+ XCTAssertNil(FocusNavigation.next(from: nil, action: .down, targets: []))+ }+}diff --git a/frontend-ios/Tests/ShellUITests/LayoutTests.swift b/frontend-ios/Tests/ShellUITests/LayoutTests.swiftnew file mode 100644index 00000000..93876687--- /dev/null+++ b/frontend-ios/Tests/ShellUITests/LayoutTests.swift@@ -0,0 +1,41 @@+import XCTest+@testable import ShellUI++final class LayoutTests: XCTestCase {+ private func layout(_ width: CGFloat, _ height: CGFloat, large: Bool = false) -> ShellLayout {+ ShellLayout.resolve(CGSize(width: width, height: height), accessibilityText: large)+ }+ func testPhone() {+ XCTAssertEqual(layout(402, 874), .column)+ XCTAssertEqual(layout(874, 402), .coverFlow(regular: false))+ }+ func testPad() {+ XCTAssertEqual(layout(834, 1194), .split)+ XCTAssertEqual(layout(1194, 834), .coverFlow(regular: true))+ // Split View and narrow Stage Manager windows are compact.+ XCTAssertEqual(layout(507, 834), .column)+ XCTAssertEqual(layout(375, 688), .column)+ }+ /// The foldable as reported so far: both screens about 1.4:1, the outer compact, the inner regular.+ /// These are sample sizes, not values the views know about.+ func testFoldable() {+ XCTAssertEqual(layout(375, 525), .column)+ XCTAssertEqual(layout(525, 375), .coverFlow(regular: false))+ XCTAssertEqual(layout(626, 890), .split)+ XCTAssertEqual(layout(890, 626), .coverFlow(regular: true))+ XCTAssertEqual(layout(669, 951), .split)+ XCTAssertEqual(layout(951, 669), .coverFlow(regular: true))+ }+ /// A nearly square window keeps two panes. Cover Flow needs clearly more width than height.+ func testSquareWindowKeepsTwoPanes() {+ XCTAssertEqual(layout(800, 760), .split)+ }+ func testAccessibilityTextUsesOneColumn() {+ XCTAssertEqual(layout(834, 1194, large: true), .column)+ }+ func testPaneWidths() {+ XCTAssertEqual(ShellLayout.column.paneWidth(402), 402)+ XCTAssertEqual(ShellLayout.split.paneWidth(626), 320)+ XCTAssertEqual(ShellLayout.coverFlow(regular: true).paneWidth(1194), 501.48, accuracy: 0.01)+ }+}diff --git a/frontend-ios/UITests/ShellAdditionalTests.swift b/frontend-ios/UITests/ShellAdditionalTests.swiftnew file mode 100644index 00000000..d9f3c33a--- /dev/null+++ b/frontend-ios/UITests/ShellAdditionalTests.swift@@ -0,0 +1,118 @@+import XCTest++@MainActor final class ShellWindowTests: XCTestCase {+ private let app = XCUIApplication()+ private func capture(_ name: String) {+ let attachment = XCTAttachment(screenshot: XCUIScreen.main.screenshot())+ attachment.name = name+ attachment.lifetime = .keepAlways+ add(attachment)+ }+ func testStageManagerResize() throws {+ try XCTSkipUnless(UIDevice.current.userInterfaceIdiom == .pad, "Stage Manager needs an iPad simulator")+ XCUIDevice.shared.orientation = .portrait+ app.launchArguments = ["--screen", "library"]+ app.launch()+ XCTAssertTrue(app.buttons["tile.tide"].waitForExistence(timeout: 10))+ app.buttons["tile.tide"].tap()+ capture("stage-manager-wide-before")+ let frame = app.windows.firstMatch.frame+ let origin = app.coordinate(withNormalizedOffset: .zero)+ let corner = origin.withOffset(CGVector(dx: frame.width - 16, dy: frame.height - 16))+ corner.press(forDuration: 0.5, thenDragTo: origin.withOffset(CGVector(dx: frame.width * 0.6, dy: frame.height * 0.72)))+ capture("stage-manager-compact")+ let tree = XCTAttachment(string: app.debugDescription + "\nSPRINGBOARD\n" + XCUIApplication(bundleIdentifier: "com.apple.springboard").debugDescription)+ tree.name = "stage-manager-hierarchy"+ tree.lifetime = .keepAlways+ add(tree)+ XCTAssertTrue(app.staticTexts["The Quiet Tide"].firstMatch.exists)+ XCTAssertTrue(app.buttons["settings.open"].waitForExistence(timeout: 5), "The actual window resize must enter compact layout")+ }+}++@MainActor final class ShellInputAndResizeTests: XCTestCase {+ private let app = XCUIApplication()+ private func capture(_ name: String) {+ let image = XCTAttachment(screenshot: XCUIScreen.main.screenshot())+ image.name = name+ image.lifetime = .keepAlways+ add(image)+ }+ func testSemanticControllerActions() {+ XCUIDevice.shared.orientation = .portrait+ app.launchArguments = ["--screen", "focus", "--input-test"]+ app.launch()+ XCTAssertTrue(app.buttons["qa.input.right"].waitForExistence(timeout: 10))+ app.buttons["qa.input.right"].tap()+ XCTAssertEqual(app.staticTexts["hero.title"].label, "The Quiet Tide")+ capture("controller-right-selects-second-cover")+ app.buttons["qa.input.activate"].tap()+ XCTAssertTrue(app.alerts["Demo action"].waitForExistence(timeout: 5))+ app.alerts.buttons["OK"].tap()+ app.buttons["qa.input.settings"].tap()+ let toggle = app.switches["setting.DM_SHOW_FPS"]+ XCTAssertTrue(toggle.waitForExistence(timeout: 5))+ // Pushed settings start on Back, then Play and the play mode choice. Beside the library they start on the choice.+ let pushed = app.buttons["library.back"].exists+ for _ in 0..<(pushed ? 3 : 1) { app.buttons["qa.input.down"].tap() }+ app.buttons["qa.input.activate"].tap()+ XCTAssertEqual(toggle.value as? String, "1")+ app.buttons["qa.input.activate"].tap()+ XCTAssertEqual(toggle.value as? String, "0")+ capture("controller-toggles-setting")+ app.buttons["qa.input.back"].tap()+ if pushed { XCTAssertFalse(app.buttons["library.back"].isHittable) }+ capture("controller-back-restores-library")+ // The one-column row: right walks through every cover, also the ones still off screen.+ guard pushed else { return }+ app.terminate()+ app.launch()+ XCTAssertTrue(app.buttons["qa.input.right"].waitForExistence(timeout: 10))+ for _ in 0..<6 { app.buttons["qa.input.right"].tap() }+ XCTAssertEqual(app.staticTexts["hero.title"].label, "Amber Hours")+ capture("controller-reaches-last-cover")+ }++ func testCoverFlowFollowsTheController() {+ XCUIDevice.shared.orientation = .landscapeLeft+ app.launchArguments = ["--screen", "focus", "--input-test"]+ app.launch()+ XCTAssertTrue(app.buttons["qa.input.right"].waitForExistence(timeout: 10))+ for _ in 0..<3 { app.buttons["qa.input.right"].tap() }+ XCTAssertEqual(app.staticTexts["hero.title"].label, "Moonlit Express")+ app.buttons["qa.input.left"].tap()+ XCTAssertEqual(app.staticTexts["hero.title"].label, "Paper Trails")+ capture("cover-flow-controller")+ XCUIDevice.shared.orientation = .portrait+ }++ /// The foldable stand-in: the same running shell goes from the folded size to the unfolded one and back.+ /// Selection, an edited toggle, the open settings and their scroll position must survive both changes.+ func testFoldKeepsSelectionSettingsAndScroll() throws {+ try XCTSkipUnless(UIDevice.current.userInterfaceIdiom == .pad, "The fold stand-in needs an iPad canvas")+ XCUIDevice.shared.orientation = .portrait+ app.launchArguments = ["--screen", "library", "--fold-test"]+ app.launch()+ XCTAssertTrue(app.buttons["tile.tide"].waitForExistence(timeout: 10))+ app.buttons["tile.tide"].tap()+ app.buttons["settings.open"].tap()+ let toggle = app.switches["setting.DM_SHOW_FPS"]+ XCTAssertTrue(toggle.waitForExistence(timeout: 5))+ toggle.tap()+ app.scrollViews.element(boundBy: app.scrollViews.count - 1).swipeUp()+ capture("folded-settings-scrolled")+ app.buttons["qa.fold"].tap()+ // Unfolded: two panes, the hero beside the open settings.+ XCTAssertEqual(app.staticTexts["hero.title"].label, "The Quiet Tide")+ XCTAssertTrue(toggle.exists)+ XCTAssertFalse(app.buttons["library.back"].exists)+ capture("unfolded-settings-scrolled")+ app.buttons["qa.fold"].tap()+ XCTAssertTrue(app.buttons["library.back"].waitForExistence(timeout: 5))+ capture("refolded-settings-scrolled")+ app.scrollViews.element(boundBy: app.scrollViews.count - 1).swipeDown()+ XCTAssertEqual(toggle.value as? String, "1")+ app.buttons["library.back"].tap()+ XCTAssertEqual(app.staticTexts["hero.title"].label, "The Quiet Tide")+ }+}diff --git a/frontend-ios/UITests/ShellCaptureTests.swift b/frontend-ios/UITests/ShellCaptureTests.swiftnew file mode 100644index 00000000..ba27a258--- /dev/null+++ b/frontend-ios/UITests/ShellCaptureTests.swift@@ -0,0 +1,79 @@+import XCTest++/// Screens for visual review. With TEST_RUNNER_SHOT_DIR set, each capture is also written there as a PNG.+@MainActor final class ShellCaptureTests: XCTestCase {+ private let app = XCUIApplication()+ private var directory: String? { ProcessInfo.processInfo.environment["SHOT_DIR"] }+ private var prefix: String { ProcessInfo.processInfo.environment["SHOT_PREFIX"] ?? (UIDevice.current.userInterfaceIdiom == .pad ? "ipad" : "phone") }+ private let screens = ["library", "settings", "needs-data", "needs-update", "broken", "empty", "controllers", "controllers-empty", "focus"]++ private func shot(_ name: String) {+ let screenshot = XCUIScreen.main.screenshot()+ let attachment = XCTAttachment(screenshot: screenshot)+ attachment.name = name+ attachment.lifetime = .keepAlways+ add(attachment)+ if let directory {+ try? screenshot.pngRepresentation.write(to: URL(fileURLWithPath: directory).appendingPathComponent("\(prefix)-\(name).png"))+ }+ }+ private func launch(_ arguments: [String]) {+ app.terminate()+ app.launchArguments = arguments+ app.launch()+ _ = app.buttons["controllers.open"].firstMatch.waitForExistence(timeout: 10)+ || app.buttons["controllers.close"].waitForExistence(timeout: 2)+ sleep(1)+ }++ func testCaptureMatrix() {+ for orientation in [UIDeviceOrientation.portrait, .landscapeLeft] {+ XCUIDevice.shared.orientation = orientation+ let suffix = orientation == .portrait ? "portrait" : "landscape"+ for screen in screens {+ launch(["--screen", screen])+ shot("\(screen)-\(suffix)")+ if screen == "settings" {+ for index in 1...2 {+ app.scrollViews.element(boundBy: app.scrollViews.count - 1).swipeUp()+ shot("settings-scroll\(index)-\(suffix)")+ }+ }+ }+ launch(["--screen", "library", "--games", "3", "--select", "tide"])+ shot("three-games-\(suffix)")+ launch(["--screen", "library", "--select", "drift"])+ shot("library-drift-\(suffix)")+ }+ XCUIDevice.shared.orientation = .portrait+ }++ /// Run with the Simulator's text size at its largest (xcrun simctl ui <id> content_size accessibility-extra-extra-extra-large).+ func testCaptureLargeText() {+ for orientation in [UIDeviceOrientation.portrait, .landscapeLeft] {+ XCUIDevice.shared.orientation = orientation+ let suffix = orientation == .portrait ? "portrait" : "landscape"+ for screen in ["library", "settings", "broken", "controllers"] {+ launch(["--screen", screen])+ shot("large-\(screen)-\(suffix)")+ }+ }+ XCUIDevice.shared.orientation = .portrait+ }++ /// The fold stand-in: one running shell resized between a folded and an unfolded screen.+ func testCaptureFold() throws {+ try XCTSkipUnless(UIDevice.current.userInterfaceIdiom == .pad, "The fold stand-in needs an iPad canvas")+ for orientation in [UIDeviceOrientation.portrait, .landscapeLeft] {+ XCUIDevice.shared.orientation = orientation+ let suffix = orientation == .portrait ? "portrait" : "landscape"+ for screen in ["library", "settings", "needs-data", "controllers"] {+ launch(["--screen", screen, "--fold-test"])+ shot("fold-\(screen)-folded-\(suffix)")+ launch(["--screen", screen, "--fold-test", "--unfolded"])+ shot("fold-\(screen)-unfolded-\(suffix)")+ }+ }+ XCUIDevice.shared.orientation = .portrait+ }+}diff --git a/frontend-ios/UITests/ShellDemoUITests.swift b/frontend-ios/UITests/ShellDemoUITests.swiftnew file mode 100644index 00000000..2ff7bf71--- /dev/null+++ b/frontend-ios/UITests/ShellDemoUITests.swift@@ -0,0 +1,70 @@+import XCTest++@MainActor final class ShellDemoUITests: XCTestCase {+ private let app = XCUIApplication()+ private var extraArguments: [String] = []+ override func setUpWithError() throws { continueAfterFailure = false }+ private func launch(_ screen: String) {+ app.launchArguments = ["--screen", screen] + extraArguments+ app.launch()+ XCTAssertTrue(app.buttons[screen.hasPrefix("controllers") ? "controllers.close" : "controllers.open"].waitForExistence(timeout: 10))+ }+ private func capture(_ name: String) {+ let attachment = XCTAttachment(screenshot: XCUIScreen.main.screenshot())+ attachment.name = name+ attachment.lifetime = .keepAlways+ add(attachment)+ }+ func testActionsAndNavigation() {+ XCUIDevice.shared.orientation = .portrait+ launch("library")+ let settings = app.buttons["settings.open"]+ if settings.exists { settings.tap() }+ let frameRate = app.switches["setting.DM_SHOW_FPS"]+ XCTAssertTrue(frameRate.waitForExistence(timeout: 5))+ frameRate.tap()+ XCTAssertEqual(frameRate.value as? String, "1")+ let primary = app.buttons.matching(identifier: "state.action").allElementsBoundByIndex.first { $0.isHittable }+ XCTAssertNotNil(primary)+ primary?.tap()+ XCTAssertTrue(app.alerts["Demo action"].waitForExistence(timeout: 5))+ XCTAssertTrue(app.alerts.staticTexts["Play requested. The demo does not launch games."].exists)+ app.alerts.buttons["OK"].tap()+ if app.buttons["library.back"].exists { app.buttons["library.back"].tap() }+ XCTAssertTrue(app.buttons["tile.orbit"].isHittable)+ app.buttons["controllers.open"].tap()+ XCTAssertTrue(app.staticTexts["Pro Controller"].waitForExistence(timeout: 5))+ app.buttons["controllers.close"].tap()+ XCTAssertFalse(app.staticTexts["Pro Controller"].exists)+ }+ func testShortShelfSelects() {+ XCUIDevice.shared.orientation = .landscapeLeft+ extraArguments = ["--games", "3"]+ launch("library")+ app.buttons["tile.paper"].tap()+ XCTAssertEqual(app.staticTexts["hero.title"].label, "Paper Trails")+ XCTAssertEqual(app.buttons["state.action"].firstMatch.label, "Choose game data…, Paper Trails")+ XCUIDevice.shared.orientation = .portrait+ }+ func testLargeText() {+ XCUIDevice.shared.orientation = .portrait+ for screen in ["library", "settings", "needs-data", "needs-update", "broken", "empty", "controllers", "controllers-empty", "focus"] {+ launch(screen)+ capture("\(screen)-largest-text")+ if screen == "settings" {+ for index in 1...4 {+ app.scrollViews.element(boundBy: app.scrollViews.count - 1).swipeUp()+ capture("settings-scroll-\(index)-largest-text")+ }+ }+ }+ }+ func testSelectionSurvivesRotation() {+ XCUIDevice.shared.orientation = .portrait+ launch("library")+ app.buttons["tile.tide"].tap()+ XCUIDevice.shared.orientation = .landscapeLeft+ XCTAssertEqual(app.staticTexts["hero.title"].label, "The Quiet Tide")+ capture("selected-after-rotation")+ }+}