Merge branch 'main' of github.com:hykilpikonna/ProjectClock into main
This commit is contained in:
@@ -71,23 +71,14 @@ class AddAlarmViewController: UIViewController
|
||||
// Pickers
|
||||
@IBOutlet weak var timePicker: UIDatePicker!
|
||||
@IBOutlet weak var wvmPicker: UIPickerView!
|
||||
@IBOutlet weak var ringtonePicker: UIPickerView!
|
||||
|
||||
// UI Elements
|
||||
@IBOutlet weak var repeatWeekdaysSwitch: UISwitch!
|
||||
@IBOutlet weak var repeatWeekendsSwitch: UISwitch!
|
||||
@IBOutlet weak var alarmNameTextField: UITextField!
|
||||
@IBOutlet weak var timeTillAlarmLabel: UILabel!
|
||||
|
||||
@IBAction func defaultRingtonesButton(_ sender: Any)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@IBAction func soundLibraryButton(_ sender: Any)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Called when the time for the alarm is changed.
|
||||
Sets the time away at the top of the View.
|
||||
@@ -138,7 +129,7 @@ class AddAlarmViewController: UIViewController
|
||||
let alarm = Alarm(hour: h, minute: m,
|
||||
text: alarmNameTextField.text ?? "Alarm",
|
||||
wakeMethod: wvms[wvmPicker.selectedRow(inComponent: 0)],
|
||||
lastActivate: Date())
|
||||
lastActivate: Date(), alarmTone: ringtones[ringtonePicker.selectedRow(inComponent: 0)].tone)
|
||||
|
||||
// Set alarm.repeats to correspond with what the user selects
|
||||
(0...6).forEach { alarm.repeats[$0] = false }
|
||||
@@ -166,7 +157,7 @@ class AddAlarmViewController: UIViewController
|
||||
let a = Alarm(hour: h, minute: m,
|
||||
text: alarmNameTextField.text ?? "Alarm",
|
||||
wakeMethod: wvms[wvmPicker.selectedRow(inComponent: 0)],
|
||||
lastActivate: Date())
|
||||
lastActivate: Date(), alarmTone: ringtones[ringtonePicker.selectedRow(inComponent: 0)].tone)
|
||||
// Set alarm.repeats to correspond with what the user selects
|
||||
(0...6).forEach { a.repeats[$0] = false }
|
||||
if repeatWeekdaysSwitch.isOn { (1...5).forEach { a.repeats[$0] = true } }
|
||||
@@ -204,3 +195,29 @@ class WVMDataSource: UIPickerView, UIPickerViewDelegate, UIPickerViewDataSource
|
||||
return wvms[r].name + " - " + wvms[r].desc
|
||||
}
|
||||
}
|
||||
|
||||
class RingtonesDataSource: UIPickerView, UIPickerViewDelegate, UIPickerViewDataSource
|
||||
{
|
||||
required init?(coder: NSCoder)
|
||||
{
|
||||
super.init(coder: coder)
|
||||
delegate = self
|
||||
dataSource = self
|
||||
}
|
||||
|
||||
func numberOfComponents(in pickerView: UIPickerView) -> Int
|
||||
{
|
||||
return 1
|
||||
}
|
||||
|
||||
func pickerView(_ v: UIPickerView, numberOfRowsInComponent: Int) -> Int
|
||||
{
|
||||
return ringtones.count
|
||||
}
|
||||
|
||||
func pickerView(_ v: UIPickerView, titleForRow r: Int, forComponent: Int) -> String?
|
||||
{
|
||||
return ringtones[r].name
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -476,44 +476,36 @@
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="bCI-jj-foN">
|
||||
<rect key="frame" x="0.0" y="258.5" width="374" height="60"/>
|
||||
<rect key="frame" x="0.0" y="258.5" width="374" height="150"/>
|
||||
<subviews>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="cZ8-yN-fp6">
|
||||
<rect key="frame" x="0.0" y="0.0" width="374" height="30"/>
|
||||
<state key="normal" title="Pick From iOS Default Ringtones"/>
|
||||
<connections>
|
||||
<action selector="defaultRingtonesButton:" destination="Mki-dC-5Kc" eventType="touchUpInside" id="0oM-fE-Gyh"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="A3Z-Qp-XmN">
|
||||
<rect key="frame" x="0.0" y="30" width="374" height="30"/>
|
||||
<state key="normal" title="Pick From Sound Library"/>
|
||||
<connections>
|
||||
<action selector="soundLibraryButton:" destination="Mki-dC-5Kc" eventType="touchUpInside" id="5G8-FV-bDx"/>
|
||||
</connections>
|
||||
</button>
|
||||
<pickerView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="JbI-Jp-vvx">
|
||||
<rect key="frame" x="0.0" y="0.0" width="374" height="150"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="150" id="OgV-hH-xcq"/>
|
||||
</constraints>
|
||||
</pickerView>
|
||||
</subviews>
|
||||
</stackView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Wakeup Verification Method" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="E4B-9M-iJd">
|
||||
<rect key="frame" x="0.0" y="338.5" width="374" height="20.5"/>
|
||||
<rect key="frame" x="0.0" y="428.5" width="374" height="20.5"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" systemColor="secondaryLabelColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<pickerView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="oae-b2-SoF" customClass="WVMDataSource" customModule="ProjectClock" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="367" width="374" height="150"/>
|
||||
<rect key="frame" x="0.0" y="457" width="374" height="150"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="150" id="C0G-jE-CPx"/>
|
||||
</constraints>
|
||||
</pickerView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Others" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eZX-HE-BKB">
|
||||
<rect key="frame" x="0.0" y="525" width="374" height="20.5"/>
|
||||
<rect key="frame" x="0.0" y="615" width="374" height="20.5"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" systemColor="secondaryLabelColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="e8v-cM-bxf">
|
||||
<rect key="frame" x="20" y="553.5" width="334" height="116"/>
|
||||
<rect key="frame" x="20" y="643.5" width="334" height="116"/>
|
||||
<subviews>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" spacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="gdH-Ok-RIH">
|
||||
<rect key="frame" x="0.0" y="0.0" width="334" height="34"/>
|
||||
@@ -632,6 +624,7 @@
|
||||
<outlet property="alarmNameTextField" destination="bJg-zp-Aan" id="Itt-3v-GJB"/>
|
||||
<outlet property="repeatWeekdaysSwitch" destination="5oN-BL-Xtu" id="gqb-l3-1jZ"/>
|
||||
<outlet property="repeatWeekendsSwitch" destination="WPM-Fh-sRB" id="LB7-zW-jpC"/>
|
||||
<outlet property="ringtonePicker" destination="JbI-Jp-vvx" id="mPO-Ej-DNU"/>
|
||||
<outlet property="scrollView" destination="ybc-8d-6pJ" id="m1B-ff-zeC"/>
|
||||
<outlet property="scrollViewInner" destination="N7f-vi-SFU" id="LQW-6T-f6x"/>
|
||||
<outlet property="timePicker" destination="qSt-1V-2DQ" id="aDM-jE-0OP"/>
|
||||
|
||||
@@ -37,6 +37,7 @@ struct WVM: Codable
|
||||
let desc: String
|
||||
}
|
||||
|
||||
|
||||
let wvms = [
|
||||
WVM(name: "Factor", desc: "Factor a binomial"),
|
||||
WVM(name: "RPS", desc: "Win a game of rock paper scissors"),
|
||||
@@ -46,7 +47,16 @@ let wvms = [
|
||||
//WVM(name: "Jump", desc: "Make a few jumps")
|
||||
]
|
||||
|
||||
class Alarm: Codable, Equatable
|
||||
|
||||
struct Tone{
|
||||
|
||||
let name: String
|
||||
let tone: SystemSoundID
|
||||
|
||||
}
|
||||
let ringtones : [Tone] = [Tone(name: "Item One", tone: SystemSoundID(1005)), Tone(name: "Item Two", tone: SystemSoundID(1254))] //SystemSoundID(1255),SystemSoundID(1256),SystemSoundID(1257)]
|
||||
|
||||
class Alarm: Codable
|
||||
{
|
||||
static func == (lhs: Alarm, rhs: Alarm) -> Bool {
|
||||
return lhs.hour == rhs.hour && lhs.minute == rhs.minute && lhs.text == rhs.text &&
|
||||
@@ -73,7 +83,8 @@ class Alarm: Codable, Equatable
|
||||
hour: Int, minute: Int, text: String, wakeMethod: WVM,
|
||||
repeats: [Bool] = [false, true, true, true, true, true, false],
|
||||
lastActivate: Date = Date(),
|
||||
alarmTone: SystemSoundID = SystemSoundID(1005)
|
||||
alarmTone: SystemSoundID = ringtones[0].tone
|
||||
|
||||
)
|
||||
{
|
||||
self.enabled = enabled
|
||||
|
||||
Reference in New Issue
Block a user