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?
|
||||
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
|
||||
FirebaseApp.configure()
|
||||
|
||||
@@ -32,6 +32,7 @@ class InfoViewController : UIViewController {
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
self.extendedLayoutIncludesOpaqueBars = true
|
||||
self.navigationController?.navigationBar.topItem?.title = NSLocalizedString("information", comment: "")
|
||||
let layer = contentView.layer
|
||||
layer.cornerRadius = 12.0
|
||||
|
||||
@@ -9,29 +9,29 @@
|
||||
import UIKit
|
||||
import MagazineLayout
|
||||
|
||||
class MenuViewController : UIViewController, UICollectionViewDataSource, UICollectionViewDelegateMagazineLayout {
|
||||
class MenuViewController : UICollectionViewController, UICollectionViewDelegateMagazineLayout {
|
||||
|
||||
var items = [String]()
|
||||
private let refreshControl = UIRefreshControl()
|
||||
let df = DataFetcher.sharedInstance
|
||||
let layout = MagazineLayout()
|
||||
var collectionView: UICollectionView
|
||||
let identifier = "menu_cell"
|
||||
|
||||
required init?(coder decoder: NSCoder) {
|
||||
collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
||||
super.init(coder: decoder)
|
||||
collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
|
||||
view.addSubview(collectionView)
|
||||
collectionView.translatesAutoresizingMaskIntoConstraints = false
|
||||
collectionView.translatesAutoresizingMaskIntoConstraints = true
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
||||
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.register(UINib(nibName: "MenuViewCell", bundle: nil), forCellWithReuseIdentifier: identifier)
|
||||
@@ -54,6 +54,8 @@ class MenuViewController : UIViewController, UICollectionViewDataSource, UIColle
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
self.extendedLayoutIncludesOpaqueBars = true
|
||||
self.collectionView.contentInsetAdjustmentBehavior = .always
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
cell.content.text = self.items[indexPath.item]
|
||||
|
||||
@@ -11,20 +11,19 @@ import MagazineLayout
|
||||
import Crashlytics
|
||||
import Firebase
|
||||
|
||||
class PlanViewController : UIViewController, UICollectionViewDataSource, UICollectionViewDelegateMagazineLayout {
|
||||
class PlanViewController : UICollectionViewController, UICollectionViewDelegateMagazineLayout {
|
||||
|
||||
let identifier = "plan_cell"
|
||||
var substs = [SubstModel]()
|
||||
let refreshControl = UIRefreshControl()
|
||||
let df = DataFetcher.sharedInstance
|
||||
let layout = MagazineLayout()
|
||||
var collectionView: UICollectionView
|
||||
var url = ""
|
||||
var indexOfPSA: Int? = nil
|
||||
|
||||
required init?(coder decoder: NSCoder) {
|
||||
collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
||||
super.init(coder: decoder)
|
||||
collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
||||
}
|
||||
|
||||
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-broadcast")
|
||||
Crashlytics.sharedInstance().setUserIdentifier(UserDefaults.standard.string(forKey: "username"))
|
||||
// check if these can be put in AppDelegate
|
||||
|
||||
view.addSubview(collectionView)
|
||||
collectionView.translatesAutoresizingMaskIntoConstraints = false
|
||||
collectionView.translatesAutoresizingMaskIntoConstraints = true
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
||||
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.register(UINib(nibName: "PlanViewCell", bundle: nil), forCellWithReuseIdentifier: identifier)
|
||||
@@ -62,7 +63,8 @@ class PlanViewController : UIViewController, UICollectionViewDataSource, UIColle
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
self.extendedLayoutIncludesOpaqueBars = true
|
||||
self.collectionView.contentInsetAdjustmentBehavior = .always
|
||||
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
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||
if indexOfPSA == indexPath.item {
|
||||
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
|
||||
|
||||
var psa = false
|
||||
|
||||
let course = self.substs[indexPath.item].course
|
||||
var image = df.getImage(from: course)
|
||||
|
||||
@@ -189,8 +189,6 @@ class PlanViewController : UIViewController, UICollectionViewDataSource, UIColle
|
||||
return cell
|
||||
}
|
||||
|
||||
// stubs
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeModeForItemAt indexPath: IndexPath) -> MagazineLayoutItemSizeMode {
|
||||
var widthMode: MagazineLayoutItemWidthMode
|
||||
if UIDevice.current.userInterfaceIdiom == .pad { // iPad
|
||||
|
||||
Reference in New Issue
Block a user