├── Notification ├── Notification.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcuserdata │ │ │ └── jordansinger.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── jordansinger.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist └── Notification │ ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json │ ├── ContentView.swift │ ├── Info.plist │ ├── NotificationApp.swift │ ├── Preview Content │ └── Preview Assets.xcassets │ │ └── Contents.json │ └── ToastView.swift └── README.md /Notification/Notification.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 86A50134258E3DFF00D42B72 /* NotificationApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86A50133258E3DFF00D42B72 /* NotificationApp.swift */; }; 11 | 86A50136258E3DFF00D42B72 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86A50135258E3DFF00D42B72 /* ContentView.swift */; }; 12 | 86A50138258E3E0400D42B72 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 86A50137258E3E0400D42B72 /* Assets.xcassets */; }; 13 | 86A5013B258E3E0400D42B72 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 86A5013A258E3E0400D42B72 /* Preview Assets.xcassets */; }; 14 | 86A50144258E3E1100D42B72 /* ToastView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86A50143258E3E1100D42B72 /* ToastView.swift */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXFileReference section */ 18 | 86A50130258E3DFF00D42B72 /* Notification.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Notification.app; sourceTree = BUILT_PRODUCTS_DIR; }; 19 | 86A50133258E3DFF00D42B72 /* NotificationApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationApp.swift; sourceTree = ""; }; 20 | 86A50135258E3DFF00D42B72 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 21 | 86A50137258E3E0400D42B72 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 22 | 86A5013A258E3E0400D42B72 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 23 | 86A5013C258E3E0400D42B72 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 24 | 86A50143258E3E1100D42B72 /* ToastView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToastView.swift; sourceTree = ""; }; 25 | /* End PBXFileReference section */ 26 | 27 | /* Begin PBXFrameworksBuildPhase section */ 28 | 86A5012D258E3DFF00D42B72 /* Frameworks */ = { 29 | isa = PBXFrameworksBuildPhase; 30 | buildActionMask = 2147483647; 31 | files = ( 32 | ); 33 | runOnlyForDeploymentPostprocessing = 0; 34 | }; 35 | /* End PBXFrameworksBuildPhase section */ 36 | 37 | /* Begin PBXGroup section */ 38 | 86A50127258E3DFF00D42B72 = { 39 | isa = PBXGroup; 40 | children = ( 41 | 86A50132258E3DFF00D42B72 /* Notification */, 42 | 86A50131258E3DFF00D42B72 /* Products */, 43 | ); 44 | sourceTree = ""; 45 | }; 46 | 86A50131258E3DFF00D42B72 /* Products */ = { 47 | isa = PBXGroup; 48 | children = ( 49 | 86A50130258E3DFF00D42B72 /* Notification.app */, 50 | ); 51 | name = Products; 52 | sourceTree = ""; 53 | }; 54 | 86A50132258E3DFF00D42B72 /* Notification */ = { 55 | isa = PBXGroup; 56 | children = ( 57 | 86A50133258E3DFF00D42B72 /* NotificationApp.swift */, 58 | 86A50135258E3DFF00D42B72 /* ContentView.swift */, 59 | 86A50143258E3E1100D42B72 /* ToastView.swift */, 60 | 86A50137258E3E0400D42B72 /* Assets.xcassets */, 61 | 86A5013C258E3E0400D42B72 /* Info.plist */, 62 | 86A50139258E3E0400D42B72 /* Preview Content */, 63 | ); 64 | path = Notification; 65 | sourceTree = ""; 66 | }; 67 | 86A50139258E3E0400D42B72 /* Preview Content */ = { 68 | isa = PBXGroup; 69 | children = ( 70 | 86A5013A258E3E0400D42B72 /* Preview Assets.xcassets */, 71 | ); 72 | path = "Preview Content"; 73 | sourceTree = ""; 74 | }; 75 | /* End PBXGroup section */ 76 | 77 | /* Begin PBXNativeTarget section */ 78 | 86A5012F258E3DFF00D42B72 /* Notification */ = { 79 | isa = PBXNativeTarget; 80 | buildConfigurationList = 86A5013F258E3E0400D42B72 /* Build configuration list for PBXNativeTarget "Notification" */; 81 | buildPhases = ( 82 | 86A5012C258E3DFF00D42B72 /* Sources */, 83 | 86A5012D258E3DFF00D42B72 /* Frameworks */, 84 | 86A5012E258E3DFF00D42B72 /* Resources */, 85 | ); 86 | buildRules = ( 87 | ); 88 | dependencies = ( 89 | ); 90 | name = Notification; 91 | productName = Notification; 92 | productReference = 86A50130258E3DFF00D42B72 /* Notification.app */; 93 | productType = "com.apple.product-type.application"; 94 | }; 95 | /* End PBXNativeTarget section */ 96 | 97 | /* Begin PBXProject section */ 98 | 86A50128258E3DFF00D42B72 /* Project object */ = { 99 | isa = PBXProject; 100 | attributes = { 101 | LastSwiftUpdateCheck = 1220; 102 | LastUpgradeCheck = 1220; 103 | TargetAttributes = { 104 | 86A5012F258E3DFF00D42B72 = { 105 | CreatedOnToolsVersion = 12.2; 106 | }; 107 | }; 108 | }; 109 | buildConfigurationList = 86A5012B258E3DFF00D42B72 /* Build configuration list for PBXProject "Notification" */; 110 | compatibilityVersion = "Xcode 9.3"; 111 | developmentRegion = en; 112 | hasScannedForEncodings = 0; 113 | knownRegions = ( 114 | en, 115 | Base, 116 | ); 117 | mainGroup = 86A50127258E3DFF00D42B72; 118 | productRefGroup = 86A50131258E3DFF00D42B72 /* Products */; 119 | projectDirPath = ""; 120 | projectRoot = ""; 121 | targets = ( 122 | 86A5012F258E3DFF00D42B72 /* Notification */, 123 | ); 124 | }; 125 | /* End PBXProject section */ 126 | 127 | /* Begin PBXResourcesBuildPhase section */ 128 | 86A5012E258E3DFF00D42B72 /* Resources */ = { 129 | isa = PBXResourcesBuildPhase; 130 | buildActionMask = 2147483647; 131 | files = ( 132 | 86A5013B258E3E0400D42B72 /* Preview Assets.xcassets in Resources */, 133 | 86A50138258E3E0400D42B72 /* Assets.xcassets in Resources */, 134 | ); 135 | runOnlyForDeploymentPostprocessing = 0; 136 | }; 137 | /* End PBXResourcesBuildPhase section */ 138 | 139 | /* Begin PBXSourcesBuildPhase section */ 140 | 86A5012C258E3DFF00D42B72 /* Sources */ = { 141 | isa = PBXSourcesBuildPhase; 142 | buildActionMask = 2147483647; 143 | files = ( 144 | 86A50136258E3DFF00D42B72 /* ContentView.swift in Sources */, 145 | 86A50144258E3E1100D42B72 /* ToastView.swift in Sources */, 146 | 86A50134258E3DFF00D42B72 /* NotificationApp.swift in Sources */, 147 | ); 148 | runOnlyForDeploymentPostprocessing = 0; 149 | }; 150 | /* End PBXSourcesBuildPhase section */ 151 | 152 | /* Begin XCBuildConfiguration section */ 153 | 86A5013D258E3E0400D42B72 /* Debug */ = { 154 | isa = XCBuildConfiguration; 155 | buildSettings = { 156 | ALWAYS_SEARCH_USER_PATHS = NO; 157 | CLANG_ANALYZER_NONNULL = YES; 158 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 159 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 160 | CLANG_CXX_LIBRARY = "libc++"; 161 | CLANG_ENABLE_MODULES = YES; 162 | CLANG_ENABLE_OBJC_ARC = YES; 163 | CLANG_ENABLE_OBJC_WEAK = YES; 164 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 165 | CLANG_WARN_BOOL_CONVERSION = YES; 166 | CLANG_WARN_COMMA = YES; 167 | CLANG_WARN_CONSTANT_CONVERSION = YES; 168 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 169 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 170 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 171 | CLANG_WARN_EMPTY_BODY = YES; 172 | CLANG_WARN_ENUM_CONVERSION = YES; 173 | CLANG_WARN_INFINITE_RECURSION = YES; 174 | CLANG_WARN_INT_CONVERSION = YES; 175 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 176 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 177 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 178 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 179 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 180 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 181 | CLANG_WARN_STRICT_PROTOTYPES = YES; 182 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 183 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 184 | CLANG_WARN_UNREACHABLE_CODE = YES; 185 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 186 | COPY_PHASE_STRIP = NO; 187 | DEBUG_INFORMATION_FORMAT = dwarf; 188 | ENABLE_STRICT_OBJC_MSGSEND = YES; 189 | ENABLE_TESTABILITY = YES; 190 | GCC_C_LANGUAGE_STANDARD = gnu11; 191 | GCC_DYNAMIC_NO_PIC = NO; 192 | GCC_NO_COMMON_BLOCKS = YES; 193 | GCC_OPTIMIZATION_LEVEL = 0; 194 | GCC_PREPROCESSOR_DEFINITIONS = ( 195 | "DEBUG=1", 196 | "$(inherited)", 197 | ); 198 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 199 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 200 | GCC_WARN_UNDECLARED_SELECTOR = YES; 201 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 202 | GCC_WARN_UNUSED_FUNCTION = YES; 203 | GCC_WARN_UNUSED_VARIABLE = YES; 204 | IPHONEOS_DEPLOYMENT_TARGET = 14.2; 205 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 206 | MTL_FAST_MATH = YES; 207 | ONLY_ACTIVE_ARCH = YES; 208 | SDKROOT = iphoneos; 209 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 210 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 211 | }; 212 | name = Debug; 213 | }; 214 | 86A5013E258E3E0400D42B72 /* Release */ = { 215 | isa = XCBuildConfiguration; 216 | buildSettings = { 217 | ALWAYS_SEARCH_USER_PATHS = NO; 218 | CLANG_ANALYZER_NONNULL = YES; 219 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 220 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 221 | CLANG_CXX_LIBRARY = "libc++"; 222 | CLANG_ENABLE_MODULES = YES; 223 | CLANG_ENABLE_OBJC_ARC = YES; 224 | CLANG_ENABLE_OBJC_WEAK = YES; 225 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 226 | CLANG_WARN_BOOL_CONVERSION = YES; 227 | CLANG_WARN_COMMA = YES; 228 | CLANG_WARN_CONSTANT_CONVERSION = YES; 229 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 230 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 231 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 232 | CLANG_WARN_EMPTY_BODY = YES; 233 | CLANG_WARN_ENUM_CONVERSION = YES; 234 | CLANG_WARN_INFINITE_RECURSION = YES; 235 | CLANG_WARN_INT_CONVERSION = YES; 236 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 237 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 238 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 239 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 240 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 241 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 242 | CLANG_WARN_STRICT_PROTOTYPES = YES; 243 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 244 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 245 | CLANG_WARN_UNREACHABLE_CODE = YES; 246 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 247 | COPY_PHASE_STRIP = NO; 248 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 249 | ENABLE_NS_ASSERTIONS = NO; 250 | ENABLE_STRICT_OBJC_MSGSEND = YES; 251 | GCC_C_LANGUAGE_STANDARD = gnu11; 252 | GCC_NO_COMMON_BLOCKS = YES; 253 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 254 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 255 | GCC_WARN_UNDECLARED_SELECTOR = YES; 256 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 257 | GCC_WARN_UNUSED_FUNCTION = YES; 258 | GCC_WARN_UNUSED_VARIABLE = YES; 259 | IPHONEOS_DEPLOYMENT_TARGET = 14.2; 260 | MTL_ENABLE_DEBUG_INFO = NO; 261 | MTL_FAST_MATH = YES; 262 | SDKROOT = iphoneos; 263 | SWIFT_COMPILATION_MODE = wholemodule; 264 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 265 | VALIDATE_PRODUCT = YES; 266 | }; 267 | name = Release; 268 | }; 269 | 86A50140258E3E0400D42B72 /* Debug */ = { 270 | isa = XCBuildConfiguration; 271 | buildSettings = { 272 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 273 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 274 | CODE_SIGN_STYLE = Automatic; 275 | DEVELOPMENT_ASSET_PATHS = "\"Notification/Preview Content\""; 276 | ENABLE_PREVIEWS = YES; 277 | INFOPLIST_FILE = Notification/Info.plist; 278 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 279 | LD_RUNPATH_SEARCH_PATHS = ( 280 | "$(inherited)", 281 | "@executable_path/Frameworks", 282 | ); 283 | PRODUCT_BUNDLE_IDENTIFIER = demo.Notification; 284 | PRODUCT_NAME = "$(TARGET_NAME)"; 285 | SWIFT_VERSION = 5.0; 286 | TARGETED_DEVICE_FAMILY = "1,2"; 287 | }; 288 | name = Debug; 289 | }; 290 | 86A50141258E3E0400D42B72 /* Release */ = { 291 | isa = XCBuildConfiguration; 292 | buildSettings = { 293 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 294 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 295 | CODE_SIGN_STYLE = Automatic; 296 | DEVELOPMENT_ASSET_PATHS = "\"Notification/Preview Content\""; 297 | ENABLE_PREVIEWS = YES; 298 | INFOPLIST_FILE = Notification/Info.plist; 299 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 300 | LD_RUNPATH_SEARCH_PATHS = ( 301 | "$(inherited)", 302 | "@executable_path/Frameworks", 303 | ); 304 | PRODUCT_BUNDLE_IDENTIFIER = demo.Notification; 305 | PRODUCT_NAME = "$(TARGET_NAME)"; 306 | SWIFT_VERSION = 5.0; 307 | TARGETED_DEVICE_FAMILY = "1,2"; 308 | }; 309 | name = Release; 310 | }; 311 | /* End XCBuildConfiguration section */ 312 | 313 | /* Begin XCConfigurationList section */ 314 | 86A5012B258E3DFF00D42B72 /* Build configuration list for PBXProject "Notification" */ = { 315 | isa = XCConfigurationList; 316 | buildConfigurations = ( 317 | 86A5013D258E3E0400D42B72 /* Debug */, 318 | 86A5013E258E3E0400D42B72 /* Release */, 319 | ); 320 | defaultConfigurationIsVisible = 0; 321 | defaultConfigurationName = Release; 322 | }; 323 | 86A5013F258E3E0400D42B72 /* Build configuration list for PBXNativeTarget "Notification" */ = { 324 | isa = XCConfigurationList; 325 | buildConfigurations = ( 326 | 86A50140258E3E0400D42B72 /* Debug */, 327 | 86A50141258E3E0400D42B72 /* Release */, 328 | ); 329 | defaultConfigurationIsVisible = 0; 330 | defaultConfigurationName = Release; 331 | }; 332 | /* End XCConfigurationList section */ 333 | }; 334 | rootObject = 86A50128258E3DFF00D42B72 /* Project object */; 335 | } 336 | -------------------------------------------------------------------------------- /Notification/Notification.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Notification/Notification.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Notification/Notification.xcodeproj/project.xcworkspace/xcuserdata/jordansinger.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jordansinger/swiftui-ios-toast-notification/e8352fc7458b2abdd5b7e2aa31c71d7f2298ed83/Notification/Notification.xcodeproj/project.xcworkspace/xcuserdata/jordansinger.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Notification/Notification.xcodeproj/xcuserdata/jordansinger.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Notification.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Notification/Notification/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 | -------------------------------------------------------------------------------- /Notification/Notification/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 | -------------------------------------------------------------------------------- /Notification/Notification/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Notification/Notification/ContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // Notification 4 | // 5 | // Created by Jordan Singer on 12/19/20. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct ContentView: View { 11 | @State var notificationIsVisible = false 12 | 13 | var body: some View { 14 | ZStack { 15 | ZStack(alignment: .top) { 16 | Color(UIColor.systemBackground) 17 | .edgesIgnoringSafeArea(.all) 18 | ToastView(image: "airpodspro", title: "AirPods Pro", subtitle: "Connected") 19 | .offset(y: notificationIsVisible ? 0 : -128) 20 | .animation( 21 | Animation.spring() 22 | ) 23 | .onTapGesture(perform: toggleVisibility) 24 | } 25 | .padding() 26 | .onAppear(perform: toggleVisibility) 27 | 28 | Button(action: toggleVisibility) { 29 | Text(notificationIsVisible ? "Hide" : "Show") 30 | .foregroundColor(.primary) 31 | } 32 | } 33 | } 34 | 35 | func toggleVisibility() { 36 | self.notificationIsVisible.toggle() 37 | } 38 | } 39 | 40 | struct ContentView_Previews: PreviewProvider { 41 | static var previews: some View { 42 | ContentView() 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Notification/Notification/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 | 28 | UIApplicationSupportsIndirectInputEvents 29 | 30 | UILaunchScreen 31 | 32 | UIRequiredDeviceCapabilities 33 | 34 | armv7 35 | 36 | UISupportedInterfaceOrientations 37 | 38 | UIInterfaceOrientationPortrait 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UISupportedInterfaceOrientations~ipad 43 | 44 | UIInterfaceOrientationPortrait 45 | UIInterfaceOrientationPortraitUpsideDown 46 | UIInterfaceOrientationLandscapeLeft 47 | UIInterfaceOrientationLandscapeRight 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /Notification/Notification/NotificationApp.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NotificationApp.swift 3 | // Notification 4 | // 5 | // Created by Jordan Singer on 12/19/20. 6 | // 7 | 8 | import SwiftUI 9 | 10 | @main 11 | struct NotificationApp: App { 12 | var body: some Scene { 13 | WindowGroup { 14 | ContentView() 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Notification/Notification/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Notification/Notification/ToastView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ToastView.swift 3 | // Notification 4 | // 5 | // Created by Jordan Singer on 12/19/20. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct ToastView: View { 11 | @Environment(\.colorScheme) var colorScheme 12 | var image: String? 13 | var title: String 14 | var subtitle: String? 15 | 16 | var body: some View { 17 | HStack(spacing: 16) { 18 | if image != nil { 19 | Image(systemName: image!) 20 | .resizable() 21 | .scaledToFit() 22 | .frame(width: 28, height: 28) 23 | } 24 | 25 | VStack(alignment: .center) { 26 | Text(title) 27 | .lineLimit(1) 28 | .font(.headline) 29 | 30 | if subtitle != nil { 31 | Text(subtitle!) 32 | .lineLimit(1) 33 | .font(.subheadline) 34 | .foregroundColor(.secondary) 35 | } 36 | } 37 | .padding(image == nil ? .horizontal : .trailing) 38 | } 39 | .padding(.horizontal) 40 | .frame(height: 56) 41 | .background(Color(colorScheme == .dark ? UIColor.secondarySystemBackground : UIColor.systemBackground)) 42 | .cornerRadius(28) 43 | .shadow(color: Color(UIColor.black.withAlphaComponent(0.08)), radius: 8, x: 0, y: 4) 44 | } 45 | } 46 | 47 | struct ToastView_Previews: PreviewProvider { 48 | static var previews: some View { 49 | VStack(spacing: 24) { 50 | ToastView(image: "airpodspro", title: "AirPods Pro", subtitle: "Connected") 51 | ToastView(title: "Safari pasted from Notes") 52 | ToastView(image: "headphones", title: "AirPods Max", subtitle: "50%") 53 | .environment(\.colorScheme, .dark) 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SwiftUI iOS 14 toast notification 2 | 3 | ![Toast](https://user-images.githubusercontent.com/110813/102691949-2e48cc00-41de-11eb-8209-5e54ed45b1c7.png) 4 | --------------------------------------------------------------------------------