├── README.md ├── VariableType.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcuserdata │ └── philipdavis.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist └── VariableType ├── Assets.xcassets ├── AccentColor.colorset │ └── Contents.json ├── AppIcon.appiconset │ └── Contents.json └── Contents.json ├── ContentView.swift ├── IKSlider.swift ├── Preview Content └── Preview Assets.xcassets │ └── Contents.json └── VariableTypeApp.swift /README.md: -------------------------------------------------------------------------------- 1 | # VariableType 2 | Variable Type in SwiftUI 3 | 4 | ![image](https://user-images.githubusercontent.com/3452573/172999114-4554113d-122d-4320-b2ad-ebf33f9219e6.png) 5 | -------------------------------------------------------------------------------- /VariableType.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 56; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 48302DCE285308A200300911 /* IKSlider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48302DCD285308A200300911 /* IKSlider.swift */; }; 11 | 48A26A64285252A1006113E8 /* VariableTypeApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48A26A63285252A1006113E8 /* VariableTypeApp.swift */; }; 12 | 48A26A66285252A1006113E8 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48A26A65285252A1006113E8 /* ContentView.swift */; }; 13 | 48A26A68285252A2006113E8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 48A26A67285252A2006113E8 /* Assets.xcassets */; }; 14 | 48A26A6B285252A2006113E8 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 48A26A6A285252A2006113E8 /* Preview Assets.xcassets */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXFileReference section */ 18 | 48302DCD285308A200300911 /* IKSlider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IKSlider.swift; sourceTree = ""; }; 19 | 48A26A60285252A1006113E8 /* VariableType.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VariableType.app; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | 48A26A63285252A1006113E8 /* VariableTypeApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VariableTypeApp.swift; sourceTree = ""; }; 21 | 48A26A65285252A1006113E8 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 22 | 48A26A67285252A2006113E8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 23 | 48A26A6A285252A2006113E8 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 24 | /* End PBXFileReference section */ 25 | 26 | /* Begin PBXFrameworksBuildPhase section */ 27 | 48A26A5D285252A1006113E8 /* Frameworks */ = { 28 | isa = PBXFrameworksBuildPhase; 29 | buildActionMask = 2147483647; 30 | files = ( 31 | ); 32 | runOnlyForDeploymentPostprocessing = 0; 33 | }; 34 | /* End PBXFrameworksBuildPhase section */ 35 | 36 | /* Begin PBXGroup section */ 37 | 48A26A57285252A1006113E8 = { 38 | isa = PBXGroup; 39 | children = ( 40 | 48A26A62285252A1006113E8 /* VariableType */, 41 | 48A26A61285252A1006113E8 /* Products */, 42 | ); 43 | sourceTree = ""; 44 | }; 45 | 48A26A61285252A1006113E8 /* Products */ = { 46 | isa = PBXGroup; 47 | children = ( 48 | 48A26A60285252A1006113E8 /* VariableType.app */, 49 | ); 50 | name = Products; 51 | sourceTree = ""; 52 | }; 53 | 48A26A62285252A1006113E8 /* VariableType */ = { 54 | isa = PBXGroup; 55 | children = ( 56 | 48A26A63285252A1006113E8 /* VariableTypeApp.swift */, 57 | 48A26A65285252A1006113E8 /* ContentView.swift */, 58 | 48302DCD285308A200300911 /* IKSlider.swift */, 59 | 48A26A67285252A2006113E8 /* Assets.xcassets */, 60 | 48A26A69285252A2006113E8 /* Preview Content */, 61 | ); 62 | path = VariableType; 63 | sourceTree = ""; 64 | }; 65 | 48A26A69285252A2006113E8 /* Preview Content */ = { 66 | isa = PBXGroup; 67 | children = ( 68 | 48A26A6A285252A2006113E8 /* Preview Assets.xcassets */, 69 | ); 70 | path = "Preview Content"; 71 | sourceTree = ""; 72 | }; 73 | /* End PBXGroup section */ 74 | 75 | /* Begin PBXNativeTarget section */ 76 | 48A26A5F285252A1006113E8 /* VariableType */ = { 77 | isa = PBXNativeTarget; 78 | buildConfigurationList = 48A26A6E285252A2006113E8 /* Build configuration list for PBXNativeTarget "VariableType" */; 79 | buildPhases = ( 80 | 48A26A5C285252A1006113E8 /* Sources */, 81 | 48A26A5D285252A1006113E8 /* Frameworks */, 82 | 48A26A5E285252A1006113E8 /* Resources */, 83 | ); 84 | buildRules = ( 85 | ); 86 | dependencies = ( 87 | ); 88 | name = VariableType; 89 | productName = VariableType; 90 | productReference = 48A26A60285252A1006113E8 /* VariableType.app */; 91 | productType = "com.apple.product-type.application"; 92 | }; 93 | /* End PBXNativeTarget section */ 94 | 95 | /* Begin PBXProject section */ 96 | 48A26A58285252A1006113E8 /* Project object */ = { 97 | isa = PBXProject; 98 | attributes = { 99 | BuildIndependentTargetsInParallel = 1; 100 | LastSwiftUpdateCheck = 1400; 101 | LastUpgradeCheck = 1400; 102 | TargetAttributes = { 103 | 48A26A5F285252A1006113E8 = { 104 | CreatedOnToolsVersion = 14.0; 105 | }; 106 | }; 107 | }; 108 | buildConfigurationList = 48A26A5B285252A1006113E8 /* Build configuration list for PBXProject "VariableType" */; 109 | compatibilityVersion = "Xcode 14.0"; 110 | developmentRegion = en; 111 | hasScannedForEncodings = 0; 112 | knownRegions = ( 113 | en, 114 | Base, 115 | ); 116 | mainGroup = 48A26A57285252A1006113E8; 117 | productRefGroup = 48A26A61285252A1006113E8 /* Products */; 118 | projectDirPath = ""; 119 | projectRoot = ""; 120 | targets = ( 121 | 48A26A5F285252A1006113E8 /* VariableType */, 122 | ); 123 | }; 124 | /* End PBXProject section */ 125 | 126 | /* Begin PBXResourcesBuildPhase section */ 127 | 48A26A5E285252A1006113E8 /* Resources */ = { 128 | isa = PBXResourcesBuildPhase; 129 | buildActionMask = 2147483647; 130 | files = ( 131 | 48A26A6B285252A2006113E8 /* Preview Assets.xcassets in Resources */, 132 | 48A26A68285252A2006113E8 /* Assets.xcassets in Resources */, 133 | ); 134 | runOnlyForDeploymentPostprocessing = 0; 135 | }; 136 | /* End PBXResourcesBuildPhase section */ 137 | 138 | /* Begin PBXSourcesBuildPhase section */ 139 | 48A26A5C285252A1006113E8 /* Sources */ = { 140 | isa = PBXSourcesBuildPhase; 141 | buildActionMask = 2147483647; 142 | files = ( 143 | 48A26A66285252A1006113E8 /* ContentView.swift in Sources */, 144 | 48A26A64285252A1006113E8 /* VariableTypeApp.swift in Sources */, 145 | 48302DCE285308A200300911 /* IKSlider.swift in Sources */, 146 | ); 147 | runOnlyForDeploymentPostprocessing = 0; 148 | }; 149 | /* End PBXSourcesBuildPhase section */ 150 | 151 | /* Begin XCBuildConfiguration section */ 152 | 48A26A6C285252A2006113E8 /* Debug */ = { 153 | isa = XCBuildConfiguration; 154 | buildSettings = { 155 | ALWAYS_SEARCH_USER_PATHS = NO; 156 | CLANG_ANALYZER_NONNULL = YES; 157 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 158 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; 159 | CLANG_ENABLE_MODULES = YES; 160 | CLANG_ENABLE_OBJC_ARC = YES; 161 | CLANG_ENABLE_OBJC_WEAK = YES; 162 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 163 | CLANG_WARN_BOOL_CONVERSION = YES; 164 | CLANG_WARN_COMMA = YES; 165 | CLANG_WARN_CONSTANT_CONVERSION = YES; 166 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 167 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 168 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 169 | CLANG_WARN_EMPTY_BODY = YES; 170 | CLANG_WARN_ENUM_CONVERSION = YES; 171 | CLANG_WARN_INFINITE_RECURSION = YES; 172 | CLANG_WARN_INT_CONVERSION = YES; 173 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 174 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 175 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 176 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 177 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 178 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 179 | CLANG_WARN_STRICT_PROTOTYPES = YES; 180 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 181 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 182 | CLANG_WARN_UNREACHABLE_CODE = YES; 183 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 184 | COPY_PHASE_STRIP = NO; 185 | DEBUG_INFORMATION_FORMAT = dwarf; 186 | ENABLE_STRICT_OBJC_MSGSEND = YES; 187 | ENABLE_TESTABILITY = YES; 188 | GCC_C_LANGUAGE_STANDARD = gnu11; 189 | GCC_DYNAMIC_NO_PIC = NO; 190 | GCC_NO_COMMON_BLOCKS = YES; 191 | GCC_OPTIMIZATION_LEVEL = 0; 192 | GCC_PREPROCESSOR_DEFINITIONS = ( 193 | "DEBUG=1", 194 | "$(inherited)", 195 | ); 196 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 197 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 198 | GCC_WARN_UNDECLARED_SELECTOR = YES; 199 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 200 | GCC_WARN_UNUSED_FUNCTION = YES; 201 | GCC_WARN_UNUSED_VARIABLE = YES; 202 | IPHONEOS_DEPLOYMENT_TARGET = 16.0; 203 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 204 | MTL_FAST_MATH = YES; 205 | ONLY_ACTIVE_ARCH = YES; 206 | SDKROOT = iphoneos; 207 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 208 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 209 | }; 210 | name = Debug; 211 | }; 212 | 48A26A6D285252A2006113E8 /* Release */ = { 213 | isa = XCBuildConfiguration; 214 | buildSettings = { 215 | ALWAYS_SEARCH_USER_PATHS = NO; 216 | CLANG_ANALYZER_NONNULL = YES; 217 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 218 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; 219 | CLANG_ENABLE_MODULES = YES; 220 | CLANG_ENABLE_OBJC_ARC = YES; 221 | CLANG_ENABLE_OBJC_WEAK = YES; 222 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 223 | CLANG_WARN_BOOL_CONVERSION = YES; 224 | CLANG_WARN_COMMA = YES; 225 | CLANG_WARN_CONSTANT_CONVERSION = YES; 226 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 227 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 228 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 229 | CLANG_WARN_EMPTY_BODY = YES; 230 | CLANG_WARN_ENUM_CONVERSION = YES; 231 | CLANG_WARN_INFINITE_RECURSION = YES; 232 | CLANG_WARN_INT_CONVERSION = YES; 233 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 234 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 235 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 236 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 237 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 238 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 239 | CLANG_WARN_STRICT_PROTOTYPES = YES; 240 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 241 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 242 | CLANG_WARN_UNREACHABLE_CODE = YES; 243 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 244 | COPY_PHASE_STRIP = NO; 245 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 246 | ENABLE_NS_ASSERTIONS = NO; 247 | ENABLE_STRICT_OBJC_MSGSEND = YES; 248 | GCC_C_LANGUAGE_STANDARD = gnu11; 249 | GCC_NO_COMMON_BLOCKS = YES; 250 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 251 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 252 | GCC_WARN_UNDECLARED_SELECTOR = YES; 253 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 254 | GCC_WARN_UNUSED_FUNCTION = YES; 255 | GCC_WARN_UNUSED_VARIABLE = YES; 256 | IPHONEOS_DEPLOYMENT_TARGET = 16.0; 257 | MTL_ENABLE_DEBUG_INFO = NO; 258 | MTL_FAST_MATH = YES; 259 | SDKROOT = iphoneos; 260 | SWIFT_COMPILATION_MODE = wholemodule; 261 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 262 | VALIDATE_PRODUCT = YES; 263 | }; 264 | name = Release; 265 | }; 266 | 48A26A6F285252A2006113E8 /* Debug */ = { 267 | isa = XCBuildConfiguration; 268 | buildSettings = { 269 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 270 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 271 | CODE_SIGN_STYLE = Automatic; 272 | CURRENT_PROJECT_VERSION = 1; 273 | DEVELOPMENT_ASSET_PATHS = "\"VariableType/Preview Content\""; 274 | DEVELOPMENT_TEAM = X8UAQWJ2PH; 275 | ENABLE_PREVIEWS = YES; 276 | GENERATE_INFOPLIST_FILE = YES; 277 | INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; 278 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 279 | INFOPLIST_KEY_UILaunchScreen_Generation = YES; 280 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 281 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 282 | LD_RUNPATH_SEARCH_PATHS = ( 283 | "$(inherited)", 284 | "@executable_path/Frameworks", 285 | ); 286 | MARKETING_VERSION = 1.0; 287 | PRODUCT_BUNDLE_IDENTIFIER = com.philipcdavis.VariableType; 288 | PRODUCT_NAME = "$(TARGET_NAME)"; 289 | SWIFT_EMIT_LOC_STRINGS = YES; 290 | SWIFT_VERSION = 5.0; 291 | TARGETED_DEVICE_FAMILY = "1,2"; 292 | }; 293 | name = Debug; 294 | }; 295 | 48A26A70285252A2006113E8 /* Release */ = { 296 | isa = XCBuildConfiguration; 297 | buildSettings = { 298 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 299 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 300 | CODE_SIGN_STYLE = Automatic; 301 | CURRENT_PROJECT_VERSION = 1; 302 | DEVELOPMENT_ASSET_PATHS = "\"VariableType/Preview Content\""; 303 | DEVELOPMENT_TEAM = X8UAQWJ2PH; 304 | ENABLE_PREVIEWS = YES; 305 | GENERATE_INFOPLIST_FILE = YES; 306 | INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; 307 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 308 | INFOPLIST_KEY_UILaunchScreen_Generation = YES; 309 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 310 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 311 | LD_RUNPATH_SEARCH_PATHS = ( 312 | "$(inherited)", 313 | "@executable_path/Frameworks", 314 | ); 315 | MARKETING_VERSION = 1.0; 316 | PRODUCT_BUNDLE_IDENTIFIER = com.philipcdavis.VariableType; 317 | PRODUCT_NAME = "$(TARGET_NAME)"; 318 | SWIFT_EMIT_LOC_STRINGS = YES; 319 | SWIFT_VERSION = 5.0; 320 | TARGETED_DEVICE_FAMILY = "1,2"; 321 | }; 322 | name = Release; 323 | }; 324 | /* End XCBuildConfiguration section */ 325 | 326 | /* Begin XCConfigurationList section */ 327 | 48A26A5B285252A1006113E8 /* Build configuration list for PBXProject "VariableType" */ = { 328 | isa = XCConfigurationList; 329 | buildConfigurations = ( 330 | 48A26A6C285252A2006113E8 /* Debug */, 331 | 48A26A6D285252A2006113E8 /* Release */, 332 | ); 333 | defaultConfigurationIsVisible = 0; 334 | defaultConfigurationName = Release; 335 | }; 336 | 48A26A6E285252A2006113E8 /* Build configuration list for PBXNativeTarget "VariableType" */ = { 337 | isa = XCConfigurationList; 338 | buildConfigurations = ( 339 | 48A26A6F285252A2006113E8 /* Debug */, 340 | 48A26A70285252A2006113E8 /* Release */, 341 | ); 342 | defaultConfigurationIsVisible = 0; 343 | defaultConfigurationName = Release; 344 | }; 345 | /* End XCConfigurationList section */ 346 | }; 347 | rootObject = 48A26A58285252A1006113E8 /* Project object */; 348 | } 349 | -------------------------------------------------------------------------------- /VariableType.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /VariableType.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /VariableType.xcodeproj/xcuserdata/philipdavis.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | VariableType.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /VariableType/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /VariableType/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "platform" : "ios", 6 | "size" : "1024x1024" 7 | } 8 | ], 9 | "info" : { 10 | "author" : "xcode", 11 | "version" : 1 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /VariableType/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /VariableType/ContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // VariableType 4 | // 5 | // Created by Philip Davis on 6/9/22. 6 | // 7 | 8 | import SwiftUI 9 | import UIKit 10 | 11 | extension UIFont { 12 | func withOptions(weight: Double, width: Double) -> UIFont { 13 | let newDescriptor = fontDescriptor.addingAttributes([.traits: [ 14 | UIFontDescriptor.TraitKey.weight: weight, 15 | UIFontDescriptor.TraitKey.width: width, 16 | ] 17 | ]) 18 | return UIFont(descriptor: newDescriptor, size: pointSize) 19 | } 20 | } 21 | 22 | struct ContentView: View { 23 | @State private var fontWeight = 0.0 24 | @State private var fontWidth = 0.0 25 | @State private var fontSlant = 0.0 26 | @State private var fontSize = 40.0 27 | 28 | var body: some View { 29 | ZStack { 30 | Color.black.ignoresSafeArea() 31 | VStack(alignment: .leading) { 32 | Text("Variable Type").font(Font(UIFont.systemFont(ofSize: fontSize).withOptions(weight: fontWeight, width: fontWidth))) 33 | .animation(.linear(duration: 0.07), value: [fontWeight]) 34 | .frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height - 300) 35 | .foregroundColor(.white) 36 | Spacer() 37 | VStack(spacing: 16) { 38 | IKSlider(value: $fontWeight, min: -1.0, max: 1.0, increment: 0.1, minLabel: "Light", maxLabel: "Heavy") 39 | 40 | IKSlider(value: $fontSize, min: 24, max: 220, increment: 1.0, minLabel: "Small", maxLabel: "Large") 41 | IKSlider(value: $fontWidth, min: -1.0, max: 1.0, increment: 0.1, minLabel: "Condensed", maxLabel: "Expanded") 42 | }.padding(.bottom, 120) 43 | 44 | 45 | 46 | } 47 | } 48 | 49 | } 50 | } 51 | 52 | struct ContentView_Previews: PreviewProvider { 53 | static var previews: some View { 54 | ContentView() 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /VariableType/IKSlider.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IKSlider.swift 3 | // VariableType 4 | // 5 | // Created by Philip Davis on 6/9/22. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct IKSlider: View { 11 | @Binding var value: Double 12 | let min: Double 13 | let max: Double 14 | let increment: Double 15 | let minLabel: String 16 | let maxLabel: String 17 | 18 | 19 | var body: some View { 20 | VStack { 21 | 22 | 23 | ZStack { 24 | Slider( 25 | value: $value, 26 | in: min...max, 27 | step:increment 28 | ).tint(.yellow) 29 | } 30 | 31 | 32 | HStack { 33 | 34 | 35 | Text(minLabel).foregroundColor(.white.opacity(0.6)) 36 | Spacer() 37 | Text(maxLabel).foregroundColor(.white.opacity(0.6)) 38 | 39 | 40 | } 41 | 42 | }.padding(20) 43 | .background(.white.opacity(0.1)) 44 | .clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous)) 45 | 46 | } 47 | } 48 | 49 | -------------------------------------------------------------------------------- /VariableType/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /VariableType/VariableTypeApp.swift: -------------------------------------------------------------------------------- 1 | // 2 | // VariableTypeApp.swift 3 | // VariableType 4 | // 5 | // Created by Philip Davis on 6/9/22. 6 | // 7 | 8 | import SwiftUI 9 | 10 | @main 11 | struct VariableTypeApp: App { 12 | var body: some Scene { 13 | WindowGroup { 14 | ContentView() 15 | } 16 | } 17 | } 18 | --------------------------------------------------------------------------------