rootviewcontroller, buttons and labels

This commit is contained in:
Johan Degraeve 2019-05-16 00:13:14 +02:00
parent db025542ff
commit b90efa12ee
19 changed files with 123 additions and 57 deletions

View File

@ -330,12 +330,11 @@ public class AlertManager:NSObject {
}
// The sound
// Start by creating the sound that will be added to the notification content
// depending on mute override on or off, the sound will either be added to the notification content, or will be played by code here
// depending on mute override off or on, the sound will either be added to the notification content, or will be played by code here respectively - except if delayInSecondsToUse > 0, in which case we must use the sound in the notification
// soundToSet is the sound that will be played,
// if soundToSet is nil ==> then default sound must be used,
// if soundToSet = "" , empty string ==> no sound will be played
// if soundToSet = "" , empty string ==> no sound needs to be played
// Start with default sound
var soundToSet:String?
@ -388,7 +387,7 @@ public class AlertManager:NSObject {
// play the sound
soundPlayer.playSound(soundFileName: soundToSet, withVolume: nil)
} else {
// mute should not be overriden, by adding the sound to the notification, we let iOS decide of the sound will be played or not
// mute should not be overriden, by adding the sound to the notification, we let iOS decide if the sound will be played or not
content.sound = UNNotificationSound.init(named: UNNotificationSoundName.init(soundToSet))
}
}

View File

@ -2,17 +2,17 @@
"images" : [
{
"idiom" : "universal",
"filename" : "Trash_48x48.png",
"filename" : "home-white_48x48.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "Trash_96x96.png",
"filename" : "home-white_96x96.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "Trash_144x144.png",
"filename" : "home-white_144x144.png",
"scale" : "3x"
}
],

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "settings-white_48x48.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "settings-white_96x96.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "settings-white_144x144.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

View File

