├── .gitignore ├── LICENSE ├── README.md ├── SwiftUIPreviewsAtScale.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist └── SwiftUIPreviewsAtScale ├── App ├── AppDelegate.swift ├── ContentView.swift └── SceneDelegate.swift ├── Landmarks ├── Landmark.swift ├── LandmarkList.swift ├── LandmarkRow.swift └── UserData.swift ├── Preview Content └── Preview Assets.xcassets │ └── Contents.json ├── PreviewPresets ├── ContentSizeCategoryPreview.swift ├── DarkThemePreview.swift ├── FontPreview.swift ├── LocalePreview.swift ├── RightToLeftPreview.swift └── View+PreviewPresets.swift ├── SendButton.swift ├── SupportingFiles ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ └── turtlerock.imageset │ │ ├── Contents.json │ │ └── turtlerock.jpg ├── Base.lproj │ └── LaunchScreen.storyboard └── Info.plist ├── en.lproj └── Localizable.strings └── ru.lproj └── Localizable.strings /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## User settings 6 | xcuserdata/ 7 | 8 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 9 | *.xcscmblueprint 10 | *.xccheckout 11 | 12 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 13 | build/ 14 | DerivedData/ 15 | *.moved-aside 16 | *.pbxuser 17 | !default.pbxuser 18 | *.mode1v3 19 | !default.mode1v3 20 | *.mode2v3 21 | !default.mode2v3 22 | *.perspectivev3 23 | !default.perspectivev3 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | 28 | ## App packaging 29 | *.ipa 30 | *.dSYM.zip 31 | *.dSYM 32 | 33 | ## Playgrounds 34 | timeline.xctimeline 35 | playground.xcworkspace 36 | 37 | # Swift Package Manager 38 | # 39 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 40 | # Packages/ 41 | # Package.pins 42 | # Package.resolved 43 | # *.xcodeproj 44 | # 45 | # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata 46 | # hence it is not needed unless you have added a package configuration file to your project 47 | # .swiftpm 48 | 49 | .build/ 50 | 51 | # CocoaPods 52 | # 53 | # We recommend against adding the Pods directory to your .gitignore. However 54 | # you should judge for yourself, the pros and cons are mentioned at: 55 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 56 | # 57 | # Pods/ 58 | # 59 | # Add this line if you want to avoid checking in source code from the Xcode workspace 60 | # *.xcworkspace 61 | 62 | # Carthage 63 | # 64 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 65 | # Carthage/Checkouts 66 | 67 | Carthage/Build/ 68 | 69 | # Accio dependency management 70 | Dependencies/ 71 | .accio/ 72 | 73 | # fastlane 74 | # 75 | # It is recommended to not store the screenshots in the git repo. 76 | # Instead, use fastlane to re-generate the screenshots whenever they are needed. 77 | # For more information about the recommended setup visit: 78 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 79 | 80 | fastlane/report.xml 81 | fastlane/Preview.html 82 | fastlane/screenshots/**/*.png 83 | fastlane/test_output 84 | 85 | # Code Injection 86 | # 87 | # After new code Injection tools there's a generated folder /iOSInjectionProject 88 | # https://github.com/johnno1962/injectionforxcode 89 | 90 | iOSInjectionProject/ 91 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Article related to this project 2 | 3 | - [SwiftUI Previews at Scale](https://www.vadimbulavin.com/swiftui-previews-at-scale/). 4 | 5 | --- 6 | 7 | # SwiftUIPreviewsAtScale 8 | 9 | A sample project showing three techniques to help you manage SwiftUI previews at scale: 10 | - Extracting reusable previews into components. 11 | - Combining groups of previews into presets. 12 | - Using Fixture Object pattern to simplify object graph instantiation. 13 | -------------------------------------------------------------------------------- /SwiftUIPreviewsAtScale.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 881B7AD12471B29500F69ED4 /* LandmarkList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881B7AD02471B29500F69ED4 /* LandmarkList.swift */; }; 11 | 881B7AD32471B2B000F69ED4 /* UserData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881B7AD22471B2B000F69ED4 /* UserData.swift */; }; 12 | 881B7AD52471B3FB00F69ED4 /* Landmark.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881B7AD42471B3FB00F69ED4 /* Landmark.swift */; }; 13 | 881B7AD82471D91C00F69ED4 /* LocalePreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881B7AD72471D91C00F69ED4 /* LocalePreview.swift */; }; 14 | 881B7ADA2471D93300F69ED4 /* DarkThemePreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881B7AD92471D93300F69ED4 /* DarkThemePreview.swift */; }; 15 | 881B7ADC2471D94900F69ED4 /* RightToLeftPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881B7ADB2471D94900F69ED4 /* RightToLeftPreview.swift */; }; 16 | 881B7ADE2471D95700F69ED4 /* ContentSizeCategoryPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881B7ADD2471D95700F69ED4 /* ContentSizeCategoryPreview.swift */; }; 17 | 881B7AE02471D96500F69ED4 /* FontPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881B7ADF2471D96500F69ED4 /* FontPreview.swift */; }; 18 | 88FFB6762463F27A00C28CBB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88FFB6752463F27A00C28CBB /* AppDelegate.swift */; }; 19 | 88FFB6782463F27A00C28CBB /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88FFB6772463F27A00C28CBB /* SceneDelegate.swift */; }; 20 | 88FFB67A2463F27A00C28CBB /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88FFB6792463F27A00C28CBB /* ContentView.swift */; }; 21 | 88FFB67C2463F27D00C28CBB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 88FFB67B2463F27D00C28CBB /* Assets.xcassets */; }; 22 | 88FFB67F2463F27D00C28CBB /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 88FFB67E2463F27D00C28CBB /* Preview Assets.xcassets */; }; 23 | 88FFB6822463F27D00C28CBB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 88FFB6802463F27D00C28CBB /* LaunchScreen.storyboard */; }; 24 | 88FFB68C2463F7C600C28CBB /* View+PreviewPresets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88FFB68B2463F7C600C28CBB /* View+PreviewPresets.swift */; }; 25 | 88FFB68E2464170100C28CBB /* SendButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88FFB68D2464170100C28CBB /* SendButton.swift */; }; 26 | 88FFB6A52464177100C28CBB /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 88FFB6A72464177100C28CBB /* Localizable.strings */; }; 27 | 88FFB6AA246423B500C28CBB /* LandmarkRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88FFB6A9246423B500C28CBB /* LandmarkRow.swift */; }; 28 | /* End PBXBuildFile section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | 881B7AD02471B29500F69ED4 /* LandmarkList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LandmarkList.swift; sourceTree = ""; }; 32 | 881B7AD22471B2B000F69ED4 /* UserData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserData.swift; sourceTree = ""; }; 33 | 881B7AD42471B3FB00F69ED4 /* Landmark.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Landmark.swift; sourceTree = ""; }; 34 | 881B7AD72471D91C00F69ED4 /* LocalePreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalePreview.swift; sourceTree = ""; }; 35 | 881B7AD92471D93300F69ED4 /* DarkThemePreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DarkThemePreview.swift; sourceTree = ""; }; 36 | 881B7ADB2471D94900F69ED4 /* RightToLeftPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RightToLeftPreview.swift; sourceTree = ""; }; 37 | 881B7ADD2471D95700F69ED4 /* ContentSizeCategoryPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentSizeCategoryPreview.swift; sourceTree = ""; }; 38 | 881B7ADF2471D96500F69ED4 /* FontPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontPreview.swift; sourceTree = ""; }; 39 | 88FFB6722463F27A00C28CBB /* SwiftUIPreviewsAtScale.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftUIPreviewsAtScale.app; sourceTree = BUILT_PRODUCTS_DIR; }; 40 | 88FFB6752463F27A00C28CBB /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 41 | 88FFB6772463F27A00C28CBB /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 42 | 88FFB6792463F27A00C28CBB /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 43 | 88FFB67B2463F27D00C28CBB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 44 | 88FFB67E2463F27D00C28CBB /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 45 | 88FFB6812463F27D00C28CBB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 46 | 88FFB6832463F27D00C28CBB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 47 | 88FFB68B2463F7C600C28CBB /* View+PreviewPresets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+PreviewPresets.swift"; sourceTree = ""; }; 48 | 88FFB68D2464170100C28CBB /* SendButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SendButton.swift; sourceTree = ""; }; 49 | 88FFB6A62464177100C28CBB /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; 50 | 88FFB6A82464177400C28CBB /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/Localizable.strings; sourceTree = ""; }; 51 | 88FFB6A9246423B500C28CBB /* LandmarkRow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LandmarkRow.swift; sourceTree = ""; }; 52 | /* End PBXFileReference section */ 53 | 54 | /* Begin PBXFrameworksBuildPhase section */ 55 | 88FFB66F2463F27A00C28CBB /* Frameworks */ = { 56 | isa = PBXFrameworksBuildPhase; 57 | buildActionMask = 2147483647; 58 | files = ( 59 | ); 60 | runOnlyForDeploymentPostprocessing = 0; 61 | }; 62 | /* End PBXFrameworksBuildPhase section */ 63 | 64 | /* Begin PBXGroup section */ 65 | 881B7AD62471D8F800F69ED4 /* Landmarks */ = { 66 | isa = PBXGroup; 67 | children = ( 68 | 88FFB6A9246423B500C28CBB /* LandmarkRow.swift */, 69 | 881B7AD42471B3FB00F69ED4 /* Landmark.swift */, 70 | 881B7AD02471B29500F69ED4 /* LandmarkList.swift */, 71 | 881B7AD22471B2B000F69ED4 /* UserData.swift */, 72 | ); 73 | path = Landmarks; 74 | sourceTree = ""; 75 | }; 76 | 881B7AE12471D97700F69ED4 /* PreviewPresets */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | 881B7ADD2471D95700F69ED4 /* ContentSizeCategoryPreview.swift */, 80 | 881B7AD92471D93300F69ED4 /* DarkThemePreview.swift */, 81 | 881B7ADF2471D96500F69ED4 /* FontPreview.swift */, 82 | 881B7AD72471D91C00F69ED4 /* LocalePreview.swift */, 83 | 881B7ADB2471D94900F69ED4 /* RightToLeftPreview.swift */, 84 | 88FFB68B2463F7C600C28CBB /* View+PreviewPresets.swift */, 85 | ); 86 | path = PreviewPresets; 87 | sourceTree = ""; 88 | }; 89 | 88FFB6692463F27A00C28CBB = { 90 | isa = PBXGroup; 91 | children = ( 92 | 88FFB6742463F27A00C28CBB /* SwiftUIPreviewsAtScale */, 93 | 88FFB6732463F27A00C28CBB /* Products */, 94 | ); 95 | sourceTree = ""; 96 | }; 97 | 88FFB6732463F27A00C28CBB /* Products */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | 88FFB6722463F27A00C28CBB /* SwiftUIPreviewsAtScale.app */, 101 | ); 102 | name = Products; 103 | sourceTree = ""; 104 | }; 105 | 88FFB6742463F27A00C28CBB /* SwiftUIPreviewsAtScale */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | 88FFB68A2463F28F00C28CBB /* App */, 109 | 881B7AE12471D97700F69ED4 /* PreviewPresets */, 110 | 88FFB68D2464170100C28CBB /* SendButton.swift */, 111 | 881B7AD62471D8F800F69ED4 /* Landmarks */, 112 | 88FFB6A72464177100C28CBB /* Localizable.strings */, 113 | 88FFB6892463F28500C28CBB /* SupportingFiles */, 114 | 88FFB67D2463F27D00C28CBB /* Preview Content */, 115 | ); 116 | path = SwiftUIPreviewsAtScale; 117 | sourceTree = ""; 118 | }; 119 | 88FFB67D2463F27D00C28CBB /* Preview Content */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | 88FFB67E2463F27D00C28CBB /* Preview Assets.xcassets */, 123 | ); 124 | path = "Preview Content"; 125 | sourceTree = ""; 126 | }; 127 | 88FFB6892463F28500C28CBB /* SupportingFiles */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | 88FFB67B2463F27D00C28CBB /* Assets.xcassets */, 131 | 88FFB6802463F27D00C28CBB /* LaunchScreen.storyboard */, 132 | 88FFB6832463F27D00C28CBB /* Info.plist */, 133 | ); 134 | path = SupportingFiles; 135 | sourceTree = ""; 136 | }; 137 | 88FFB68A2463F28F00C28CBB /* App */ = { 138 | isa = PBXGroup; 139 | children = ( 140 | 88FFB6752463F27A00C28CBB /* AppDelegate.swift */, 141 | 88FFB6772463F27A00C28CBB /* SceneDelegate.swift */, 142 | 88FFB6792463F27A00C28CBB /* ContentView.swift */, 143 | ); 144 | path = App; 145 | sourceTree = ""; 146 | }; 147 | /* End PBXGroup section */ 148 | 149 | /* Begin PBXNativeTarget section */ 150 | 88FFB6712463F27A00C28CBB /* SwiftUIPreviewsAtScale */ = { 151 | isa = PBXNativeTarget; 152 | buildConfigurationList = 88FFB6862463F27D00C28CBB /* Build configuration list for PBXNativeTarget "SwiftUIPreviewsAtScale" */; 153 | buildPhases = ( 154 | 88FFB66E2463F27A00C28CBB /* Sources */, 155 | 88FFB66F2463F27A00C28CBB /* Frameworks */, 156 | 88FFB6702463F27A00C28CBB /* Resources */, 157 | ); 158 | buildRules = ( 159 | ); 160 | dependencies = ( 161 | ); 162 | name = SwiftUIPreviewsAtScale; 163 | productName = ScalingSwiftUIPreviews; 164 | productReference = 88FFB6722463F27A00C28CBB /* SwiftUIPreviewsAtScale.app */; 165 | productType = "com.apple.product-type.application"; 166 | }; 167 | /* End PBXNativeTarget section */ 168 | 169 | /* Begin PBXProject section */ 170 | 88FFB66A2463F27A00C28CBB /* Project object */ = { 171 | isa = PBXProject; 172 | attributes = { 173 | LastSwiftUpdateCheck = 1150; 174 | LastUpgradeCheck = 1150; 175 | ORGANIZATIONNAME = "Vadim Bulavin"; 176 | TargetAttributes = { 177 | 88FFB6712463F27A00C28CBB = { 178 | CreatedOnToolsVersion = 11.5; 179 | }; 180 | }; 181 | }; 182 | buildConfigurationList = 88FFB66D2463F27A00C28CBB /* Build configuration list for PBXProject "SwiftUIPreviewsAtScale" */; 183 | compatibilityVersion = "Xcode 9.3"; 184 | developmentRegion = en; 185 | hasScannedForEncodings = 0; 186 | knownRegions = ( 187 | en, 188 | Base, 189 | ru, 190 | ); 191 | mainGroup = 88FFB6692463F27A00C28CBB; 192 | productRefGroup = 88FFB6732463F27A00C28CBB /* Products */; 193 | projectDirPath = ""; 194 | projectRoot = ""; 195 | targets = ( 196 | 88FFB6712463F27A00C28CBB /* SwiftUIPreviewsAtScale */, 197 | ); 198 | }; 199 | /* End PBXProject section */ 200 | 201 | /* Begin PBXResourcesBuildPhase section */ 202 | 88FFB6702463F27A00C28CBB /* Resources */ = { 203 | isa = PBXResourcesBuildPhase; 204 | buildActionMask = 2147483647; 205 | files = ( 206 | 88FFB6822463F27D00C28CBB /* LaunchScreen.storyboard in Resources */, 207 | 88FFB6A52464177100C28CBB /* Localizable.strings in Resources */, 208 | 88FFB67F2463F27D00C28CBB /* Preview Assets.xcassets in Resources */, 209 | 88FFB67C2463F27D00C28CBB /* Assets.xcassets in Resources */, 210 | ); 211 | runOnlyForDeploymentPostprocessing = 0; 212 | }; 213 | /* End PBXResourcesBuildPhase section */ 214 | 215 | /* Begin PBXSourcesBuildPhase section */ 216 | 88FFB66E2463F27A00C28CBB /* Sources */ = { 217 | isa = PBXSourcesBuildPhase; 218 | buildActionMask = 2147483647; 219 | files = ( 220 | 88FFB6762463F27A00C28CBB /* AppDelegate.swift in Sources */, 221 | 881B7AE02471D96500F69ED4 /* FontPreview.swift in Sources */, 222 | 881B7ADC2471D94900F69ED4 /* RightToLeftPreview.swift in Sources */, 223 | 88FFB6782463F27A00C28CBB /* SceneDelegate.swift in Sources */, 224 | 881B7AD82471D91C00F69ED4 /* LocalePreview.swift in Sources */, 225 | 881B7AD32471B2B000F69ED4 /* UserData.swift in Sources */, 226 | 88FFB68E2464170100C28CBB /* SendButton.swift in Sources */, 227 | 881B7AD12471B29500F69ED4 /* LandmarkList.swift in Sources */, 228 | 881B7AD52471B3FB00F69ED4 /* Landmark.swift in Sources */, 229 | 88FFB68C2463F7C600C28CBB /* View+PreviewPresets.swift in Sources */, 230 | 881B7ADE2471D95700F69ED4 /* ContentSizeCategoryPreview.swift in Sources */, 231 | 88FFB67A2463F27A00C28CBB /* ContentView.swift in Sources */, 232 | 88FFB6AA246423B500C28CBB /* LandmarkRow.swift in Sources */, 233 | 881B7ADA2471D93300F69ED4 /* DarkThemePreview.swift in Sources */, 234 | ); 235 | runOnlyForDeploymentPostprocessing = 0; 236 | }; 237 | /* End PBXSourcesBuildPhase section */ 238 | 239 | /* Begin PBXVariantGroup section */ 240 | 88FFB6802463F27D00C28CBB /* LaunchScreen.storyboard */ = { 241 | isa = PBXVariantGroup; 242 | children = ( 243 | 88FFB6812463F27D00C28CBB /* Base */, 244 | ); 245 | name = LaunchScreen.storyboard; 246 | sourceTree = ""; 247 | }; 248 | 88FFB6A72464177100C28CBB /* Localizable.strings */ = { 249 | isa = PBXVariantGroup; 250 | children = ( 251 | 88FFB6A62464177100C28CBB /* en */, 252 | 88FFB6A82464177400C28CBB /* ru */, 253 | ); 254 | name = Localizable.strings; 255 | sourceTree = ""; 256 | }; 257 | /* End PBXVariantGroup section */ 258 | 259 | /* Begin XCBuildConfiguration section */ 260 | 88FFB6842463F27D00C28CBB /* Debug */ = { 261 | isa = XCBuildConfiguration; 262 | buildSettings = { 263 | ALWAYS_SEARCH_USER_PATHS = NO; 264 | CLANG_ANALYZER_NONNULL = YES; 265 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 266 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 267 | CLANG_CXX_LIBRARY = "libc++"; 268 | CLANG_ENABLE_MODULES = YES; 269 | CLANG_ENABLE_OBJC_ARC = YES; 270 | CLANG_ENABLE_OBJC_WEAK = YES; 271 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 272 | CLANG_WARN_BOOL_CONVERSION = YES; 273 | CLANG_WARN_COMMA = YES; 274 | CLANG_WARN_CONSTANT_CONVERSION = YES; 275 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 276 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 277 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 278 | CLANG_WARN_EMPTY_BODY = YES; 279 | CLANG_WARN_ENUM_CONVERSION = YES; 280 | CLANG_WARN_INFINITE_RECURSION = YES; 281 | CLANG_WARN_INT_CONVERSION = YES; 282 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 283 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 284 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 285 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 286 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 287 | CLANG_WARN_STRICT_PROTOTYPES = YES; 288 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 289 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 290 | CLANG_WARN_UNREACHABLE_CODE = YES; 291 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 292 | COPY_PHASE_STRIP = NO; 293 | DEBUG_INFORMATION_FORMAT = dwarf; 294 | ENABLE_STRICT_OBJC_MSGSEND = YES; 295 | ENABLE_TESTABILITY = YES; 296 | GCC_C_LANGUAGE_STANDARD = gnu11; 297 | GCC_DYNAMIC_NO_PIC = NO; 298 | GCC_NO_COMMON_BLOCKS = YES; 299 | GCC_OPTIMIZATION_LEVEL = 0; 300 | GCC_PREPROCESSOR_DEFINITIONS = ( 301 | "DEBUG=1", 302 | "$(inherited)", 303 | ); 304 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 305 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 306 | GCC_WARN_UNDECLARED_SELECTOR = YES; 307 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 308 | GCC_WARN_UNUSED_FUNCTION = YES; 309 | GCC_WARN_UNUSED_VARIABLE = YES; 310 | IPHONEOS_DEPLOYMENT_TARGET = 13.5; 311 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 312 | MTL_FAST_MATH = YES; 313 | ONLY_ACTIVE_ARCH = YES; 314 | SDKROOT = iphoneos; 315 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 316 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 317 | }; 318 | name = Debug; 319 | }; 320 | 88FFB6852463F27D00C28CBB /* Release */ = { 321 | isa = XCBuildConfiguration; 322 | buildSettings = { 323 | ALWAYS_SEARCH_USER_PATHS = NO; 324 | CLANG_ANALYZER_NONNULL = YES; 325 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 326 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 327 | CLANG_CXX_LIBRARY = "libc++"; 328 | CLANG_ENABLE_MODULES = YES; 329 | CLANG_ENABLE_OBJC_ARC = YES; 330 | CLANG_ENABLE_OBJC_WEAK = YES; 331 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 332 | CLANG_WARN_BOOL_CONVERSION = YES; 333 | CLANG_WARN_COMMA = YES; 334 | CLANG_WARN_CONSTANT_CONVERSION = YES; 335 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 336 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 337 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 338 | CLANG_WARN_EMPTY_BODY = YES; 339 | CLANG_WARN_ENUM_CONVERSION = YES; 340 | CLANG_WARN_INFINITE_RECURSION = YES; 341 | CLANG_WARN_INT_CONVERSION = YES; 342 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 343 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 344 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 345 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 346 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 347 | CLANG_WARN_STRICT_PROTOTYPES = YES; 348 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 349 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 350 | CLANG_WARN_UNREACHABLE_CODE = YES; 351 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 352 | COPY_PHASE_STRIP = NO; 353 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 354 | ENABLE_NS_ASSERTIONS = NO; 355 | ENABLE_STRICT_OBJC_MSGSEND = YES; 356 | GCC_C_LANGUAGE_STANDARD = gnu11; 357 | GCC_NO_COMMON_BLOCKS = YES; 358 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 359 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 360 | GCC_WARN_UNDECLARED_SELECTOR = YES; 361 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 362 | GCC_WARN_UNUSED_FUNCTION = YES; 363 | GCC_WARN_UNUSED_VARIABLE = YES; 364 | IPHONEOS_DEPLOYMENT_TARGET = 13.5; 365 | MTL_ENABLE_DEBUG_INFO = NO; 366 | MTL_FAST_MATH = YES; 367 | SDKROOT = iphoneos; 368 | SWIFT_COMPILATION_MODE = wholemodule; 369 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 370 | VALIDATE_PRODUCT = YES; 371 | }; 372 | name = Release; 373 | }; 374 | 88FFB6872463F27D00C28CBB /* Debug */ = { 375 | isa = XCBuildConfiguration; 376 | buildSettings = { 377 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 378 | CODE_SIGN_STYLE = Automatic; 379 | DEVELOPMENT_ASSET_PATHS = "\"SwiftUIPreviewsAtScale/Preview Content\""; 380 | ENABLE_PREVIEWS = YES; 381 | INFOPLIST_FILE = SwiftUIPreviewsAtScale/SupportingFiles/Info.plist; 382 | LD_RUNPATH_SEARCH_PATHS = ( 383 | "$(inherited)", 384 | "@executable_path/Frameworks", 385 | ); 386 | PRODUCT_BUNDLE_IDENTIFIER = vadimbulavin.SwiftUIPreviewsAtScale; 387 | PRODUCT_NAME = "$(TARGET_NAME)"; 388 | SWIFT_VERSION = 5.0; 389 | TARGETED_DEVICE_FAMILY = "1,2"; 390 | }; 391 | name = Debug; 392 | }; 393 | 88FFB6882463F27D00C28CBB /* Release */ = { 394 | isa = XCBuildConfiguration; 395 | buildSettings = { 396 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 397 | CODE_SIGN_STYLE = Automatic; 398 | DEVELOPMENT_ASSET_PATHS = "\"SwiftUIPreviewsAtScale/Preview Content\""; 399 | ENABLE_PREVIEWS = YES; 400 | INFOPLIST_FILE = SwiftUIPreviewsAtScale/SupportingFiles/Info.plist; 401 | LD_RUNPATH_SEARCH_PATHS = ( 402 | "$(inherited)", 403 | "@executable_path/Frameworks", 404 | ); 405 | PRODUCT_BUNDLE_IDENTIFIER = vadimbulavin.SwiftUIPreviewsAtScale; 406 | PRODUCT_NAME = "$(TARGET_NAME)"; 407 | SWIFT_VERSION = 5.0; 408 | TARGETED_DEVICE_FAMILY = "1,2"; 409 | }; 410 | name = Release; 411 | }; 412 | /* End XCBuildConfiguration section */ 413 | 414 | /* Begin XCConfigurationList section */ 415 | 88FFB66D2463F27A00C28CBB /* Build configuration list for PBXProject "SwiftUIPreviewsAtScale" */ = { 416 | isa = XCConfigurationList; 417 | buildConfigurations = ( 418 | 88FFB6842463F27D00C28CBB /* Debug */, 419 | 88FFB6852463F27D00C28CBB /* Release */, 420 | ); 421 | defaultConfigurationIsVisible = 0; 422 | defaultConfigurationName = Release; 423 | }; 424 | 88FFB6862463F27D00C28CBB /* Build configuration list for PBXNativeTarget "SwiftUIPreviewsAtScale" */ = { 425 | isa = XCConfigurationList; 426 | buildConfigurations = ( 427 | 88FFB6872463F27D00C28CBB /* Debug */, 428 | 88FFB6882463F27D00C28CBB /* Release */, 429 | ); 430 | defaultConfigurationIsVisible = 0; 431 | defaultConfigurationName = Release; 432 | }; 433 | /* End XCConfigurationList section */ 434 | }; 435 | rootObject = 88FFB66A2463F27A00C28CBB /* Project object */; 436 | } 437 | -------------------------------------------------------------------------------- /SwiftUIPreviewsAtScale.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SwiftUIPreviewsAtScale.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /SwiftUIPreviewsAtScale/App/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // SwiftUIPreviewsAtScale 4 | // 5 | // Created by Vadim Bulavin on 5/7/20. 6 | // Copyright © 2020 Vadim Bulavin. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 15 | // Override point for customization after application launch. 16 | return true 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /SwiftUIPreviewsAtScale/App/ContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // SwiftUIPreviewsAtScale 4 | // 5 | // Created by Vadim Bulavin on 5/7/20. 6 | // Copyright © 2020 Vadim Bulavin. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct ContentView: View { 12 | var body: some View { 13 | Text("Hello, World!") 14 | } 15 | } 16 | 17 | struct ContentView_Previews: PreviewProvider { 18 | static var previews: some View { 19 | ContentView() 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /SwiftUIPreviewsAtScale/App/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // SwiftUIPreviewsAtScale 4 | // 5 | // Created by Vadim Bulavin on 5/7/20. 6 | // Copyright © 2020 Vadim Bulavin. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SwiftUI 11 | 12 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 17 | if let windowScene = scene as? UIWindowScene { 18 | let window = UIWindow(windowScene: windowScene) 19 | window.rootViewController = UIHostingController(rootView: ContentView()) 20 | self.window = window 21 | window.makeKeyAndVisible() 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /SwiftUIPreviewsAtScale/Landmarks/Landmark.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright © 2020 Apple Inc. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | import SwiftUI 12 | import CoreLocation 13 | 14 | struct Landmark: Hashable, Codable, Identifiable { 15 | var id: Int 16 | var name: String 17 | var imageName: String 18 | var coordinates: Coordinates 19 | var state: String 20 | var park: String 21 | var category: Category 22 | var isFavorite: Bool 23 | 24 | var locationCoordinate: CLLocationCoordinate2D { 25 | CLLocationCoordinate2D( 26 | latitude: coordinates.latitude, 27 | longitude: coordinates.longitude) 28 | } 29 | 30 | enum Category: String, CaseIterable, Codable, Hashable { 31 | case featured = "Featured" 32 | case lakes = "Lakes" 33 | case rivers = "Rivers" 34 | case mountains = "Mountains" 35 | } 36 | } 37 | 38 | extension Landmark { 39 | var image: Image { 40 | Image(imageName) 41 | } 42 | } 43 | 44 | struct Coordinates: Hashable, Codable { 45 | var latitude: Double 46 | var longitude: Double 47 | } 48 | 49 | extension Landmark { 50 | static func fixture( 51 | id: Int = 1, 52 | name: String = "", 53 | imageName: String = "", 54 | coordinates: Coordinates = .fixture(), 55 | state: String = "", 56 | park: String = "", 57 | category: Category = .featured, 58 | isFavorite: Bool = false 59 | ) -> Landmark { 60 | Landmark( 61 | id: id, 62 | name: name, 63 | imageName: imageName, 64 | coordinates: coordinates, 65 | state: state, 66 | park: park, 67 | category: category, 68 | isFavorite: isFavorite 69 | ) 70 | } 71 | } 72 | 73 | extension Coordinates { 74 | static func fixture(latitude: Double = 0, longitude: Double = 0) -> Coordinates { 75 | Coordinates(latitude: latitude, longitude: longitude) 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /SwiftUIPreviewsAtScale/Landmarks/LandmarkList.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright © 2020 Apple Inc. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | import SwiftUI 12 | 13 | struct LandmarkList: View { 14 | @EnvironmentObject private var userData: UserData 15 | 16 | var body: some View { 17 | NavigationView { 18 | List { 19 | Toggle(isOn: $userData.showFavoritesOnly) { 20 | Text("Show Favorites Only") 21 | } 22 | 23 | ForEach(userData.landmarks) { landmark in 24 | if !self.userData.showFavoritesOnly || landmark.isFavorite { 25 | LandmarkRow(landmark: landmark) 26 | } 27 | } 28 | } 29 | .navigationBarTitle(Text("Landmarks")) 30 | } 31 | } 32 | } 33 | 34 | struct LandmarksList_Previews: PreviewProvider { 35 | static var previews: some View { 36 | let twoRows = UserData() 37 | twoRows.landmarks = [.fixture(name: "Turtle Rock", imageName: "turtlerock", isFavorite: true)] 38 | 39 | let longList = UserData() 40 | longList.landmarks = Array(repeating: .fixture(name: "A"), count: 100) 41 | 42 | let longName = UserData() 43 | longName.landmarks = [.fixture(name: String(repeating: "A", count: 200))] 44 | 45 | let favorites = UserData() 46 | favorites.landmarks = [ 47 | .fixture(id: 1, name: "A", isFavorite: true), 48 | .fixture(id: 2, name: "B", isFavorite: false) 49 | ] 50 | 51 | return Group { 52 | LandmarkList() 53 | .environmentObject(twoRows) 54 | 55 | LandmarkList() 56 | .environmentObject(longList) 57 | 58 | LandmarkList() 59 | .environmentObject(longName) 60 | 61 | LandmarkList() 62 | .environmentObject(favorites) 63 | }.previewDevice("iPhone SE") 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /SwiftUIPreviewsAtScale/Landmarks/LandmarkRow.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright © 2020 Apple Inc. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | import SwiftUI 12 | 13 | struct LandmarkRow: View { 14 | var landmark: Landmark 15 | 16 | var body: some View { 17 | HStack { 18 | Image(landmark.imageName) 19 | .resizable() 20 | .frame(width: 50, height: 50) 21 | Text(landmark.name) 22 | Spacer() 23 | 24 | if landmark.isFavorite { 25 | Image(systemName: "star.fill") 26 | .imageScale(.medium) 27 | .foregroundColor(.yellow) 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /SwiftUIPreviewsAtScale/Landmarks/UserData.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright © 2020 Apple Inc. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | */ 10 | 11 | import Combine 12 | import SwiftUI 13 | 14 | final class UserData: ObservableObject { 15 | @Published var showFavoritesOnly = false 16 | @Published var landmarks: [Landmark] = [] 17 | } 18 | -------------------------------------------------------------------------------- /SwiftUIPreviewsAtScale/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /SwiftUIPreviewsAtScale/PreviewPresets/ContentSizeCategoryPreview.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentSizeCategoryPreview.swift 3 | // SwiftUIPreviewsAtScale 4 | // 5 | // Created by Vadim Bulavin on 5/17/20. 6 | // Copyright © 2020 Vadim Bulavin. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct ContentSizeCategoryPreview: View { 12 | private let preview: Preview 13 | private let sizeCategory: ContentSizeCategory 14 | 15 | var body: some View { 16 | preview 17 | .previewLayout(PreviewLayout.sizeThatFits) 18 | .environment(\.sizeCategory, sizeCategory) 19 | .previewDisplayName("Content Size Category: \(sizeCategory)") 20 | } 21 | 22 | init(_ sizeCategory: ContentSizeCategory, @ViewBuilder builder: @escaping () -> Preview) { 23 | self.sizeCategory = sizeCategory 24 | preview = builder() 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /SwiftUIPreviewsAtScale/PreviewPresets/DarkThemePreview.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DarkThemePreview.swift 3 | // SwiftUIPreviewsAtScale 4 | // 5 | // Created by Vadim Bulavin on 5/17/20. 6 | // Copyright © 2020 Vadim Bulavin. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct DarkThemePreview: View { 12 | private let preview: Preview 13 | 14 | var body: some View { 15 | preview 16 | .previewLayout(PreviewLayout.sizeThatFits) 17 | .background(Color(.systemBackground)) 18 | .environment(\.colorScheme, .dark) 19 | .previewDisplayName("Dark Theme") 20 | } 21 | 22 | init(@ViewBuilder builder: @escaping () -> Preview) { 23 | preview = builder() 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /SwiftUIPreviewsAtScale/PreviewPresets/FontPreview.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FontPreview.swift 3 | // SwiftUIPreviewsAtScale 4 | // 5 | // Created by Vadim Bulavin on 5/17/20. 6 | // Copyright © 2020 Vadim Bulavin. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct FontPreview: View { 12 | private let preview: Preview 13 | private let font: Font 14 | 15 | var body: some View { 16 | preview 17 | .previewLayout(PreviewLayout.sizeThatFits) 18 | .environment(\.font, font) 19 | .previewDisplayName("Font") 20 | } 21 | 22 | init(_ font: Font, @ViewBuilder builder: @escaping () -> Preview) { 23 | self.font = font 24 | preview = builder() 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /SwiftUIPreviewsAtScale/PreviewPresets/LocalePreview.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LocalePreview.swift 3 | // SwiftUIPreviewsAtScale 4 | // 5 | // Created by Vadim Bulavin on 5/17/20. 6 | // Copyright © 2020 Vadim Bulavin. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct LocalePreview: View { 12 | private let preview: Preview 13 | 14 | var body: some View { 15 | ForEach(Locale.all, id: \.self) { locale in 16 | self.preview 17 | .previewLayout(PreviewLayout.sizeThatFits) 18 | .environment(\.locale, locale) 19 | .previewDisplayName("Locale: \(locale.identifier)") 20 | } 21 | } 22 | 23 | init(@ViewBuilder builder: @escaping () -> Preview) { 24 | preview = builder() 25 | } 26 | } 27 | 28 | // From https://www.avanderlee.com/swiftui/previews-different-states/ 29 | extension Locale { 30 | static let all = Bundle.main.localizations.map(Locale.init).filter { $0.identifier != "base" } 31 | } 32 | 33 | -------------------------------------------------------------------------------- /SwiftUIPreviewsAtScale/PreviewPresets/RightToLeftPreview.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RightToLeftPreview.swift 3 | // SwiftUIPreviewsAtScale 4 | // 5 | // Created by Vadim Bulavin on 5/17/20. 6 | // Copyright © 2020 Vadim Bulavin. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct RightToLeftPreview: View { 12 | private let preview: Preview 13 | 14 | var body: some View { 15 | preview 16 | .previewLayout(PreviewLayout.sizeThatFits) 17 | .environment(\.layoutDirection, .rightToLeft) 18 | .previewDisplayName("Right to Left") 19 | } 20 | 21 | init(@ViewBuilder builder: @escaping () -> Preview) { 22 | preview = builder() 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /SwiftUIPreviewsAtScale/PreviewPresets/View+PreviewPresets.swift: -------------------------------------------------------------------------------- 1 | // 2 | // View+PreviewPresets.swift 3 | // SwiftUIPreviewsAtScale 4 | // 5 | // Created by Vadim Bulavin on 5/7/20. 6 | // Copyright © 2020 Vadim Bulavin. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | extension View { 12 | func previewSupportedLocales() -> some View { 13 | LocalePreview { self } 14 | } 15 | 16 | func previewDarkTheme() -> some View { 17 | DarkThemePreview { self } 18 | } 19 | 20 | func previewRightToLeft() -> some View { 21 | RightToLeftPreview { self } 22 | } 23 | 24 | func previewContentSize(_ sizeCategory: ContentSizeCategory) -> some View { 25 | ContentSizeCategoryPreview(sizeCategory) { self } 26 | } 27 | } 28 | 29 | extension View { 30 | func previewButtonPreset() -> some View { 31 | let content = self.padding() 32 | 33 | return Group { 34 | content.previewSupportedLocales() 35 | content.previewRightToLeft() 36 | content.previewDarkTheme() 37 | content.previewContentSize(.extraSmall) 38 | content.previewContentSize(.medium) 39 | content.previewContentSize(.extraExtraExtraLarge) 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /SwiftUIPreviewsAtScale/SendButton.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SendButton.swift 3 | // SwiftUIPreviewsAtScale 4 | // 5 | // Created by Vadim Bulavin on 5/7/20. 6 | // Copyright © 2020 Vadim Bulavin. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct SendButton: View { 12 | let onAction: () -> Void = {} 13 | 14 | var body: some View { 15 | Button( 16 | action: onAction, 17 | label: { 18 | HStack { 19 | Image(systemName: "square.and.arrow.up") 20 | Text("common.button.send") 21 | } 22 | }) 23 | } 24 | } 25 | 26 | struct SendButton_Preview_Preset: PreviewProvider { 27 | static var previews: some View { 28 | SendButton() 29 | .previewButtonPreset() 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /SwiftUIPreviewsAtScale/SupportingFiles/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /SwiftUIPreviewsAtScale/SupportingFiles/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /SwiftUIPreviewsAtScale/SupportingFiles/Assets.xcassets/turtlerock.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "turtlerock.jpg", 5 | "idiom" : "universal", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "author" : "xcode", 19 | "version" : 1 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /SwiftUIPreviewsAtScale/SupportingFiles/Assets.xcassets/turtlerock.imageset/turtlerock.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/V8tr/SwiftUIPreviewsAtScale/ac2f9e3e3c8dbb8298b4e4ad2e19ebbaf7df2336/SwiftUIPreviewsAtScale/SupportingFiles/Assets.xcassets/turtlerock.imageset/turtlerock.jpg -------------------------------------------------------------------------------- /SwiftUIPreviewsAtScale/SupportingFiles/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /SwiftUIPreviewsAtScale/SupportingFiles/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | UISceneConfigurations 28 | 29 | UIWindowSceneSessionRoleApplication 30 | 31 | 32 | UISceneConfigurationName 33 | Default Configuration 34 | UISceneDelegateClassName 35 | $(PRODUCT_MODULE_NAME).SceneDelegate 36 | 37 | 38 | 39 | 40 | UILaunchStoryboardName 41 | LaunchScreen 42 | UIRequiredDeviceCapabilities 43 | 44 | armv7 45 | 46 | UISupportedInterfaceOrientations 47 | 48 | UIInterfaceOrientationPortrait 49 | UIInterfaceOrientationLandscapeLeft 50 | UIInterfaceOrientationLandscapeRight 51 | 52 | UISupportedInterfaceOrientations~ipad 53 | 54 | UIInterfaceOrientationPortrait 55 | UIInterfaceOrientationPortraitUpsideDown 56 | UIInterfaceOrientationLandscapeLeft 57 | UIInterfaceOrientationLandscapeRight 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /SwiftUIPreviewsAtScale/en.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* 2 | Localizable.strings 3 | SnapshotTestingSwiftUI 4 | 5 | Created by Vadim Bulavin on 4/27/20. 6 | Copyright © 2020 Vadim Bulavin. All rights reserved. 7 | */ 8 | 9 | "common.button.send" = "Send"; 10 | -------------------------------------------------------------------------------- /SwiftUIPreviewsAtScale/ru.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | /* 2 | Localizable.strings 3 | SnapshotTestingSwiftUI 4 | 5 | Created by Vadim Bulavin on 4/27/20. 6 | Copyright © 2020 Vadim Bulavin. All rights reserved. 7 | */ 8 | 9 | "common.button.send" = "Отправить"; 10 | --------------------------------------------------------------------------------