Cleaned up some code

This commit is contained in:
Deniz Duezgoeren
2019-08-23 13:04:36 +02:00
parent 6bb14d659d
commit c92d47f224
8 changed files with 17 additions and 85 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ class ColourPickerView: UIViewController, UICollectionViewDataSource, UICollecti
currentSelected = indexPath
// // For reload the selected cell
// For reload the selected cell
self.collectionView.reloadItems(at: [currentSelected!])
}
@@ -15,7 +15,6 @@ class CustomizationViewController: UIViewController, UICollectionViewDataSource,
var translatedCourses = [String]()
@IBOutlet weak var collectionView: UICollectionView!
let identifier = "customisation_cell"
// let storyboard = UIStoryboard(name: "main", bundle: nil)
let prefs = UserDefaults.standard
let df = DataFetcher.sharedInstance
@@ -23,7 +22,6 @@ class CustomizationViewController: UIViewController, UICollectionViewDataSource,
@IBOutlet weak var txtClasses: UITextField!
@IBOutlet weak var txtCourses: UITextField!
@IBOutlet weak var defaultSegments: UISegmentedControl!
@IBOutlet weak var textToolbar: UIToolbar!
@IBAction func textDismissButton(_ sender: Any) {
+11 -6
View File
@@ -174,12 +174,6 @@ class DataFetcher {
try db.run(foodmenu.delete())
// for i in 0..<ef.size() {
// menuList.append(try ef.get(i).text())
// let insert = foodmenu.insert(text <- try ef.get(i).text())
// _ = try db.run(insert)
// }
var indices = [Int]()
let daysAndVon = ["Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "von"]
for i in 0..<ef.size() {
@@ -364,4 +358,15 @@ class DataFetcher {
let courses = ["German", "English", "French", "Spanish", "Latin", "Turkish", "Chinese", "Arts", "Music", "Theatre", "Geography", "History", "Politics", "Philosophy", "Religion", "Maths", "Biology", "Chemistry", "Physics", "CompSci", "PhysEd", "GLL", "WAT", "Forder", "WP"]
let translatedCourses = [NSLocalizedString("german", comment: ""), NSLocalizedString("english", comment: ""), NSLocalizedString("french", comment: ""), NSLocalizedString("spanish", comment: ""), NSLocalizedString("latin", comment: ""), NSLocalizedString("turkish", comment: ""), NSLocalizedString("chinese", comment: ""), NSLocalizedString("arts", comment: ""), NSLocalizedString("music", comment: ""), NSLocalizedString("theatre", comment: ""), NSLocalizedString("geography", comment: ""), NSLocalizedString("history", comment: ""), NSLocalizedString("politics", comment: ""), NSLocalizedString("philosophy", comment: ""), NSLocalizedString("religion", comment: ""), NSLocalizedString("mathematics", comment: ""), NSLocalizedString("biology", comment: ""), NSLocalizedString("chemistry", comment: ""), NSLocalizedString("physics", comment: ""), NSLocalizedString("compsci", comment: ""), NSLocalizedString("physed", comment: ""), NSLocalizedString("gll", comment: ""), NSLocalizedString("wat", comment: ""), NSLocalizedString("forder", comment: ""), NSLocalizedString("wp", comment: "")]
func setTabBarBadge(for tabBarItems: [UITabBarItem]?) {
if let tabItems = tabBarItems {
let tabItem = tabItems[1]
if self.prefs.integer(forKey: "personalPlanCount") != 0 {
tabItem.badgeValue = "\(self.prefs.integer(forKey: "personalPlanCount"))"
} else {
tabItem.badgeValue = nil
}
}
}
}
-10
View File
@@ -27,14 +27,4 @@ class GeneralViewController: PlanViewController {
return df.getFromDatabase()
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}
+1 -9
View File
@@ -12,7 +12,6 @@ class InfoViewController : UIViewController {
@IBOutlet weak var content: UILabel!
@IBOutlet weak var contentView: UIView!
let prefs = UserDefaults.standard
@IBOutlet weak var scrollView: UIScrollView!
private let refreshControl = UIRefreshControl()
let df = DataFetcher.sharedInstance
@@ -46,14 +45,7 @@ class InfoViewController : UIViewController {
self.df.doAsync(do: "info") { infoArray in
self.content.text = infoArray[0] as? String
self.refreshControl.endRefreshing()
if let tabItems = self.tabBarController?.tabBar.items {
let tabItem = tabItems[1]
if self.prefs.integer(forKey: "personalPlanCount") != 0 {
tabItem.badgeValue = "\(self.prefs.integer(forKey: "personalPlanCount"))"
} else {
tabItem.badgeValue = nil
}
}
self.df.setTabBarBadge(for: self.tabBarController?.tabBar.items)
}
}
}
+2 -10
View File
@@ -17,7 +17,6 @@ class MenuViewController : UIViewController, UICollectionViewDataSource, UIColle
let layout = MagazineLayout()
var collectionView: UICollectionView
let identifier = "menu_cell"
let prefs = UserDefaults.standard
required init?(coder decoder: NSCoder) {
collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
@@ -43,7 +42,7 @@ class MenuViewController : UIViewController, UICollectionViewDataSource, UIColle
if #available(iOS 10.0, *) {
collectionView.refreshControl = refreshControl
} else {
collectionView.addSubview(refreshControl) // likely unnecessary
collectionView.addSubview(refreshControl)
}
refreshControl.addTarget(self, action: #selector(objDoAsync(_:)), for: .valueChanged)
refreshControl.tintColor = #colorLiteral(red: 0.07843137255, green: 0.5568627451, blue: 1, alpha: 1)
@@ -63,14 +62,7 @@ class MenuViewController : UIViewController, UICollectionViewDataSource, UIColle
self.items = menuItems as! [String]
self.collectionView.reloadData()
self.refreshControl.endRefreshing()
if let tabItems = self.tabBarController?.tabBar.items {
let tabItem = tabItems[1]
if self.prefs.integer(forKey: "personalPlanCount") != 0 {
tabItem.badgeValue = "\(self.prefs.integer(forKey: "personalPlanCount"))"
} else {
tabItem.badgeValue = nil
}
}
self.df.setTabBarBadge(for: self.tabBarController?.tabBar.items)
}
}
-26
View File
@@ -12,32 +12,6 @@ class PersonalPlanViewController: PlanViewController {
let prefs = UserDefaults.standard
@IBAction func toolbarButtonCustomise(_ sender: UIBarButtonItem) {
// let alert = UIAlertController(title: NSLocalizedString("customize_alert_title", comment: ""), message: nil, preferredStyle: .alert)
// alert.addTextField { (name) in
// name.text = self.prefs.string(forKey: "username")
// name.placeholder = NSLocalizedString("name", comment: "")
// }
// alert.addTextField { (classes) in
// classes.text = self.prefs.string(forKey: "classes")
// classes.placeholder = NSLocalizedString("classes", comment: "")
// }
// alert.addTextField { (courses) in
// courses.text = self.prefs.string(forKey: "courses")
// courses.placeholder = NSLocalizedString("courses", comment: "")
// }
// alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { [weak alert] (action) -> Void in
// _ = self.prefs.set(alert!.textFields![0].text, forKey: "username")
// _ = self.prefs.set(alert!.textFields![1].text, forKey: "classes")
// _ = self.prefs.set(alert!.textFields![2].text, forKey: "courses")
// _ = self.prefs.synchronize()
// }))
//
// self.present(alert, animated: true, completion: nil)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
let user = self.prefs.string(forKey: "username")
+2 -21
View File
@@ -17,7 +17,6 @@ class PlanViewController : UIViewController, UICollectionViewDataSource, UIColle
var substs = [SubstModel]()
let refreshControl = UIRefreshControl()
let df = DataFetcher.sharedInstance
let planPrefs = UserDefaults.standard
let layout = MagazineLayout()
var collectionView: UICollectionView
var url = ""
@@ -28,10 +27,6 @@ class PlanViewController : UIViewController, UICollectionViewDataSource, UIColle
super.init(coder: decoder)
}
func getToolbarBottomAnchor() -> NSLayoutYAxisAnchor {
return view.topAnchor
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
@@ -68,14 +63,7 @@ class PlanViewController : UIViewController, UICollectionViewDataSource, UIColle
override func viewDidLoad() {
super.viewDidLoad()
if let tabItems = self.tabBarController?.tabBar.items {
let tabItem = tabItems[1]
if self.planPrefs.integer(forKey: "personalPlanCount") != 0 {
tabItem.badgeValue = "\(self.planPrefs.integer(forKey: "personalPlanCount"))"
} else {
tabItem.badgeValue = nil
}
}
self.df.setTabBarBadge(for: self.tabBarController?.tabBar.items)
}
func getViewType() -> String {
@@ -95,14 +83,7 @@ class PlanViewController : UIViewController, UICollectionViewDataSource, UIColle
self.substs = substitutions as! [SubstModel]
self.collectionView.reloadData()
self.refreshControl.endRefreshing()
if let tabItems = self.tabBarController?.tabBar.items {
let tabItem = tabItems[1]
if self.planPrefs.integer(forKey: "personalPlanCount") != 0 {
tabItem.badgeValue = "\(self.planPrefs.integer(forKey: "personalPlanCount"))"
} else {
tabItem.badgeValue = nil
}
}
self.df.setTabBarBadge(for: self.tabBarController?.tabBar.items)
}
}