Add examples project

This commit is contained in:
Ivan Vorobei
2019-06-06 11:16:28 +03:00
parent 86fe2d7323
commit b866885a44
962 changed files with 45026 additions and 5 deletions

14
Examples/Example To-Do App/.gitignore vendored Executable file
View File

@@ -0,0 +1,14 @@
.DS_Store
.bundle
**/xcuserdata
*.pbxuser
*.mode1v3
Pods/
Carthage/
vendor/
fastlane/report.xml
*.ipa
*.dSYM.zip

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2019 Suyeol Jeon (xoul.kr)
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:
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.

View File

@@ -0,0 +1,14 @@
# SwiftUITodo
SwiftUITodo is an example to-do list application using [SwiftUI](https://developer.apple.com/xcode/swiftui/) which is first introduced in WWDC19 keynote.
![screenshot](https://user-images.githubusercontent.com/931655/58843349-f6dbf400-8626-11e9-8227-fbd369c29515.png)
## Requirements
* Xcode 11 Beta
* Swift 5.1
## License
SwiftUITodo is under MIT license. See the [LICENSE](LICENSE) file for more info.

View File

@@ -0,0 +1,367 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objects = {
/* Begin PBXBuildFile section */
031596AE22A5BDBA001BBA1B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 031596AD22A5BDBA001BBA1B /* AppDelegate.swift */; };
031596B022A5BDBA001BBA1B /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 031596AF22A5BDBA001BBA1B /* SceneDelegate.swift */; };
031596B222A5BDBA001BBA1B /* TaskListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 031596B122A5BDBA001BBA1B /* TaskListView.swift */; };
031596B422A5BDBB001BBA1B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 031596B322A5BDBB001BBA1B /* Assets.xcassets */; };
031596B722A5BDBB001BBA1B /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 031596B622A5BDBB001BBA1B /* Preview Assets.xcassets */; };
031596BA22A5BDBB001BBA1B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 031596B822A5BDBB001BBA1B /* LaunchScreen.storyboard */; };
031596C222A5BDE8001BBA1B /* Task.swift in Sources */ = {isa = PBXBuildFile; fileRef = 031596C122A5BDE8001BBA1B /* Task.swift */; };
031596C822A5C661001BBA1B /* UserData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 031596C722A5C661001BBA1B /* UserData.swift */; };
031596CA22A5DDE0001BBA1B /* TaskEditView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 031596C922A5DDE0001BBA1B /* TaskEditView.swift */; };
031596CC22A5F360001BBA1B /* TaskItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 031596CB22A5F360001BBA1B /* TaskItemView.swift */; };
C8E0A25922A789D100E940E8 /* UserDefaultsValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8E0A25822A789D100E940E8 /* UserDefaultsValue.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
031596AA22A5BDBA001BBA1B /* SwiftUITodo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftUITodo.app; sourceTree = BUILT_PRODUCTS_DIR; };
031596AD22A5BDBA001BBA1B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
031596AF22A5BDBA001BBA1B /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
031596B122A5BDBA001BBA1B /* TaskListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskListView.swift; sourceTree = "<group>"; };
031596B322A5BDBB001BBA1B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
031596B622A5BDBB001BBA1B /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
031596B922A5BDBB001BBA1B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
031596BB22A5BDBB001BBA1B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
031596C122A5BDE8001BBA1B /* Task.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Task.swift; sourceTree = "<group>"; };
031596C722A5C661001BBA1B /* UserData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserData.swift; sourceTree = "<group>"; };
031596C922A5DDE0001BBA1B /* TaskEditView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskEditView.swift; sourceTree = "<group>"; };
031596CB22A5F360001BBA1B /* TaskItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskItemView.swift; sourceTree = "<group>"; };
C8E0A25822A789D100E940E8 /* UserDefaultsValue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaultsValue.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
031596A722A5BDBA001BBA1B /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
031596A122A5BDBA001BBA1B = {
isa = PBXGroup;
children = (
031596AC22A5BDBA001BBA1B /* SwiftUITodo */,
031596AB22A5BDBA001BBA1B /* Products */,
);
sourceTree = "<group>";
};
031596AB22A5BDBA001BBA1B /* Products */ = {
isa = PBXGroup;
children = (
031596AA22A5BDBA001BBA1B /* SwiftUITodo.app */,
);
name = Products;
sourceTree = "<group>";
};
031596AC22A5BDBA001BBA1B /* SwiftUITodo */ = {
isa = PBXGroup;
children = (
031596AD22A5BDBA001BBA1B /* AppDelegate.swift */,
031596AF22A5BDBA001BBA1B /* SceneDelegate.swift */,
031596C722A5C661001BBA1B /* UserData.swift */,
031596C122A5BDE8001BBA1B /* Task.swift */,
031596B122A5BDBA001BBA1B /* TaskListView.swift */,
031596CB22A5F360001BBA1B /* TaskItemView.swift */,
031596C922A5DDE0001BBA1B /* TaskEditView.swift */,
C8E0A25822A789D100E940E8 /* UserDefaultsValue.swift */,
031596B322A5BDBB001BBA1B /* Assets.xcassets */,
031596B822A5BDBB001BBA1B /* LaunchScreen.storyboard */,
031596BB22A5BDBB001BBA1B /* Info.plist */,
031596B522A5BDBB001BBA1B /* Preview Content */,
);
path = SwiftUITodo;
sourceTree = "<group>";
};
031596B522A5BDBB001BBA1B /* Preview Content */ = {
isa = PBXGroup;
children = (
031596B622A5BDBB001BBA1B /* Preview Assets.xcassets */,
);
path = "Preview Content";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
031596A922A5BDBA001BBA1B /* SwiftUITodo */ = {
isa = PBXNativeTarget;
buildConfigurationList = 031596BE22A5BDBB001BBA1B /* Build configuration list for PBXNativeTarget "SwiftUITodo" */;
buildPhases = (
031596A622A5BDBA001BBA1B /* Sources */,
031596A722A5BDBA001BBA1B /* Frameworks */,
031596A822A5BDBA001BBA1B /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = SwiftUITodo;
productName = SwiftUITodo;
productReference = 031596AA22A5BDBA001BBA1B /* SwiftUITodo.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
031596A222A5BDBA001BBA1B /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1100;
LastUpgradeCheck = 1100;
ORGANIZATIONNAME = "Suyeol Jeon";
TargetAttributes = {
031596A922A5BDBA001BBA1B = {
CreatedOnToolsVersion = 11.0;
};
};
};
buildConfigurationList = 031596A522A5BDBA001BBA1B /* Build configuration list for PBXProject "SwiftUITodo" */;
compatibilityVersion = "Xcode 9.3";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 031596A122A5BDBA001BBA1B;
productRefGroup = 031596AB22A5BDBA001BBA1B /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
031596A922A5BDBA001BBA1B /* SwiftUITodo */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
031596A822A5BDBA001BBA1B /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
031596BA22A5BDBB001BBA1B /* LaunchScreen.storyboard in Resources */,
031596B722A5BDBB001BBA1B /* Preview Assets.xcassets in Resources */,
031596B422A5BDBB001BBA1B /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
031596A622A5BDBA001BBA1B /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
031596C222A5BDE8001BBA1B /* Task.swift in Sources */,
031596AE22A5BDBA001BBA1B /* AppDelegate.swift in Sources */,
031596C822A5C661001BBA1B /* UserData.swift in Sources */,
031596CC22A5F360001BBA1B /* TaskItemView.swift in Sources */,
031596CA22A5DDE0001BBA1B /* TaskEditView.swift in Sources */,
031596B022A5BDBA001BBA1B /* SceneDelegate.swift in Sources */,
C8E0A25922A789D100E940E8 /* UserDefaultsValue.swift in Sources */,
031596B222A5BDBA001BBA1B /* TaskListView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
031596B822A5BDBB001BBA1B /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
031596B922A5BDBB001BBA1B /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
031596BC22A5BDBB001BBA1B /* 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;
};
031596BD22A5BDBB001BBA1B /* 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;
};
031596BF22A5BDBB001BBA1B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "SwiftUITodo/Preview\\ Content";
DEVELOPMENT_TEAM = N2C267LBVY;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = SwiftUITodo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = kr.xoul.SwiftUITodo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
031596C022A5BDBB001BBA1B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "SwiftUITodo/Preview\\ Content";
DEVELOPMENT_TEAM = N2C267LBVY;
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = SwiftUITodo/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = kr.xoul.SwiftUITodo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
031596A522A5BDBA001BBA1B /* Build configuration list for PBXProject "SwiftUITodo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
031596BC22A5BDBB001BBA1B /* Debug */,
031596BD22A5BDBB001BBA1B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
031596BE22A5BDBB001BBA1B /* Build configuration list for PBXNativeTarget "SwiftUITodo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
031596BF22A5BDBB001BBA1B /* Debug */,
031596C022A5BDBB001BBA1B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 031596A222A5BDBA001BBA1B /* Project object */;
}

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:SwiftUITodo.xcodeproj">
</FileRef>
</Workspace>

View File

@@ -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>

View File

@@ -0,0 +1,41 @@
//
// AppDelegate.swift
// SwiftUITodo
//
// Created by Suyeol Jeon on 03/06/2019.
// Copyright © 2019 Suyeol Jeon. All rights reserved.
//
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.
}
}

View File

@@ -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"
}
}

View File

@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View 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>

View 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>

View File

@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@@ -0,0 +1,61 @@
//
// SceneDelegate.swift
// SwiftUITodo
//
// Created by Suyeol Jeon on 03/06/2019.
// Copyright © 2019 Suyeol Jeon. All rights reserved.
//
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: NavigationView {
TaskListView().environmentObject(UserData())
})
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.
}
}

View File

@@ -0,0 +1,21 @@
//
// Task.swift
// SwiftUITodo
//
// Created by Suyeol Jeon on 03/06/2019.
// Copyright © 2019 Suyeol Jeon. All rights reserved.
//
import SwiftUI
struct Task: Equatable, Hashable, Codable, Identifiable {
let id: UUID
var title: String
var isDone: Bool
init(title: String, isDone: Bool) {
self.id = UUID()
self.title = title
self.isDone = isDone
}
}

View File

@@ -0,0 +1,52 @@
//
// TaskEditView.swift
// SwiftUITodo
//
// Created by Suyeol Jeon on 03/06/2019.
// Copyright © 2019 Suyeol Jeon. All rights reserved.
//
import SwiftUI
struct TaskEditView: View {
@EnvironmentObject var userData: UserData
private let task: Task
private var draftTitle: State<String>
init(task: Task) {
self.task = task
self.draftTitle = .init(initialValue: task.title)
}
var body: some View {
let inset = EdgeInsets(top: -8, leading: -10, bottom: -7, trailing: -10)
return VStack(alignment: .leading, spacing: 0) {
TextField(
self.draftTitle.binding,
placeholder: Text("Enter New Title..."),
onEditingChanged: { _ in self.updateTask() },
onCommit: {}
)
.background(
RoundedRectangle(cornerRadius: 5)
.fill(Color.clear)
.border(Color(red: 0.7, green: 0.7, blue: 0.7), width: 1 / UIScreen.main.scale, cornerRadius: 5)
.padding(inset)
)
.padding(EdgeInsets(
top: 15 - inset.top,
leading: 20 - inset.leading,
bottom: 15 - inset.bottom,
trailing: 20 - inset.trailing
))
Spacer()
}
.navigationBarTitle(Text("Edit Task 📝"))
}
private func updateTask() {
guard let index = self.userData.tasks.firstIndex(of: self.task) else { return }
self.userData.tasks[index].title = self.draftTitle.value
}
}

