diff --git a/Examples/Flux/SwiftUI-Flux.xcodeproj/project.pbxproj b/Examples/Flux/SwiftUI-Flux.xcodeproj/project.pbxproj new file mode 100755 index 0000000..3c3b710 --- /dev/null +++ b/Examples/Flux/SwiftUI-Flux.xcodeproj/project.pbxproj @@ -0,0 +1,349 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 6B90B43122A92BBE0017BE2B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B90B43022A92BBE0017BE2B /* AppDelegate.swift */; }; + 6B90B43322A92BBE0017BE2B /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B90B43222A92BBE0017BE2B /* SceneDelegate.swift */; }; + 6B90B43722A92BBF0017BE2B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6B90B43622A92BBF0017BE2B /* Assets.xcassets */; }; + 6B90B43A22A92BBF0017BE2B /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6B90B43922A92BBF0017BE2B /* Preview Assets.xcassets */; }; + 6B90B43D22A92BBF0017BE2B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6B90B43B22A92BBF0017BE2B /* LaunchScreen.storyboard */; }; + 6B90B44622A92C3B0017BE2B /* Store.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B90B44422A92C3B0017BE2B /* Store.swift */; }; + 6B90B44722A92C3B0017BE2B /* CounterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B90B44522A92C3B0017BE2B /* CounterView.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 6B90B42D22A92BBE0017BE2B /* SwiftUI-Flux.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "SwiftUI-Flux.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 6B90B43022A92BBE0017BE2B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 6B90B43222A92BBE0017BE2B /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 6B90B43622A92BBF0017BE2B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 6B90B43922A92BBF0017BE2B /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; + 6B90B43C22A92BBF0017BE2B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 6B90B43E22A92BBF0017BE2B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 6B90B44422A92C3B0017BE2B /* Store.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Store.swift; sourceTree = ""; }; + 6B90B44522A92C3B0017BE2B /* CounterView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CounterView.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 6B90B42A22A92BBE0017BE2B /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 6B90B42422A92BBE0017BE2B = { + isa = PBXGroup; + children = ( + 6B90B42F22A92BBE0017BE2B /* SwiftUI-Flux */, + 6B90B42E22A92BBE0017BE2B /* Products */, + ); + sourceTree = ""; + }; + 6B90B42E22A92BBE0017BE2B /* Products */ = { + isa = PBXGroup; + children = ( + 6B90B42D22A92BBE0017BE2B /* SwiftUI-Flux.app */, + ); + name = Products; + sourceTree = ""; + }; + 6B90B42F22A92BBE0017BE2B /* SwiftUI-Flux */ = { + isa = PBXGroup; + children = ( + 6B90B44422A92C3B0017BE2B /* Store.swift */, + 6B90B44522A92C3B0017BE2B /* CounterView.swift */, + 6B90B43022A92BBE0017BE2B /* AppDelegate.swift */, + 6B90B43222A92BBE0017BE2B /* SceneDelegate.swift */, + 6B90B43622A92BBF0017BE2B /* Assets.xcassets */, + 6B90B43B22A92BBF0017BE2B /* LaunchScreen.storyboard */, + 6B90B43E22A92BBF0017BE2B /* Info.plist */, + 6B90B43822A92BBF0017BE2B /* Preview Content */, + ); + path = "SwiftUI-Flux"; + sourceTree = ""; + }; + 6B90B43822A92BBF0017BE2B /* Preview Content */ = { + isa = PBXGroup; + children = ( + 6B90B43922A92BBF0017BE2B /* Preview Assets.xcassets */, + ); + path = "Preview Content"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 6B90B42C22A92BBE0017BE2B /* SwiftUI-Flux */ = { + isa = PBXNativeTarget; + buildConfigurationList = 6B90B44122A92BBF0017BE2B /* Build configuration list for PBXNativeTarget "SwiftUI-Flux" */; + buildPhases = ( + 6B90B42922A92BBE0017BE2B /* Sources */, + 6B90B42A22A92BBE0017BE2B /* Frameworks */, + 6B90B42B22A92BBE0017BE2B /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "SwiftUI-Flux"; + productName = "SwiftUI-Flux"; + productReference = 6B90B42D22A92BBE0017BE2B /* SwiftUI-Flux.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 6B90B42522A92BBE0017BE2B /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1100; + LastUpgradeCheck = 1100; + ORGANIZATIONNAME = "Ryo Aoyama"; + TargetAttributes = { + 6B90B42C22A92BBE0017BE2B = { + CreatedOnToolsVersion = 11.0; + }; + }; + }; + buildConfigurationList = 6B90B42822A92BBE0017BE2B /* Build configuration list for PBXProject "SwiftUI-Flux" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 6B90B42422A92BBE0017BE2B; + productRefGroup = 6B90B42E22A92BBE0017BE2B /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 6B90B42C22A92BBE0017BE2B /* SwiftUI-Flux */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 6B90B42B22A92BBE0017BE2B /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6B90B43D22A92BBF0017BE2B /* LaunchScreen.storyboard in Resources */, + 6B90B43A22A92BBF0017BE2B /* Preview Assets.xcassets in Resources */, + 6B90B43722A92BBF0017BE2B /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 6B90B42922A92BBE0017BE2B /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 6B90B43122A92BBE0017BE2B /* AppDelegate.swift in Sources */, + 6B90B43322A92BBE0017BE2B /* SceneDelegate.swift in Sources */, + 6B90B44622A92C3B0017BE2B /* Store.swift in Sources */, + 6B90B44722A92C3B0017BE2B /* CounterView.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 6B90B43B22A92BBF0017BE2B /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 6B90B43C22A92BBF0017BE2B /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 6B90B43F22A92BBF0017BE2B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_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; + GCC_C_LANGUAGE_STANDARD = gnu11; + 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 = 13.0; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 6B90B44022A92BBF0017BE2B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_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; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 6B90B44222A92BBF0017BE2B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_ASSET_PATHS = "SwiftUI-Flux/Preview\\ Content"; + ENABLE_PREVIEWS = YES; + INFOPLIST_FILE = "SwiftUI-Flux/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.ryo.SwiftUI-Flux"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 6B90B44322A92BBF0017BE2B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_ASSET_PATHS = "SwiftUI-Flux/Preview\\ Content"; + ENABLE_PREVIEWS = YES; + INFOPLIST_FILE = "SwiftUI-Flux/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.ryo.SwiftUI-Flux"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 6B90B42822A92BBE0017BE2B /* Build configuration list for PBXProject "SwiftUI-Flux" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6B90B43F22A92BBF0017BE2B /* Debug */, + 6B90B44022A92BBF0017BE2B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 6B90B44122A92BBF0017BE2B /* Build configuration list for PBXNativeTarget "SwiftUI-Flux" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 6B90B44222A92BBF0017BE2B /* Debug */, + 6B90B44322A92BBF0017BE2B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 6B90B42522A92BBE0017BE2B /* Project object */; +} diff --git a/Examples/Flux/SwiftUI-Flux.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Examples/Flux/SwiftUI-Flux.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100755 index 0000000..59f0ffb --- /dev/null +++ b/Examples/Flux/SwiftUI-Flux.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Examples/Flux/SwiftUI-Flux.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Examples/Flux/SwiftUI-Flux.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100755 index 0000000..18d9810 --- /dev/null +++ b/Examples/Flux/SwiftUI-Flux.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Examples/Flux/SwiftUI-Flux/AppDelegate.swift b/Examples/Flux/SwiftUI-Flux/AppDelegate.swift new file mode 100755 index 0000000..b259097 --- /dev/null +++ b/Examples/Flux/SwiftUI-Flux/AppDelegate.swift @@ -0,0 +1,4 @@ +import UIKit + +@UIApplicationMain +final class AppDelegate: UIResponder, UIApplicationDelegate {} diff --git a/Examples/Flux/SwiftUI-Flux/Assets.xcassets/AppIcon.appiconset/Contents.json b/Examples/Flux/SwiftUI-Flux/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100755 index 0000000..d8db8d6 --- /dev/null +++ b/Examples/Flux/SwiftUI-Flux/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Examples/Flux/SwiftUI-Flux/Assets.xcassets/Contents.json b/Examples/Flux/SwiftUI-Flux/Assets.xcassets/Contents.json new file mode 100755 index 0000000..da4a164 --- /dev/null +++ b/Examples/Flux/SwiftUI-Flux/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Examples/Flux/SwiftUI-Flux/Base.lproj/LaunchScreen.storyboard b/Examples/Flux/SwiftUI-Flux/Base.lproj/LaunchScreen.storyboard new file mode 100755 index 0000000..865e932 --- /dev/null +++ b/Examples/Flux/SwiftUI-Flux/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/Flux/SwiftUI-Flux/CounterView.swift b/Examples/Flux/SwiftUI-Flux/CounterView.swift new file mode 100755 index 0000000..ffb557b --- /dev/null +++ b/Examples/Flux/SwiftUI-Flux/CounterView.swift @@ -0,0 +1,34 @@ +import SwiftUI + +struct CounterView : View { + enum Action { + case increment + case decrement + } + + @State var store = Store(initial: 0) { count, action in + switch action { + case .increment: + return count + 1 + + case .decrement: + return max(0, count - 1) + } + } + + var body: some View { + VStack { + Text("\(store.state)") + + HStack { + Button(action: { self.store.dispatch(action: .decrement) }) { + Text("Decrement") + } + + Button(action: { self.store.dispatch(action: .increment) }) { + Text("Increment") + } + } + } + } +} diff --git a/Examples/Flux/SwiftUI-Flux/Info.plist b/Examples/Flux/SwiftUI-Flux/Info.plist new file mode 100755 index 0000000..e8bb4c6 --- /dev/null +++ b/Examples/Flux/SwiftUI-Flux/Info.plist @@ -0,0 +1,62 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UILaunchStoryboardName + LaunchScreen + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + + + + + UILaunchStoryboardName + LaunchScreen + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Examples/Flux/SwiftUI-Flux/Preview Content/Preview Assets.xcassets/Contents.json b/Examples/Flux/SwiftUI-Flux/Preview Content/Preview Assets.xcassets/Contents.json new file mode 100755 index 0000000..da4a164 --- /dev/null +++ b/Examples/Flux/SwiftUI-Flux/Preview Content/Preview Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Examples/Flux/SwiftUI-Flux/SceneDelegate.swift b/Examples/Flux/SwiftUI-Flux/SceneDelegate.swift new file mode 100755 index 0000000..577877f --- /dev/null +++ b/Examples/Flux/SwiftUI-Flux/SceneDelegate.swift @@ -0,0 +1,13 @@ +import UIKit +import SwiftUI + +final class SceneDelegate: UIResponder, UIWindowSceneDelegate { + var window: UIWindow? + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + let window = UIWindow(frame: UIScreen.main.bounds) + window.rootViewController = UIHostingController(rootView: CounterView()) + self.window = window + window.makeKeyAndVisible() + } +} diff --git a/Examples/Flux/SwiftUI-Flux/Store.swift b/Examples/Flux/SwiftUI-Flux/Store.swift new file mode 100755 index 0000000..e425b2f --- /dev/null +++ b/Examples/Flux/SwiftUI-Flux/Store.swift @@ -0,0 +1,34 @@ +import SwiftUI +import Combine + +final class Store: BindableObject { + typealias Reducer = (State, Action) -> State + + let didChange = PassthroughSubject() + + var state: State { + lock.lock() + defer { lock.unlock() } + return _state + } + + private let lock = NSLock() + private let reducer: Reducer + private var _state: State + + init(initial state: State, reducer: @escaping Reducer) { + _state = state + self.reducer = reducer + } + + func dispatch(action: Action) { + lock.lock() + + let newState = reducer(_state, action) + _state = newState + + lock.unlock() + + didChange.send(newState) + } +} diff --git a/README.md b/README.md index 3e84261..de70f92 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ Include Layout, UI, Animations, Gestures, Draw and Data. See projects files in ` - [Time Travel](#time-travel) - [Drawing Paths And Shapes](#drawing-paths-and-shapes) - [Animating Views And Transitions](#animating-views-and-transitions) +- [Flux](#flux) ## Projects @@ -39,7 +40,7 @@ Include Layout, UI, Animations, Gestures, Draw and Data. See projects files in ` #### 2048 Game - + #### Composing Complex Interfaces @@ -86,6 +87,10 @@ Include Layout, UI, Animations, Gestures, Draw and Data. See projects files in ` +#### Flux + + + #### Authors Thanks for [Jinxiansen](https://github.com/Jinxiansen), [ra1028](https://github.com/ra1028), [timdonnelly](https://github.com/timdonnelly), [TwoLivesLeft](https://github.com/TwoLivesLeft), [devxoul](https://github.com/devxoul), [cmtrounce](https://github.com/cmtrounce), [unixzii](https://github.com/unixzii) for examples project. diff --git a/Resources/Flux.gif b/Resources/Flux.gif new file mode 100755 index 0000000..e457bd6 Binary files /dev/null and b/Resources/Flux.gif differ