Skip to content

Commit

Permalink
Merge pull request #7 from chaione/add-login-style
Browse files Browse the repository at this point in the history
Add login style
  • Loading branch information
initFabian authored Nov 5, 2016
2 parents 53b3a43 + 4aff6dc commit ab32bfc
Show file tree
Hide file tree
Showing 41 changed files with 976 additions and 282 deletions.
1 change: 1 addition & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ disabled_rules: # rule identifiers to exclude from running
- line_length
- variable_name
- force_cast
- type_name

opt_in_rules:
- missing-docs
Expand Down
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "matthewpalmer/Locksmith"
github "matthewpalmer/Locksmith" ~> 3.0
10 changes: 5 additions & 5 deletions Cely Demo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

Cely.setup(with: window!, forModel: User.ref, requiredProperties: [.Token], withOptions: [
.LoginCompletionBlock: { (username: String, password: String) in
Cely.setup(with: window!, forModel: User(), requiredProperties: [.token], withOptions: [
.loginCompletionBlock: { (username: String, password: String) in
if username == "asdf" && password == "asdf" {
Cely.save(username, forKey: "username", persisted: true)
Cely.save(username, forKey: "username")
Cely.save("FAKETOKEN:\(username)\(password)", forKey: "token", securely: true)
Cely.changeStatus(to: .LoggedIn)
Cely.changeStatus(to: .loggedIn)
}
}
])
])

return true
}
Expand Down
25 changes: 25 additions & 0 deletions Cely Demo/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
Expand Down Expand Up @@ -30,6 +40,16 @@
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
Expand Down Expand Up @@ -59,6 +79,11 @@
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
}
],
"info" : {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions Cely Demo/Assets.xcassets/CelyThin.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "CelyThin.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "CelyThin@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions Cely Demo/Assets.xcassets/ChaiOneLogo.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "511993.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
6 changes: 6 additions & 0 deletions Cely Demo/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
4 changes: 2 additions & 2 deletions Cely Demo/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="15G1004" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="15G1108" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
Expand All @@ -26,7 +26,7 @@
</connections>
</button>
</subviews>
<color key="backgroundColor" red="0.59607845540000004" green="0.66274511810000003" blue="0.98431372640000003" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" red="0.33725490200000002" green="0.79607843140000001" blue="0.97647058819999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="xxd-Ai-Z3U" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" id="kQN-ME-Rw9"/>
<constraint firstItem="xxd-Ai-Z3U" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leadingMargin" id="yYA-Xs-rH6"/>
Expand Down
17 changes: 17 additions & 0 deletions Cely Demo/LoginStyles.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// LoginStyles.swift
// Cely
//
// Created by Fabian Buentello on 11/4/16.
// Copyright © 2016 Fabian Buentello. All rights reserved.
//

import Foundation
import Cely

struct LoginStyles: CelyStyle {

func appLogo() -> UIImage? {
return UIImage(named: "ChaiOneLogo")
}
}
19 changes: 8 additions & 11 deletions Cely Demo/User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@ import Cely

struct User: CelyUser {

private init() {}
static let ref = User()

enum Property: CelyProperty {
case Username = "username"
case Email = "email"
case Token = "token"
case username = "username"
case email = "email"
case token = "token"

func securely() -> Bool {
switch self {
case .Token:
case .token:
return true
default:
return false
Expand All @@ -30,7 +27,7 @@ struct User: CelyUser {

func persisted() -> Bool {
switch self {
case .Username:
case .username:
return true
default:
return false
Expand All @@ -51,17 +48,17 @@ struct User: CelyUser {

extension User {

static func save(value: Any, as property: Property) {
static func save(_ value: Any, as property: Property) {
property.save(value: value)
}

static func save(data: [Property : Any]) {
static func save(_ data: [Property : Any]) {
data.forEach { property, value in
property.save(value)
}
}

static func get(property: Property) -> Any? {
static func get(_ property: Property) -> Any? {
return property.get()
}
}
50 changes: 40 additions & 10 deletions Cely.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@
31358EC51DB31D3300AC7119 /* Locksmith.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 31358EC41DB31D3300AC7119 /* Locksmith.framework */; };
31358EC61DB31D3300AC7119 /* Locksmith.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 31358EC41DB31D3300AC7119 /* Locksmith.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
317516421DB7BD9D00974002 /* TestStoryboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 317516401DB7B23C00974002 /* TestStoryboard.storyboard */; };
31D9B96C1DCD72700039BCB8 /* CelyProtocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31D9B96B1DCD72700039BCB8 /* CelyProtocols.swift */; };
31D9B96E1DCD748F0039BCB8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 31D9B96D1DCD748F0039BCB8 /* Assets.xcassets */; };
31DA8A581DCD8E8F0006C598 /* LoginStyles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31DA8A571DCD8E8F0006C598 /* LoginStyles.swift */; };
31DAA33E1DB289220040B266 /* CelyWindowManagerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31DAA33D1DB289220040B266 /* CelyWindowManagerTest.swift */; };
31DB1FEB1DCE111900BE1D1A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 31D9B96D1DCD748F0039BCB8 /* Assets.xcassets */; };
31DB1FED1DCE132200BE1D1A /* ChaiOneLogo.png in Resources */ = {isa = PBXBuildFile; fileRef = 31DB1FEC1DCE132200BE1D1A /* ChaiOneLogo.png */; };
31DB1FEF1DCE226700BE1D1A /* ConstantsAndProtocolTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31DB1FEE1DCE226700BE1D1A /* ConstantsAndProtocolTests.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -93,13 +99,13 @@
1F9E55C21DC2426000435B52 /* LoginViewControllerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginViewControllerTests.swift; sourceTree = "<group>"; };
1FAA023C1D4E7B5B00A6D209 /* Cely.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Cely.framework; sourceTree = BUILT_PRODUCTS_DIR; };
1FAA023F1D4E7B5B00A6D209 /* Cely.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Cely.h; sourceTree = "<group>"; };
1FAA02411D4E7B5B00A6D209 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
1FAA02411D4E7B5B00A6D209 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = "Supporting Files/Info.plist"; sourceTree = "<group>"; };
1FABFAEC1DBE727F0096DD36 /* TestMain.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = TestMain.storyboard; path = CelyTests/TestMain.storyboard; sourceTree = SOURCE_ROOT; };
1FB2B23C1DB1751600716E80 /* CelyTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CelyTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
1FB2B23E1DB1751600716E80 /* CelyTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = CelyTests.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
1FB2B2401DB1751600716E80 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
1FDAB4D91D4E7BC9003AC5EE /* Cely.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Cely.storyboard; sourceTree = "<group>"; };
1FDAB4DB1D4E7BDC003AC5EE /* CelyLoginViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CelyLoginViewController.swift; sourceTree = "<group>"; };
1FDAB4D91D4E7BC9003AC5EE /* Cely.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Cely.storyboard; path = "Supporting Files/Cely.storyboard"; sourceTree = "<group>"; };
1FDAB4DB1D4E7BDC003AC5EE /* CelyLoginViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CelyLoginViewController.swift; path = "Supporting Files/CelyLoginViewController.swift"; sourceTree = "<group>"; };
1FDAB4DD1D4E7BE4003AC5EE /* Cely.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = Cely.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
311B1F2B1DB31FF6005A155B /* User.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = "<group>"; };
311B1F2D1DB3230F005A155B /* SettingsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsViewController.swift; sourceTree = "<group>"; };
Expand All @@ -115,7 +121,12 @@
31358EBF1DB31CA800AC7119 /* Locksmith.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Locksmith.framework; sourceTree = "<group>"; };
31358EC41DB31D3300AC7119 /* Locksmith.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Locksmith.framework; path = "Cely Demo/Locksmith.framework"; sourceTree = "<group>"; };
317516401DB7B23C00974002 /* TestStoryboard.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = TestStoryboard.storyboard; path = ../CelyTests/Frameworks/TestStoryboard.storyboard; sourceTree = "<group>"; };
31D9B96B1DCD72700039BCB8 /* CelyProtocols.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CelyProtocols.swift; sourceTree = "<group>"; };
31D9B96D1DCD748F0039BCB8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = "Supporting Files/Assets.xcassets"; sourceTree = "<group>"; };
31DA8A571DCD8E8F0006C598 /* LoginStyles.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginStyles.swift; sourceTree = "<group>"; };
31DAA33D1DB289220040B266 /* CelyWindowManagerTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CelyWindowManagerTest.swift; sourceTree = "<group>"; };
31DB1FEC1DCE132200BE1D1A /* ChaiOneLogo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ChaiOneLogo.png; sourceTree = "<group>"; };
31DB1FEE1DCE226700BE1D1A /* ConstantsAndProtocolTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstantsAndProtocolTests.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -172,11 +183,12 @@
1FAA023E1D4E7B5B00A6D209 /* Cely */ = {
isa = PBXGroup;
children = (
1FAA023F1D4E7B5B00A6D209 /* Cely.h */,
1FDAB4DD1D4E7BE4003AC5EE /* Cely.swift */,
1F801A1F1DB143C100187FA6 /* CelyConstants.swift */,
31D9B96B1DCD72700039BCB8 /* CelyProtocols.swift */,
1F801A211DB1473A00187FA6 /* CelyStorage.swift */,
1F801A1A1DB141C100187FA6 /* CelyWindowManager.swift */,
1FAA023F1D4E7B5B00A6D209 /* Cely.h */,
1FB2B24A1DB1754B00716E80 /* Supporting Files */,
1FAA023D1D4E7B5B00A6D209 /* Products */,
);
Expand All @@ -186,8 +198,11 @@
1FB2B23D1DB1751600716E80 /* CelyTests */ = {
isa = PBXGroup;
children = (
31DB1FEC1DCE132200BE1D1A /* ChaiOneLogo.png */,
1FABFAEC1DBE727F0096DD36 /* TestMain.storyboard */,
1FB2B23E1DB1751600716E80 /* CelyTests.swift */,
1F9E55C21DC2426000435B52 /* LoginViewControllerTests.swift */,
31DB1FEE1DCE226700BE1D1A /* ConstantsAndProtocolTests.swift */,
1F0C13341DB188AB00AC1C94 /* CelyStorageTests.swift */,
31DAA33D1DB289220040B266 /* CelyWindowManagerTest.swift */,
1FB2B2401DB1751600716E80 /* Info.plist */,
Expand All @@ -198,9 +213,9 @@
1FB2B24A1DB1754B00716E80 /* Supporting Files */ = {
isa = PBXGroup;
children = (
31D9B96D1DCD748F0039BCB8 /* Assets.xcassets */,
1FAA02411D4E7B5B00A6D209 /* Info.plist */,
1FDAB4D91D4E7BC9003AC5EE /* Cely.storyboard */,
1FABFAEC1DBE727F0096DD36 /* TestMain.storyboard */,
1FDAB4DB1D4E7BDC003AC5EE /* CelyLoginViewController.swift */,
);
name = "Supporting Files";
Expand All @@ -218,18 +233,27 @@
isa = PBXGroup;
children = (
31358EBF1DB31CA800AC7119 /* Locksmith.framework */,
31358EB91DB31BDE00AC7119 /* Cely Demo.entitlements */,
31358EA91DB31BC400AC7119 /* AppDelegate.swift */,
311B1F2B1DB31FF6005A155B /* User.swift */,
31358EAB1DB31BC400AC7119 /* ViewController.swift */,
31DA8A571DCD8E8F0006C598 /* LoginStyles.swift */,
311B1F2D1DB3230F005A155B /* SettingsViewController.swift */,
31DA8A561DCD8E600006C598 /* Supporting Files */,
);
path = "Cely Demo";
sourceTree = "<group>";
};
31DA8A561DCD8E600006C598 /* Supporting Files */ = {
isa = PBXGroup;
children = (
31358EB91DB31BDE00AC7119 /* Cely Demo.entitlements */,
31358EAD1DB31BC400AC7119 /* Main.storyboard */,
317516401DB7B23C00974002 /* TestStoryboard.storyboard */,
31358EB01DB31BC400AC7119 /* Assets.xcassets */,
31358EB21DB31BC400AC7119 /* LaunchScreen.storyboard */,
31358EB51DB31BC400AC7119 /* Info.plist */,
311B1F2B1DB31FF6005A155B /* User.swift */,
);
path = "Cely Demo";
name = "Supporting Files";
sourceTree = "<group>";
};
/* End PBXGroup section */
Expand Down Expand Up @@ -363,6 +387,7 @@
buildActionMask = 2147483647;
files = (
1FDAB4DA1D4E7BC9003AC5EE /* Cely.storyboard in Resources */,
31D9B96E1DCD748F0039BCB8 /* Assets.xcassets in Resources */,
1FABFAED1DBE727F0096DD36 /* TestMain.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -371,6 +396,8 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
31DB1FED1DCE132200BE1D1A /* ChaiOneLogo.png in Resources */,
31DB1FEB1DCE111900BE1D1A /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -409,6 +436,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
31D9B96C1DCD72700039BCB8 /* CelyProtocols.swift in Sources */,
1F801A201DB143C100187FA6 /* CelyConstants.swift in Sources */,
1FDAB4DE1D4E7BE4003AC5EE /* Cely.swift in Sources */,
1FDAB4DC1D4E7BDC003AC5EE /* CelyLoginViewController.swift in Sources */,
Expand All @@ -421,6 +449,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
31DB1FEF1DCE226700BE1D1A /* ConstantsAndProtocolTests.swift in Sources */,
1F9E55C31DC2426000435B52 /* LoginViewControllerTests.swift in Sources */,
1F0C13351DB188AB00AC1C94 /* CelyStorageTests.swift in Sources */,
1FB2B23F1DB1751600716E80 /* CelyTests.swift in Sources */,
Expand All @@ -434,6 +463,7 @@
files = (
31358EAC1DB31BC400AC7119 /* ViewController.swift in Sources */,
31358EAA1DB31BC400AC7119 /* AppDelegate.swift in Sources */,
31DA8A581DCD8E8F0006C598 /* LoginStyles.swift in Sources */,
311B1F2C1DB31FF6005A155B /* User.swift in Sources */,
311B1F2E1DB3230F005A155B /* SettingsViewController.swift in Sources */,
);
Expand Down Expand Up @@ -591,7 +621,7 @@
"$(PROJECT_DIR)/Carthage/Build/iOS",
"$(PROJECT_DIR)/Cely\\ Demo",
);
INFOPLIST_FILE = Cely/Info.plist;
INFOPLIST_FILE = "$(SRCROOT)/Cely/Supporting Files/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.chaione.Cely;
Expand All @@ -618,7 +648,7 @@
"$(PROJECT_DIR)/Carthage/Build/iOS",
"$(PROJECT_DIR)/Cely\\ Demo",
);
INFOPLIST_FILE = Cely/Info.plist;
INFOPLIST_FILE = "$(SRCROOT)/Cely/Supporting Files/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.chaione.Cely;
Expand Down
Loading

0 comments on commit ab32bfc

Please sign in to comment.