View File

@@ -0,0 +1,52 @@
//
// TaskItemView.swift
// SwiftUITodo
//
// Created by Suyeol Jeon on 03/06/2019.
// Copyright © 2019 Suyeol Jeon. All rights reserved.
//
import SwiftUI
struct TaskItemView: View {
@EnvironmentObject var userData: UserData
let task: Task
@Binding var isEditing: Bool
var body: some View {
return HStack {
if self.isEditing {
Image(systemName: "minus.circle")
.foregroundColor(.red)
.tapAction(count: 1) {
self.delete()
}
NavigationButton(destination: TaskEditView(task: task).environmentObject(self.userData)) {
Text(task.title)
}
} else {
Button(action: { self.toggleDone() }) {
Text(self.task.title)
}
Spacer()
if task.isDone {
Image(systemName: "checkmark").foregroundColor(.green)
}
}
}
}
private func toggleDone() {
guard !self.isEditing else { return }
guard let index = self.userData.tasks.firstIndex(where: { $0.id == self.task.id }) else { return }
self.userData.tasks[index].isDone.toggle()
}
private func delete() {
self.userData.tasks.removeAll(where: { $0.id == self.task.id })
if self.userData.tasks.isEmpty {
self.isEditing = false
}
}
}

View File

@@ -0,0 +1,38 @@
//
// TaskListView.swift
// SwiftUITodo
//
// Created by Suyeol Jeon on 03/06/2019.
// Copyright © 2019 Suyeol Jeon. All rights reserved.
//
import SwiftUI
struct TaskListView: View {
@EnvironmentObject var userData: UserData
@State var draftTitle: String = ""
@State var isEditing: Bool = false
var body: some View {
List {
TextField($draftTitle, placeholder: Text("Create a New Task..."), onCommit: self.createTask)
ForEach(self.userData.tasks) { task in
TaskItemView(task: task, isEditing: self.$isEditing)
}
}
.navigationBarItem(title: Text("Tasks 👀"))
.navigationBarItems(trailing: Button(action: { self.isEditing.toggle() }) {
if !self.isEditing {
Text("Edit")
} else {
Text("Done").bold()
}
})
}
private func createTask() {
let newTask = Task(title: self.draftTitle, isDone: false)
self.userData.tasks.insert(newTask, at: 0)
self.draftTitle = ""
}
}