@ -1,12 +0,0 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "first.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@ -1,12 +0,0 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "second.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@ -10,7 +10,7 @@
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--First-->
<!--Root View Controller-->
<scene sceneID="hNz-n2-bh7">
<objects>
<viewController id="9pv-A4-QxB" customClass="RootViewController" customModule="xdrip" customModuleProvider="target" sceneMemberID="viewController">
@ -18,30 +18,76 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" text="First View" textAlignment="center" lineBreakMode="tailTruncation" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="KQZ-1w-vlD">
<rect key="frame" x="112.5" y="312" width="150" height="43"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="36"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="mSJ-jy-nHJ">
<rect key="frame" x="289" y="20" width="86" height="39"/>
<fontDescription key="fontDescription" type="system" pointSize="22"/>
<state key="normal" title="Calibrate"/>
<connections>
<action selector="calibrateButtonAction:" destination="9pv-A4-QxB" eventType="touchUpInside" id="JB2-Sk-Tge"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="zWo-AR-qJE">
<rect key="frame" x="172" y="20" width="107" height="39"/>
<fontDescription key="fontDescription" type="system" pointSize="22"/>
<state key="normal" title="Transmitter"/>
<connections>
<action selector="transmitterButtonAction:" destination="9pv-A4-QxB" eventType="touchUpInside" id="iJp-CH-PZa"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fSY-nc-amN">
<rect key="frame" x="62" y="20" width="100" height="39"/>
<fontDescription key="fontDescription" type="system" pointSize="22"/>
<state key="normal" title="Presnooze"/>
<connections>
<action selector="preSnoozeButtonAction:" destination="9pv-A4-QxB" eventType="touchUpInside" id="nuJ-Sh-3Xy"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="-----" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="We3-bN-ffR">
<rect key="frame" x="43" y="252.5" width="289" height="162"/>
<fontDescription key="fontDescription" type="system" pointSize="125"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Loaded by FirstViewController" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="A5M-7J-77L">
<rect key="frame" x="90.5" y="363" width="194" height="17"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uyn-2k-K74">
<rect key="frame" x="10" y="69" width="61.5" height="31.5"/>
<fontDescription key="fontDescription" type="system" pointSize="26"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7Wo-wd-80o">
<rect key="frame" x="10" y="110.5" width="61.5" height="31.5"/>
<fontDescription key="fontDescription" type="system" pointSize="26"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="centerX" secondItem="KQZ-1w-vlD" secondAttribute="centerX" id="6BV-lF-sBN"/>
<constraint firstItem="A5M-7J-77L" firstAttribute="top" secondItem="KQZ-1w-vlD" secondAttribute="bottom" constant="8" symbolic="YES" id="cfb-er-3JN"/>
<constraint firstItem="A5M-7J-77L" firstAttribute="centerX" secondItem="KQZ-1w-vlD" secondAttribute="centerX" id="e1l-AV-tCB"/>
<constraint firstAttribute="centerY" secondItem="KQZ-1w-vlD" secondAttribute="centerY" id="exm-UA-ej4"/>
<constraint firstItem="zWo-AR-qJE" firstAttribute="leading" secondItem="fSY-nc-amN" secondAttribute="trailing" constant="10" id="25g-Is-au8"/>
<constraint firstItem="7Wo-wd-80o" firstAttribute="top" secondItem="uyn-2k-K74" secondAttribute="bottom" constant="10" id="ARe-Dm-DA6"/>
<constraint firstItem="PQr-Ze-W5v" firstAttribute="bottom" secondItem="We3-bN-ffR" secondAttribute="bottom" constant="203.5" id="Dh8-YX-1qs"/>
<constraint firstItem="fSY-nc-amN" firstAttribute="top" secondItem="PQr-Ze-W5v" secondAttribute="top" id="Gsa-fG-7Wh"/>
<constraint firstItem="We3-bN-ffR" firstAttribute="centerY" secondItem="tsR-hK-woN" secondAttribute="centerY" id="Ihy-GJ-OoS"/>
<constraint firstItem="zWo-AR-qJE" firstAttribute="top" secondItem="PQr-Ze-W5v" secondAttribute="top" id="WMb-YS-LdS"/>
<constraint firstItem="mSJ-jy-nHJ" firstAttribute="leading" secondItem="zWo-AR-qJE" secondAttribute="trailing" constant="10" id="YZw-LD-39g"/>
<constraint firstItem="mSJ-jy-nHJ" firstAttribute="top" secondItem="PQr-Ze-W5v" secondAttribute="top" id="Ydd-ev-OLz"/>
<constraint firstItem="uyn-2k-K74" firstAttribute="leading" secondItem="PQr-Ze-W5v" secondAttribute="leading" constant="10" id="fmo-f7-DDl"/>
<constraint firstItem="We3-bN-ffR" firstAttribute="centerX" secondItem="tsR-hK-woN" secondAttribute="centerX" id="fz5-iV-QmC"/>
<constraint firstItem="We3-bN-ffR" firstAttribute="leading" secondItem="PQr-Ze-W5v" secondAttribute="leading" constant="43" id="ghV-YB-SJY"/>
<constraint firstItem="uyn-2k-K74" firstAttribute="top" secondItem="fSY-nc-amN" secondAttribute="bottom" constant="10" id="pqR-9I-Dpv"/>
<constraint firstItem="7Wo-wd-80o" firstAttribute="leading" secondItem="PQr-Ze-W5v" secondAttribute="leading" constant="10" id="rno-l9-zuR"/>
<constraint firstItem="PQr-Ze-W5v" firstAttribute="trailing" secondItem="mSJ-jy-nHJ" secondAttribute="trailing" id="sen-S3-K5r"/>
</constraints>
<viewLayoutGuide key="safeArea" id="PQr-Ze-W5v"/>
</view>
<tabBarItem key="tabBarItem" title="First" image="first" id="acW-dT-cKf"/>
<tabBarItem key="tabBarItem" image="Home" selectedImage="Home" id="acW-dT-cKf">
<color key="badgeColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</tabBarItem>
<connections>
<outlet property="calibrateButtonOutlet" destination="mSJ-jy-nHJ" id="XSS-W3-gbX"/>
<outlet property="preSnoozeButtonOutlet" destination="fSY-nc-amN" id="T25-Z1-3Ad"/>
<outlet property="transmitterButtonOutlet" destination="zWo-AR-qJE" id="uuB-WI-JKe"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="W5J-7L-Pyd" sceneMemberID="firstResponder"/>
</objects>
@ -497,11 +543,11 @@
</objects>
<point key="canvasLocation" x="0.0" y="0.0"/>
</scene>
<!--Second-->
<!--Settings Navigation Controller-->
<scene sceneID="jbr-kK-p6W">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="dyf-bd-1WE" customClass="SettingsNavigationController" customModule="xdrip" customModuleProvider="target" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="Second" image="second" id="cPa-gy-q4n"/>
<tabBarItem key="tabBarItem" title="" image="Settings" selectedImage="Settings" id="cPa-gy-q4n"/>
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="Q1d-AD-CWJ">
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
@ -593,7 +639,7 @@
</scene>
</scenes>
<resources>
<image name="first" width="30" height="30"/>
<image name="second" width="30" height="30"/>
<image name="Home" width="48" height="48"/>
<image name="Settings" width="48" height="48"/>
</resources>
</document>

