Archived
Fixed one source of the large title jumping bug when refreshing, made collectionviews fit to insets as to not cut into the notch on iPhone X and successors
This commit is contained in:
@@ -14,7 +14,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|||||||
|
|
||||||
var window: UIWindow?
|
var window: UIWindow?
|
||||||
|
|
||||||
|
|
||||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||||
|
|
||||||
FirebaseApp.configure()
|
FirebaseApp.configure()
|
||||||
@@ -48,7 +47,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|||||||
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
|
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) {
|
||||||
print("Firebase registration token: \(fcmToken)")
|
print("Firebase registration token: \(fcmToken)")
|
||||||
|
|
||||||
let dataDict:[String: String] = ["token": fcmToken]
|
let dataDict: [String: String] = ["token": fcmToken]
|
||||||
NotificationCenter.default.post(name: Notification.Name("FCMToken"), object: nil, userInfo: dataDict)
|
NotificationCenter.default.post(name: Notification.Name("FCMToken"), object: nil, userInfo: dataDict)
|
||||||
// TODO: If necessary send token to application server.
|
// TODO: If necessary send token to application server.
|
||||||
// Note: This callback is fired at each app startup and whenever a new token is generated.
|
// Note: This callback is fired at each app startup and whenever a new token is generated.
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class InfoViewController : UIViewController {
|
|||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
self.extendedLayoutIncludesOpaqueBars = true
|
||||||
self.navigationController?.navigationBar.topItem?.title = NSLocalizedString("information", comment: "")
|
self.navigationController?.navigationBar.topItem?.title = NSLocalizedString("information", comment: "")
|
||||||
let layer = contentView.layer
|
let layer = contentView.layer
|
||||||
layer.cornerRadius = 12.0
|
layer.cornerRadius = 12.0
|
||||||
|
|||||||
@@ -9,29 +9,29 @@
|
|||||||
import UIKit
|
import UIKit
|
||||||
import MagazineLayout
|
import MagazineLayout
|
||||||
|
|
||||||
class MenuViewController : UIViewController, UICollectionViewDataSource, UICollectionViewDelegateMagazineLayout {
|
class MenuViewController : UICollectionViewController, UICollectionViewDelegateMagazineLayout {
|
||||||
|
|
||||||
var items = [String]()
|
var items = [String]()
|
||||||
private let refreshControl = UIRefreshControl()
|
private let refreshControl = UIRefreshControl()
|
||||||
let df = DataFetcher.sharedInstance
|
let df = DataFetcher.sharedInstance
|
||||||
let layout = MagazineLayout()
|
let layout = MagazineLayout()
|
||||||
var collectionView: UICollectionView
|
|
||||||
let identifier = "menu_cell"
|
let identifier = "menu_cell"
|
||||||
|
|
||||||
required init?(coder decoder: NSCoder) {
|
required init?(coder decoder: NSCoder) {
|
||||||
collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
|
||||||
super.init(coder: decoder)
|
super.init(coder: decoder)
|
||||||
|
collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewWillAppear(_ animated: Bool) {
|
override func viewWillAppear(_ animated: Bool) {
|
||||||
super.viewWillAppear(animated)
|
super.viewWillAppear(animated)
|
||||||
|
|
||||||
view.addSubview(collectionView)
|
view.addSubview(collectionView)
|
||||||
collectionView.translatesAutoresizingMaskIntoConstraints = false
|
collectionView.translatesAutoresizingMaskIntoConstraints = true
|
||||||
|
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
||||||
collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
||||||
collectionView.topAnchor.constraint(equalTo: view.topAnchor),
|
collectionView.topAnchor.constraint(equalTo: view.superview!.topAnchor),
|
||||||
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
|
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
|
||||||
])
|
])
|
||||||
collectionView.register(UINib(nibName: "MenuViewCell", bundle: nil), forCellWithReuseIdentifier: identifier)
|
collectionView.register(UINib(nibName: "MenuViewCell", bundle: nil), forCellWithReuseIdentifier: identifier)
|
||||||
@@ -54,6 +54,8 @@ class MenuViewController : UIViewController, UICollectionViewDataSource, UIColle
|
|||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
self.extendedLayoutIncludesOpaqueBars = true
|
||||||
|
self.collectionView.contentInsetAdjustmentBehavior = .always
|
||||||
self.navigationController?.navigationBar.topItem?.title = NSLocalizedString("food_menu", comment: "")
|
self.navigationController?.navigationBar.topItem?.title = NSLocalizedString("food_menu", comment: "")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,11 +68,11 @@ class MenuViewController : UIViewController, UICollectionViewDataSource, UIColle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
||||||
return self.items.count
|
return self.items.count
|
||||||
}
|
}
|
||||||
|
|
||||||
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
||||||
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath as IndexPath) as! MenuViewCell
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath as IndexPath) as! MenuViewCell
|
||||||
|
|
||||||
cell.content.text = self.items[indexPath.item]
|
cell.content.text = self.items[indexPath.item]
|
||||||
|
|||||||
@@ -11,20 +11,19 @@ import MagazineLayout
|
|||||||
import Crashlytics
|
import Crashlytics
|
||||||
import Firebase
|
import Firebase
|
||||||
|
|
||||||
class PlanViewController : UIViewController, UICollectionViewDataSource, UICollectionViewDelegateMagazineLayout {
|
class PlanViewController : UICollectionViewController, UICollectionViewDelegateMagazineLayout {
|
||||||
|
|
||||||
let identifier = "plan_cell"
|
let identifier = "plan_cell"
|
||||||
var substs = [SubstModel]()
|
var substs = [SubstModel]()
|
||||||
let refreshControl = UIRefreshControl()
|
let refreshControl = UIRefreshControl()
|
||||||
let df = DataFetcher.sharedInstance
|
let df = DataFetcher.sharedInstance
|
||||||
let layout = MagazineLayout()
|
let layout = MagazineLayout()
|
||||||
var collectionView: UICollectionView
|
|
||||||
var url = ""
|
var url = ""
|
||||||
var indexOfPSA: Int? = nil
|
var indexOfPSA: Int? = nil
|
||||||
|
|
||||||
required init?(coder decoder: NSCoder) {
|
required init?(coder decoder: NSCoder) {
|
||||||
collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
|
||||||
super.init(coder: decoder)
|
super.init(coder: decoder)
|
||||||
|
collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewWillAppear(_ animated: Bool) {
|
override func viewWillAppear(_ animated: Bool) {
|
||||||
@@ -33,13 +32,15 @@ class PlanViewController : UIViewController, UICollectionViewDataSource, UIColle
|
|||||||
Messaging.messaging().subscribe(toTopic: "substitutions-ios")
|
Messaging.messaging().subscribe(toTopic: "substitutions-ios")
|
||||||
Messaging.messaging().subscribe(toTopic: "substitutions-broadcast")
|
Messaging.messaging().subscribe(toTopic: "substitutions-broadcast")
|
||||||
Crashlytics.sharedInstance().setUserIdentifier(UserDefaults.standard.string(forKey: "username"))
|
Crashlytics.sharedInstance().setUserIdentifier(UserDefaults.standard.string(forKey: "username"))
|
||||||
|
// check if these can be put in AppDelegate
|
||||||
|
|
||||||
view.addSubview(collectionView)
|
view.addSubview(collectionView)
|
||||||
collectionView.translatesAutoresizingMaskIntoConstraints = false
|
collectionView.translatesAutoresizingMaskIntoConstraints = true
|
||||||
|
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
||||||
collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
||||||
collectionView.topAnchor.constraint(equalTo: view.topAnchor),
|
collectionView.topAnchor.constraint(equalTo: view.superview!.topAnchor),
|
||||||
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
|
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
|
||||||
])
|
])
|
||||||
collectionView.register(UINib(nibName: "PlanViewCell", bundle: nil), forCellWithReuseIdentifier: identifier)
|
collectionView.register(UINib(nibName: "PlanViewCell", bundle: nil), forCellWithReuseIdentifier: identifier)
|
||||||
@@ -62,7 +63,8 @@ class PlanViewController : UIViewController, UICollectionViewDataSource, UIColle
|
|||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
self.extendedLayoutIncludesOpaqueBars = true
|
||||||
|
self.collectionView.contentInsetAdjustmentBehavior = .always
|
||||||
self.df.setTabBarBadge(for: self.tabBarController?.tabBar.items)
|
self.df.setTabBarBadge(for: self.tabBarController?.tabBar.items)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,21 +89,19 @@ class PlanViewController : UIViewController, UICollectionViewDataSource, UIColle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
||||||
return self.substs.count
|
return self.substs.count
|
||||||
}
|
}
|
||||||
|
|
||||||
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||||
if indexOfPSA == indexPath.item {
|
if indexOfPSA == indexPath.item {
|
||||||
UIApplication.shared.open(URL(string: url)!)
|
UIApplication.shared.open(URL(string: url)!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
||||||
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath as IndexPath) as! PlanViewCell
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: identifier, for: indexPath as IndexPath) as! PlanViewCell
|
||||||
|
|
||||||
var psa = false
|
var psa = false
|
||||||
|
|
||||||
let course = self.substs[indexPath.item].course
|
let course = self.substs[indexPath.item].course
|
||||||
var image = df.getImage(from: course)
|
var image = df.getImage(from: course)
|
||||||
|
|
||||||
@@ -189,8 +189,6 @@ class PlanViewController : UIViewController, UICollectionViewDataSource, UIColle
|
|||||||
return cell
|
return cell
|
||||||
}
|
}
|
||||||
|
|
||||||
// stubs
|
|
||||||
|
|
||||||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeModeForItemAt indexPath: IndexPath) -> MagazineLayoutItemSizeMode {
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeModeForItemAt indexPath: IndexPath) -> MagazineLayoutItemSizeMode {
|
||||||
var widthMode: MagazineLayoutItemWidthMode
|
var widthMode: MagazineLayoutItemWidthMode
|
||||||
if UIDevice.current.userInterfaceIdiom == .pad { // iPad
|
if UIDevice.current.userInterfaceIdiom == .pad { // iPad
|
||||||
|
|||||||
Reference in New Issue
Block a user