Changed InfoViewController out for a UIAlertController

This commit is contained in:
Deniz Duezgoeren
2019-09-16 19:05:06 +02:00
parent d83f8f7342
commit 3608d7d363
9 changed files with 51 additions and 120 deletions
-4
View File
@@ -30,7 +30,6 @@
A9B0464E22E1F75A005FB0DB /* CustomizationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9B0464D22E1F75A005FB0DB /* CustomizationViewController.swift */; };
A9B0465022E21207005FB0DB /* ColourPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9B0464F22E21207005FB0DB /* ColourPickerView.swift */; };
A9B0465422E448EC005FB0DB /* GenericViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9B0465322E448EC005FB0DB /* GenericViewCell.swift */; };
A9C1D2FE22D656A400139043 /* InfoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C1D2FD22D656A400139043 /* InfoViewController.swift */; };
A9C1D30022D656DD00139043 /* MenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C1D2FF22D656DD00139043 /* MenuViewController.swift */; };
A9C1D30222D7237200139043 /* DataFetcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9C1D30122D7237200139043 /* DataFetcher.swift */; };
A9D830A722DE258C00D7EA05 /* PlanViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D830A522DE258C00D7EA05 /* PlanViewCell.swift */; };
@@ -101,7 +100,6 @@
A9B0464D22E1F75A005FB0DB /* CustomizationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomizationViewController.swift; sourceTree = "<group>"; };
A9B0464F22E21207005FB0DB /* ColourPickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColourPickerView.swift; sourceTree = "<group>"; };
A9B0465322E448EC005FB0DB /* GenericViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GenericViewCell.swift; sourceTree = "<group>"; };
A9C1D2FD22D656A400139043 /* InfoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoViewController.swift; sourceTree = "<group>"; };
A9C1D2FF22D656DD00139043 /* MenuViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuViewController.swift; sourceTree = "<group>"; };
A9C1D30122D7237200139043 /* DataFetcher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataFetcher.swift; sourceTree = "<group>"; };
A9D830A522DE258C00D7EA05 /* PlanViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlanViewCell.swift; sourceTree = "<group>"; };
@@ -193,7 +191,6 @@
A99AB5F7230155DE00555295 /* GoogleService-Info.plist */,
A961337F2299867400B541D4 /* AppDelegate.swift */,
A96133812299867400B541D4 /* PlanViewController.swift */,
A9C1D2FD22D656A400139043 /* InfoViewController.swift */,
A9C1D2FF22D656DD00139043 /* MenuViewController.swift */,
A96133852299867400B541D4 /* Main.storyboard */,
A96133882299867A00B541D4 /* Assets.xcassets */,
@@ -489,7 +486,6 @@
A9A3496C22D4859200F35AE0 /* SubstModel.swift in Sources */,
A9C1D30022D656DD00139043 /* MenuViewController.swift in Sources */,
A957A75122DDC15500E0A2ED /* MenuViewCell.swift in Sources */,
A9C1D2FE22D656A400139043 /* InfoViewController.swift in Sources */,
A9B0464C22E1F255005FB0DB /* CustomTabBarController.swift in Sources */,
A9D830A722DE258C00D7EA05 /* PlanViewCell.swift in Sources */,
A96D4CC822DDE01A006BAB34 /* GeneralPlanViewController.swift in Sources */,
+2 -64
View File
@@ -242,65 +242,6 @@
</objects>
<point key="canvasLocation" x="3503" y="-514"/>
</scene>
<!--Info View Controller-->
<scene sceneID="tt5-VM-aeV">
<objects>
<viewController id="Ve9-lV-ekU" customClass="InfoViewController" customModule="AvH_Plan" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="eFO-Bf-72I">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uw2-gR-W7a">
<rect key="frame" x="0.0" y="140" width="414" height="673"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="3fL-cf-hwr">
<rect key="frame" x="8" y="3" width="398" height="46.333333333333336"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6H8-lj-boN">
<rect key="frame" x="16" y="12.999999999999998" width="366" height="20.333333333333329"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="6H8-lj-boN" firstAttribute="top" secondItem="3fL-cf-hwr" secondAttribute="top" constant="13" id="7vg-94-kgE"/>
<constraint firstAttribute="trailing" secondItem="6H8-lj-boN" secondAttribute="trailing" constant="16" id="L2I-aF-rMP"/>
<constraint firstItem="6H8-lj-boN" firstAttribute="leading" secondItem="3fL-cf-hwr" secondAttribute="leading" constant="16" id="XFt-8f-uB8"/>
<constraint firstAttribute="bottom" secondItem="6H8-lj-boN" secondAttribute="bottom" constant="13" id="ix6-T3-Xby"/>
</constraints>
</view>
</subviews>
<constraints>
<constraint firstItem="3fL-cf-hwr" firstAttribute="width" secondItem="uw2-gR-W7a" secondAttribute="width" constant="-16" id="2Zp-WB-kqG"/>
<constraint firstItem="3fL-cf-hwr" firstAttribute="top" secondItem="uw2-gR-W7a" secondAttribute="top" constant="3" id="CK9-Ci-1Uz"/>
<constraint firstItem="3fL-cf-hwr" firstAttribute="leading" secondItem="uw2-gR-W7a" secondAttribute="leading" constant="8" id="H8E-nR-Ao4"/>
<constraint firstAttribute="trailing" secondItem="3fL-cf-hwr" secondAttribute="trailing" constant="8" id="Qn2-pu-ejr"/>
<constraint firstAttribute="bottom" secondItem="3fL-cf-hwr" secondAttribute="bottom" constant="3" id="h0k-Nd-ev6"/>
</constraints>
</scrollView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="uw2-gR-W7a" firstAttribute="leading" secondItem="fuI-1W-d0u" secondAttribute="leading" id="SHL-lX-cF5"/>
<constraint firstItem="fuI-1W-d0u" firstAttribute="trailing" secondItem="uw2-gR-W7a" secondAttribute="trailing" id="Ypb-ba-cQV"/>
<constraint firstItem="uw2-gR-W7a" firstAttribute="top" secondItem="fuI-1W-d0u" secondAttribute="top" id="hcg-67-avl"/>
<constraint firstItem="fuI-1W-d0u" firstAttribute="bottom" secondItem="uw2-gR-W7a" secondAttribute="bottom" id="uXS-YK-oIz"/>
</constraints>
<viewLayoutGuide key="safeArea" id="fuI-1W-d0u"/>
</view>
<navigationItem key="navigationItem" id="ZSj-6h-iwN"/>
<connections>
<outlet property="content" destination="6H8-lj-boN" id="Q49-OJ-zsl"/>
<outlet property="contentView" destination="3fL-cf-hwr" id="boC-XG-8z1"/>
<outlet property="scrollView" destination="uw2-gR-W7a" id="C2y-Jf-fgR"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="JwL-CA-SQG" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1631.8840579710147" y="572.54464285714278"/>
</scene>
<!--Menu View Controller-->
<scene sceneID="JTo-oO-5Xc">
<objects>
@@ -377,6 +318,7 @@
<!--Information-->
<scene sceneID="8Mm-U7-JgF">
<objects>
<placeholder placeholderIdentifier="IBFirstResponder" id="IMM-XL-aYt" userLabel="First Responder" sceneMemberID="firstResponder"/>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="QLo-hR-KTA" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="Information" image="ic_information" selectedImage="ic_information" id="BQ7-VO-yI4"/>
<toolbarItems/>
@@ -385,11 +327,7 @@
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="Ve9-lV-ekU" kind="relationship" relationship="rootViewController" id="CgO-X2-kmQ"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="IMM-XL-aYt" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="721.73913043478262" y="572.54464285714278"/>
</scene>
@@ -420,6 +358,6 @@
<image name="ic_writing" width="25" height="25"/>
</resources>
<inferredMetricsTieBreakers>
<segue reference="0Bb-6a-gkf"/>
<segue reference="OZ6-ZZ-xdo"/>
</inferredMetricsTieBreakers>
</document>
+24 -2
View File
@@ -151,8 +151,8 @@ class DataFetcher {
prefs.set(personalPlanCount, forKey: "personalPlanCount")
if isPersonalEmpty {
personalSubst.append(SubstModel(group: NSLocalizedString("personal_plan_empty", comment: ""), course: "", additional: "", date: "", time: "", room: "", teacher: "", type: ""))
let insertPersonal = personal.insert(group <- NSLocalizedString("personal_plan_empty", comment: ""), course <- "", additional <- "", date <- "", time <- "", room <- "", teacher <- "", substType <- "")
personalSubst.append(SubstModel(group: "", course: NSLocalizedString("personal_plan_empty", comment: ""), additional: "", date: "", time: "", room: "", teacher: "", type: ""))
let insertPersonal = personal.insert(group <- "", course <- NSLocalizedString("personal_plan_empty", comment: ""), additional <- "", date <- "", time <- "", room <- "", teacher <- "", substType <- "")
try db.run(insertPersonal)
}
@@ -386,4 +386,26 @@ class DataFetcher {
layer.shadowRadius = 1.5
layer.shadowOpacity = 0.7
}
func presentInformationAlert(for tabBarController: UITabBarController, at index: Int) -> UIAlertController? {
if tabBarController.selectedIndex == 2 {
tabBarController.selectedIndex = index
let alert = UIAlertController(title: NSLocalizedString("information", comment: ""), message: self.readInformation(), preferredStyle: .alert)
alert.addAction(UIAlertAction(title: NSLocalizedString("dismiss", comment: ""), style: .default) { action in
})
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = NSTextAlignment.left
let messageText = NSMutableAttributedString(
string: self.readInformation(),
attributes: [
NSAttributedString.Key.paragraphStyle: paragraphStyle,
NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: UIFont.TextStyle.caption1)
]
)
alert.setValue(messageText, forKey: "attributedMessage")
return alert
} else {
return nil
}
}
}
-48
View File
@@ -1,48 +0,0 @@
//
// InfoViewController.swift
// AvH Plan
//
// Created by Deniz Duezgoeren on 10.07.19.
// Copyright © 2019 Deniz Duezgoeren. All rights reserved.
//
import UIKit
class InfoViewController : UIViewController {
@IBOutlet weak var content: UILabel!
@IBOutlet weak var contentView: UIView!
@IBOutlet weak var scrollView: UIScrollView!
private let refreshControl = UIRefreshControl()
let df = DataFetcher.sharedInstance
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if #available(iOS 10.0, *) {
scrollView.refreshControl = refreshControl
} else {
scrollView.addSubview(refreshControl)
}
refreshControl.addTarget(self, action: #selector(objDoAsync(_:)), for: .valueChanged)
refreshControl.tintColor = #colorLiteral(red: 0.07843137255, green: 0.5568627451, blue: 1, alpha: 1)
refreshControl.attributedTitle = NSAttributedString(string: NSLocalizedString("fetch_info", comment: ""))
self.scrollView.isDirectionalLockEnabled = true
content.text = df.readInformation()
}
override func viewDidLoad() {
super.viewDidLoad()
self.extendedLayoutIncludesOpaqueBars = true
self.navigationController?.navigationBar.topItem?.title = NSLocalizedString("information", comment: "")
let layer = contentView.layer
df.setCardFormatting(for: layer)
}
@objc private func objDoAsync(_ sender: Any) {
self.df.doAsync(do: "info") { infoArray in
self.content.text = infoArray[0] as? String
self.refreshControl.endRefreshing()
self.df.setTabBarBadge(for: self.tabBarController?.tabBar.items)
}
}
}
+8 -1
View File
@@ -9,7 +9,7 @@
import UIKit
import MagazineLayout
class MenuViewController : UICollectionViewController, UICollectionViewDelegateMagazineLayout {
class MenuViewController : UICollectionViewController, UICollectionViewDelegateMagazineLayout, UITabBarControllerDelegate {
var items = [String]()
private let refreshControl = UIRefreshControl()
@@ -47,6 +47,7 @@ class MenuViewController : UICollectionViewController, UICollectionViewDelegateM
refreshControl.addTarget(self, action: #selector(objDoAsync(_:)), for: .valueChanged)
refreshControl.tintColor = #colorLiteral(red: 0.07843137255, green: 0.5568627451, blue: 1, alpha: 1)
refreshControl.attributedTitle = NSAttributedString(string: NSLocalizedString("fetch_menu", comment: ""))
self.tabBarController?.delegate = self
self.items = self.df.readMenu()
self.collectionView.reloadData()
@@ -68,6 +69,12 @@ class MenuViewController : UICollectionViewController, UICollectionViewDelegateM
}
}
func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
if let alert = self.df.presentInformationAlert(for: tabBarController, at: 3) {
self.present(alert, animated: true, completion: nil)
}
}
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return self.items.count
}
@@ -40,4 +40,7 @@ class PersonalPlanViewController: PlanViewController {
return df.getPersonalFromDatabase()
}
override func getIndex() -> Int {
return 1
}
}
+12 -1
View File
@@ -11,7 +11,7 @@ import MagazineLayout
import Crashlytics
import Firebase
class PlanViewController : UICollectionViewController, UICollectionViewDelegateMagazineLayout {
class PlanViewController : UICollectionViewController, UICollectionViewDelegateMagazineLayout, UITabBarControllerDelegate {
let identifier = "plan_cell"
var substs = [SubstModel]()
@@ -57,6 +57,7 @@ class PlanViewController : UICollectionViewController, UICollectionViewDelegateM
refreshControl.addTarget(self, action: #selector(objDoAsync(_:)), for: .valueChanged)
refreshControl.tintColor = #colorLiteral(red: 0.07843137255, green: 0.5568627451, blue: 1, alpha: 1)
refreshControl.attributedTitle = NSAttributedString(string: getRefreshViewString())
self.tabBarController?.delegate = self
self.substs = getFromDatabase()
self.collectionView.reloadData()
@@ -81,6 +82,10 @@ class PlanViewController : UICollectionViewController, UICollectionViewDelegateM
return NSLocalizedString("fetch_plan", comment: "")
}
func getIndex() -> Int {
return 0
}
@objc private func objDoAsync(_ sender: Any) {
self.df.doAsync(do: self.getViewType()) { substitutions in
self.substs = substitutions as! [SubstModel]
@@ -90,6 +95,12 @@ class PlanViewController : UICollectionViewController, UICollectionViewDelegateM
}
}
func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
if let alert = self.df.presentInformationAlert(for: tabBarController, at: self.getIndex()) {
self.present(alert, animated: true, completion: nil)
}
}
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return self.substs.count
}
+1
View File
@@ -75,3 +75,4 @@
"last_updated" = "Zuletzt aktualisiert: ";
"back" = "Zurück";
"your_plan" = "Dein Plan";
"dismiss" = "Schließen";
+1
View File
@@ -76,3 +76,4 @@
"last_updated" = "Last updated: ";
"back" = "Back";
"your_plan" = "Your Plan";
"dismiss" = "Dismiss";