From: AceVest Date: Sat, 19 Nov 2016 15:38:08 +0000 (+0800) Subject: add foodtracker X-Git-Url: http://zhaoyanbai.com/repos/rndc.html?a=commitdiff_plain;h=4af797d28ce51aae63361d64b3612a6ec20a4972;p=acecode.git add foodtracker --- diff --git a/learn/AcePlay/AcePlay.playground/playground.xcworkspace/xcuserdata/Ace.xcuserdatad/UserInterfaceState.xcuserstate b/learn/AcePlay/AcePlay.playground/playground.xcworkspace/xcuserdata/Ace.xcuserdatad/UserInterfaceState.xcuserstate index 83c223d..dde461f 100644 Binary files a/learn/AcePlay/AcePlay.playground/playground.xcworkspace/xcuserdata/Ace.xcuserdatad/UserInterfaceState.xcuserstate and b/learn/AcePlay/AcePlay.playground/playground.xcworkspace/xcuserdata/Ace.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/learn/FoodTracker/FoodTracker.xcodeproj/project.pbxproj b/learn/FoodTracker/FoodTracker.xcodeproj/project.pbxproj new file mode 100644 index 0000000..f6a26d1 --- /dev/null +++ b/learn/FoodTracker/FoodTracker.xcodeproj/project.pbxproj @@ -0,0 +1,447 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 50B9071E1DCEFF5F00D6482E /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50B9071D1DCEFF5F00D6482E /* AppDelegate.swift */; }; + 50B907201DCEFF5F00D6482E /* MealViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50B9071F1DCEFF5F00D6482E /* MealViewController.swift */; }; + 50B907231DCEFF5F00D6482E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 50B907211DCEFF5F00D6482E /* Main.storyboard */; }; + 50B907251DCEFF5F00D6482E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 50B907241DCEFF5F00D6482E /* Assets.xcassets */; }; + 50B907281DCEFF5F00D6482E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 50B907261DCEFF5F00D6482E /* LaunchScreen.storyboard */; }; + 50B907331DCEFF5F00D6482E /* FoodTrackerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50B907321DCEFF5F00D6482E /* FoodTrackerTests.swift */; }; + 50B9073E1DD2255900D6482E /* RatingControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50B9073D1DD2255900D6482E /* RatingControl.swift */; }; + 50B907401DD434C000D6482E /* Meal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50B9073F1DD434C000D6482E /* Meal.swift */; }; + 50B907411DD434C000D6482E /* Meal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50B9073F1DD434C000D6482E /* Meal.swift */; }; + 50B907431DD49D4600D6482E /* MealTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50B907421DD49D4600D6482E /* MealTableViewCell.swift */; }; + 50B907451DD6178100D6482E /* MealTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50B907441DD6178100D6482E /* MealTableViewController.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 50B9072F1DCEFF5F00D6482E /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 50B907121DCEFF5F00D6482E /* Project object */; + proxyType = 1; + remoteGlobalIDString = 50B907191DCEFF5F00D6482E; + remoteInfo = FoodTracker; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 50B9071A1DCEFF5F00D6482E /* FoodTracker.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FoodTracker.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 50B9071D1DCEFF5F00D6482E /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 50B9071F1DCEFF5F00D6482E /* MealViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MealViewController.swift; sourceTree = ""; }; + 50B907221DCEFF5F00D6482E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 50B907241DCEFF5F00D6482E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 50B907271DCEFF5F00D6482E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 50B907291DCEFF5F00D6482E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 50B9072E1DCEFF5F00D6482E /* FoodTrackerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FoodTrackerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 50B907321DCEFF5F00D6482E /* FoodTrackerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FoodTrackerTests.swift; sourceTree = ""; }; + 50B907341DCEFF5F00D6482E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 50B9073D1DD2255900D6482E /* RatingControl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RatingControl.swift; sourceTree = ""; }; + 50B9073F1DD434C000D6482E /* Meal.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Meal.swift; sourceTree = ""; }; + 50B907421DD49D4600D6482E /* MealTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MealTableViewCell.swift; sourceTree = ""; }; + 50B907441DD6178100D6482E /* MealTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MealTableViewController.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 50B907171DCEFF5F00D6482E /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 50B9072B1DCEFF5F00D6482E /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 50B907111DCEFF5E00D6482E = { + isa = PBXGroup; + children = ( + 50B9071C1DCEFF5F00D6482E /* FoodTracker */, + 50B907311DCEFF5F00D6482E /* FoodTrackerTests */, + 50B9071B1DCEFF5F00D6482E /* Products */, + ); + sourceTree = ""; + }; + 50B9071B1DCEFF5F00D6482E /* Products */ = { + isa = PBXGroup; + children = ( + 50B9071A1DCEFF5F00D6482E /* FoodTracker.app */, + 50B9072E1DCEFF5F00D6482E /* FoodTrackerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 50B9071C1DCEFF5F00D6482E /* FoodTracker */ = { + isa = PBXGroup; + children = ( + 50B9071D1DCEFF5F00D6482E /* AppDelegate.swift */, + 50B9071F1DCEFF5F00D6482E /* MealViewController.swift */, + 50B907211DCEFF5F00D6482E /* Main.storyboard */, + 50B907421DD49D4600D6482E /* MealTableViewCell.swift */, + 50B9073F1DD434C000D6482E /* Meal.swift */, + 50B907241DCEFF5F00D6482E /* Assets.xcassets */, + 50B907261DCEFF5F00D6482E /* LaunchScreen.storyboard */, + 50B907441DD6178100D6482E /* MealTableViewController.swift */, + 50B907291DCEFF5F00D6482E /* Info.plist */, + 50B9073D1DD2255900D6482E /* RatingControl.swift */, + ); + path = FoodTracker; + sourceTree = ""; + }; + 50B907311DCEFF5F00D6482E /* FoodTrackerTests */ = { + isa = PBXGroup; + children = ( + 50B907321DCEFF5F00D6482E /* FoodTrackerTests.swift */, + 50B907341DCEFF5F00D6482E /* Info.plist */, + ); + path = FoodTrackerTests; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 50B907191DCEFF5F00D6482E /* FoodTracker */ = { + isa = PBXNativeTarget; + buildConfigurationList = 50B907371DCEFF5F00D6482E /* Build configuration list for PBXNativeTarget "FoodTracker" */; + buildPhases = ( + 50B907161DCEFF5F00D6482E /* Sources */, + 50B907171DCEFF5F00D6482E /* Frameworks */, + 50B907181DCEFF5F00D6482E /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = FoodTracker; + productName = FoodTracker; + productReference = 50B9071A1DCEFF5F00D6482E /* FoodTracker.app */; + productType = "com.apple.product-type.application"; + }; + 50B9072D1DCEFF5F00D6482E /* FoodTrackerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 50B9073A1DCEFF5F00D6482E /* Build configuration list for PBXNativeTarget "FoodTrackerTests" */; + buildPhases = ( + 50B9072A1DCEFF5F00D6482E /* Sources */, + 50B9072B1DCEFF5F00D6482E /* Frameworks */, + 50B9072C1DCEFF5F00D6482E /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 50B907301DCEFF5F00D6482E /* PBXTargetDependency */, + ); + name = FoodTrackerTests; + productName = FoodTrackerTests; + productReference = 50B9072E1DCEFF5F00D6482E /* FoodTrackerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 50B907121DCEFF5F00D6482E /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0810; + LastUpgradeCheck = 0810; + ORGANIZATIONNAME = Ace; + TargetAttributes = { + 50B907191DCEFF5F00D6482E = { + CreatedOnToolsVersion = 8.1; + DevelopmentTeam = VR7L9Q5L2E; + ProvisioningStyle = Automatic; + }; + 50B9072D1DCEFF5F00D6482E = { + CreatedOnToolsVersion = 8.1; + DevelopmentTeam = VR7L9Q5L2E; + ProvisioningStyle = Automatic; + TestTargetID = 50B907191DCEFF5F00D6482E; + }; + }; + }; + buildConfigurationList = 50B907151DCEFF5F00D6482E /* Build configuration list for PBXProject "FoodTracker" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 50B907111DCEFF5E00D6482E; + productRefGroup = 50B9071B1DCEFF5F00D6482E /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 50B907191DCEFF5F00D6482E /* FoodTracker */, + 50B9072D1DCEFF5F00D6482E /* FoodTrackerTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 50B907181DCEFF5F00D6482E /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 50B907281DCEFF5F00D6482E /* LaunchScreen.storyboard in Resources */, + 50B907251DCEFF5F00D6482E /* Assets.xcassets in Resources */, + 50B907231DCEFF5F00D6482E /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 50B9072C1DCEFF5F00D6482E /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 50B907161DCEFF5F00D6482E /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 50B907401DD434C000D6482E /* Meal.swift in Sources */, + 50B907201DCEFF5F00D6482E /* MealViewController.swift in Sources */, + 50B9073E1DD2255900D6482E /* RatingControl.swift in Sources */, + 50B9071E1DCEFF5F00D6482E /* AppDelegate.swift in Sources */, + 50B907451DD6178100D6482E /* MealTableViewController.swift in Sources */, + 50B907431DD49D4600D6482E /* MealTableViewCell.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 50B9072A1DCEFF5F00D6482E /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 50B907411DD434C000D6482E /* Meal.swift in Sources */, + 50B907331DCEFF5F00D6482E /* FoodTrackerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 50B907301DCEFF5F00D6482E /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 50B907191DCEFF5F00D6482E /* FoodTracker */; + targetProxy = 50B9072F1DCEFF5F00D6482E /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 50B907211DCEFF5F00D6482E /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 50B907221DCEFF5F00D6482E /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 50B907261DCEFF5F00D6482E /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 50B907271DCEFF5F00D6482E /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 50B907351DCEFF5F00D6482E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = 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_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVES = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + 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 = 10.1; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 50B907361DCEFF5F00D6482E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = 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_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVES = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + 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 = 10.1; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 50B907381DCEFF5F00D6482E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = VR7L9Q5L2E; + INFOPLIST_FILE = FoodTracker/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.ace.FoodTracker; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + }; + name = Debug; + }; + 50B907391DCEFF5F00D6482E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = VR7L9Q5L2E; + INFOPLIST_FILE = FoodTracker/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.ace.FoodTracker; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + }; + name = Release; + }; + 50B9073B1DCEFF5F00D6482E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + BUNDLE_LOADER = "$(TEST_HOST)"; + DEVELOPMENT_TEAM = VR7L9Q5L2E; + INFOPLIST_FILE = FoodTrackerTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.ace.FoodTrackerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FoodTracker.app/FoodTracker"; + }; + name = Debug; + }; + 50B9073C1DCEFF5F00D6482E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + BUNDLE_LOADER = "$(TEST_HOST)"; + DEVELOPMENT_TEAM = VR7L9Q5L2E; + INFOPLIST_FILE = FoodTrackerTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.ace.FoodTrackerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FoodTracker.app/FoodTracker"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 50B907151DCEFF5F00D6482E /* Build configuration list for PBXProject "FoodTracker" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 50B907351DCEFF5F00D6482E /* Debug */, + 50B907361DCEFF5F00D6482E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 50B907371DCEFF5F00D6482E /* Build configuration list for PBXNativeTarget "FoodTracker" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 50B907381DCEFF5F00D6482E /* Debug */, + 50B907391DCEFF5F00D6482E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 50B9073A1DCEFF5F00D6482E /* Build configuration list for PBXNativeTarget "FoodTrackerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 50B9073B1DCEFF5F00D6482E /* Debug */, + 50B9073C1DCEFF5F00D6482E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 50B907121DCEFF5F00D6482E /* Project object */; +} diff --git a/learn/FoodTracker/FoodTracker.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/learn/FoodTracker/FoodTracker.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..112b993 --- /dev/null +++ b/learn/FoodTracker/FoodTracker.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/learn/FoodTracker/FoodTracker.xcodeproj/project.xcworkspace/xcuserdata/ace.xcuserdatad/UserInterfaceState.xcuserstate b/learn/FoodTracker/FoodTracker.xcodeproj/project.xcworkspace/xcuserdata/ace.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..e455e34 Binary files /dev/null and b/learn/FoodTracker/FoodTracker.xcodeproj/project.xcworkspace/xcuserdata/ace.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/learn/FoodTracker/FoodTracker.xcodeproj/xcuserdata/ace.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/learn/FoodTracker/FoodTracker.xcodeproj/xcuserdata/ace.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..c4f1a7f --- /dev/null +++ b/learn/FoodTracker/FoodTracker.xcodeproj/xcuserdata/ace.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/learn/FoodTracker/FoodTracker.xcodeproj/xcuserdata/ace.xcuserdatad/xcschemes/FoodTracker.xcscheme b/learn/FoodTracker/FoodTracker.xcodeproj/xcuserdata/ace.xcuserdatad/xcschemes/FoodTracker.xcscheme new file mode 100644 index 0000000..1f51f81 --- /dev/null +++ b/learn/FoodTracker/FoodTracker.xcodeproj/xcuserdata/ace.xcuserdatad/xcschemes/FoodTracker.xcscheme @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/learn/FoodTracker/FoodTracker.xcodeproj/xcuserdata/ace.xcuserdatad/xcschemes/xcschememanagement.plist b/learn/FoodTracker/FoodTracker.xcodeproj/xcuserdata/ace.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..824cf1d --- /dev/null +++ b/learn/FoodTracker/FoodTracker.xcodeproj/xcuserdata/ace.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,27 @@ + + + + + SchemeUserState + + FoodTracker.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 50B907191DCEFF5F00D6482E + + primary + + + 50B9072D1DCEFF5F00D6482E + + primary + + + + + diff --git a/learn/FoodTracker/FoodTracker/AppDelegate.swift b/learn/FoodTracker/FoodTracker/AppDelegate.swift new file mode 100644 index 0000000..fb6dff1 --- /dev/null +++ b/learn/FoodTracker/FoodTracker/AppDelegate.swift @@ -0,0 +1,46 @@ +// +// AppDelegate.swift +// FoodTracker +// +// Created by Ace on 06/11/2016. +// Copyright © 2016 Ace. All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + func applicationWillResignActive(_ application: UIApplication) { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. + } + + func applicationDidEnterBackground(_ application: UIApplication) { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + } + + func applicationWillEnterForeground(_ application: UIApplication) { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. + } + + func applicationDidBecomeActive(_ application: UIApplication) { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + } + + func applicationWillTerminate(_ application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + } + + +} + diff --git a/learn/FoodTracker/FoodTracker/Assets.xcassets/AppIcon.appiconset/Contents.json b/learn/FoodTracker/FoodTracker/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..e5217d5 --- /dev/null +++ b/learn/FoodTracker/FoodTracker/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,94 @@ +{ + "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" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "appicon@3x.png", + "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" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/learn/FoodTracker/FoodTracker/Assets.xcassets/AppIcon.appiconset/appicon@3x.png b/learn/FoodTracker/FoodTracker/Assets.xcassets/AppIcon.appiconset/appicon@3x.png new file mode 100644 index 0000000..922cb1e Binary files /dev/null and b/learn/FoodTracker/FoodTracker/Assets.xcassets/AppIcon.appiconset/appicon@3x.png differ diff --git a/learn/FoodTracker/FoodTracker/Assets.xcassets/Contents.json b/learn/FoodTracker/FoodTracker/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/learn/FoodTracker/FoodTracker/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/learn/FoodTracker/FoodTracker/Assets.xcassets/RatingImages/Contents.json b/learn/FoodTracker/FoodTracker/Assets.xcassets/RatingImages/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/learn/FoodTracker/FoodTracker/Assets.xcassets/RatingImages/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/learn/FoodTracker/FoodTracker/Assets.xcassets/RatingImages/emptyStar.imageset/5_emptyStar_2x.png b/learn/FoodTracker/FoodTracker/Assets.xcassets/RatingImages/emptyStar.imageset/5_emptyStar_2x.png new file mode 100644 index 0000000..08d2203 Binary files /dev/null and b/learn/FoodTracker/FoodTracker/Assets.xcassets/RatingImages/emptyStar.imageset/5_emptyStar_2x.png differ diff --git a/learn/FoodTracker/FoodTracker/Assets.xcassets/RatingImages/emptyStar.imageset/Contents.json b/learn/FoodTracker/FoodTracker/Assets.xcassets/RatingImages/emptyStar.imageset/Contents.json new file mode 100644 index 0000000..2cf3eae --- /dev/null +++ b/learn/FoodTracker/FoodTracker/Assets.xcassets/RatingImages/emptyStar.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "5_emptyStar_2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/learn/FoodTracker/FoodTracker/Assets.xcassets/RatingImages/filledStar.imageset/5_filledStar_2x.png b/learn/FoodTracker/FoodTracker/Assets.xcassets/RatingImages/filledStar.imageset/5_filledStar_2x.png new file mode 100644 index 0000000..de24c53 Binary files /dev/null and b/learn/FoodTracker/FoodTracker/Assets.xcassets/RatingImages/filledStar.imageset/5_filledStar_2x.png differ diff --git a/learn/FoodTracker/FoodTracker/Assets.xcassets/RatingImages/filledStar.imageset/Contents.json b/learn/FoodTracker/FoodTracker/Assets.xcassets/RatingImages/filledStar.imageset/Contents.json new file mode 100644 index 0000000..0bcf0ad --- /dev/null +++ b/learn/FoodTracker/FoodTracker/Assets.xcassets/RatingImages/filledStar.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "5_filledStar_2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/learn/FoodTracker/FoodTracker/Assets.xcassets/SampleImages/Contents.json b/learn/FoodTracker/FoodTracker/Assets.xcassets/SampleImages/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/learn/FoodTracker/FoodTracker/Assets.xcassets/SampleImages/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/learn/FoodTracker/FoodTracker/Assets.xcassets/SampleImages/meal1.imageset/Contents.json b/learn/FoodTracker/FoodTracker/Assets.xcassets/SampleImages/meal1.imageset/Contents.json new file mode 100644 index 0000000..a06189d --- /dev/null +++ b/learn/FoodTracker/FoodTracker/Assets.xcassets/SampleImages/meal1.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "meal1.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/learn/FoodTracker/FoodTracker/Assets.xcassets/SampleImages/meal1.imageset/meal1.png b/learn/FoodTracker/FoodTracker/Assets.xcassets/SampleImages/meal1.imageset/meal1.png new file mode 100644 index 0000000..373957b Binary files /dev/null and b/learn/FoodTracker/FoodTracker/Assets.xcassets/SampleImages/meal1.imageset/meal1.png differ diff --git a/learn/FoodTracker/FoodTracker/Assets.xcassets/SampleImages/meal2.imageset/Contents.json b/learn/FoodTracker/FoodTracker/Assets.xcassets/SampleImages/meal2.imageset/Contents.json new file mode 100644 index 0000000..877323f --- /dev/null +++ b/learn/FoodTracker/FoodTracker/Assets.xcassets/SampleImages/meal2.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "meal2.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/learn/FoodTracker/FoodTracker/Assets.xcassets/SampleImages/meal2.imageset/meal2.png b/learn/FoodTracker/FoodTracker/Assets.xcassets/SampleImages/meal2.imageset/meal2.png new file mode 100644 index 0000000..5c2f7f7 Binary files /dev/null and b/learn/FoodTracker/FoodTracker/Assets.xcassets/SampleImages/meal2.imageset/meal2.png differ diff --git a/learn/FoodTracker/FoodTracker/Assets.xcassets/SampleImages/meal3.imageset/Contents.json b/learn/FoodTracker/FoodTracker/Assets.xcassets/SampleImages/meal3.imageset/Contents.json new file mode 100644 index 0000000..f44dc0e --- /dev/null +++ b/learn/FoodTracker/FoodTracker/Assets.xcassets/SampleImages/meal3.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "meal3.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/learn/FoodTracker/FoodTracker/Assets.xcassets/SampleImages/meal3.imageset/meal3.png b/learn/FoodTracker/FoodTracker/Assets.xcassets/SampleImages/meal3.imageset/meal3.png new file mode 100644 index 0000000..f2de346 Binary files /dev/null and b/learn/FoodTracker/FoodTracker/Assets.xcassets/SampleImages/meal3.imageset/meal3.png differ diff --git a/learn/FoodTracker/FoodTracker/Assets.xcassets/defaultPhoto.imageset/Contents.json b/learn/FoodTracker/FoodTracker/Assets.xcassets/defaultPhoto.imageset/Contents.json new file mode 100644 index 0000000..64cc7f4 --- /dev/null +++ b/learn/FoodTracker/FoodTracker/Assets.xcassets/defaultPhoto.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "defaultphoto_2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/learn/FoodTracker/FoodTracker/Assets.xcassets/defaultPhoto.imageset/defaultphoto_2x.png b/learn/FoodTracker/FoodTracker/Assets.xcassets/defaultPhoto.imageset/defaultphoto_2x.png new file mode 100644 index 0000000..0a17edc Binary files /dev/null and b/learn/FoodTracker/FoodTracker/Assets.xcassets/defaultPhoto.imageset/defaultphoto_2x.png differ diff --git a/learn/FoodTracker/FoodTracker/Base.lproj/LaunchScreen.storyboard b/learn/FoodTracker/FoodTracker/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..fdf3f97 --- /dev/null +++ b/learn/FoodTracker/FoodTracker/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/learn/FoodTracker/FoodTracker/Base.lproj/Main.storyboard b/learn/FoodTracker/FoodTracker/Base.lproj/Main.storyboard new file mode 100644 index 0000000..a4ada04 --- /dev/null +++ b/learn/FoodTracker/FoodTracker/Base.lproj/Main.storyboard @@ -0,0 +1,204 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/learn/FoodTracker/FoodTracker/Info.plist b/learn/FoodTracker/FoodTracker/Info.plist new file mode 100644 index 0000000..06a999d --- /dev/null +++ b/learn/FoodTracker/FoodTracker/Info.plist @@ -0,0 +1,49 @@ + + + + + NSCameraUsageDescription + Camera + NSPhotoLibraryUsageDescription + i need your photo + CFBundleDevelopmentRegion + zh_CN + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/learn/FoodTracker/FoodTracker/Meal.swift b/learn/FoodTracker/FoodTracker/Meal.swift new file mode 100644 index 0000000..aec1361 --- /dev/null +++ b/learn/FoodTracker/FoodTracker/Meal.swift @@ -0,0 +1,37 @@ +// +// Meal.swift +// FoodTracker +// +// Created by Ace on 10/11/2016. +// Copyright © 2016 Ace. All rights reserved. +// + +import UIKit + +class Meal { + + // MARK: Properties + var name: String + + var photo: UIImage? + + var rating: Int + + + // MARK: Initializtion + + init?(name: String, photo: UIImage?, rating: Int) { + guard !name.isEmpty else { + return nil + } + + guard rating >= 0 else { + return nil + } + + self.name = name + self.photo = photo + self.rating = rating + } + +} diff --git a/learn/FoodTracker/FoodTracker/MealTableViewCell.swift b/learn/FoodTracker/FoodTracker/MealTableViewCell.swift new file mode 100644 index 0000000..4847f51 --- /dev/null +++ b/learn/FoodTracker/FoodTracker/MealTableViewCell.swift @@ -0,0 +1,29 @@ +// +// MealTableViewCell.swift +// FoodTracker +// +// Created by Ace on 10/11/2016. +// Copyright © 2016 Ace. All rights reserved. +// + +import UIKit + +class MealTableViewCell: UITableViewCell { + + // MARK: Properties + @IBOutlet weak var nameLabel: UILabel! + @IBOutlet weak var photoImageView: UIImageView! + @IBOutlet weak var ratingControl: RatingControl! + + override func awakeFromNib() { + super.awakeFromNib() + // Initialization code + } + + override func setSelected(_ selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) + + // Configure the view for the selected state + } + +} diff --git a/learn/FoodTracker/FoodTracker/MealTableViewController.swift b/learn/FoodTracker/FoodTracker/MealTableViewController.swift new file mode 100644 index 0000000..2991d61 --- /dev/null +++ b/learn/FoodTracker/FoodTracker/MealTableViewController.swift @@ -0,0 +1,132 @@ +// +// MealTableViewController.swift +// FoodTracker +// +// Created by Ace on 11/11/2016. +// Copyright © 2016 Ace. All rights reserved. +// + +import UIKit + +class MealTableViewController: UITableViewController { + + // MARK: Properties + var meals = [Meal]() + + override func viewDidLoad() { + super.viewDidLoad() + + // Uncomment the following line to preserve selection between presentations + // self.clearsSelectionOnViewWillAppear = false + + // Uncomment the following line to display an Edit button in the navigation bar for this view controller. + // self.navigationItem.rightBarButtonItem = self.editButtonItem() + + loadSampleMeals() + } + + func loadSampleMeals() { + let photo1 = UIImage(named: "meal1") + let meal1 = Meal(name: "Caprese Salad", photo: photo1, rating: 4)! + + + let photo2 = UIImage(named: "meal2") + let meal2 = Meal(name: "Chicken and Potatoes", photo: photo2, rating: 5)! + + let photo3 = UIImage(named: "meal3") + let meal3 = Meal(name: "Pasta with Meatballs", photo: photo3, rating: 3)! + + meals += [meal1, meal2, meal3] + + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + // MARK: - Table view data source + + override func numberOfSections(in tableView: UITableView) -> Int { + // #warning Incomplete implementation, return the number of sections + return 1 + } + + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + // #warning Incomplete implementation, return the number of rows + return meals.count + } + + + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cellIdentifier = "MealTableViewCell" + let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as! MealTableViewCell + + let meal = meals[indexPath.row] + + cell.nameLabel.text = meal.name + cell.photoImageView.image = meal.photo + cell.ratingControl.rating = meal.rating + + // Configure the cell... + + return cell + } + + + /* + // Override to support conditional editing of the table view. + override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { + // Return false if you do not want the specified item to be editable. + return true + } + */ + + /* + // Override to support editing the table view. + override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) { + if editingStyle == .delete { + // Delete the row from the data source + tableView.deleteRows(at: [indexPath], with: .fade) + } else if editingStyle == .insert { + // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view + } + } + */ + + /* + // Override to support rearranging the table view. + override func tableView(_ tableView: UITableView, moveRowAt fromIndexPath: IndexPath, to: IndexPath) { + + } + */ + + /* + // Override to support conditional rearranging of the table view. + override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool { + // Return false if you do not want the item to be re-orderable. + return true + } + */ + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + // Get the new view controller using segue.destinationViewController. + // Pass the selected object to the new view controller. + } + */ + + + @IBAction func unwindToMealList(_ sender: UIStoryboardSegue) { + if let sourceViewController = sender.source as? MealViewController, let meal = sourceViewController.meal { + let newIndexPath = IndexPath(row: meals.count, section: 0) + meals.append(meal) + tableView.insertRows(at: [newIndexPath], with: .bottom) + + } + } + +} diff --git a/learn/FoodTracker/FoodTracker/MealViewController.swift b/learn/FoodTracker/FoodTracker/MealViewController.swift new file mode 100644 index 0000000..73d8a86 --- /dev/null +++ b/learn/FoodTracker/FoodTracker/MealViewController.swift @@ -0,0 +1,113 @@ +// +// ViewController.swift +// FoodTracker +// +// Created by Ace on 06/11/2016. +// Copyright © 2016 Ace. All rights reserved. +// + +import UIKit + +class MealViewController: UIViewController, UITextFieldDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate { + + // MARK: Properties + @IBOutlet weak var nameTextField: UITextField! + @IBOutlet weak var mealNameLabel: UILabel! + @IBOutlet weak var photoImageView: UIImageView! + @IBOutlet weak var ratingControl: RatingControl! + @IBOutlet weak var saveButton: UIBarButtonItem! + + var meal: Meal? + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view, typically from a nib. + + nameTextField.delegate = self + + checkValidMealName() + + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + // MARK: UITextFieldDelegate + func textFieldShouldReturn(_ textField: UITextField) -> Bool { + // Hide Keyboard + textField.resignFirstResponder() + return true; + } + + func textFieldDidBeginEditing(_ textField: UITextField) { + saveButton.isEnabled = false + } + func checkValidMealName() { + let name = nameTextField.text ?? "" + + saveButton.isEnabled = !name.isEmpty + } + + func textFieldDidEndEditing(_ textField: UITextField) { + checkValidMealName() + navigationItem.title = textField.text + mealNameLabel.text = textField.text + } + + + // MARK: UIImagePickerControllerDelegate + + func imagePickerControllerDidCancel(_ picker: UIImagePickerController) { + dismiss(animated: true, completion: nil) + } + + func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) { + + let selectedImage = info[UIImagePickerControllerOriginalImage] as! UIImage + + photoImageView.image = selectedImage + + dismiss(animated: true, completion: nil) + } + + + // MARK: Navigation + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + if let barButton = sender as? UIBarButtonItem { + if saveButton === barButton { + let name = nameTextField.text ?? "" + let photo = photoImageView.image + let rating = ratingControl.rating + + meal = Meal(name: name, photo: photo, rating: rating) + } + } + } + + @IBAction func cancel(_ sender: UIBarButtonItem) { + dismiss(animated: true, completion: nil) + } + + + // MARK: Actions + + @IBAction func selectImageFromPhotoLibrary(_ sender: UITapGestureRecognizer) { + + nameTextField.resignFirstResponder() + + let imagePickerController = UIImagePickerController() + + imagePickerController.sourceType = .photoLibrary + + imagePickerController.delegate = self + + present(imagePickerController, animated: true, completion: nil) + } + + @IBAction func setDefaultLabelText(_ sender: UIButton) { + mealNameLabel.text = "Default Text" + } +} + diff --git a/learn/FoodTracker/FoodTracker/RatingControl.swift b/learn/FoodTracker/FoodTracker/RatingControl.swift new file mode 100644 index 0000000..906cd95 --- /dev/null +++ b/learn/FoodTracker/FoodTracker/RatingControl.swift @@ -0,0 +1,99 @@ +// +// RatingControl.swift +// FoodTracker +// +// Created by Ace on 08/11/2016. +// Copyright © 2016 Ace. All rights reserved. +// + +import UIKit + +class RatingControl: UIView { + + /* + // Only override draw() if you perform custom drawing. + // An empty implementation adversely affects performance during animation. + override func draw(_ rect: CGRect) { + // Drawing code + } + */ + + // MARK: Initialization + + var spacing = 5 + var stars = 5 + + var rating = 0 { + didSet { + setNeedsLayout() + } + } + var ratingButtons = [UIButton]() + + + required init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + +/* + for _ in 0.. + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + +