From 80100d3fa6e6022bcd62b7e88a01dafd4b7a5414 Mon Sep 17 00:00:00 2001 From: taka-2120 Date: Mon, 7 Apr 2025 21:47:02 +0900 Subject: [PATCH 1/9] Remove the test target --- Package.swift | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Package.swift b/Package.swift index 64eb5c4..36f8eb8 100644 --- a/Package.swift +++ b/Package.swift @@ -18,9 +18,5 @@ let package = Package( .process("Localizable.xcstrings"), ] ), - .testTarget( - name: "AlertPresentableTests", - dependencies: ["AlertPresentable"] - ), ] ) From 8d6519d80b5f460119c409c1e1af9aeb5b50f7ed Mon Sep 17 00:00:00 2001 From: taka-2120 Date: Mon, 7 Apr 2025 21:47:12 +0900 Subject: [PATCH 2/9] Update LICENSE --- LICENSE | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/LICENSE b/LICENSE index 1358af0..8d2eb8c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,16 +1,8 @@ -MIT License +The MIT License (MIT) +Copyright © 2025 Yu Takahashi -Copyright 2024 Yu Takahashi +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: -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. +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -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. \ No newline at end of file +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. From 67f835ce7434946baf5626f6e2d7da0e4c5866ab Mon Sep 17 00:00:00 2001 From: taka-2120 Date: Mon, 7 Apr 2025 21:47:20 +0900 Subject: [PATCH 3/9] Modify README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6f8d964..d095f86 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Show native alerts from ViewModel with ease. 1. Setup `AlertController` - Using View Model - + a. Add `AlertPresentable` protocol to your class (like view model). ```swift @@ -92,7 +92,7 @@ Show native alerts from ViewModel with ease. ``` - Using View Only (Above 1.1.0 or later) - + ```swift import AlertPresentable @@ -105,7 +105,7 @@ Show native alerts from ViewModel with ease. } } ``` - + 2. Call `showAlert` function to show the alert. ```swift @@ -128,5 +128,5 @@ Show native alerts from ViewModel with ease. .init(label: "Details...") { // Transition to the news page... } - ]) + ]) ``` From 66914843b39ae7cd9f6bc862ed9c22ccbea763b9 Mon Sep 17 00:00:00 2001 From: taka-2120 Date: Mon, 7 Apr 2025 21:47:31 +0900 Subject: [PATCH 4/9] Add SwiftFormat configurations --- .swift-version | 1 + .swiftformat | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 .swift-version create mode 100644 .swiftformat diff --git a/.swift-version b/.swift-version new file mode 100644 index 0000000..e8f1734 --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +6.1 \ No newline at end of file diff --git a/.swiftformat b/.swiftformat new file mode 100644 index 0000000..1ee91f1 --- /dev/null +++ b/.swiftformat @@ -0,0 +1,2 @@ +--languagemode 6 +--header "" From d0ce77106707601def3843c0cba70b655240f60c Mon Sep 17 00:00:00 2001 From: taka-2120 Date: Mon, 7 Apr 2025 21:47:48 +0900 Subject: [PATCH 5/9] Remove test related files --- Tests/AlertPresentableTests/AlertPresentableTests.swift | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 Tests/AlertPresentableTests/AlertPresentableTests.swift diff --git a/Tests/AlertPresentableTests/AlertPresentableTests.swift b/Tests/AlertPresentableTests/AlertPresentableTests.swift deleted file mode 100644 index 4c41f24..0000000 --- a/Tests/AlertPresentableTests/AlertPresentableTests.swift +++ /dev/null @@ -1,6 +0,0 @@ -@testable import AlertPresentable -import Testing - -@Test func example() async throws { - // Write your test here and use APIs like `#expect(...)` to check expected conditions. -} From 5d444a0e223e9a389262feea8ca95d9e2fd1a8f6 Mon Sep 17 00:00:00 2001 From: taka-2120 Date: Mon, 7 Apr 2025 21:48:01 +0900 Subject: [PATCH 6/9] Add example project --- .../project.pbxproj | 354 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../AlertPresentableExampleApp.swift | 10 + .../AccentColor.colorset/Contents.json | 11 + .../AppIcon.appiconset/Contents.json | 35 ++ .../Assets.xcassets/Contents.json | 6 + .../AlertPresentableExample/ContentView.swift | 61 +++ .../Preview Assets.xcassets/Contents.json | 6 + 8 files changed, 490 insertions(+) create mode 100644 AlertPresentableExample/AlertPresentableExample.xcodeproj/project.pbxproj create mode 100644 AlertPresentableExample/AlertPresentableExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 AlertPresentableExample/AlertPresentableExample/AlertPresentableExampleApp.swift create mode 100644 AlertPresentableExample/AlertPresentableExample/Assets.xcassets/AccentColor.colorset/Contents.json create mode 100644 AlertPresentableExample/AlertPresentableExample/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 AlertPresentableExample/AlertPresentableExample/Assets.xcassets/Contents.json create mode 100644 AlertPresentableExample/AlertPresentableExample/ContentView.swift create mode 100644 AlertPresentableExample/AlertPresentableExample/Preview Content/Preview Assets.xcassets/Contents.json diff --git a/AlertPresentableExample/AlertPresentableExample.xcodeproj/project.pbxproj b/AlertPresentableExample/AlertPresentableExample.xcodeproj/project.pbxproj new file mode 100644 index 0000000..e9b15f9 --- /dev/null +++ b/AlertPresentableExample/AlertPresentableExample.xcodeproj/project.pbxproj @@ -0,0 +1,354 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 77; + objects = { + +/* Begin PBXBuildFile section */ + 9A08D9162DA351C900A3F486 /* AlertPresentable in Frameworks */ = {isa = PBXBuildFile; productRef = 9A08D9152DA351C900A3F486 /* AlertPresentable */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 9A08D8FA2DA3515A00A3F486 /* AlertPresentableExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AlertPresentableExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFileSystemSynchronizedRootGroup section */ + 9A08D8FC2DA3515A00A3F486 /* AlertPresentableExample */ = { + isa = PBXFileSystemSynchronizedRootGroup; + path = AlertPresentableExample; + sourceTree = ""; + }; +/* End PBXFileSystemSynchronizedRootGroup section */ + +/* Begin PBXFrameworksBuildPhase section */ + 9A08D8F72DA3515A00A3F486 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 9A08D9162DA351C900A3F486 /* AlertPresentable in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9A08D8F12DA3515A00A3F486 = { + isa = PBXGroup; + children = ( + 9A08D8FC2DA3515A00A3F486 /* AlertPresentableExample */, + 9A08D8FB2DA3515A00A3F486 /* Products */, + ); + sourceTree = ""; + }; + 9A08D8FB2DA3515A00A3F486 /* Products */ = { + isa = PBXGroup; + children = ( + 9A08D8FA2DA3515A00A3F486 /* AlertPresentableExample.app */, + ); + name = Products; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 9A08D8F92DA3515A00A3F486 /* AlertPresentableExample */ = { + isa = PBXNativeTarget; + buildConfigurationList = 9A08D9082DA3515C00A3F486 /* Build configuration list for PBXNativeTarget "AlertPresentableExample" */; + buildPhases = ( + 9A08D8F62DA3515A00A3F486 /* Sources */, + 9A08D8F72DA3515A00A3F486 /* Frameworks */, + 9A08D8F82DA3515A00A3F486 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + fileSystemSynchronizedGroups = ( + 9A08D8FC2DA3515A00A3F486 /* AlertPresentableExample */, + ); + name = AlertPresentableExample; + packageProductDependencies = ( + 9A08D9152DA351C900A3F486 /* AlertPresentable */, + ); + productName = AlertPresentableExample; + productReference = 9A08D8FA2DA3515A00A3F486 /* AlertPresentableExample.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 9A08D8F22DA3515A00A3F486 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1620; + LastUpgradeCheck = 1620; + TargetAttributes = { + 9A08D8F92DA3515A00A3F486 = { + CreatedOnToolsVersion = 16.2; + }; + }; + }; + buildConfigurationList = 9A08D8F52DA3515A00A3F486 /* Build configuration list for PBXProject "AlertPresentableExample" */; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 9A08D8F12DA3515A00A3F486; + minimizedProjectReferenceProxies = 1; + packageReferences = ( + 9A08D9142DA351C900A3F486 /* XCLocalSwiftPackageReference "../../AlertPresentable" */, + ); + preferredProjectObjectVersion = 77; + productRefGroup = 9A08D8FB2DA3515A00A3F486 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 9A08D8F92DA3515A00A3F486 /* AlertPresentableExample */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 9A08D8F82DA3515A00A3F486 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 9A08D8F62DA3515A00A3F486 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 9A08D9062DA3515C00A3F486 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 18.2; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 6.0; + }; + name = Debug; + }; + 9A08D9072DA3515C00A3F486 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 18.2; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_VERSION = 6.0; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 9A08D9092DA3515C00A3F486 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"AlertPresentableExample/Preview Content\""; + DEVELOPMENT_TEAM = ""; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.AlertPresentableExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 9A08D90A2DA3515C00A3F486 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"AlertPresentableExample/Preview Content\""; + DEVELOPMENT_TEAM = ""; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.AlertPresentableExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 9A08D8F52DA3515A00A3F486 /* Build configuration list for PBXProject "AlertPresentableExample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9A08D9062DA3515C00A3F486 /* Debug */, + 9A08D9072DA3515C00A3F486 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 9A08D9082DA3515C00A3F486 /* Build configuration list for PBXNativeTarget "AlertPresentableExample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9A08D9092DA3515C00A3F486 /* Debug */, + 9A08D90A2DA3515C00A3F486 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCLocalSwiftPackageReference section */ + 9A08D9142DA351C900A3F486 /* XCLocalSwiftPackageReference "../../AlertPresentable" */ = { + isa = XCLocalSwiftPackageReference; + relativePath = ../../AlertPresentable; + }; +/* End XCLocalSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 9A08D9152DA351C900A3F486 /* AlertPresentable */ = { + isa = XCSwiftPackageProductDependency; + productName = AlertPresentable; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 9A08D8F22DA3515A00A3F486 /* Project object */; +} diff --git a/AlertPresentableExample/AlertPresentableExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/AlertPresentableExample/AlertPresentableExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/AlertPresentableExample/AlertPresentableExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/AlertPresentableExample/AlertPresentableExample/AlertPresentableExampleApp.swift b/AlertPresentableExample/AlertPresentableExample/AlertPresentableExampleApp.swift new file mode 100644 index 0000000..d91fd31 --- /dev/null +++ b/AlertPresentableExample/AlertPresentableExample/AlertPresentableExampleApp.swift @@ -0,0 +1,10 @@ +import SwiftUI + +@main +struct AlertPresentableExampleApp: App { + var body: some Scene { + WindowGroup { + ContentView() + } + } +} diff --git a/AlertPresentableExample/AlertPresentableExample/Assets.xcassets/AccentColor.colorset/Contents.json b/AlertPresentableExample/AlertPresentableExample/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/AlertPresentableExample/AlertPresentableExample/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/AlertPresentableExample/AlertPresentableExample/Assets.xcassets/AppIcon.appiconset/Contents.json b/AlertPresentableExample/AlertPresentableExample/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..2305880 --- /dev/null +++ b/AlertPresentableExample/AlertPresentableExample/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,35 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "tinted" + } + ], + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/AlertPresentableExample/AlertPresentableExample/Assets.xcassets/Contents.json b/AlertPresentableExample/AlertPresentableExample/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/AlertPresentableExample/AlertPresentableExample/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/AlertPresentableExample/AlertPresentableExample/ContentView.swift b/AlertPresentableExample/AlertPresentableExample/ContentView.swift new file mode 100644 index 0000000..39b6109 --- /dev/null +++ b/AlertPresentableExample/AlertPresentableExample/ContentView.swift @@ -0,0 +1,61 @@ +import AlertPresentable +import SwiftUI + +struct ContentView: View { + @State private var alertController = AlertController() + + var body: some View { + VStack { + Button("Error") { + alertController.showAlert(mode: .error, message: "This is an error dialog.") + } + + Button("Warning") { + alertController.showAlert(mode: .warning, message: "This is a warning dialog.") + } + + Button("Yes / No") { + alertController.showAlert( + title: "Yes/No", + message: "This is a yes / no dialog.", + actions: [ + .no, + .yes, + ] + ) + } + + Button("Custom Actions") { + alertController.showAlert( + title: "Custom Actions", + message: "This is a customized dialog.", + actions: [ + .no, + .yes { + print("Hello, world!") + }, + ] + ) + } + + Button("Custom Buttons") { + alertController.showAlert( + title: "Custom Actions", + message: "This is a customized dialog.", + actions: [ + .init(label: "Hello", role: .cancel), + .init(label: "World", role: .destructive) { + print("Hello, world!") + }, + ] + ) + } + } + .padding() + .alert(using: $alertController) + } +} + +#Preview { + ContentView() +} diff --git a/AlertPresentableExample/AlertPresentableExample/Preview Content/Preview Assets.xcassets/Contents.json b/AlertPresentableExample/AlertPresentableExample/Preview Content/Preview Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/AlertPresentableExample/AlertPresentableExample/Preview Content/Preview Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} From 9e963e34866f5d334bc16986771530bf6d9cbfbf Mon Sep 17 00:00:00 2001 From: taka-2120 Date: Mon, 7 Apr 2025 21:48:30 +0900 Subject: [PATCH 7/9] Fix a missing dismiss action --- Sources/AlertPresentable/View+Alert.swift | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Sources/AlertPresentable/View+Alert.swift b/Sources/AlertPresentable/View+Alert.swift index 3c6f922..30e6beb 100644 --- a/Sources/AlertPresentable/View+Alert.swift +++ b/Sources/AlertPresentable/View+Alert.swift @@ -1,10 +1,3 @@ -// -// View+Alert.swift -// FTPresentation -// -// Created by Yu Takahashi on 12/9/24. -// - import SwiftUI public extension View { @@ -37,6 +30,7 @@ private struct CommonAlert: ViewModifier { Button(action.label, role: action.role) { if let action = action.action { action() + alertController.isPresented = false return } alertController.isPresented = false From 588dab8673fe05fb239198b85d1d5dc65ff7df13 Mon Sep 17 00:00:00 2001 From: taka-2120 Date: Mon, 7 Apr 2025 21:48:38 +0900 Subject: [PATCH 8/9] Apply alert title localizations --- .../AlertPresentable/AlertController.swift | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/Sources/AlertPresentable/AlertController.swift b/Sources/AlertPresentable/AlertController.swift index a86cbc7..b7ec4b3 100644 --- a/Sources/AlertPresentable/AlertController.swift +++ b/Sources/AlertPresentable/AlertController.swift @@ -1,18 +1,22 @@ -// -// AlertController.swift -// Components -// -// Created by Yu Takahashi on 12/9/24. -// - import SwiftUI -@Observable +@MainActor @Observable public class AlertController { - public enum Mode: LocalizedStringKey { - case error = "error" - case warning = "warning" - case message = "message" + public enum Mode { + case error + case warning + case message + + var label: String { + switch self { + case .error: + String(localized: String.LocalizationValue("error"), bundle: .module) + case .warning: + String(localized: String.LocalizationValue("warning"), bundle: .module) + case .message: + String(localized: String.LocalizationValue("message"), bundle: .module) + } + } } /// @@ -144,7 +148,8 @@ public class AlertController { /// public func showAlert(mode: Mode, message: String, actions: [Action] = [.ok]) { - title = mode.rawValue + isPresented = false + title = "\(mode.label)" self.message = message if actions.isEmpty { self.actions = [.ok] @@ -162,6 +167,7 @@ public class AlertController { /// - parameter actions: The actions which can be set up multiple actions including predefined ones: `ok`, `yes`, `no`, and `cancel`. If it is empty, automatically applied `ok`. Items in the left of this array are displayed on the left. /// public func showAlert(title: LocalizedStringKey, message: String, actions: [Action] = [.ok]) { + isPresented = false self.title = title self.message = message if actions.isEmpty { From 571ffab7f1b768ee8b4938d6639d6e960c3faf73 Mon Sep 17 00:00:00 2001 From: taka-2120 Date: Mon, 7 Apr 2025 21:53:21 +0900 Subject: [PATCH 9/9] Remove header comments --- Sources/AlertPresentable/AlertPresentableProtocol.swift | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Sources/AlertPresentable/AlertPresentableProtocol.swift b/Sources/AlertPresentable/AlertPresentableProtocol.swift index 512a07d..9f378ad 100644 --- a/Sources/AlertPresentable/AlertPresentableProtocol.swift +++ b/Sources/AlertPresentable/AlertPresentableProtocol.swift @@ -1,10 +1,3 @@ -// -// AlertPresentableProtocol.swift -// FTPresentation -// -// Created by Yu Takahashi on 12/9/24. -// - /// /// `AlertPresentable` protocol is required when you use `alert(using: AlertPresentable)` modifier /// This protocol includes `alertController` variable to configure all necessary structs and values.