From 94fa7d4f2569c26a1d238a2e3470494dc9c2a8fa Mon Sep 17 00:00:00 2001 From: "Huai-Che (Acsa) Lu" Date: Fri, 27 Nov 2015 12:20:43 -0500 Subject: [PATCH 1/7] Revamp new interaction flow. --- Emome.xcodeproj/project.pbxproj | 8 + .../btn-eraser.imageset/Contents.json | 22 + .../btn-eraser.imageset/btn-eraser@2x.png | Bin 0 -> 1248 bytes .../btn-eraser.imageset/btn-eraser@3x.png | Bin 0 -> 2006 bytes Emome/Base.lproj/LaunchScreen.storyboard | 2 +- Emome/Base.lproj/Main.storyboard | 882 ++++-------------- Emome/EMOColorSplashViewController.swift | 238 +++++ Emome/EMOEnums.swift | 22 + Emome/EMOHomeViewController.swift | 36 + Emome/EMOSuggestionView.xib | 2 +- Emome/EmoEmomeColors.swift | 9 + 11 files changed, 525 insertions(+), 696 deletions(-) create mode 100644 Emome/Assets.xcassets/btn-eraser.imageset/Contents.json create mode 100644 Emome/Assets.xcassets/btn-eraser.imageset/btn-eraser@2x.png create mode 100644 Emome/Assets.xcassets/btn-eraser.imageset/btn-eraser@3x.png create mode 100644 Emome/EMOColorSplashViewController.swift create mode 100644 Emome/EMOHomeViewController.swift diff --git a/Emome.xcodeproj/project.pbxproj b/Emome.xcodeproj/project.pbxproj index 347949b..df2f552 100644 --- a/Emome.xcodeproj/project.pbxproj +++ b/Emome.xcodeproj/project.pbxproj @@ -17,6 +17,7 @@ 9030FF4B1BFA416300948793 /* EMOSuggestionView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9030FF4A1BFA416300948793 /* EMOSuggestionView.xib */; }; 9030FF4E1BFA419100948793 /* EMOSuggestion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9030FF4D1BFA419100948793 /* EMOSuggestion.swift */; }; 9030FF511BFAC92300948793 /* EMOEnums.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9030FF501BFAC92300948793 /* EMOEnums.swift */; }; + 903A2DE11C07B27C00C8964A /* EMOColorSplashViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 903A2DE01C07B27C00C8964A /* EMOColorSplashViewController.swift */; }; 906190B61BE6E4BC0061E103 /* EmoEmomeColors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 906190B51BE6E4BC0061E103 /* EmoEmomeColors.swift */; }; 907C0F411BDEA8E700C896D3 /* EMOEmotionMeterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 907C0F401BDEA8E700C896D3 /* EMOEmotionMeterViewController.swift */; }; 907C0F431BDEA94C00C896D3 /* EMOScenarioSelectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 907C0F421BDEA94C00C896D3 /* EMOScenarioSelectionViewController.swift */; }; @@ -30,6 +31,7 @@ 90C6FD4A1BB0B5CF009F9FB3 /* EMOEmotionSelectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90C6FD491BB0B5CF009F9FB3 /* EMOEmotionSelectionViewController.swift */; }; 90C6FD4F1BB0B5CF009F9FB3 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 90C6FD4E1BB0B5CF009F9FB3 /* Assets.xcassets */; }; 90C6FD521BB0B5CF009F9FB3 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 90C6FD501BB0B5CF009F9FB3 /* LaunchScreen.storyboard */; }; + 90EFFD851C0806BF005AD750 /* EMOHomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90EFFD841C0806BF005AD750 /* EMOHomeViewController.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -64,6 +66,7 @@ 9030FF4A1BFA416300948793 /* EMOSuggestionView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = EMOSuggestionView.xib; sourceTree = ""; }; 9030FF4D1BFA419100948793 /* EMOSuggestion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EMOSuggestion.swift; sourceTree = ""; }; 9030FF501BFAC92300948793 /* EMOEnums.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EMOEnums.swift; sourceTree = ""; }; + 903A2DE01C07B27C00C8964A /* EMOColorSplashViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EMOColorSplashViewController.swift; sourceTree = ""; }; 906190B51BE6E4BC0061E103 /* EmoEmomeColors.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EmoEmomeColors.swift; sourceTree = ""; }; 907C0F401BDEA8E700C896D3 /* EMOEmotionMeterViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EMOEmotionMeterViewController.swift; sourceTree = ""; }; 907C0F421BDEA94C00C896D3 /* EMOScenarioSelectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EMOScenarioSelectionViewController.swift; sourceTree = ""; }; @@ -81,6 +84,7 @@ 90C6FD4E1BB0B5CF009F9FB3 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 90C6FD511BB0B5CF009F9FB3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 90C6FD531BB0B5CF009F9FB3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 90EFFD841C0806BF005AD750 /* EMOHomeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EMOHomeViewController.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -154,6 +158,8 @@ 90979B3B1BF8E84000F0DD67 /* MyIdeasTab */, 90DC3F4A1BFD057F0064DE5D /* MeTab */, 35E703041BE6E3CD0001B75D /* SpotifyApiTestViewController.swift */, + 903A2DE01C07B27C00C8964A /* EMOColorSplashViewController.swift */, + 90EFFD841C0806BF005AD750 /* EMOHomeViewController.swift */, ); name = ViewControllers; sourceTree = ""; @@ -469,6 +475,8 @@ 907C0F411BDEA8E700C896D3 /* EMOEmotionMeterViewController.swift in Sources */, 35E703051BE6E3CD0001B75D /* SpotifyApiTestViewController.swift in Sources */, 90979B3D1BF8EADB00F0DD67 /* EMOMyIdeasViewController.swift in Sources */, + 903A2DE11C07B27C00C8964A /* EMOColorSplashViewController.swift in Sources */, + 90EFFD851C0806BF005AD750 /* EMOHomeViewController.swift in Sources */, 907C0F431BDEA94C00C896D3 /* EMOScenarioSelectionViewController.swift in Sources */, 907C0F451BDEA9AC00C896D3 /* EMOSeggestionViewController.swift in Sources */, 90C6FD4A1BB0B5CF009F9FB3 /* EMOEmotionSelectionViewController.swift in Sources */, diff --git a/Emome/Assets.xcassets/btn-eraser.imageset/Contents.json b/Emome/Assets.xcassets/btn-eraser.imageset/Contents.json new file mode 100644 index 0000000..dab0191 --- /dev/null +++ b/Emome/Assets.xcassets/btn-eraser.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "btn-eraser@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "btn-eraser@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Emome/Assets.xcassets/btn-eraser.imageset/btn-eraser@2x.png b/Emome/Assets.xcassets/btn-eraser.imageset/btn-eraser@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..5af0d163c40d87662c38d7cd591047f3c21d3bf5 GIT binary patch literal 1248 zcmeAS@N?(olHy`uVBq!ia0vp^89+RVgAGWo6z#tUq*&4&eH|GXHuiJ>Nn{0br+d0M zhEy=Vyo^5kJ08>rCHWe*D zYr68S^^3Dg4^|k-q(7ZoQd06|q3<@g1rcSYVz#-Pd!BE}SJ-E9=g$56`)`-HDF^6i zT$kIo*3|Uo$B&=%tnBRSZk9wzFZeV+Adi#x$niUSmu<~$SZAvH@Z(J>3rowLH%iig zvb=rKPRz@fFJBCjeX~Ex{O^Qy{nK9u1aC8Q@U^b6*~r)+bb9SZsRdHHYVQ~{Hr|n1 z&A94f(j&fs6_%KGclPYr=8vv_ns)W|o40RQZhV__@l#$-j!jVNvHMXH>({TZw`1AFNje=hn^IRbN(aA@i@RUgxvm@>_*7ZT9&khz#@ym)78&qol`;+0C}V{AOHXW literal 0 HcmV?d00001 diff --git a/Emome/Assets.xcassets/btn-eraser.imageset/btn-eraser@3x.png b/Emome/Assets.xcassets/btn-eraser.imageset/btn-eraser@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..dac20b9539fceeaa81fec11ed0eaddca1b20774a GIT binary patch literal 2006 zcmeAS@N?(olHy`uVBq!ia0vp^bAb3Z2OE%_@$|<`AjOjI=ksv-tE=<>>o}fcR(x*5s2NYc2-%}@k zZ2k8OGq;y`Klt;fMreN7{v+pq{%$#qbF*TdErp2FAH<@3;&dzSH|LK)A zyZBP`da2xfZx1H7vdp@FSyoQ2?#5T$ay~u2oPA#pCbP0Wn*6SNUH&?!Eg>;Ms4@g2KX!zoL_3 zo2qxtui3MD8`JdZ)6d%5W`BJl6!ZE0%?gDAeY=PAvQ9e`j-}s{?`|tG_plU1s zCuvJrXW3h9VFjwZZ9KzWft5o~bH_>ng&ka}=R6pjyt(qUSUA=>%`^^bcrdAHHWy>l z>VRiGA__Z}JXq$`@IY&drSdS;^5c7b?B?y;zb9D8)Y+bIw6?b9e?If|?=vMfQCwl4MzkfErtL>Ye|B0BtJ#oCkrf#9+qv;`@ zM;n409?Y5bW)c&NdZ$DIm%yCh$+5ryRS{(NV{9tU+T;xsQb{_X=}_S3Tjt5wG}(p6 zf|cXk%9DCPp-CN#%NY(@n%-1p - + diff --git a/Emome/Base.lproj/Main.storyboard b/Emome/Base.lproj/Main.storyboard index 283356e..ba49c57 100644 --- a/Emome/Base.lproj/Main.storyboard +++ b/Emome/Base.lproj/Main.storyboard @@ -1,8 +1,9 @@ - + + @@ -67,624 +68,144 @@ - - + + - + - - + + - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - - + + - + - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + - + - + @@ -789,7 +310,7 @@ - + @@ -803,43 +324,6 @@ - - @@ -855,26 +339,60 @@ + - + + + - + - - - @@ -899,10 +417,11 @@ + - + @@ -931,17 +450,32 @@ + - + + - + @@ -953,41 +487,25 @@ - - + - - + - + + - @@ -1005,47 +523,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1085,10 +563,10 @@ - + - - - + + + + + + + + + + + + + + + + + + + + + - - + - + - + - + - + @@ -1178,8 +674,6 @@ - - diff --git a/Emome/EMOColorSplashViewController.swift b/Emome/EMOColorSplashViewController.swift new file mode 100644 index 0000000..31043e9 --- /dev/null +++ b/Emome/EMOColorSplashViewController.swift @@ -0,0 +1,238 @@ +// +// EMOColorSplashViewController.swift +// Emome +// +// Created by Huai-Che Lu on 11/26/15. +// Copyright © 2015 Emome. All rights reserved. +// + +import UIKit +import QuartzCore + +class EMOColorSplashViewController: UIViewController { + + @IBOutlet weak var panelView: UIView! + var pusher: UIPushBehavior! + var animator: UIDynamicAnimator! + + var touchStartTime: NSTimeInterval? + + var newLayer: CAShapeLayer? + + var isPanelSetUp = false + + var eraserButton: UIButton! + + var currentColor: UIColor? + + var colorLayers: [CAShapeLayer] = [] + + override func viewDidLoad() { + super.viewDidLoad() + + self.navigationController?.navigationBarHidden = true + + // Do any additional setup after loading the view. +// let circleView = UIView(frame: CGRect(x: 100.0, y: 200.0, width: 40.0, height: 40.0)) +// circleView.backgroundColor = UIColor.emomeThemeColor() +// circleView.layer.cornerRadius = 20.0 +// self.view.addSubview(circleView) +// +// self.animator = UIDynamicAnimator.init(referenceView: self.view) +// +// self.pusher = UIPushBehavior.init(items: [circleView], mode: .Instantaneous) +// self.pusher.pushDirection = CGVector(dx: 0.1, dy: 0.1) +// self.pusher.active = true +// +// self.animator.addBehavior(self.pusher) +// +// let collision = UICollisionBehavior.init(items: [circleView]) +// collision.translatesReferenceBoundsIntoBoundary = true +// self.animator.addBehavior(collision) + + } + + override func viewDidLayoutSubviews() { + if !self.isPanelSetUp { + setUpPanel() + self.isPanelSetUp = true + } + } + + override func prefersStatusBarHidden() -> Bool { + return true + } + + @IBAction func backToHome(sender: AnyObject) { + self.presentingViewController?.dismissViewControllerAnimated(true, completion: nil) + } + + + func setUpPanel() { + let maskPath = UIBezierPath.init(roundedRect: self.panelView.bounds, byRoundingCorners: [.TopLeft, .TopRight], cornerRadii: CGSize(width: 8.0, height: 8.0)) + let maskLayer = CAShapeLayer() + maskLayer.path = maskPath.CGPath + self.panelView.layer.mask = maskLayer + + let height = self.panelView.bounds.size.height + let width = self.panelView.bounds.size.width / CGFloat(EMOEmotion.allValues.count + 1) + + // Add Button + var x: CGFloat = 0.0 + var tag: Int = 0 + for emotion in EMOEmotion.allValues { + let button = UIButton.init(frame: CGRect(x: x, y: 0, width: width, height: height)) + button.setTitle("\(emotion)", forState: .Normal) + button.setTitleColor(UIColor.whiteColor(), forState: .Normal) + button.titleEdgeInsets = UIEdgeInsets(top: 60.0, left: 0.0, bottom: 0.0, right: 0.0) + button.titleLabel?.font = UIFont.systemFontOfSize(14.0) + button.tag = tag + button.addTarget(self, action: "toolDidSelect:", forControlEvents: .TouchUpInside) + self.panelView.addSubview(button) + + x += width + tag += 1 + } + + self.eraserButton = UIButton.init(frame: CGRect(x: x, y: 0, width: width, height: height)) + eraserButton.setImage(UIImage(named: "btn-eraser"), forState: .Normal) + eraserButton.imageEdgeInsets = UIEdgeInsets(top: 18.0, left: 0.0, bottom: 0.0, right: 0.0) + eraserButton.addTarget(self, action: "toolDidSelect:", forControlEvents: .TouchUpInside) + self.panelView.addSubview(eraserButton) + } + + func toolDidSelect(sender: UIButton) { + if sender == self.eraserButton { + self.currentColor = nil + self.newLayer = nil + + } else { + print("\(EMOEmotion.allValues[sender.tag]) selected") + self.currentColor = UIColor.colorForEmotion(EMOEmotion.allValues[sender.tag]) + } + } + + func setUpEmitter() { + let emitterLayer = CAEmitterLayer() + emitterLayer.emitterPosition = CGPoint(x: self.view.bounds.size.width / 2, y: self.view.bounds.origin.y) + emitterLayer.emitterZPosition = 10 + emitterLayer.emitterSize = CGSize(width: self.view.bounds.size.width, height: 0.0) + emitterLayer.emitterShape = kCAEmitterLayerSphere + + let emitterCell = CAEmitterCell() + emitterCell.scale = 0.1 + emitterCell.scaleRange = 0.2 + emitterCell.emissionRange = CGFloat(M_PI_2) + emitterCell.lifetime = 5.0 + emitterCell.birthRate = 10 + emitterCell.velocity = 200 + emitterCell.velocityRange = 50 + emitterCell.yAcceleration = 250 + + emitterCell.contents = UIImage(imageLiteral: "ic-cross").CGImage + + emitterLayer.emitterCells = [emitterCell] + + self.view.layer.addSublayer(emitterLayer) + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + override func touchesBegan(touches: Set, withEvent event: UIEvent?) { + if let touch = touches.first { + print("\(touch.locationInView(self.view))") + self.touchStartTime = event?.timestamp + + if let color = self.currentColor { + + self.newLayer = CAShapeLayer() + self.newLayer!.bounds = CGRect(x: 0.0, y: 0.0, width: 40.0, height: 40.0) + self.newLayer!.position = touch.locationInView(self.view) + self.newLayer!.backgroundColor = color.CGColor + self.newLayer!.cornerRadius = 20.0 + self.newLayer!.opacity = 0.6 + self.view.layer.addSublayer(self.newLayer!) + + let scaleAnimation = CABasicAnimation.init(keyPath: "transform") + scaleAnimation.fromValue = NSValue.init(CATransform3D: CATransform3DIdentity) + scaleAnimation.toValue = NSValue.init(CATransform3D: CATransform3DMakeScale(6.0, 6.0, 1.0)) + + scaleAnimation.duration = 4.0 + scaleAnimation.fillMode = kCAFillModeBoth + scaleAnimation.removedOnCompletion = false + + self.newLayer!.addAnimation(scaleAnimation, forKey: "zoom") + + } else { + + let touchedLayer = self.view.layer.presentationLayer()?.hitTest(touch.locationInView(self.view)) + let actualLayer = touchedLayer!.modelLayer() as! CALayer + + if actualLayer == self.view.layer { + print("self") + } else { + for i in 0.., withEvent event: UIEvent?) { + if let touch = touches.first { + + if let layer = self.newLayer { + CATransaction.begin() + layer.position = touch.locationInView(self.view) + CATransaction.commit() + } + + } + } + + override func touchesEnded(touches: Set, withEvent event: UIEvent?) { + if let touch = touches.first { + print("\(touch.locationInView(self.view))") + + if let layer = self.newLayer { + if let frame = layer.presentationLayer()?.frame { + +// CATransaction.begin() + layer.bounds = CGRectMake(0.0, 0.0, frame.size.width, frame.size.height) + layer.cornerRadius = frame .size.width / 2 + layer.removeAnimationForKey("zoom") +// CATransaction.commit() + } + + self.colorLayers.append(layer) + } + } + } +// +// func radiusForTouchDuraiton(touchDuration: NSTimeInterval) -> CGFloat { +// +// let ratio: CGFloat = CGFloat(touchDuration / 1.5) +// print("ratio \(ratio) duration \(touchDuration)") +// return CGFloat(20.0 + ratio * 40.0) +// } + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { + // Get the new view controller using segue.destinationViewController. + // Pass the selected object to the new view controller. + } + */ + +} diff --git a/Emome/EMOEnums.swift b/Emome/EMOEnums.swift index 64608ee..9eaac9b 100644 --- a/Emome/EMOEnums.swift +++ b/Emome/EMOEnums.swift @@ -20,4 +20,26 @@ enum EMOActivityType { return "View on Yelp" } } +} + +enum EMOEmotion: CustomStringConvertible { + case Sad + case Frustrated + case Anger + case Anxious + + static let allValues = [Sad, Frustrated, Anger, Anxious] + + var description: String { + switch self { + case .Sad: + return "sad" + case .Frustrated: + return "frustrated" + case .Anger: + return "anger" + case .Anxious: + return "anxious" + } + } } \ No newline at end of file diff --git a/Emome/EMOHomeViewController.swift b/Emome/EMOHomeViewController.swift new file mode 100644 index 0000000..cf036c1 --- /dev/null +++ b/Emome/EMOHomeViewController.swift @@ -0,0 +1,36 @@ +// +// EMOHomeViewController.swift +// Emome +// +// Created by Huai-Che Lu on 11/26/15. +// Copyright © 2015 Emome. All rights reserved. +// + +import UIKit + +class EMOHomeViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + + // Do any additional setup after loading the view. + self.navigationController?.navigationBarHidden = true + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { + // Get the new view controller using segue.destinationViewController. + // Pass the selected object to the new view controller. + } + */ + +} diff --git a/Emome/EMOSuggestionView.xib b/Emome/EMOSuggestionView.xib index 06b33b3..6340c54 100644 --- a/Emome/EMOSuggestionView.xib +++ b/Emome/EMOSuggestionView.xib @@ -38,7 +38,7 @@ -