[+] Create add alarm debug button

This commit is contained in:
Hykilpikonna
2021-01-17 15:47:20 -05:00
parent 06d639c912
commit cb80b2925d
2 changed files with 65 additions and 36 deletions
+50 -20
View File
@@ -339,30 +339,60 @@
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/> <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="GhB-GA-PWg"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Debug" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="w0P-Jb-Y3X">
<rect key="frame" x="92.5" y="128" width="229" height="40"/> <rect key="frame" x="20" y="54.000000000000007" width="374" height="20.333333333333336"/>
<fontDescription key="fontDescription" type="system" pointSize="23"/> <fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<state key="normal" title="Send Accel. to Console"/> <nil key="textColor"/>
<connections> <nil key="highlightedColor"/>
<action selector="getAccel:" destination="r8W-6e-Hn2" eventType="touchUpInside" id="hDu-Hj-vnU"/> </label>
</connections> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="What is this?" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tcW-ZW-HgZ">
</button> <rect key="frame" x="20" y="74.333333333333329" width="374" height="14.333333333333329"/>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="8o4-jF-mCC"> <fontDescription key="fontDescription" type="system" pointSize="12"/>
<rect key="frame" x="152" y="232" width="110" height="41"/> <nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="24"/> <nil key="highlightedColor"/>
<state key="normal" title="Send Notif"/> </label>
<connections> <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillEqually" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="oTa-Ok-U9h">
<action selector="sendNotification:" destination="r8W-6e-Hn2" eventType="touchUpInside" id="ry0-VK-YRb"/> <rect key="frame" x="20" y="108.66666666666669" width="374" height="128"/>
</connections> <subviews>
</button> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="GhB-GA-PWg">
<rect key="frame" x="0.0" y="0.0" width="374" height="36"/>
<fontDescription key="fontDescription" type="system" pointSize="20"/>
<state key="normal" title="Test Accelerometer"/>
<connections>
<action selector="getAccel:" destination="r8W-6e-Hn2" eventType="touchUpInside" id="hDu-Hj-vnU"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="8o4-jF-mCC">
<rect key="frame" x="0.0" y="45.999999999999986" width="374" height="36"/>
<fontDescription key="fontDescription" type="system" pointSize="20"/>
<state key="normal" title="Send Notification"/>
<connections>
<action selector="sendNotification:" destination="r8W-6e-Hn2" eventType="touchUpInside" id="ry0-VK-YRb"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="oK7-CW-NUv">
<rect key="frame" x="0.0" y="91.999999999999986" width="374" height="36"/>
<fontDescription key="fontDescription" type="system" pointSize="20"/>
<state key="normal" title="Add an alarm activating one minute later"/>
<connections>
<action selector="addAlarm:" destination="r8W-6e-Hn2" eventType="touchUpInside" id="Ctz-XA-1z2"/>
</connections>
</button>
</subviews>
</stackView>
</subviews> </subviews>
<viewLayoutGuide key="safeArea" id="hX1-uy-i87"/> <viewLayoutGuide key="safeArea" id="hX1-uy-i87"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/> <color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints> <constraints>
<constraint firstItem="GhB-GA-PWg" firstAttribute="top" secondItem="hX1-uy-i87" secondAttribute="top" constant="84" id="Y9z-Si-SeI"/> <constraint firstItem="w0P-Jb-Y3X" firstAttribute="top" secondItem="hX1-uy-i87" secondAttribute="top" constant="10" id="42B-VU-jVH"/>
<constraint firstItem="8o4-jF-mCC" firstAttribute="top" secondItem="GhB-GA-PWg" secondAttribute="bottom" constant="64" id="gz0-iN-cIY"/> <constraint firstItem="hX1-uy-i87" firstAttribute="trailing" secondItem="oTa-Ok-U9h" secondAttribute="trailing" constant="20" id="BZf-0X-jDK"/>
<constraint firstItem="GhB-GA-PWg" firstAttribute="centerX" secondItem="xd9-wc-Vc7" secondAttribute="centerX" id="v3H-yu-QkZ"/> <constraint firstItem="oTa-Ok-U9h" firstAttribute="leading" secondItem="hX1-uy-i87" secondAttribute="leading" constant="20" id="DjJ-yy-Jc0"/>
<constraint firstItem="8o4-jF-mCC" firstAttribute="centerX" secondItem="xd9-wc-Vc7" secondAttribute="centerX" id="v4t-MW-7lU"/> <constraint firstItem="tcW-ZW-HgZ" firstAttribute="leading" secondItem="hX1-uy-i87" secondAttribute="leading" constant="20" id="MMc-9X-wep"/>
<constraint firstItem="hX1-uy-i87" firstAttribute="trailing" secondItem="tcW-ZW-HgZ" secondAttribute="trailing" constant="20" id="TuV-bF-NqF"/>
<constraint firstItem="oTa-Ok-U9h" firstAttribute="top" secondItem="tcW-ZW-HgZ" secondAttribute="bottom" constant="20" id="Xiz-02-dUA"/>
<constraint firstItem="tcW-ZW-HgZ" firstAttribute="top" secondItem="w0P-Jb-Y3X" secondAttribute="bottom" id="i43-E7-hoY"/>
<constraint firstItem="w0P-Jb-Y3X" firstAttribute="leading" secondItem="hX1-uy-i87" secondAttribute="leading" constant="20" id="mKZ-sC-tZt"/>
<constraint firstItem="hX1-uy-i87" firstAttribute="trailing" secondItem="w0P-Jb-Y3X" secondAttribute="trailing" constant="20" id="zYy-da-HnI"/>
</constraints> </constraints>
</view> </view>
<tabBarItem key="tabBarItem" title="Debug" image="hammer.fill" catalog="system" selectedImage="hammer.fill" id="QZ2-fJ-hLg"/> <tabBarItem key="tabBarItem" title="Debug" image="hammer.fill" catalog="system" selectedImage="hammer.fill" id="QZ2-fJ-hLg"/>
+15 -16
View File
@@ -8,11 +8,13 @@
import UIKit import UIKit
import UserNotifications import UserNotifications
class TestingViewController: UIViewController { class TestingViewController: UIViewController
{
override func viewDidLoad() { override func viewDidLoad()
{
super.viewDidLoad() super.viewDidLoad()
// Request notification permission
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { success, error in UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { success, error in
if success { if success {
print("All set!") print("All set!")
@@ -20,16 +22,16 @@ class TestingViewController: UIViewController {
print(error.localizedDescription) print(error.localizedDescription)
} }
} }
// Do any additional setup after loading the view.
} }
@IBAction func getAccel(_ sender: Any) { @IBAction func getAccel(_ sender: Any)
{
getAccelerometer() getAccelerometer()
} }
//Sends a test notification //Sends a test notification
@IBAction func sendNotification(_ sender: Any) { @IBAction func sendNotification(_ sender: Any)
{
let alarm = Alarm(enabled: true, hour: 7, minute: 20, text: "Good morning!", wakeMethod: WVM(name: "walking", desc: "Walk")) let alarm = Alarm(enabled: true, hour: 7, minute: 20, text: "Good morning!", wakeMethod: WVM(name: "walking", desc: "Walk"))
let content = UNMutableNotificationContent() let content = UNMutableNotificationContent()
@@ -58,14 +60,11 @@ class TestingViewController: UIViewController {
UNUserNotificationCenter.current().add(request, withCompletionHandler: nil) UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
} }
/* @IBAction func addAlarm(_ sender: Any)
// MARK: - Navigation {
let (h, m, _) = Date().getHMS()
// In a storyboard-based application, you will often want to do a little preparation before navigation let alarms = Alarms.fromLocal()
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { alarms.list.append(Alarm(enabled: true, hour: h, minute: m, text: "Test alarm - \(h * m)", wakeMethod: wvms[0]))
// Get the new view controller using segue.destination. alarms.localSave()
// Pass the selected object to the new view controller.
} }
*/
} }