diff --git a/ProjectClock.xcodeproj/project.pbxproj b/ProjectClock.xcodeproj/project.pbxproj index 7c84686..5bfe699 100644 --- a/ProjectClock.xcodeproj/project.pbxproj +++ b/ProjectClock.xcodeproj/project.pbxproj @@ -15,7 +15,7 @@ 4FD642DB25B4B7F60069171E /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FD642DA25B4B7F60069171E /* Utils.swift */; }; 4FD642E025B4D5F30069171E /* AlarmActivationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FD642DF25B4D5F30069171E /* AlarmActivationViewController.swift */; }; 4FF0683F25A5F18700304E6B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF0683E25A5F18700304E6B /* AppDelegate.swift */; }; - 4FF0684325A5F18700304E6B /* AccountViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF0684225A5F18700304E6B /* AccountViewController.swift */; }; + 4FF0684325A5F18700304E6B /* Account.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FF0684225A5F18700304E6B /* Account.swift */; }; 4FF0684625A5F18700304E6B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4FF0684425A5F18700304E6B /* Main.storyboard */; }; 4FF0684825A5F18800304E6B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4FF0684725A5F18800304E6B /* Assets.xcassets */; }; 4FF0684B25A5F18800304E6B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4FF0684925A5F18800304E6B /* LaunchScreen.storyboard */; }; @@ -38,7 +38,7 @@ 4FD642DF25B4D5F30069171E /* AlarmActivationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlarmActivationViewController.swift; sourceTree = ""; }; 4FF0683B25A5F18700304E6B /* ProjectClock.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ProjectClock.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4FF0683E25A5F18700304E6B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - 4FF0684225A5F18700304E6B /* AccountViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountViewController.swift; sourceTree = ""; }; + 4FF0684225A5F18700304E6B /* Account.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Account.swift; sourceTree = ""; }; 4FF0684525A5F18700304E6B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 4FF0684725A5F18800304E6B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 4FF0684A25A5F18800304E6B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; @@ -86,7 +86,7 @@ isa = PBXGroup; children = ( 7CD385A425BE4639007E9890 /* Sounds */, - 4FF0684225A5F18700304E6B /* AccountViewController.swift */, + 4FF0684225A5F18700304E6B /* Account.swift */, 4F8A607025A9160400D88DC3 /* AddAlarmViewController.swift */, 4FD642DF25B4D5F30069171E /* AlarmActivationViewController.swift */, 4FD642D225B48C380069171E /* AlarmActivator.swift */, @@ -204,7 +204,7 @@ 4F8A607125A9160400D88DC3 /* AddAlarmViewController.swift in Sources */, 4F98955225A9260400F51321 /* Net.swift in Sources */, 7C83963925AF68980027A94C /* DebugViewController.swift in Sources */, - 4FF0684325A5F18700304E6B /* AccountViewController.swift in Sources */, + 4FF0684325A5F18700304E6B /* Account.swift in Sources */, F0DF7C0725BCD9FC0064A26B /* StopwatchViewController.swift in Sources */, 4FF0683F25A5F18700304E6B /* AppDelegate.swift in Sources */, 4FD642D325B48C380069171E /* AlarmActivator.swift in Sources */, diff --git a/ProjectClock/AccountViewController.swift b/ProjectClock/Account.swift similarity index 90% rename from ProjectClock/AccountViewController.swift rename to ProjectClock/Account.swift index d5a8327..dddb40a 100644 --- a/ProjectClock/AccountViewController.swift +++ b/ProjectClock/Account.swift @@ -358,7 +358,7 @@ extension FamilyVC: UITableViewDelegate, UITableViewDataSource */ func tableView(_ view: UITableView, cellForRowAt i: IndexPath) -> UITableViewCell { - let cell = view.dequeueReusableCell(withIdentifier: "cell", for: i) + let cell = view.dequeueReusableCell(withIdentifier: "family-member-cell", for: i) cell.textLabel?.text = Family.fromLocal()!.membersList[i.row] return cell } @@ -369,6 +369,7 @@ extension FamilyVC: UITableViewDelegate, UITableViewDataSource func tableView(_ view: UITableView, didSelectRowAt i: IndexPath) { print(i.row) + view.deselectRow(at: i, animated: true) } } @@ -461,3 +462,51 @@ class FamilyCreateJoinVC: UIViewController } } +/** + View controller for adding an alarm to a fmaily member + */ +class FamilyAddAlarmVC: UIViewController +{ + @IBOutlet weak var table: UITableView! + + override func viewDidLoad() + { + super.viewDidLoad() + + table.delegate = self + table.dataSource = self + } +} + +/** + Table data source + */ +extension FamilyAddAlarmVC: UITableViewDelegate, UITableViewDataSource +{ + /** + Define row count + */ + func tableView(_ _: UITableView, numberOfRowsInSection _: Int) -> Int + { + return Alarms.fromLocal().list.count + } + + /** + Set cell at i + */ + func tableView(_ view: UITableView, cellForRowAt i: IndexPath) -> UITableViewCell + { + let cell = view.dequeueReusableCell(withIdentifier: "family-alarm-cell", for: i) + let alarm = Alarms.fromLocal().list[i.row] + cell.textLabel?.text = String(format: "%i:%02i", alarm.hour, alarm.minute) + return cell + } + + /** + Called when the user clicks on the cell at i + */ + func tableView(_ view: UITableView, didSelectRowAt i: IndexPath) + { + view.deselectRow(at: i, animated: true) + } +} diff --git a/ProjectClock/AlarmActivationViewController.swift b/ProjectClock/AlarmActivationViewController.swift index 54a7f7f..bda8dab 100644 --- a/ProjectClock/AlarmActivationViewController.swift +++ b/ProjectClock/AlarmActivationViewController.swift @@ -23,6 +23,9 @@ class AlarmActivationViewController: UIViewController @IBOutlet weak var rpsView: UIView! @IBOutlet weak var rpsResult: UILabel! + //Shake Outlets + @IBOutlet weak var shakeView: UIView! + //Other Outlets @IBOutlet weak var timeLabel: UILabel! @IBOutlet weak var dateLabel: UILabel! @@ -55,6 +58,7 @@ class AlarmActivationViewController: UIViewController //Hide all inactive wakemethods puzzleView.isHidden = true rpsView.isHidden = true + shakeView.isHidden = true timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(AlarmActivationViewController.playSound), userInfo: nil, repeats: true) setAlarmType() @@ -85,6 +89,12 @@ class AlarmActivationViewController: UIViewController rpsView.isHidden = false //Get Choice here //rpsAction(choice: choice) + case "Shake": + shakeView.isHidden = false + shakeAction() + if regulate { + endAlarm() + } default: print("Invalid alarm type") } diff --git a/ProjectClock/AlarmActivator.swift b/ProjectClock/AlarmActivator.swift index 29b81d0..16fee0f 100644 --- a/ProjectClock/AlarmActivator.swift +++ b/ProjectClock/AlarmActivator.swift @@ -72,5 +72,4 @@ class AlarmActivator: UITabBarController @IBSegueAction func sendAlarm(_ coder: NSCoder) -> AlarmActivationViewController? { return AlarmActivationViewController(coder: coder, currentAlarm: alarm!) } - } diff --git a/ProjectClock/Assets.xcassets/AppIcon.appiconset/120-1.png b/ProjectClock/Assets.xcassets/AppIcon.appiconset/120-1.png new file mode 100644 index 0000000..0338e30 Binary files /dev/null and b/ProjectClock/Assets.xcassets/AppIcon.appiconset/120-1.png differ diff --git a/ProjectClock/Assets.xcassets/AppIcon.appiconset/120.png b/ProjectClock/Assets.xcassets/AppIcon.appiconset/120.png new file mode 100644 index 0000000..0338e30 Binary files /dev/null and b/ProjectClock/Assets.xcassets/AppIcon.appiconset/120.png differ diff --git a/ProjectClock/Assets.xcassets/AppIcon.appiconset/152.png b/ProjectClock/Assets.xcassets/AppIcon.appiconset/152.png new file mode 100644 index 0000000..cc25f40 Binary files /dev/null and b/ProjectClock/Assets.xcassets/AppIcon.appiconset/152.png differ diff --git a/ProjectClock/Assets.xcassets/AppIcon.appiconset/167.png b/ProjectClock/Assets.xcassets/AppIcon.appiconset/167.png new file mode 100644 index 0000000..3af8026 Binary files /dev/null and b/ProjectClock/Assets.xcassets/AppIcon.appiconset/167.png differ diff --git a/ProjectClock/Assets.xcassets/AppIcon.appiconset/180.png b/ProjectClock/Assets.xcassets/AppIcon.appiconset/180.png new file mode 100644 index 0000000..fa526ee Binary files /dev/null and b/ProjectClock/Assets.xcassets/AppIcon.appiconset/180.png differ diff --git a/ProjectClock/Assets.xcassets/AppIcon.appiconset/20.png b/ProjectClock/Assets.xcassets/AppIcon.appiconset/20.png new file mode 100644 index 0000000..84b8b8f Binary files /dev/null and b/ProjectClock/Assets.xcassets/AppIcon.appiconset/20.png differ diff --git a/ProjectClock/Assets.xcassets/AppIcon.appiconset/29.png b/ProjectClock/Assets.xcassets/AppIcon.appiconset/29.png new file mode 100644 index 0000000..14386dd Binary files /dev/null and b/ProjectClock/Assets.xcassets/AppIcon.appiconset/29.png differ diff --git a/ProjectClock/Assets.xcassets/AppIcon.appiconset/40-1.png b/ProjectClock/Assets.xcassets/AppIcon.appiconset/40-1.png new file mode 100644 index 0000000..056a87b Binary files /dev/null and b/ProjectClock/Assets.xcassets/AppIcon.appiconset/40-1.png differ diff --git a/ProjectClock/Assets.xcassets/AppIcon.appiconset/40-2.png b/ProjectClock/Assets.xcassets/AppIcon.appiconset/40-2.png new file mode 100644 index 0000000..056a87b Binary files /dev/null and b/ProjectClock/Assets.xcassets/AppIcon.appiconset/40-2.png differ diff --git a/ProjectClock/Assets.xcassets/AppIcon.appiconset/40.png b/ProjectClock/Assets.xcassets/AppIcon.appiconset/40.png new file mode 100644 index 0000000..056a87b Binary files /dev/null and b/ProjectClock/Assets.xcassets/AppIcon.appiconset/40.png differ diff --git a/ProjectClock/Assets.xcassets/AppIcon.appiconset/58-1.png b/ProjectClock/Assets.xcassets/AppIcon.appiconset/58-1.png new file mode 100644 index 0000000..c4c386e Binary files /dev/null and b/ProjectClock/Assets.xcassets/AppIcon.appiconset/58-1.png differ diff --git a/ProjectClock/Assets.xcassets/AppIcon.appiconset/58.png b/ProjectClock/Assets.xcassets/AppIcon.appiconset/58.png new file mode 100644 index 0000000..c4c386e Binary files /dev/null and b/ProjectClock/Assets.xcassets/AppIcon.appiconset/58.png differ diff --git a/ProjectClock/Assets.xcassets/AppIcon.appiconset/60.png b/ProjectClock/Assets.xcassets/AppIcon.appiconset/60.png new file mode 100644 index 0000000..14cd30b Binary files /dev/null and b/ProjectClock/Assets.xcassets/AppIcon.appiconset/60.png differ diff --git a/ProjectClock/Assets.xcassets/AppIcon.appiconset/76.png b/ProjectClock/Assets.xcassets/AppIcon.appiconset/76.png new file mode 100644 index 0000000..ae7a366 Binary files /dev/null and b/ProjectClock/Assets.xcassets/AppIcon.appiconset/76.png differ diff --git a/ProjectClock/Assets.xcassets/AppIcon.appiconset/80-1.png b/ProjectClock/Assets.xcassets/AppIcon.appiconset/80-1.png new file mode 100644 index 0000000..bec56d7 Binary files /dev/null and b/ProjectClock/Assets.xcassets/AppIcon.appiconset/80-1.png differ diff --git a/ProjectClock/Assets.xcassets/AppIcon.appiconset/80.png b/ProjectClock/Assets.xcassets/AppIcon.appiconset/80.png new file mode 100644 index 0000000..bec56d7 Binary files /dev/null and b/ProjectClock/Assets.xcassets/AppIcon.appiconset/80.png differ diff --git a/ProjectClock/Assets.xcassets/AppIcon.appiconset/87.png b/ProjectClock/Assets.xcassets/AppIcon.appiconset/87.png new file mode 100644 index 0000000..90020bf Binary files /dev/null and b/ProjectClock/Assets.xcassets/AppIcon.appiconset/87.png differ diff --git a/ProjectClock/Assets.xcassets/AppIcon.appiconset/Contents.json b/ProjectClock/Assets.xcassets/AppIcon.appiconset/Contents.json index 9221b9b..246dc81 100644 --- a/ProjectClock/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/ProjectClock/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1,91 +1,109 @@ { "images" : [ { + "filename" : "40.png", "idiom" : "iphone", "scale" : "2x", "size" : "20x20" }, { + "filename" : "60.png", "idiom" : "iphone", "scale" : "3x", "size" : "20x20" }, { + "filename" : "58.png", "idiom" : "iphone", "scale" : "2x", "size" : "29x29" }, { + "filename" : "87.png", "idiom" : "iphone", "scale" : "3x", "size" : "29x29" }, { + "filename" : "80.png", "idiom" : "iphone", "scale" : "2x", "size" : "40x40" }, { + "filename" : "120.png", "idiom" : "iphone", "scale" : "3x", "size" : "40x40" }, { + "filename" : "120-1.png", "idiom" : "iphone", "scale" : "2x", "size" : "60x60" }, { + "filename" : "180.png", "idiom" : "iphone", "scale" : "3x", "size" : "60x60" }, { + "filename" : "20.png", "idiom" : "ipad", "scale" : "1x", "size" : "20x20" }, { + "filename" : "40-1.png", "idiom" : "ipad", "scale" : "2x", "size" : "20x20" }, { + "filename" : "29.png", "idiom" : "ipad", "scale" : "1x", "size" : "29x29" }, { + "filename" : "58-1.png", "idiom" : "ipad", "scale" : "2x", "size" : "29x29" }, { + "filename" : "40-2.png", "idiom" : "ipad", "scale" : "1x", "size" : "40x40" }, { + "filename" : "80-1.png", "idiom" : "ipad", "scale" : "2x", "size" : "40x40" }, { + "filename" : "76.png", "idiom" : "ipad", "scale" : "1x", "size" : "76x76" }, { + "filename" : "152.png", "idiom" : "ipad", "scale" : "2x", "size" : "76x76" }, { + "filename" : "167.png", "idiom" : "ipad", "scale" : "2x", "size" : "83.5x83.5" }, { + "filename" : "appstore.png", "idiom" : "ios-marketing", "scale" : "1x", "size" : "1024x1024" diff --git a/ProjectClock/Assets.xcassets/AppIcon.appiconset/appstore.png b/ProjectClock/Assets.xcassets/AppIcon.appiconset/appstore.png new file mode 100644 index 0000000..d498ac0 Binary files /dev/null and b/ProjectClock/Assets.xcassets/AppIcon.appiconset/appstore.png differ diff --git a/ProjectClock/Base.lproj/Main.storyboard b/ProjectClock/Base.lproj/Main.storyboard index d97b155..f03659c 100644 --- a/ProjectClock/Base.lproj/Main.storyboard +++ b/ProjectClock/Base.lproj/Main.storyboard @@ -237,7 +237,7 @@ - + + @@ -281,6 +290,9 @@ + + + @@ -429,7 +441,7 @@ - - + + - + @@ -586,8 +598,11 @@ + + + @@ -676,6 +691,20 @@ + + + + + + + + @@ -759,6 +788,7 @@ + @@ -1021,7 +1051,7 @@ - + @@ -1071,13 +1101,31 @@ + + - + + + + + + + @@ -1092,6 +1140,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1119,13 +1236,16 @@ - + + + + @@ -1248,11 +1368,6 @@ - - - - - diff --git a/ProjectClock/DebugViewController.swift b/ProjectClock/DebugViewController.swift index c4a989c..825db9b 100644 --- a/ProjectClock/DebugViewController.swift +++ b/ProjectClock/DebugViewController.swift @@ -10,6 +10,9 @@ import UserNotifications class DebugViewController: UIViewController { + @IBOutlet weak var userModeButton: UIButton! + var darkMode = false + override func viewDidLoad() { super.viewDidLoad() @@ -43,4 +46,16 @@ class DebugViewController: UIViewController { Alarms.fromLocal().apply { $0.list.removeAll() }.localSave() } + + @IBAction func switchViewingMode(_ sender: Any) { + if !darkMode { + view.window?.overrideUserInterfaceStyle = .dark + userModeButton.setTitle("Switch to Light Mode", for: .normal) + darkMode = true + } else { + view.window?.overrideUserInterfaceStyle = .light + userModeButton.setTitle("Switch to Dark Mode", for: .normal) + darkMode = false + } + } } diff --git a/ProjectClock/MathExpressions.swift b/ProjectClock/MathExpressions.swift index 862caa1..a264d6a 100644 --- a/ProjectClock/MathExpressions.swift +++ b/ProjectClock/MathExpressions.swift @@ -198,6 +198,7 @@ class RPS { */ } +/** //Reference: https://youtu.be/XDuchXYiWuE class Shake { var motionManager = CMMotionManager() @@ -214,3 +215,4 @@ class Shake { } } } +*/ diff --git a/ProjectClock/Models.swift b/ProjectClock/Models.swift index 721788f..75bb2f9 100644 --- a/ProjectClock/Models.swift +++ b/ProjectClock/Models.swift @@ -40,6 +40,7 @@ struct WVM: Codable let wvms = [ WVM(name: "Factor", desc: "Factor a binomial"), WVM(name: "RPS", desc: "Win a game of rock paper scissors"), + WVM(name: "Shake", desc: "Shake your phone... aggresively!"), //WVM(name: "Smash", desc: "It'll never turn off"), //WVM(name: "Walk", desc: "Walk a few steps"), //WVM(name: "Jump", desc: "Make a few jumps") diff --git a/ProjectClock/NotificationLogic.swift b/ProjectClock/NotificationLogic.swift index 29a620c..1c6322b 100644 --- a/ProjectClock/NotificationLogic.swift +++ b/ProjectClock/NotificationLogic.swift @@ -10,6 +10,9 @@ import CoreMotion import UserNotifications import UIKit +var motionManager = CMMotionManager() +var regulate = true + func walkAction() { } @@ -18,6 +21,23 @@ func jumpAction() { } +func shakeAction() { + regulate = true + + while regulate { + motionManager.accelerometerUpdateInterval = 0.2 + + motionManager.startAccelerometerUpdates(to: OperationQueue.current!) { (data,error) in + if let myData = data { + if myData.acceleration.x > 5 { + print("DO SOMETHING SPECIAL") + regulate = false + } + } + } + } +} + func rpsAction(choice: RPS.Choice) -> Bool? { let rps = RPS() return rps.playRPS(you: choice, computer: RPS.randomComputerChoice())