mirror of
https://github.com/ivanvorobei/SwiftUI.git
synced 2026-01-11 20:00:26 +01:00
Add Time Travel
This commit is contained in:
82
Examples/TimeTravel/.gitignore
vendored
Executable file
82
Examples/TimeTravel/.gitignore
vendored
Executable file
@@ -0,0 +1,82 @@
|
||||
# Xcode
|
||||
#
|
||||
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
|
||||
|
||||
## Build generated
|
||||
build/
|
||||
DerivedData/
|
||||
|
||||
## Various settings
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
xcuserdata/
|
||||
|
||||
## Other
|
||||
*.moved-aside
|
||||
*.xccheckout
|
||||
*.xcscmblueprint
|
||||
|
||||
## Obj-C/Swift specific
|
||||
*.hmap
|
||||
*.ipa
|
||||
*.dSYM.zip
|
||||
*.dSYM
|
||||
|
||||
## Playgrounds
|
||||
timeline.xctimeline
|
||||
playground.xcworkspace
|
||||
|
||||
# Swift Package Manager
|
||||
#
|
||||
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
|
||||
# Packages/
|
||||
# Package.pins
|
||||
# Package.resolved
|
||||
.build/
|
||||
|
||||
# CocoaPods
|
||||
#
|
||||
# We recommend against adding the Pods directory to your .gitignore. However
|
||||
# you should judge for yourself, the pros and cons are mentioned at:
|
||||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
||||
#
|
||||
# Pods/
|
||||
#
|
||||
# Add this line if you want to avoid checking in source code from the Xcode workspace
|
||||
# *.xcworkspace
|
||||
|
||||
# Carthage
|
||||
#
|
||||
# Add this line if you want to avoid checking in source code from Carthage dependencies.
|
||||
# Carthage/Checkouts
|
||||
|
||||
Carthage/Build
|
||||
|
||||
# Accio dependency management
|
||||
Dependencies/
|
||||
.accio/
|
||||
|
||||
# fastlane
|
||||
#
|
||||
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
|
||||
# screenshots whenever they are needed.
|
||||
# For more information about the recommended setup visit:
|
||||
# https://docs.fastlane.tools/best-practices/source-control/#source-control
|
||||
|
||||
fastlane/report.xml
|
||||
fastlane/Preview.html
|
||||
fastlane/screenshots/**/*.png
|
||||
fastlane/test_output
|
||||
|
||||
# Code Injection
|
||||
#
|
||||
# After new code Injection tools there's a generated folder /iOSInjectionProject
|
||||
# https://github.com/johnno1962/injectionforxcode
|
||||
|
||||
iOSInjectionProject/
|
||||
421
Examples/TimeTravel/SwiftUITimeTravel.xcodeproj/project.pbxproj
Executable file
421
Examples/TimeTravel/SwiftUITimeTravel.xcodeproj/project.pbxproj
Executable file
@@ -0,0 +1,421 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 50;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
22316DC622A7B255004124F2 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22316DC522A7B255004124F2 /* AppDelegate.swift */; };
|
||||
22316DC822A7B255004124F2 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22316DC722A7B255004124F2 /* SceneDelegate.swift */; };
|
||||
22316DCA22A7B255004124F2 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22316DC922A7B255004124F2 /* ContentView.swift */; };
|
||||
22316DCC22A7B255004124F2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 22316DCB22A7B255004124F2 /* Assets.xcassets */; };
|
||||
22316DCF22A7B255004124F2 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 22316DCE22A7B255004124F2 /* Preview Assets.xcassets */; };
|
||||
22316DD222A7B255004124F2 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 22316DD022A7B255004124F2 /* LaunchScreen.storyboard */; };
|
||||
22316DE722A7B287004124F2 /* TodoListItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22316DE022A7B263004124F2 /* TodoListItemView.swift */; };
|
||||
22316DE822A7B287004124F2 /* ModalDimmingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22316DE122A7B263004124F2 /* ModalDimmingView.swift */; };
|
||||
22316DE922A7B287004124F2 /* AddItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22316DE222A7B263004124F2 /* AddItemView.swift */; };
|
||||
22316DEA22A7B28B004124F2 /* TodoItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22316DE422A7B263004124F2 /* TodoItem.swift */; };
|
||||
22316DEB22A7B28B004124F2 /* TodoState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22316DE522A7B263004124F2 /* TodoState.swift */; };
|
||||
22316DEC22A7B28D004124F2 /* TodoListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22316DE622A7B263004124F2 /* TodoListView.swift */; };
|
||||
22316DED22A7B291004124F2 /* StateMachine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22316DDA22A7B263004124F2 /* StateMachine.swift */; };
|
||||
22316DEE22A7B291004124F2 /* TimeTravelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22316DDB22A7B263004124F2 /* TimeTravelView.swift */; };
|
||||
22316DEF22A7B291004124F2 /* Store.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22316DDC22A7B263004124F2 /* Store.swift */; };
|
||||
22316DF022A7B291004124F2 /* TimeTravelBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22316DDD22A7B263004124F2 /* TimeTravelBarView.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
22316DC222A7B255004124F2 /* SwiftUITimeTravel.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftUITimeTravel.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
22316DC522A7B255004124F2 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
22316DC722A7B255004124F2 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
|
||||
22316DC922A7B255004124F2 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
|
||||
22316DCB22A7B255004124F2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
22316DCE22A7B255004124F2 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
|
||||
22316DD122A7B255004124F2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
22316DD322A7B255004124F2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
22316DDA22A7B263004124F2 /* StateMachine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StateMachine.swift; sourceTree = "<group>"; };
|
||||
22316DDB22A7B263004124F2 /* TimeTravelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimeTravelView.swift; sourceTree = "<group>"; };
|
||||
22316DDC22A7B263004124F2 /* Store.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Store.swift; sourceTree = "<group>"; };
|
||||
22316DDD22A7B263004124F2 /* TimeTravelBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimeTravelBarView.swift; sourceTree = "<group>"; };
|
||||
22316DE022A7B263004124F2 /* TodoListItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodoListItemView.swift; sourceTree = "<group>"; };
|
||||
22316DE122A7B263004124F2 /* ModalDimmingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalDimmingView.swift; sourceTree = "<group>"; };
|
||||
22316DE222A7B263004124F2 /* AddItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddItemView.swift; sourceTree = "<group>"; };
|
||||
22316DE422A7B263004124F2 /* TodoItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodoItem.swift; sourceTree = "<group>"; };
|
||||
22316DE522A7B263004124F2 /* TodoState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodoState.swift; sourceTree = "<group>"; };
|
||||
22316DE622A7B263004124F2 /* TodoListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodoListView.swift; sourceTree = "<group>"; };
|
||||
22316DF122A7B3FB004124F2 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
22316DBF22A7B255004124F2 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
22316DB922A7B255004124F2 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
22316DF122A7B3FB004124F2 /* README.md */,
|
||||
22316DC422A7B255004124F2 /* SwiftUITimeTravel */,
|
||||
22316DC322A7B255004124F2 /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
22316DC322A7B255004124F2 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
22316DC222A7B255004124F2 /* SwiftUITimeTravel.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
22316DC422A7B255004124F2 /* SwiftUITimeTravel */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
22316DD922A7B263004124F2 /* TimeTravelView */,
|
||||
22316DDE22A7B263004124F2 /* TodoList */,
|
||||
22316DC522A7B255004124F2 /* AppDelegate.swift */,
|
||||
22316DC722A7B255004124F2 /* SceneDelegate.swift */,
|
||||
22316DC922A7B255004124F2 /* ContentView.swift */,
|
||||
22316DCB22A7B255004124F2 /* Assets.xcassets */,
|
||||
22316DD022A7B255004124F2 /* LaunchScreen.storyboard */,
|
||||
22316DD322A7B255004124F2 /* Info.plist */,
|
||||
22316DCD22A7B255004124F2 /* Preview Content */,
|
||||
);
|
||||
path = SwiftUITimeTravel;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
22316DCD22A7B255004124F2 /* Preview Content */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
22316DCE22A7B255004124F2 /* Preview Assets.xcassets */,
|
||||
);
|
||||
path = "Preview Content";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
22316DD922A7B263004124F2 /* TimeTravelView */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
22316DDA22A7B263004124F2 /* StateMachine.swift */,
|
||||
22316DDB22A7B263004124F2 /* TimeTravelView.swift */,
|
||||
22316DDC22A7B263004124F2 /* Store.swift */,
|
||||
22316DDD22A7B263004124F2 /* TimeTravelBarView.swift */,
|
||||
);
|
||||
path = TimeTravelView;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
22316DDE22A7B263004124F2 /* TodoList */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
22316DDF22A7B263004124F2 /* Internal Views */,
|
||||
22316DE322A7B263004124F2 /* Model */,
|
||||
22316DE622A7B263004124F2 /* TodoListView.swift */,
|
||||
);
|
||||
path = TodoList;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
22316DDF22A7B263004124F2 /* Internal Views */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
22316DE022A7B263004124F2 /* TodoListItemView.swift */,
|
||||
22316DE122A7B263004124F2 /* ModalDimmingView.swift */,
|
||||
22316DE222A7B263004124F2 /* AddItemView.swift */,
|
||||
);
|
||||
path = "Internal Views";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
22316DE322A7B263004124F2 /* Model */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
22316DE422A7B263004124F2 /* TodoItem.swift */,
|
||||
22316DE522A7B263004124F2 /* TodoState.swift */,
|
||||
);
|
||||
path = Model;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
22316DC122A7B255004124F2 /* SwiftUITimeTravel */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 22316DD622A7B255004124F2 /* Build configuration list for PBXNativeTarget "SwiftUITimeTravel" */;
|
||||
buildPhases = (
|
||||
22316DBE22A7B255004124F2 /* Sources */,
|
||||
22316DBF22A7B255004124F2 /* Frameworks */,
|
||||
22316DC022A7B255004124F2 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = SwiftUITimeTravel;
|
||||
productName = SwiftUITimeTravel;
|
||||
productReference = 22316DC222A7B255004124F2 /* SwiftUITimeTravel.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
22316DBA22A7B255004124F2 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 1100;
|
||||
LastUpgradeCheck = 1100;
|
||||
ORGANIZATIONNAME = "Tim Donnelly";
|
||||
TargetAttributes = {
|
||||
22316DC122A7B255004124F2 = {
|
||||
CreatedOnToolsVersion = 11.0;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 22316DBD22A7B255004124F2 /* Build configuration list for PBXProject "SwiftUITimeTravel" */;
|
||||
compatibilityVersion = "Xcode 9.3";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = 22316DB922A7B255004124F2;
|
||||
productRefGroup = 22316DC322A7B255004124F2 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
22316DC122A7B255004124F2 /* SwiftUITimeTravel */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
22316DC022A7B255004124F2 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
22316DD222A7B255004124F2 /* LaunchScreen.storyboard in Resources */,
|
||||
22316DCF22A7B255004124F2 /* Preview Assets.xcassets in Resources */,
|
||||
22316DCC22A7B255004124F2 /* Assets.xcassets in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
22316DBE22A7B255004124F2 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
22316DEA22A7B28B004124F2 /* TodoItem.swift in Sources */,
|
||||
22316DEE22A7B291004124F2 /* TimeTravelView.swift in Sources */,
|
||||
22316DEB22A7B28B004124F2 /* TodoState.swift in Sources */,
|
||||
22316DEF22A7B291004124F2 /* Store.swift in Sources */,
|
||||
22316DC622A7B255004124F2 /* AppDelegate.swift in Sources */,
|
||||
22316DED22A7B291004124F2 /* StateMachine.swift in Sources */,
|
||||
22316DE922A7B287004124F2 /* AddItemView.swift in Sources */,
|
||||
22316DF022A7B291004124F2 /* TimeTravelBarView.swift in Sources */,
|
||||
22316DE722A7B287004124F2 /* TodoListItemView.swift in Sources */,
|
||||
22316DEC22A7B28D004124F2 /* TodoListView.swift in Sources */,
|
||||
22316DE822A7B287004124F2 /* ModalDimmingView.swift in Sources */,
|
||||
22316DC822A7B255004124F2 /* SceneDelegate.swift in Sources */,
|
||||
22316DCA22A7B255004124F2 /* ContentView.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
22316DD022A7B255004124F2 /* LaunchScreen.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
22316DD122A7B255004124F2 /* Base */,
|
||||
);
|
||||
name = LaunchScreen.storyboard;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
22316DD422A7B255004124F2 /* 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;
|
||||
};
|
||||
22316DD522A7B255004124F2 /* 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;
|
||||
};
|
||||
22316DD722A7B255004124F2 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_ASSET_PATHS = "SwiftUITimeTravel/Preview\\ Content";
|
||||
DEVELOPMENT_TEAM = MM763NMPEA;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
INFOPLIST_FILE = SwiftUITimeTravel/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.tdonnelly.SwiftUITimeTravel;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
22316DD822A7B255004124F2 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_ASSET_PATHS = "SwiftUITimeTravel/Preview\\ Content";
|
||||
DEVELOPMENT_TEAM = MM763NMPEA;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
INFOPLIST_FILE = SwiftUITimeTravel/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.tdonnelly.SwiftUITimeTravel;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
22316DBD22A7B255004124F2 /* Build configuration list for PBXProject "SwiftUITimeTravel" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
22316DD422A7B255004124F2 /* Debug */,
|
||||
22316DD522A7B255004124F2 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
22316DD622A7B255004124F2 /* Build configuration list for PBXNativeTarget "SwiftUITimeTravel" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
22316DD722A7B255004124F2 /* Debug */,
|
||||
22316DD822A7B255004124F2 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 22316DBA22A7B255004124F2 /* Project object */;
|
||||
}
|
||||
7
Examples/TimeTravel/SwiftUITimeTravel.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Executable file
7
Examples/TimeTravel/SwiftUITimeTravel.xcodeproj/project.xcworkspace/contents.xcworkspacedata
generated
Executable file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:SwiftUITimeTravel.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
33
Examples/TimeTravel/SwiftUITimeTravel/AppDelegate.swift
Executable file
33
Examples/TimeTravel/SwiftUITimeTravel/AppDelegate.swift
Executable file
@@ -0,0 +1,33 @@
|
||||
import UIKit
|
||||
|
||||
@UIApplicationMain
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
// Override point for customization after application launch.
|
||||
return true
|
||||
}
|
||||
|
||||
func applicationWillTerminate(_ application: UIApplication) {
|
||||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
|
||||
}
|
||||
|
||||
// MARK: UISceneSession Lifecycle
|
||||
|
||||
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
|
||||
// Called when a new scene session is being created.
|
||||
// Use this method to select a configuration to create the new scene with.
|
||||
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
|
||||
}
|
||||
|
||||
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
|
||||
// Called when the user discards a scene session.
|
||||
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
|
||||
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
6
Examples/TimeTravel/SwiftUITimeTravel/Assets.xcassets/Contents.json
Executable file
6
Examples/TimeTravel/SwiftUITimeTravel/Assets.xcassets/Contents.json
Executable file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
25
Examples/TimeTravel/SwiftUITimeTravel/Base.lproj/LaunchScreen.storyboard
Executable file
25
Examples/TimeTravel/SwiftUITimeTravel/Base.lproj/LaunchScreen.storyboard
Executable file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="EHf-IW-A2E">
|
||||
<objects>
|
||||
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
||||
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="53" y="375"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
||||
17
Examples/TimeTravel/SwiftUITimeTravel/ContentView.swift
Executable file
17
Examples/TimeTravel/SwiftUITimeTravel/ContentView.swift
Executable file
@@ -0,0 +1,17 @@
|
||||
import SwiftUI
|
||||
|
||||
struct ContentView : View {
|
||||
var body: some View {
|
||||
TimeTravelView(initialState: TodoState()) {
|
||||
TodoListView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
struct ContentView_Previews : PreviewProvider {
|
||||
static var previews: some View {
|
||||
ContentView()
|
||||
}
|
||||
}
|
||||
#endif
|
||||
62
Examples/TimeTravel/SwiftUITimeTravel/Info.plist
Executable file
62
Examples/TimeTravel/SwiftUITimeTravel/Info.plist
Executable file
@@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>UIApplicationSceneManifest</key>
|
||||
<dict>
|
||||
<key>UIApplicationSupportsMultipleScenes</key>
|
||||
<false/>
|
||||
<key>UISceneConfigurations</key>
|
||||
<dict>
|
||||
<key>UIWindowSceneSessionRoleApplication</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UISceneConfigurationName</key>
|
||||
<string>Default Configuration</string>
|
||||
<key>UISceneDelegateClassName</key>
|
||||
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
51
Examples/TimeTravel/SwiftUITimeTravel/SceneDelegate.swift
Executable file
51
Examples/TimeTravel/SwiftUITimeTravel/SceneDelegate.swift
Executable file
@@ -0,0 +1,51 @@
|
||||
import UIKit
|
||||
import SwiftUI
|
||||
|
||||
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||
|
||||
var window: UIWindow?
|
||||
|
||||
|
||||
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
|
||||
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
|
||||
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
|
||||
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
|
||||
|
||||
// Use a UIHostingController as window root view controller
|
||||
let window = UIWindow(frame: UIScreen.main.bounds)
|
||||
window.rootViewController = UIHostingController(rootView: ContentView())
|
||||
self.window = window
|
||||
window.makeKeyAndVisible()
|
||||
}
|
||||
|
||||
func sceneDidDisconnect(_ scene: UIScene) {
|
||||
// Called as the scene is being released by the system.
|
||||
// This occurs shortly after the scene enters the background, or when its session is discarded.
|
||||
// Release any resources associated with this scene that can be re-created the next time the scene connects.
|
||||
// The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead).
|
||||
}
|
||||
|
||||
func sceneDidBecomeActive(_ scene: UIScene) {
|
||||
// Called when the scene has moved from an inactive state to an active state.
|
||||
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
|
||||
}
|
||||
|
||||
func sceneWillResignActive(_ scene: UIScene) {
|
||||
// Called when the scene will move from an active state to an inactive state.
|
||||
// This may occur due to temporary interruptions (ex. an incoming phone call).
|
||||
}
|
||||
|
||||
func sceneWillEnterForeground(_ scene: UIScene) {
|
||||
// Called as the scene transitions from the background to the foreground.
|
||||
// Use this method to undo the changes made on entering the background.
|
||||
}
|
||||
|
||||
func sceneDidEnterBackground(_ scene: UIScene) {
|
||||
// Called as the scene transitions from the foreground to the background.
|
||||
// Use this method to save data, release shared resources, and store enough scene-specific state information
|
||||
// to restore the scene back to its current state.
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
11
Examples/TimeTravel/SwiftUITimeTravel/TimeTravelView/StateMachine.swift
Executable file
11
Examples/TimeTravel/SwiftUITimeTravel/TimeTravelView/StateMachine.swift
Executable file
@@ -0,0 +1,11 @@
|
||||
/// Conforming types serve as the state of a time travelable application
|
||||
public protocol StateMachine {
|
||||
|
||||
/// Events define things that can happen within your application that change its state.
|
||||
///
|
||||
/// This might include things like text editing, button taps, or network responses.
|
||||
associatedtype Event
|
||||
|
||||
/// Applies an event to the current state.
|
||||
mutating func update(with event: Event)
|
||||
}
|
||||
44
Examples/TimeTravel/SwiftUITimeTravel/TimeTravelView/Store.swift
Executable file
44
Examples/TimeTravel/SwiftUITimeTravel/TimeTravelView/Store.swift
Executable file
@@ -0,0 +1,44 @@
|
||||
import SwiftUI
|
||||
import Combine
|
||||
|
||||
public final class Store<StateType>: BindableObject where StateType: StateMachine {
|
||||
|
||||
private let initialState: StateType
|
||||
private var subsequentStates: [StateType] = []
|
||||
|
||||
public let didChange = PassthroughSubject<Void, Never>()
|
||||
|
||||
public init(state: StateType) {
|
||||
initialState = state
|
||||
}
|
||||
|
||||
var allStates: [StateType] {
|
||||
[[initialState], subsequentStates].flatMap({ $0 })
|
||||
}
|
||||
|
||||
var stateCount: Int {
|
||||
1 + subsequentStates.count
|
||||
}
|
||||
|
||||
var currentStateIndex: Int = 0 {
|
||||
didSet {
|
||||
withAnimation {
|
||||
didChange.send(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The current state of the store. This will update as time traveling occurs.
|
||||
public var state: StateType {
|
||||
allStates[currentStateIndex]
|
||||
}
|
||||
|
||||
/// Dispatches an event to be applied to the current state.
|
||||
public func dispatch(event: StateType.Event) {
|
||||
var newState = state
|
||||
newState.update(with: event)
|
||||
subsequentStates.append(newState)
|
||||
currentStateIndex = stateCount - 1
|
||||
}
|
||||
|
||||
}
|
||||
25
Examples/TimeTravel/SwiftUITimeTravel/TimeTravelView/TimeTravelBarView.swift
Executable file
25
Examples/TimeTravel/SwiftUITimeTravel/TimeTravelView/TimeTravelBarView.swift
Executable file
@@ -0,0 +1,25 @@
|
||||
import SwiftUI
|
||||
|
||||
struct TimeTravelBarView : View {
|
||||
|
||||
@EnvironmentObject var store: Store<TodoState>
|
||||
|
||||
var body: some View {
|
||||
let indexBinding = Binding<Double>(
|
||||
getValue: { Double(self.store.currentStateIndex) },
|
||||
setValue: { self.store.currentStateIndex = Int($0) })
|
||||
|
||||
return Slider(value: indexBinding, from: 0, through: Double(store.stateCount-1))
|
||||
.background(Color.white)
|
||||
.frame(height: 44.0, alignment: .bottom)
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
struct TimeTravelBarView_Previews : PreviewProvider {
|
||||
static var previews: some View {
|
||||
TimeTravelBarView()
|
||||
}
|
||||
}
|
||||
#endif
|
||||
39
Examples/TimeTravel/SwiftUITimeTravel/TimeTravelView/TimeTravelView.swift
Executable file
39
Examples/TimeTravel/SwiftUITimeTravel/TimeTravelView/TimeTravelView.swift
Executable file
@@ -0,0 +1,39 @@
|
||||
import SwiftUI
|
||||
|
||||
public struct TimeTravelView<StateType, Content>: View where StateType: StateMachine, Content: View {
|
||||
|
||||
let initialState: StateType
|
||||
|
||||
private let content: Content
|
||||
|
||||
@State var store: Store<StateType>? = nil
|
||||
|
||||
public init(initialState: StateType, content: () -> Content) {
|
||||
self.initialState = initialState
|
||||
self.content = content()
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
|
||||
let store = self.store ?? Store(state: initialState)
|
||||
if (self.store == nil) {
|
||||
self.store = store
|
||||
}
|
||||
|
||||
return VStack {
|
||||
content
|
||||
TimeTravelBarView()
|
||||
}
|
||||
.environmentObject(store)
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
struct TimeTravelView_Previews : PreviewProvider {
|
||||
static var previews: some View {
|
||||
TimeTravelView(initialState: TodoState()) {
|
||||
TodoListView()
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,40 @@
|
||||
import SwiftUI
|
||||
|
||||
struct AddItemView: View {
|
||||
|
||||
@EnvironmentObject var store: Store<TodoState>
|
||||
|
||||
var body: some View {
|
||||
|
||||
let textBinding = Binding<String>(
|
||||
getValue: { self.store.state.partialItemName },
|
||||
setValue: { self.store.dispatch(event: .changePartialItemName($0)) })
|
||||
|
||||
return VStack(spacing: 16) {
|
||||
TextField(textBinding, placeholder: Text("Title"))
|
||||
Button(action: {
|
||||
self.store.dispatch(event: .addItem)
|
||||
}) {
|
||||
HStack {
|
||||
Spacer()
|
||||
Text("Add").padding([.top, .bottom], 8.0)
|
||||
Spacer()
|
||||
}
|
||||
|
||||
}
|
||||
.relativeWidth(1.0)
|
||||
.background(Color.accentColor)
|
||||
.disabled(store.state.partialItemName.isEmpty)
|
||||
.foregroundColor(.white)
|
||||
.cornerRadius(8.0)
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
#if DEBUG
|
||||
struct AddItemView_Previews : PreviewProvider {
|
||||
static var previews: some View {
|
||||
AddItemView()
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
import SwiftUI
|
||||
|
||||
struct ModalDimmingView : View {
|
||||
|
||||
@EnvironmentObject var store: Store<TodoState>
|
||||
|
||||
var body: some View {
|
||||
Color
|
||||
.black
|
||||
.relativeWidth(1.0)
|
||||
.relativeHeight(1.0)
|
||||
.opacity(0.3)
|
||||
.edgesIgnoringSafeArea([.bottom, .top])
|
||||
.transition(.opacity)
|
||||
.tapAction {
|
||||
self.store.dispatch(event: .cancelCreatingItem)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
struct ModalDimmingView_Previews : PreviewProvider {
|
||||
static var previews: some View {
|
||||
ModalDimmingView()
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,26 @@
|
||||
import SwiftUI
|
||||
|
||||
struct TodoListItemView : View {
|
||||
|
||||
@EnvironmentObject var store: Store<TodoState>
|
||||
|
||||
let item: TodoItem
|
||||
|
||||
var body: some View {
|
||||
let binding = Binding(
|
||||
getValue: { self.item.isFinished },
|
||||
setValue: { self.store.dispatch(event: .setItemDone(identifier: self.item.id, isDone: $0)) })
|
||||
|
||||
return Toggle(isOn: binding) {
|
||||
Text(item.title)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
struct TodoListItemView_Previews : PreviewProvider {
|
||||
static var previews: some View {
|
||||
TodoListItemView(item: TodoItem(id: UUID(), title: "Test", isFinished: false))
|
||||
}
|
||||
}
|
||||
#endif
|
||||
7
Examples/TimeTravel/SwiftUITimeTravel/TodoList/Model/TodoItem.swift
Executable file
7
Examples/TimeTravel/SwiftUITimeTravel/TodoList/Model/TodoItem.swift
Executable file
@@ -0,0 +1,7 @@
|
||||
import SwiftUI
|
||||
|
||||
struct TodoItem: Identifiable {
|
||||
var id: UUID
|
||||
var title: String
|
||||
var isFinished: Bool
|
||||
}
|
||||
39
Examples/TimeTravel/SwiftUITimeTravel/TodoList/Model/TodoState.swift
Executable file
39
Examples/TimeTravel/SwiftUITimeTravel/TodoList/Model/TodoState.swift
Executable file
@@ -0,0 +1,39 @@
|
||||
import SwiftUI
|
||||
|
||||
struct TodoState {
|
||||
var isCreatingItem: Bool = false
|
||||
var partialItemName: String = ""
|
||||
var todoItems: [TodoItem] = []
|
||||
}
|
||||
|
||||
extension TodoState: StateMachine {
|
||||
|
||||
enum Event {
|
||||
case startCreatingItem
|
||||
case cancelCreatingItem
|
||||
case changePartialItemName(String)
|
||||
case addItem
|
||||
case setItemDone(identifier: UUID, isDone: Bool)
|
||||
}
|
||||
|
||||
mutating func update(with event: TodoState.Event) {
|
||||
switch event {
|
||||
case .addItem:
|
||||
todoItems.append(TodoItem(id: UUID(), title: partialItemName, isFinished: false))
|
||||
partialItemName = ""
|
||||
isCreatingItem = false
|
||||
case .changePartialItemName(let name):
|
||||
partialItemName = name
|
||||
case .cancelCreatingItem:
|
||||
isCreatingItem = false
|
||||
case .startCreatingItem:
|
||||
isCreatingItem = true
|
||||
partialItemName = ""
|
||||
case .setItemDone(let identifier, let isDone):
|
||||
if let index = todoItems.firstIndex(where: { $0.id == identifier }) {
|
||||
todoItems[index].isFinished = isDone
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
43
Examples/TimeTravel/SwiftUITimeTravel/TodoList/TodoListView.swift
Executable file
43
Examples/TimeTravel/SwiftUITimeTravel/TodoList/TodoListView.swift
Executable file
@@ -0,0 +1,43 @@
|
||||
import SwiftUI
|
||||
|
||||
struct TodoListView : View {
|
||||
|
||||
@EnvironmentObject var store: Store<TodoState>
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
NavigationView {
|
||||
List(store.state.todoItems) { item in TodoListItemView(item: item) }
|
||||
.navigationBarTitle(Text("Todo List"))
|
||||
.navigationBarItems(trailing: Button(action: {
|
||||
withAnimation {
|
||||
self.store.dispatch(event: .startCreatingItem)
|
||||
}
|
||||
}, label: { Image(systemName: "plus.circle") })) }
|
||||
|
||||
if store.state.isCreatingItem {
|
||||
|
||||
ModalDimmingView()
|
||||
|
||||
VStack {
|
||||
Spacer()
|
||||
AddItemView()
|
||||
.relativeWidth(1.0)
|
||||
.background(Color.white)
|
||||
.cornerRadius(12.0)
|
||||
.shadow(radius: 16.0)
|
||||
.padding()
|
||||
Spacer()
|
||||
}
|
||||
.transition(.move(edge: .bottom))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#if DEBUG
|
||||
struct TodoListView_Previews : PreviewProvider {
|
||||
static var previews: some View {
|
||||
TodoListView()
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -14,6 +14,7 @@ If you have project, make a pull request.
|
||||
- [Combine using GitHub API](#combine-using-github-api)
|
||||
- [Interfacing With UIKit](#interfacing-with-uikit)
|
||||
- [GitHub Search](#github-search)
|
||||
- [Time Travel](#time-travel)
|
||||
- [Drawing and Animation](#drawing-and-animation)
|
||||
- [Drawing Paths And Shapes](#drawing-paths-and-shapes)
|
||||
- [Animating Views And Transitions](#animating-views-and-transitions)
|
||||
@@ -57,6 +58,10 @@ If you have project, make a pull request.
|
||||
|
||||
<img src="Resources/GitHubSearch.png" width="260">
|
||||
|
||||
### Time Travel
|
||||
|
||||
<img src="Resources/TimveTravel.gif" width="260">
|
||||
|
||||
## Drawing and Animation
|
||||
|
||||
#### Drawing Paths And Shapes
|
||||
|
||||
BIN
Resources/TimeTravel.gif
Executable file
BIN
Resources/TimeTravel.gif
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 815 KiB |
Reference in New Issue
Block a user