View File

@ -22,7 +22,7 @@ class Texts_Alerts {
}()
static let missedReadingAlertTitle: String = {
return NSLocalizedString("alerts_missedreadingalerttitle", tableName: filename, bundle: Bundle.main, value: "Missed Reading", comment: "When Missed reading alert happens, this is the title of the alert notification, also in alert settings list, for the name of the alert")
return NSLocalizedString("alerts_missedreadingalerttitle", tableName: filename, bundle: Bundle.main, value: "Missed Reading Alert", comment: "When Missed reading alert happens, this is the title of the alert notification, also in alert settings list, for the name of the alert")
}()
static let calibrationNeededAlertTitle: String = {

View File

@ -7,8 +7,25 @@ import UserNotifications
/// viewcontroller for the home screen
final class RootViewController: UIViewController, CGMTransmitterDelegate, UNUserNotificationCenterDelegate {
// MARK: - Properties
// MARK: - Properties - Outlets and Actions for buttons and labels in home screen
@IBOutlet weak var calibrateButtonOutlet: UIButton!
@IBAction func calibrateButtonAction(_ sender: UIButton) {
}
@IBOutlet weak var transmitterButtonOutlet: UIButton!
@IBAction func transmitterButtonAction(_ sender: UIButton) {
}
@IBOutlet weak var preSnoozeButtonOutlet: UIButton!
@IBAction func preSnoozeButtonAction(_ sender: UIButton) {
}
private var test:CGMTransmitter?
private var log = OSLog(subsystem: Constants.Log.subSystem, category: Constants.Log.categoryFirstView)
@ -189,8 +206,13 @@ final class RootViewController: UIViewController, CGMTransmitterDelegate, UNUser
}
}
// send request calibration notification
private func requestCalibrationNotification() {
// creates notification with bg reading
// for the moment also creates calibration request if there's no calibration done yet
private func createBGReadingNotification() {
// first remove existing notification
UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: [Constants.Notifications.NotificationIdentifiersForAlerts.initialCalibrationRequest])
// Create Notification Content
let notificationContent = UNMutableNotificationContent()
@ -329,7 +351,7 @@ final class RootViewController: UIViewController, CGMTransmitterDelegate, UNUser
}
coreDataManager.saveChanges()
if glucoseData.count > 0 {requestCalibrationNotification()}
if glucoseData.count > 0 {createBGReadingNotification()}
if let nightScoutManager = nightScoutManager {
nightScoutManager.synchronize()
}