From 866b8868407c734e869d6a1a3758d43bf9e1fca0 Mon Sep 17 00:00:00 2001 From: Deniz Duezgoeren Date: Sat, 3 Aug 2019 11:01:56 +0200 Subject: [PATCH] Wrapped view controllers in navigation controllers to add large titles, added "Last updated" string in information view controller --- AvH Plan/Base.lproj/Main.storyboard | 217 +++++++++++---------- AvH Plan/CustomizationViewController.swift | 2 - AvH Plan/DataFetcher.swift | 10 +- AvH Plan/GeneralPlanViewController.swift | 7 +- AvH Plan/InfoViewController.swift | 5 + AvH Plan/MenuViewController.swift | 12 +- AvH Plan/PersonalPlanViewController.swift | 9 +- AvH Plan/PlanViewController.swift | 2 +- AvH Plan/de.lproj/Main.strings | 4 + 9 files changed, 140 insertions(+), 128 deletions(-) diff --git a/AvH Plan/Base.lproj/Main.storyboard b/AvH Plan/Base.lproj/Main.storyboard index 21657fc..a45a8dd 100644 --- a/AvH Plan/Base.lproj/Main.storyboard +++ b/AvH Plan/Base.lproj/Main.storyboard @@ -15,79 +15,48 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + - + @@ -194,7 +163,6 @@ - @@ -202,7 +170,7 @@ - + @@ -259,25 +227,18 @@ - + - + - + - - - - - - - - + @@ -309,17 +270,14 @@ - - - - + - + @@ -327,60 +285,119 @@ - + - + - + - - - - - - - - - - - - - - - - - - + - + - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -389,6 +406,6 @@ - + diff --git a/AvH Plan/CustomizationViewController.swift b/AvH Plan/CustomizationViewController.swift index af668cd..b4590e5 100644 --- a/AvH Plan/CustomizationViewController.swift +++ b/AvH Plan/CustomizationViewController.swift @@ -24,8 +24,6 @@ class CustomizationViewController: UIViewController, UICollectionViewDataSource, @IBOutlet weak var txtCourses: UITextField! @IBOutlet weak var defaultSegments: UISegmentedControl! - @IBOutlet weak var toolbar: UINavigationBar! - override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) courses = self.df.courses diff --git a/AvH Plan/DataFetcher.swift b/AvH Plan/DataFetcher.swift index c72747c..a86124e 100644 --- a/AvH Plan/DataFetcher.swift +++ b/AvH Plan/DataFetcher.swift @@ -35,7 +35,7 @@ class DataFetcher { func doAsync(do task: String, completionHandler: @escaping (_ substitutions: [Any]) -> ()) { DispatchQueue(label: "work-queue").async { let foodUrl = "https://djd4rkn355.github.io/food.html" - let url = "https://djd4rkn355.github.io/subst.html" + let url = "https://djd4rkn355.github.io/subst_test.html" Alamofire.request(url).responseString { response in if let html = response.result.value { Alamofire.request(foodUrl).responseString { response in @@ -139,14 +139,12 @@ class DataFetcher { _ = try db.run(insertPersonal) } + let lastUpdated = try doc.select("h1").get(0).text() + info = "\(NSLocalizedString("last_updated", comment: ""))\(lastUpdated)." let pi: Elements = try doc.select("p") for item in pi { - if info.isEmpty { - info = try item.text() - } else { - info += "\n\n\(try item.text())" - } + info += "\n\n\(try item.text())" } _ = prefs.set(info, forKey: "information") diff --git a/AvH Plan/GeneralPlanViewController.swift b/AvH Plan/GeneralPlanViewController.swift index bc2da31..5f1cf0c 100644 --- a/AvH Plan/GeneralPlanViewController.swift +++ b/AvH Plan/GeneralPlanViewController.swift @@ -9,11 +9,10 @@ import UIKit class GeneralViewController: PlanViewController { - - @IBOutlet weak var toolbar: UINavigationBar! override func viewDidLoad() { super.viewDidLoad() + self.navigationController?.navigationBar.topItem?.title = NSLocalizedString("avh_plan", comment: "") } override func getViewType() -> String { @@ -27,10 +26,6 @@ class GeneralViewController: PlanViewController { override func getFromDatabase() -> [SubstModel] { return df.getFromDatabase() } - - override func getToolbarBottomAnchor() -> NSLayoutYAxisAnchor { - return toolbar.bottomAnchor - } /* // MARK: - Navigation diff --git a/AvH Plan/InfoViewController.swift b/AvH Plan/InfoViewController.swift index 2172a67..b70317f 100644 --- a/AvH Plan/InfoViewController.swift +++ b/AvH Plan/InfoViewController.swift @@ -30,6 +30,11 @@ class InfoViewController : UIViewController { content.text = df.readInformation() } + override func viewDidLoad() { + super.viewDidLoad() + self.navigationController?.navigationBar.topItem?.title = NSLocalizedString("information", comment: "") + } + @objc private func objDoAsync(_ sender: Any) { self.df.doAsync(do: "info") { infoArray in self.content.text = infoArray[0] as? String diff --git a/AvH Plan/MenuViewController.swift b/AvH Plan/MenuViewController.swift index 391c125..4509dc6 100644 --- a/AvH Plan/MenuViewController.swift +++ b/AvH Plan/MenuViewController.swift @@ -14,7 +14,6 @@ class MenuViewController : UIViewController, UICollectionViewDataSource, UIColle var items = [String]() private let refreshControl = UIRefreshControl() let df = DataFetcher.sharedInstance - @IBOutlet weak var toolbar: UINavigationBar! let layout = MagazineLayout() var collectionView: UICollectionView let identifier = "menu_cell" @@ -32,7 +31,7 @@ class MenuViewController : UIViewController, UICollectionViewDataSource, UIColle NSLayoutConstraint.activate([ collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor), collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - collectionView.topAnchor.constraint(equalTo: self.toolbar.bottomAnchor), + collectionView.topAnchor.constraint(equalTo: view.topAnchor), collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor), ]) collectionView.register(UINib(nibName: "MenuViewCell", bundle: nil), forCellWithReuseIdentifier: identifier) @@ -53,6 +52,11 @@ class MenuViewController : UIViewController, UICollectionViewDataSource, UIColle self.collectionView.reloadData() } + override func viewDidLoad() { + super.viewDidLoad() + self.navigationController?.navigationBar.topItem?.title = NSLocalizedString("food_menu", comment: "") + } + @objc private func objDoAsync(_ sender: Any) { df.doAsync(do: "menu") { menuItems in self.items = menuItems as! [String] @@ -74,10 +78,6 @@ class MenuViewController : UIViewController, UICollectionViewDataSource, UIColle cell.backgroundColor = #colorLiteral(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0) return cell } - - func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - print("You selected cell#\(indexPath.item)!") - } // generated stubs filled with return values diff --git a/AvH Plan/PersonalPlanViewController.swift b/AvH Plan/PersonalPlanViewController.swift index 904b78b..8e7625d 100644 --- a/AvH Plan/PersonalPlanViewController.swift +++ b/AvH Plan/PersonalPlanViewController.swift @@ -10,7 +10,6 @@ import UIKit class PersonalPlanViewController: PlanViewController { - @IBOutlet weak var toolbar: UINavigationBar! let prefs = UserDefaults.standard @IBAction func toolbarButtonCustomise(_ sender: UIBarButtonItem) { @@ -44,9 +43,9 @@ class PersonalPlanViewController: PlanViewController { let user = self.prefs.string(forKey: "username") if (user != nil && user != "") { if (user!.last == "x" || user!.last == "s" || user!.last == "z") { - self.toolbar!.topItem!.title = "\(user!)\(NSLocalizedString("nosplan", comment: ""))" + self.navigationController?.navigationBar.topItem?.title = "\(user!)\(NSLocalizedString("nosplan", comment: ""))" } else { - self.toolbar!.topItem!.title = "\(user!)\(NSLocalizedString("splan", comment: ""))" + self.navigationController?.navigationBar.topItem?.title = "\(user!)\(NSLocalizedString("splan", comment: ""))" } } } @@ -62,9 +61,5 @@ class PersonalPlanViewController: PlanViewController { override func getFromDatabase() -> [SubstModel] { return df.getPersonalFromDatabase() } - - override func getToolbarBottomAnchor() -> NSLayoutYAxisAnchor { - return toolbar.bottomAnchor - } } diff --git a/AvH Plan/PlanViewController.swift b/AvH Plan/PlanViewController.swift index 09c7071..3143ff6 100644 --- a/AvH Plan/PlanViewController.swift +++ b/AvH Plan/PlanViewController.swift @@ -35,7 +35,7 @@ class PlanViewController : UIViewController, UICollectionViewDataSource, UIColle NSLayoutConstraint.activate([ collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor), collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - collectionView.topAnchor.constraint(equalTo: getToolbarBottomAnchor()), + collectionView.topAnchor.constraint(equalTo: view.topAnchor), // getToolbarBottomAnchor()), collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor), ]) collectionView.register(UINib(nibName: "PlanViewCell", bundle: nil), forCellWithReuseIdentifier: identifier) diff --git a/AvH Plan/de.lproj/Main.strings b/AvH Plan/de.lproj/Main.strings index 4185842..213606e 100644 --- a/AvH Plan/de.lproj/Main.strings +++ b/AvH Plan/de.lproj/Main.strings @@ -78,3 +78,7 @@ /* Class = "UILabel"; text = "Custom colours"; ObjectID = "rks-gf-AM4"; */ "rks-gf-AM4.text" = "Benutzerdefinierte Farben"; + +"bae-uC-OAx.text" = "Anpassen"; + +"zsF-Jh-U3n.text" = "Anpassen";