Merge branch 'main' of github.com:hykilpikonna/ProjectClock into main
This commit is contained in:
@@ -71,6 +71,7 @@ class AddAlarmViewController: UIViewController
|
|||||||
// Pickers
|
// Pickers
|
||||||
@IBOutlet weak var timePicker: UIDatePicker!
|
@IBOutlet weak var timePicker: UIDatePicker!
|
||||||
@IBOutlet weak var wvmPicker: UIPickerView!
|
@IBOutlet weak var wvmPicker: UIPickerView!
|
||||||
|
@IBOutlet weak var ringtonePicker: UIPickerView!
|
||||||
|
|
||||||
// UI Elements
|
// UI Elements
|
||||||
@IBOutlet weak var repeatWeekdaysSwitch: UISwitch!
|
@IBOutlet weak var repeatWeekdaysSwitch: UISwitch!
|
||||||
@@ -78,16 +79,6 @@ class AddAlarmViewController: UIViewController
|
|||||||
@IBOutlet weak var alarmNameTextField: UITextField!
|
@IBOutlet weak var alarmNameTextField: UITextField!
|
||||||
@IBOutlet weak var timeTillAlarmLabel: UILabel!
|
@IBOutlet weak var timeTillAlarmLabel: UILabel!
|
||||||
|
|
||||||
@IBAction func defaultRingtonesButton(_ sender: Any)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@IBAction func soundLibraryButton(_ sender: Any)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Called when the time for the alarm is changed.
|
Called when the time for the alarm is changed.
|
||||||
Sets the time away at the top of the View.
|
Sets the time away at the top of the View.
|
||||||
@@ -138,7 +129,7 @@ class AddAlarmViewController: UIViewController
|
|||||||
let alarm = Alarm(hour: h, minute: m,
|
let alarm = Alarm(hour: h, minute: m,
|
||||||
text: alarmNameTextField.text ?? "Alarm",
|
text: alarmNameTextField.text ?? "Alarm",
|
||||||
wakeMethod: wvms[wvmPicker.selectedRow(inComponent: 0)],
|
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
|
// Set alarm.repeats to correspond with what the user selects
|
||||||
(0...6).forEach { alarm.repeats[$0] = false }
|
(0...6).forEach { alarm.repeats[$0] = false }
|
||||||
@@ -166,7 +157,7 @@ class AddAlarmViewController: UIViewController
|
|||||||
let a = Alarm(hour: h, minute: m,
|
let a = Alarm(hour: h, minute: m,
|
||||||
text: alarmNameTextField.text ?? "Alarm",
|
text: alarmNameTextField.text ?? "Alarm",
|
||||||
wakeMethod: wvms[wvmPicker.selectedRow(inComponent: 0)],
|
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
|
// Set alarm.repeats to correspond with what the user selects
|
||||||
(0...6).forEach { a.repeats[$0] = false }
|
(0...6).forEach { a.repeats[$0] = false }
|
||||||
if repeatWeekdaysSwitch.isOn { (1...5).forEach { a.repeats[$0] = true } }
|
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
|
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"/>
|
<nil key="highlightedColor"/>
|
||||||
</label>
|
</label>
|
||||||
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="bCI-jj-foN">
|
<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>
|
<subviews>
|
||||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="cZ8-yN-fp6">
|
<pickerView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="JbI-Jp-vvx">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="374" height="30"/>
|
<rect key="frame" x="0.0" y="0.0" width="374" height="150"/>
|
||||||
<state key="normal" title="Pick From iOS Default Ringtones"/>
|
<constraints>
|
||||||
<connections>
|
<constraint firstAttribute="height" constant="150" id="OgV-hH-xcq"/>
|
||||||
<action selector="defaultRingtonesButton:" destination="Mki-dC-5Kc" eventType="touchUpInside" id="0oM-fE-Gyh"/>
|
</constraints>
|
||||||
</connections>
|
</pickerView>
|
||||||
</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>
|
|
||||||
</subviews>
|
</subviews>
|
||||||
</stackView>
|
</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">
|
<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"/>
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
<color key="textColor" systemColor="secondaryLabelColor"/>
|
<color key="textColor" systemColor="secondaryLabelColor"/>
|
||||||
<nil key="highlightedColor"/>
|
<nil key="highlightedColor"/>
|
||||||
</label>
|
</label>
|
||||||
<pickerView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="oae-b2-SoF" customClass="WVMDataSource" customModule="ProjectClock" customModuleProvider="target">
|
<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>
|
<constraints>
|
||||||
<constraint firstAttribute="height" constant="150" id="C0G-jE-CPx"/>
|
<constraint firstAttribute="height" constant="150" id="C0G-jE-CPx"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
</pickerView>
|
</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">
|
<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"/>
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
<color key="textColor" systemColor="secondaryLabelColor"/>
|
<color key="textColor" systemColor="secondaryLabelColor"/>
|
||||||
<nil key="highlightedColor"/>
|
<nil key="highlightedColor"/>
|
||||||
</label>
|
</label>
|
||||||
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="e8v-cM-bxf">
|
<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>
|
<subviews>
|
||||||
<stackView opaque="NO" contentMode="scaleToFill" spacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="gdH-Ok-RIH">
|
<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"/>
|
<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="alarmNameTextField" destination="bJg-zp-Aan" id="Itt-3v-GJB"/>
|
||||||
<outlet property="repeatWeekdaysSwitch" destination="5oN-BL-Xtu" id="gqb-l3-1jZ"/>
|
<outlet property="repeatWeekdaysSwitch" destination="5oN-BL-Xtu" id="gqb-l3-1jZ"/>
|
||||||
<outlet property="repeatWeekendsSwitch" destination="WPM-Fh-sRB" id="LB7-zW-jpC"/>
|
<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="scrollView" destination="ybc-8d-6pJ" id="m1B-ff-zeC"/>
|
||||||
<outlet property="scrollViewInner" destination="N7f-vi-SFU" id="LQW-6T-f6x"/>
|
<outlet property="scrollViewInner" destination="N7f-vi-SFU" id="LQW-6T-f6x"/>
|
||||||
<outlet property="timePicker" destination="qSt-1V-2DQ" id="aDM-jE-0OP"/>
|
<outlet property="timePicker" destination="qSt-1V-2DQ" id="aDM-jE-0OP"/>
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ struct WVM: Codable
|
|||||||
let desc: String
|
let desc: String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let wvms = [
|
let wvms = [
|
||||||
WVM(name: "Factor", desc: "Factor a binomial"),
|
WVM(name: "Factor", desc: "Factor a binomial"),
|
||||||
WVM(name: "RPS", desc: "Win a game of rock paper scissors"),
|
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")
|
//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 {
|
static func == (lhs: Alarm, rhs: Alarm) -> Bool {
|
||||||
return lhs.hour == rhs.hour && lhs.minute == rhs.minute && lhs.text == rhs.text &&
|
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,
|
hour: Int, minute: Int, text: String, wakeMethod: WVM,
|
||||||
repeats: [Bool] = [false, true, true, true, true, true, false],
|
repeats: [Bool] = [false, true, true, true, true, true, false],
|
||||||
lastActivate: Date = Date(),
|
lastActivate: Date = Date(),
|
||||||
alarmTone: SystemSoundID = SystemSoundID(1005)
|
alarmTone: SystemSoundID = ringtones[0].tone
|
||||||
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
self.enabled = enabled
|
self.enabled = enabled
|
||||||
|
|||||||
Reference in New Issue
Block a user