Skip to content

Commit

Permalink
PoC #1
Browse files Browse the repository at this point in the history
  • Loading branch information
bielikb committed May 3, 2020
1 parent b324521 commit 9386433
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 19 deletions.
1 change: 1 addition & 0 deletions .swiftlint.yml
Expand Up @@ -4,6 +4,7 @@ disabled_rules:

excluded:
- Pods
- Vendor

indentation: tabs

Expand Down
8 changes: 4 additions & 4 deletions Covid/Base.lproj/Main.storyboard
Expand Up @@ -3744,21 +3744,21 @@ Cg
</view>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="RegionCell" textLabel="aGH-ve-69U" detailTextLabel="n6v-Ta-yMa" style="IBUITableViewCellStyleValue1" id="RUU-X6-TP6" customClass="RegionCell" customModule="Covid_19_SR" customModuleProvider="target">
<rect key="frame" x="0.0" y="135" width="375" height="48.666667938232422"/>
<rect key="frame" x="0.0" y="135" width="375" height="43.666667938232422"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="RUU-X6-TP6" id="QqD-ND-D2R">
<rect key="frame" x="0.0" y="0.0" width="375" height="48.666667938232422"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="43.666667938232422"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="aGH-ve-69U">
<rect key="frame" x="24.000000000000004" y="14.000000000000002" width="32.333333333333336" height="22.666666666666668"/>
<rect key="frame" x="24" y="13.000000000000002" width="30" height="18.666666666666668"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" name="Poppins-Regular" family="Poppins" pointSize="16"/>
<color key="textColor" red="0.22352941179999999" green="0.22352941179999999" blue="0.22352941179999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="n6v-Ta-yMa">
<rect key="frame" x="310.66666666666669" y="14.000000000000002" width="48.333333333333336" height="22.666666666666668"/>
<rect key="frame" x="318.33333333333331" y="13.000000000000002" width="40.666666666666664" height="18.666666666666668"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" name="Poppins-Bold" family="Poppins" pointSize="16"/>
<color key="textColor" red="0.22352941179999999" green="0.22352941179999999" blue="0.22352941179999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
Expand Down
58 changes: 43 additions & 15 deletions Covid/MainScreen/MainViewController.swift
Expand Up @@ -137,21 +137,42 @@ final class MainViewController: ViewController, NotificationCenterObserver {
// MARK: Permissions

private func registerForPushNotifications() {
let current = UNUserNotificationCenter.current()

current.getNotificationSettings { (settings) in
if settings.authorizationStatus == .notDetermined {
current.requestAuthorization(options: [.alert, .sound, .badge]) { [weak self] _, _ in
DispatchQueue.main.async {
if !Defaults.didShowForeignAlert {
self?.performSegue(.foreignAlert)
}
}
}
}
// TODO: handle other cases
}
UIApplication.shared.registerForRemoteNotifications()
let permissions: [SPPermission] = [.notification,
.bluetooth,
.locationAlwaysAndWhenInUse,
.locationWhenInUse]
.filter { $0.isAuthorized }
guard permissions.isEmpty == false else { return }

let controller = SPPermissions.dialog(permissions)

// Ovveride texts in controller
controller.titleText = "Title Text"
controller.headerText = "Header Text"
controller.footerText = "Footer Text"

// Set `DataSource` or `Delegate` if need.
// By default using project texts and icons.
controller.dataSource = self
controller.delegate = self

// Always use this method for present
controller.present(on: self)
// let current = UNUserNotificationCenter.current()
//
// current.getNotificationSettings { (settings) in
// if settings.authorizationStatus == .notDetermined {
// current.requestAuthorization(options: [.alert, .sound, .badge]) { [weak self] _, _ in
// DispatchQueue.main.async {
// if !Defaults.didShowForeignAlert {
// self?.performSegue(.foreignAlert)
// }
// }
// }
// }
// // TODO: handle other cases
// }
// UIApplication.shared.registerForRemoteNotifications()
}

@IBAction private func emergencyDidTap(_ sender: Any) {
Expand Down Expand Up @@ -192,3 +213,10 @@ extension MainViewController {
}
}
}

extension MainViewController: SPPermissionsDelegate, SPPermissionsDataSource {
func configure(_ cell: SPPermissionTableViewCell, for permission: SPPermission) -> SPPermissionTableViewCell {
cell
}

}
2 changes: 2 additions & 0 deletions Covid/Resources/Info.plist
Expand Up @@ -45,6 +45,8 @@
<string>Používame Váš bluetooth s cieľom ochrany pred šírením vírusu COVID-19 za účelom zistenia potenciálneho výskytu v blízkosti nakazeného pacienta.</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>Bluetooth</string>
<key>NSFileProviderDomainUsageDescription</key>
<string></string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Používame Vašu pozíciu s cieľom ochrany pred šírením vírusu COVID-19 za účelom informovania o karanténnej povinnosti obyvateľov.</string>
<key>NSLocationAlwaysUsageDescription</key>
Expand Down
3 changes: 3 additions & 0 deletions Covid/Services/LocationServices/BeaconManager.swift
Expand Up @@ -90,6 +90,9 @@ final class BeaconManager: NSObject {
guard let monitoringRegion = monitoringRegion else { return }

locationManager.startMonitoring(for: monitoringRegion)
after(.milliseconds(10)) { [weak self] in
self?.locationManager.requestState(for: monitoringRegion)
}
isMonitoring = true
print("start monitor")
}
Expand Down

0 comments on commit 9386433

Please sign in to comment.