[+] Allow AlarmActivator to segue to the alarm activating view

This commit is contained in:
Hykilpikonna
2021-01-17 15:13:11 -05:00
parent f88c48b9ad
commit d90c792436
3 changed files with 33 additions and 12 deletions
+11 -3
View File
@@ -6,20 +6,26 @@
//
import Foundation
import UIKit
/**
Class to activate alarms when the user is inside the app
Note: This will not run when app is switched to the background or when the display is turned off, but it will run right after the user switched back to the app.
*/
class AlarmActivator
class AlarmActivator: UITabBarController
{
/// Interval in seconds
static var interval = 1.0
static var interval = 2.0
/// Timer for scheduled calls
var timer: Timer?
override func viewDidLoad()
{
start()
}
/**
Start detecting alarms
*/
@@ -43,9 +49,11 @@ class AlarmActivator
*/
@objc func check()
{
NSLog("Check")
// Get the alarm to activate
guard let alarm = Alarms.fromLocal().listActivating.first else { return }
NSLog(JSON.stringify(alarm)!)
performSegue(withIdentifier: "activate-alarmactivate-alarm", sender: nil)
}
}
-6
View File
@@ -10,8 +10,6 @@ import UIKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate
{
var alarmActivator: AlarmActivator!
/// Override point for customization after application launch.
func application(_ app: UIApplication, didFinishLaunchingWithOptions op: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
{
@@ -20,10 +18,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate
"alarms": JSON.stringify([Alarm(enabled: true, hour: 7, minute: 20, text: "Wake up lol", wakeMethod: wvms[0])])!
])
// Start alarm activator
alarmActivator = AlarmActivator()
alarmActivator.start()
return true
}
+22 -3
View File
@@ -25,7 +25,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Add Alarm"/>
<connections>
<segue destination="Mki-dC-5Kc" kind="presentation" id="Qim-4Q-43N"/>
<segue destination="Mki-dC-5Kc" kind="presentation" identifier="alarm-edit" id="Qim-4Q-43N"/>
</connections>
</button>
<prototypes>
@@ -422,6 +422,9 @@
<constraints>
<constraint firstAttribute="height" constant="220" id="VCm-rY-H4H"/>
</constraints>
<connections>
<action selector="datePickerChange:" destination="Mki-dC-5Kc" eventType="valueChanged" id="rTz-ne-1Rk"/>
</connections>
</datePicker>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Alarm Ringtone" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="O5c-Ga-0xh">
<rect key="frame" x="0.0" y="228" width="374" height="20.5"/>
@@ -562,10 +565,25 @@
</objects>
<point key="canvasLocation" x="-494" y="1576"/>
</scene>
<!--Tab Bar Controller-->
<!--View Controller-->
<scene sceneID="21H-AI-pzd">
<objects>
<viewController id="hDW-11-g9U" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="BZn-UX-vps">
<rect key="frame" x="0.0" y="0.0" width="414" height="842"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<viewLayoutGuide key="safeArea" id="hS6-fS-yWp"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="78q-sr-CNz" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1701" y="1102"/>
</scene>
<!--Alarm Activator-->
<scene sceneID="c7a-VN-D68">
<objects>
<tabBarController automaticallyAdjustsScrollViewInsets="NO" id="s8U-C8-W2S" sceneMemberID="viewController">
<tabBarController automaticallyAdjustsScrollViewInsets="NO" id="s8U-C8-W2S" customClass="AlarmActivator" customModule="ProjectClock" customModuleProvider="target" sceneMemberID="viewController">
<toolbarItems/>
<tabBar key="tabBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="203-Gr-Mvz">
<rect key="frame" x="0.0" y="0.0" width="1000" height="1000"/>
@@ -576,6 +594,7 @@
<segue destination="Bqt-du-DT2" kind="relationship" relationship="viewControllers" id="ZTh-ke-ZIV"/>
<segue destination="BYZ-38-t0r" kind="relationship" relationship="viewControllers" destinationCreationSelector="Account" id="NN6-JO-Hmi"/>
<segue destination="r8W-6e-Hn2" kind="relationship" relationship="viewControllers" destinationCreationSelector="Testing" id="SLn-vq-UnH"/>
<segue destination="hDW-11-g9U" kind="showDetail" identifier="activate-alarm" id="z9o-Jh-fnM"/>
</connections>
</tabBarController>
<placeholder placeholderIdentifier="IBFirstResponder" id="S6R-Xr-Nfe" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>