Archived
Push from command line
This commit is contained in:
+17
-56
@@ -19,25 +19,24 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
FirebaseApp.configure()
|
||||
|
||||
if #available(iOS 10.0, *) {
|
||||
// For iOS 10 display notification (sent via APNS)
|
||||
UNUserNotificationCenter.current().delegate = self
|
||||
|
||||
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
|
||||
UNUserNotificationCenter.current().requestAuthorization(
|
||||
options: authOptions,
|
||||
completionHandler: {_, _ in })
|
||||
} else {
|
||||
let settings: UIUserNotificationSettings =
|
||||
UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
|
||||
application.registerUserNotificationSettings(settings)
|
||||
}
|
||||
// if #available(iOS 10.0, *) {
|
||||
// // For iOS 10 display notification (sent via APNS)
|
||||
// UNUserNotificationCenter.current().delegate = self
|
||||
//
|
||||
// let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
|
||||
// UNUserNotificationCenter.current().requestAuthorization(
|
||||
// options: authOptions,
|
||||
// completionHandler: {_, _ in })
|
||||
// } else {
|
||||
// let settings: UIUserNotificationSettings =
|
||||
// UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
|
||||
// application.registerUserNotificationSettings(settings)
|
||||
// }
|
||||
//
|
||||
// application.registerForRemoteNotifications()
|
||||
|
||||
application.registerForRemoteNotifications()
|
||||
|
||||
Messaging.messaging().subscribe(toTopic: "substitutions-ios") { error in
|
||||
print("Subscribed to substitutions topic")
|
||||
}
|
||||
Messaging.messaging().subscribe(toTopic: "substitutions-ios")
|
||||
Messaging.messaging().subscribe(toTopic: "substitutions-broadcast")
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -62,43 +61,5 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
func applicationWillTerminate(_ application: UIApplication) {
|
||||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
|
||||
}
|
||||
|
||||
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
|
||||
// If you are receiving a notification message while your app is in the background,
|
||||
// this callback will not be fired till the user taps on the notification launching the application.
|
||||
// TODO: Handle data of notification
|
||||
|
||||
// With swizzling disabled you must let Messaging know about the message, for Analytics
|
||||
// Messaging.messaging().appDidReceiveMessage(userInfo)
|
||||
|
||||
// Print message ID.
|
||||
if let messageID = userInfo[gcmMessageIDKey] {
|
||||
print("Message ID: \(messageID)")
|
||||
}
|
||||
|
||||
// Print full message.
|
||||
print(userInfo)
|
||||
}
|
||||
|
||||
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any],
|
||||
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
|
||||
// If you are receiving a notification message while your app is in the background,
|
||||
// this callback will not be fired till the user taps on the notification launching the application.
|
||||
// TODO: Handle data of notification
|
||||
|
||||
// With swizzling disabled you must let Messaging know about the message, for Analytics
|
||||
// Messaging.messaging().appDidReceiveMessage(userInfo)
|
||||
|
||||
// Print message ID.
|
||||
if let messageID = userInfo[gcmMessageIDKey] {
|
||||
print("Message ID: \(messageID)")
|
||||
}
|
||||
|
||||
// Print full message.
|
||||
print(userInfo)
|
||||
|
||||
completionHandler(UIBackgroundFetchResult.newData)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 274 B |
Binary file not shown.
|
After Width: | Height: | Size: 416 B |
Binary file not shown.
|
After Width: | Height: | Size: 608 B |
@@ -0,0 +1,127 @@
|
||||
//
|
||||
// ColourPickerView.swift
|
||||
// AvH Plan
|
||||
//
|
||||
// Created by Deniz Duezgoeren on 19.07.19.
|
||||
// Copyright © 2019 Deniz Duezgoeren. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import MagazineLayout
|
||||
|
||||
class ColourPickerView: UIViewController, UICollectionViewDataSource, UICollectionViewDelegateMagazineLayout {
|
||||
|
||||
let identifier = "colour-cell"
|
||||
var course = ""
|
||||
var currentIndexPath: IndexPath? = nil
|
||||
var internalCourse = ""
|
||||
@IBOutlet weak var toolbar: UINavigationBar!
|
||||
let prefs = UserDefaults.standard
|
||||
let df = DataFetcher.sharedInstance
|
||||
var index = 0
|
||||
var key = ""
|
||||
@IBOutlet weak var collectionView: UICollectionView!
|
||||
var previousSelected: IndexPath? = nil
|
||||
var currentSelected: IndexPath? = nil
|
||||
var selectedNewItem = false
|
||||
|
||||
@IBAction func done(_ sender: UIBarButtonItem) {
|
||||
prefs.set(currentSelected!.item, forKey: key) // index is used for the colour array in DataFetcher
|
||||
let dict: [String: IndexPath] = ["indexPath": currentIndexPath!]
|
||||
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "load"), object: nil, userInfo: dict)
|
||||
self.dismiss(animated: true, completion: nil)
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
key = "colour-index-\(internalCourse)"
|
||||
|
||||
self.collectionView.register(UINib(nibName: "ColourViewCell", bundle: nil), forCellWithReuseIdentifier: identifier)
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
index = prefs.integer(forKey: key)
|
||||
self.toolbar!.topItem!.title = "\(course)"
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||
// For remove previously selection
|
||||
if currentSelected != nil {
|
||||
if let cell = collectionView.cellForItem(at: currentSelected!) as? ColourViewCell {
|
||||
cell.imageView.image = UIImage(named: "ic_empty")
|
||||
}
|
||||
}
|
||||
|
||||
if let cell = collectionView.cellForItem(at: indexPath) as? ColourViewCell {
|
||||
cell.imageView.image = UIImage(named: "checkmark")
|
||||
}
|
||||
|
||||
currentSelected = indexPath
|
||||
|
||||
// // For reload the selected cell
|
||||
self.collectionView.reloadItems(at: [currentSelected!])
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeModeForItemAt indexPath: IndexPath) -> MagazineLayoutItemSizeMode {
|
||||
let widthMode = MagazineLayoutItemWidthMode.fullWidth(respectsHorizontalInsets: true)
|
||||
let heightMode = MagazineLayoutItemHeightMode.static(height: 55)
|
||||
return MagazineLayoutItemSizeMode(widthMode: widthMode, heightMode: heightMode)
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, visibilityModeForHeaderInSectionAtIndex index: Int) -> MagazineLayoutHeaderVisibilityMode {
|
||||
return .hidden
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, visibilityModeForFooterInSectionAtIndex index: Int) -> MagazineLayoutFooterVisibilityMode {
|
||||
return .hidden
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, visibilityModeForBackgroundInSectionAtIndex index: Int) -> MagazineLayoutBackgroundVisibilityMode {
|
||||
return .hidden
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, horizontalSpacingForItemsInSectionAtIndex index: Int) -> CGFloat {
|
||||
return 0
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, verticalSpacingForElementsInSectionAtIndex index: Int) -> CGFloat {
|
||||
return 0
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetsForSectionAtIndex index: Int) -> UIEdgeInsets {
|
||||
return UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetsForItemsInSectionAtIndex index: Int) -> UIEdgeInsets {
|
||||
return UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
||||
return self.df.getColourPalette().count
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
||||
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath as IndexPath) as! ColourViewCell
|
||||
cell.label.text = self.df.getColourPaletteNames()[indexPath.item]
|
||||
cell.colorView.layer.cornerRadius = cell.colorView.frame.height / 2
|
||||
cell.colorView.backgroundColor = self.df.getColourPalette()[indexPath.item]
|
||||
cell.backgroundColor = #colorLiteral(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)
|
||||
cell.colorView.layer.borderWidth = 0.4
|
||||
cell.colorView.layer.borderColor = #colorLiteral(red: 0.2549019754, green: 0.2745098174, blue: 0.3019607961, alpha: 1)
|
||||
|
||||
if currentSelected == indexPath {
|
||||
cell.imageView.image = UIImage(named: "checkmark")
|
||||
} else {
|
||||
cell.imageView.image = UIImage(named: "ic_empty")
|
||||
}
|
||||
|
||||
if !selectedNewItem, indexPath.item == prefs.integer(forKey: key) {
|
||||
currentSelected = indexPath
|
||||
cell.imageView.image = UIImage(named: "checkmark")
|
||||
selectedNewItem = true
|
||||
}
|
||||
|
||||
return cell
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user