View File

@@ -0,0 +1,26 @@
//
// UserData.swift
// SwiftUITodo
//
// Created by Suyeol Jeon on 03/06/2019.
// Copyright © 2019 Suyeol Jeon. All rights reserved.
//
import Combine
import SwiftUI
private let defaultTasks: [Task] = [
Task(title: "Read SwiftUI Documentation 📚", isDone: false),
Task(title: "Watch WWDC19 Keynote 🎉", isDone: true),
]
final class UserData: BindableObject {
let didChange = PassthroughSubject<UserData, Never>()
@UserDefaultValue(key: "Tasks", defaultValue: defaultTasks)
var tasks: [Task] {
didSet {
didChange.send(self)
}
}
}

View File

@@ -0,0 +1,28 @@
//
// UserDefaultsValue.swift
// SwiftUITodo
//
// Created by kemchenj on 2019/6/5.
// Copyright © 2019 Suyeol Jeon. All rights reserved.
//
import Foundation
@propertyDelegate
struct UserDefaultValue<Value: Codable> {
let key: String
let defaultValue: Value
var value: Value {
get {
let data = UserDefaults.standard.data(forKey: key)
let value = data.flatMap { try? JSONDecoder().decode(Value.self, from: $0) }
return value ?? defaultValue
}
set {
let data = try? JSONEncoder().encode(newValue)
UserDefaults.standard.set(data, forKey: key)
}
}
}