Archived
Implemented functions for fetching and storing general information and the food menu, including UI for the food menu, TODO: resizing cells for the plan and food menu
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
1BF3A6CA97BA41C38482C1A6 /* Pods_AvH_PlanTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D9D6269E96544A9242A29611 /* Pods_AvH_PlanTests.framework */; };
|
1BF3A6CA97BA41C38482C1A6 /* Pods_AvH_PlanTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D9D6269E96544A9242A29611 /* Pods_AvH_PlanTests.framework */; };
|
||||||
2E65263AFD35D6B542E89AE4 /* Pods_AvH_Plan.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7605BB0678C9E27A1D3E9DAA /* Pods_AvH_Plan.framework */; };
|
2E65263AFD35D6B542E89AE4 /* Pods_AvH_Plan.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7605BB0678C9E27A1D3E9DAA /* Pods_AvH_Plan.framework */; };
|
||||||
A949F26322D7938700D4BFFD /* db.sqlite3 in Resources */ = {isa = PBXBuildFile; fileRef = A949F26222D7938700D4BFFD /* db.sqlite3 */; };
|
A9128EDD22D88E8E006976C8 /* MenuViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9128EDC22D88E8E006976C8 /* MenuViewCell.swift */; };
|
||||||
A96133802299867400B541D4 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A961337F2299867400B541D4 /* AppDelegate.swift */; };
|
A96133802299867400B541D4 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A961337F2299867400B541D4 /* AppDelegate.swift */; };
|
||||||
A96133822299867400B541D4 /* PlanViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A96133812299867400B541D4 /* PlanViewController.swift */; };
|
A96133822299867400B541D4 /* PlanViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A96133812299867400B541D4 /* PlanViewController.swift */; };
|
||||||
A96133842299867400B541D4 /* PersonalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A96133832299867400B541D4 /* PersonalViewController.swift */; };
|
A96133842299867400B541D4 /* PersonalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A96133832299867400B541D4 /* PersonalViewController.swift */; };
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
589FBD2CE6A9C73CD9B81441 /* Pods-AvH PlanUITests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AvH PlanUITests.release.xcconfig"; path = "Target Support Files/Pods-AvH PlanUITests/Pods-AvH PlanUITests.release.xcconfig"; sourceTree = "<group>"; };
|
589FBD2CE6A9C73CD9B81441 /* Pods-AvH PlanUITests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AvH PlanUITests.release.xcconfig"; path = "Target Support Files/Pods-AvH PlanUITests/Pods-AvH PlanUITests.release.xcconfig"; sourceTree = "<group>"; };
|
||||||
74EDE3D8134812AB76BEB988 /* Pods_AvH_PlanUITests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AvH_PlanUITests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
74EDE3D8134812AB76BEB988 /* Pods_AvH_PlanUITests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AvH_PlanUITests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
7605BB0678C9E27A1D3E9DAA /* Pods_AvH_Plan.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AvH_Plan.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
7605BB0678C9E27A1D3E9DAA /* Pods_AvH_Plan.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AvH_Plan.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
A949F26222D7938700D4BFFD /* db.sqlite3 */ = {isa = PBXFileReference; lastKnownFileType = text; path = db.sqlite3; sourceTree = "<group>"; };
|
A9128EDC22D88E8E006976C8 /* MenuViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuViewCell.swift; sourceTree = "<group>"; };
|
||||||
A961337C2299867400B541D4 /* AvH Plan.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "AvH Plan.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
A961337C2299867400B541D4 /* AvH Plan.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "AvH Plan.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
A961337F2299867400B541D4 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
A961337F2299867400B541D4 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||||
A96133812299867400B541D4 /* PlanViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlanViewController.swift; sourceTree = "<group>"; };
|
A96133812299867400B541D4 /* PlanViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlanViewController.swift; sourceTree = "<group>"; };
|
||||||
@@ -162,8 +162,8 @@
|
|||||||
A961338D2299867A00B541D4 /* Info.plist */,
|
A961338D2299867A00B541D4 /* Info.plist */,
|
||||||
A96133AF229986DF00B541D4 /* CollectionViewCell.swift */,
|
A96133AF229986DF00B541D4 /* CollectionViewCell.swift */,
|
||||||
A9A3496B22D4859200F35AE0 /* SubstModel.swift */,
|
A9A3496B22D4859200F35AE0 /* SubstModel.swift */,
|
||||||
|
A9128EDC22D88E8E006976C8 /* MenuViewCell.swift */,
|
||||||
A9C1D30122D7237200139043 /* DataFetcher.swift */,
|
A9C1D30122D7237200139043 /* DataFetcher.swift */,
|
||||||
A949F26222D7938700D4BFFD /* db.sqlite3 */,
|
|
||||||
);
|
);
|
||||||
path = "AvH Plan";
|
path = "AvH Plan";
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -297,7 +297,6 @@
|
|||||||
A961338C2299867A00B541D4 /* LaunchScreen.storyboard in Resources */,
|
A961338C2299867A00B541D4 /* LaunchScreen.storyboard in Resources */,
|
||||||
A96133892299867A00B541D4 /* Assets.xcassets in Resources */,
|
A96133892299867A00B541D4 /* Assets.xcassets in Resources */,
|
||||||
A96133872299867400B541D4 /* Main.storyboard in Resources */,
|
A96133872299867400B541D4 /* Main.storyboard in Resources */,
|
||||||
A949F26322D7938700D4BFFD /* db.sqlite3 in Resources */,
|
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@@ -424,6 +423,7 @@
|
|||||||
A9A3496C22D4859200F35AE0 /* SubstModel.swift in Sources */,
|
A9A3496C22D4859200F35AE0 /* SubstModel.swift in Sources */,
|
||||||
A9C1D30022D656DD00139043 /* MenuViewController.swift in Sources */,
|
A9C1D30022D656DD00139043 /* MenuViewController.swift in Sources */,
|
||||||
A96133B0229986DF00B541D4 /* CollectionViewCell.swift in Sources */,
|
A96133B0229986DF00B541D4 /* CollectionViewCell.swift in Sources */,
|
||||||
|
A9128EDD22D88E8E006976C8 /* MenuViewCell.swift in Sources */,
|
||||||
A9C1D2FE22D656A400139043 /* InfoViewController.swift in Sources */,
|
A9C1D2FE22D656A400139043 /* InfoViewController.swift in Sources */,
|
||||||
A96133822299867400B541D4 /* PlanViewController.swift in Sources */,
|
A96133822299867400B541D4 /* PlanViewController.swift in Sources */,
|
||||||
A9C1D30222D7237200139043 /* DataFetcher.swift in Sources */,
|
A9C1D30222D7237200139043 /* DataFetcher.swift in Sources */,
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -166,34 +166,144 @@
|
|||||||
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
|
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Loaded by SecondViewController" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="NDk-cv-Gan">
|
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="o8P-y4-8Is">
|
||||||
<rect key="frame" x="99.666666666666686" y="477.66666666666669" width="215" height="17"/>
|
<rect key="frame" x="0.0" y="88" width="414" height="725"/>
|
||||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="1" minimumInteritemSpacing="1" id="A6C-To-dsF">
|
||||||
|
<size key="itemSize" width="380" height="140"/>
|
||||||
|
<size key="headerReferenceSize" width="0.0" height="0.0"/>
|
||||||
|
<size key="footerReferenceSize" width="0.0" height="0.0"/>
|
||||||
|
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
|
||||||
|
</collectionViewFlowLayout>
|
||||||
|
<cells>
|
||||||
|
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" layoutMarginsFollowReadableWidth="YES" reuseIdentifier="cell" id="wDJ-H7-UTw" customClass="CollectionViewCell" customModule="AvH_Plan" customModuleProvider="target">
|
||||||
|
<rect key="frame" x="17" y="0.0" width="380" height="100"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="380" height="100"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<subviews>
|
||||||
|
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="QWo-jL-Zoa">
|
||||||
|
<rect key="frame" x="12" y="4" width="356" height="92"/>
|
||||||
|
<subviews>
|
||||||
|
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="8wB-59-rKw">
|
||||||
|
<rect key="frame" x="12" y="12" width="332" height="68"/>
|
||||||
|
<subviews>
|
||||||
|
<stackView opaque="NO" contentMode="scaleToFill" ambiguous="YES" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="Tyb-ku-8cY">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="332" height="20.333333333333332"/>
|
||||||
|
<subviews>
|
||||||
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="UpH-FU-des">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="282.33333333333331" height="20.333333333333332"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
<nil key="highlightedColor"/>
|
<nil key="highlightedColor"/>
|
||||||
</label>
|
</label>
|
||||||
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" misplaced="YES" text="Second View" textAlignment="center" lineBreakMode="tailTruncation" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="zEq-FU-wV5">
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Label" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="FOx-L6-Vkf">
|
||||||
<rect key="frame" x="-33" y="417" width="201.5" height="43"/>
|
<rect key="frame" x="290.33333333333331" y="0.0" width="41.666666666666686" height="20.333333333333332"/>
|
||||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
<fontDescription key="fontDescription" type="system" pointSize="36"/>
|
<nil key="textColor"/>
|
||||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
|
||||||
<nil key="highlightedColor"/>
|
<nil key="highlightedColor"/>
|
||||||
</label>
|
</label>
|
||||||
</subviews>
|
</subviews>
|
||||||
|
</stackView>
|
||||||
|
<stackView opaque="NO" contentMode="scaleToFill" ambiguous="YES" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="eZN-T6-u2T">
|
||||||
|
<rect key="frame" x="0.0" y="28.333333333333336" width="332" height="20.333333333333336"/>
|
||||||
|
<subviews>
|
||||||
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="I2T-ff-7vX">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="41.666666666666664" height="20.333333333333332"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Label" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="X2M-gp-JGL">
|
||||||
|
<rect key="frame" x="49.666666666666657" y="0.0" width="282.33333333333337" height="20.333333333333332"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
</subviews>
|
||||||
|
</stackView>
|
||||||
|
<stackView opaque="NO" contentMode="scaleToFill" ambiguous="YES" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="Xl9-k6-4bf">
|
||||||
|
<rect key="frame" x="0.0" y="56.666666666666671" width="332" height="11.333333333333329"/>
|
||||||
|
<subviews>
|
||||||
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="0Xd-5X-OCi">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="41.666666666666664" height="11.333333333333334"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" text="Label" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="n2h-fH-OLe">
|
||||||
|
<rect key="frame" x="49.666666666666657" y="0.0" width="282.33333333333337" height="11.333333333333334"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
</subviews>
|
||||||
|
</stackView>
|
||||||
|
</subviews>
|
||||||
|
</stackView>
|
||||||
|
</subviews>
|
||||||
|
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstAttribute="trailing" secondItem="8wB-59-rKw" secondAttribute="trailing" constant="12" id="5VU-QX-iX7"/>
|
||||||
|
<constraint firstAttribute="bottom" secondItem="8wB-59-rKw" secondAttribute="bottom" constant="12" id="TgW-Ta-0fg"/>
|
||||||
|
<constraint firstItem="8wB-59-rKw" firstAttribute="top" secondItem="QWo-jL-Zoa" secondAttribute="top" constant="12" id="fLq-Vs-f3Q"/>
|
||||||
|
<constraint firstItem="8wB-59-rKw" firstAttribute="leading" secondItem="QWo-jL-Zoa" secondAttribute="leading" constant="12" id="vSL-dI-fN1"/>
|
||||||
|
</constraints>
|
||||||
|
</view>
|
||||||
|
</subviews>
|
||||||
|
</view>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstAttribute="bottom" secondItem="QWo-jL-Zoa" secondAttribute="bottom" constant="4" id="VeP-p7-VHS"/>
|
||||||
|
<constraint firstItem="QWo-jL-Zoa" firstAttribute="leading" secondItem="wDJ-H7-UTw" secondAttribute="leading" constant="12" id="Y66-G9-D7i"/>
|
||||||
|
<constraint firstAttribute="trailing" secondItem="QWo-jL-Zoa" secondAttribute="trailing" constant="12" id="cXg-tE-HH3"/>
|
||||||
|
<constraint firstItem="QWo-jL-Zoa" firstAttribute="top" secondItem="wDJ-H7-UTw" secondAttribute="top" constant="4" id="lGD-Ud-2wl"/>
|
||||||
|
</constraints>
|
||||||
|
<size key="customSize" width="380" height="100"/>
|
||||||
|
<connections>
|
||||||
|
<outlet property="additional" destination="0Xd-5X-OCi" id="zwQ-2f-uTT"/>
|
||||||
|
<outlet property="course" destination="I2T-ff-7vX" id="Ta3-Ju-3al"/>
|
||||||
|
<outlet property="date" destination="FOx-L6-Vkf" id="OYE-zY-5a0"/>
|
||||||
|
<outlet property="group" destination="UpH-FU-des" id="8Lz-X2-zbv"/>
|
||||||
|
<outlet property="room" destination="n2h-fH-OLe" id="ntU-iT-AHV"/>
|
||||||
|
<outlet property="time" destination="X2M-gp-JGL" id="F6J-Fe-WhS"/>
|
||||||
|
<outlet property="tintView" destination="QWo-jL-Zoa" id="gp0-x8-Cuu"/>
|
||||||
|
</connections>
|
||||||
|
</collectionViewCell>
|
||||||
|
</cells>
|
||||||
|
<connections>
|
||||||
|
<outlet property="dataSource" destination="8rJ-Kc-sve" id="uZJ-WZ-kcW"/>
|
||||||
|
<outlet property="delegate" destination="8rJ-Kc-sve" id="R8H-qW-bbB"/>
|
||||||
|
</connections>
|
||||||
|
</collectionView>
|
||||||
|
<navigationBar contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" translatesAutoresizingMaskIntoConstraints="NO" id="zYA-MY-Azp">
|
||||||
|
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
|
||||||
|
<viewLayoutGuide key="safeArea" id="Or0-Ph-ylC"/>
|
||||||
|
<items>
|
||||||
|
<navigationItem title="Personal Plan" id="8j4-CR-EDO"/>
|
||||||
|
</items>
|
||||||
|
</navigationBar>
|
||||||
|
</subviews>
|
||||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint firstItem="NDk-cv-Gan" firstAttribute="top" secondItem="zEq-FU-wV5" secondAttribute="bottom" constant="8" symbolic="YES" id="Day-4N-Vmt"/>
|
<constraint firstItem="o8P-y4-8Is" firstAttribute="leading" secondItem="O1u-W8-tvY" secondAttribute="leading" id="6CV-3q-qko"/>
|
||||||
<constraint firstItem="NDk-cv-Gan" firstAttribute="centerX" secondItem="zEq-FU-wV5" secondAttribute="centerX" id="JgO-Fn-dHn"/>
|
<constraint firstItem="zYA-MY-Azp" firstAttribute="trailing" secondItem="O1u-W8-tvY" secondAttribute="trailing" id="AhQ-VX-SQ8"/>
|
||||||
<constraint firstAttribute="centerX" secondItem="zEq-FU-wV5" secondAttribute="centerX" id="qqM-NS-xev"/>
|
<constraint firstItem="O1u-W8-tvY" firstAttribute="bottom" secondItem="o8P-y4-8Is" secondAttribute="bottom" id="Cnb-HM-WIg"/>
|
||||||
<constraint firstAttribute="centerY" secondItem="zEq-FU-wV5" secondAttribute="centerY" id="qzY-Ky-pLD"/>
|
<constraint firstItem="o8P-y4-8Is" firstAttribute="trailing" secondItem="O1u-W8-tvY" secondAttribute="trailing" id="PQh-Z4-g23"/>
|
||||||
|
<constraint firstItem="o8P-y4-8Is" firstAttribute="top" secondItem="zYA-MY-Azp" secondAttribute="bottom" id="Z88-qD-HMv"/>
|
||||||
|
<constraint firstItem="zYA-MY-Azp" firstAttribute="top" secondItem="O1u-W8-tvY" secondAttribute="top" id="h9U-jR-HuZ"/>
|
||||||
|
<constraint firstItem="zYA-MY-Azp" firstAttribute="leading" secondItem="O1u-W8-tvY" secondAttribute="leading" id="odb-l1-x2e"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<viewLayoutGuide key="safeArea" id="O1u-W8-tvY"/>
|
<viewLayoutGuide key="safeArea" id="O1u-W8-tvY"/>
|
||||||
</view>
|
</view>
|
||||||
<tabBarItem key="tabBarItem" title="Personal" image="ic_idea" selectedImage="ic_idea" id="cPa-gy-q4n"/>
|
<tabBarItem key="tabBarItem" title="Personal" image="ic_idea" selectedImage="ic_idea" id="cPa-gy-q4n"/>
|
||||||
|
<connections>
|
||||||
|
<outlet property="collectionView" destination="o8P-y4-8Is" id="1GW-Wu-fUg"/>
|
||||||
|
</connections>
|
||||||
</viewController>
|
</viewController>
|
||||||
<placeholder placeholderIdentifier="IBFirstResponder" id="4Nw-L8-lE0" sceneMemberID="firstResponder"/>
|
<placeholder placeholderIdentifier="IBFirstResponder" id="4Nw-L8-lE0" sceneMemberID="firstResponder"/>
|
||||||
</objects>
|
</objects>
|
||||||
<point key="canvasLocation" x="1491" y="-321"/>
|
<point key="canvasLocation" x="1489.8550724637682" y="-321.42857142857139"/>
|
||||||
</scene>
|
</scene>
|
||||||
<!--Information-->
|
<!--Information-->
|
||||||
<scene sceneID="tt5-VM-aeV">
|
<scene sceneID="tt5-VM-aeV">
|
||||||
@@ -202,7 +312,21 @@
|
|||||||
<view key="view" contentMode="scaleToFill" id="eFO-Bf-72I">
|
<view key="view" contentMode="scaleToFill" id="eFO-Bf-72I">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
|
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<navigationBar contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" translatesAutoresizingMaskIntoConstraints="NO" id="n9O-m5-UQM">
|
||||||
|
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
|
||||||
|
<viewLayoutGuide key="safeArea" id="YA8-Ln-bdM"/>
|
||||||
|
<items>
|
||||||
|
<navigationItem title="Information" id="9lv-eD-jS6"/>
|
||||||
|
</items>
|
||||||
|
</navigationBar>
|
||||||
|
</subviews>
|
||||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstItem="n9O-m5-UQM" firstAttribute="leading" secondItem="eFO-Bf-72I" secondAttribute="leading" id="1Wa-Qr-Bhb"/>
|
||||||
|
<constraint firstItem="fuI-1W-d0u" firstAttribute="trailing" secondItem="n9O-m5-UQM" secondAttribute="trailing" id="Itb-7h-ird"/>
|
||||||
|
<constraint firstItem="n9O-m5-UQM" firstAttribute="top" secondItem="fuI-1W-d0u" secondAttribute="top" id="ccZ-hZ-aNP"/>
|
||||||
|
</constraints>
|
||||||
<viewLayoutGuide key="safeArea" id="fuI-1W-d0u"/>
|
<viewLayoutGuide key="safeArea" id="fuI-1W-d0u"/>
|
||||||
</view>
|
</view>
|
||||||
<tabBarItem key="tabBarItem" title="Information" image="ic_information" selectedImage="ic_information" id="BQ7-VO-yI4"/>
|
<tabBarItem key="tabBarItem" title="Information" image="ic_information" selectedImage="ic_information" id="BQ7-VO-yI4"/>
|
||||||
@@ -218,14 +342,77 @@
|
|||||||
<view key="view" contentMode="scaleToFill" id="nOs-f2-7qu">
|
<view key="view" contentMode="scaleToFill" id="nOs-f2-7qu">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
|
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<navigationBar contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" translatesAutoresizingMaskIntoConstraints="NO" id="R10-r1-giF">
|
||||||
|
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
|
||||||
|
<viewLayoutGuide key="safeArea" id="zEW-od-JDN"/>
|
||||||
|
<items>
|
||||||
|
<navigationItem title="Food Menu" id="mFX-6q-tAs"/>
|
||||||
|
</items>
|
||||||
|
</navigationBar>
|
||||||
|
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="GXo-AH-UZe">
|
||||||
|
<rect key="frame" x="0.0" y="88" width="414" height="725"/>
|
||||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
|
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="1" minimumInteritemSpacing="1" id="7xu-lu-j4n">
|
||||||
|
<size key="itemSize" width="380" height="140"/>
|
||||||
|
<size key="headerReferenceSize" width="0.0" height="0.0"/>
|
||||||
|
<size key="footerReferenceSize" width="0.0" height="0.0"/>
|
||||||
|
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
|
||||||
|
</collectionViewFlowLayout>
|
||||||
|
<cells>
|
||||||
|
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" layoutMarginsFollowReadableWidth="YES" reuseIdentifier="cell" id="GNK-S9-s6Y" customClass="MenuViewCell" customModule="AvH_Plan" customModuleProvider="target">
|
||||||
|
<rect key="frame" x="17" y="0.0" width="380" height="100"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="380" height="100"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<subviews>
|
||||||
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="FiL-oG-5NS">
|
||||||
|
<rect key="frame" x="24" y="4" width="332" height="92"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||||
|
<nil key="textColor"/>
|
||||||
|
<nil key="highlightedColor"/>
|
||||||
|
</label>
|
||||||
|
</subviews>
|
||||||
|
</view>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstAttribute="bottom" secondItem="FiL-oG-5NS" secondAttribute="bottom" constant="4" id="Luj-VM-NXr"/>
|
||||||
|
<constraint firstAttribute="trailing" secondItem="FiL-oG-5NS" secondAttribute="trailing" constant="24" id="MRl-Fb-lcN"/>
|
||||||
|
<constraint firstItem="FiL-oG-5NS" firstAttribute="top" secondItem="GNK-S9-s6Y" secondAttribute="top" constant="4" id="tSv-yf-nyx"/>
|
||||||
|
<constraint firstItem="FiL-oG-5NS" firstAttribute="leading" secondItem="GNK-S9-s6Y" secondAttribute="leading" constant="24" id="uoj-TR-t8r"/>
|
||||||
|
</constraints>
|
||||||
|
<size key="customSize" width="380" height="100"/>
|
||||||
|
<connections>
|
||||||
|
<outlet property="content" destination="FiL-oG-5NS" id="9CZ-mR-oqN"/>
|
||||||
|
</connections>
|
||||||
|
</collectionViewCell>
|
||||||
|
</cells>
|
||||||
|
<connections>
|
||||||
|
<outlet property="dataSource" destination="bBH-of-tdd" id="hWU-Ox-LbT"/>
|
||||||
|
<outlet property="delegate" destination="bBH-of-tdd" id="Goe-Im-LUU"/>
|
||||||
|
</connections>
|
||||||
|
</collectionView>
|
||||||
|
</subviews>
|
||||||
|
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
|
<constraints>
|
||||||
|
<constraint firstItem="2XG-5F-awv" firstAttribute="trailing" secondItem="R10-r1-giF" secondAttribute="trailing" id="2ph-BT-xaa"/>
|
||||||
|
<constraint firstItem="GXo-AH-UZe" firstAttribute="top" secondItem="R10-r1-giF" secondAttribute="bottom" id="LJZ-CD-zAQ"/>
|
||||||
|
<constraint firstItem="R10-r1-giF" firstAttribute="top" secondItem="2XG-5F-awv" secondAttribute="top" id="MXM-m5-w5i"/>
|
||||||
|
<constraint firstItem="GXo-AH-UZe" firstAttribute="leading" secondItem="nOs-f2-7qu" secondAttribute="leading" id="MZD-gw-lhn"/>
|
||||||
|
<constraint firstItem="2XG-5F-awv" firstAttribute="trailing" secondItem="GXo-AH-UZe" secondAttribute="trailing" id="gFX-sE-QMR"/>
|
||||||
|
<constraint firstItem="R10-r1-giF" firstAttribute="leading" secondItem="nOs-f2-7qu" secondAttribute="leading" id="hI9-lC-axL"/>
|
||||||
|
<constraint firstItem="2XG-5F-awv" firstAttribute="bottom" secondItem="GXo-AH-UZe" secondAttribute="bottom" id="zs4-d5-ZjJ"/>
|
||||||
|
</constraints>
|
||||||
<viewLayoutGuide key="safeArea" id="2XG-5F-awv"/>
|
<viewLayoutGuide key="safeArea" id="2XG-5F-awv"/>
|
||||||
</view>
|
</view>
|
||||||
<tabBarItem key="tabBarItem" title="Menu" image="ic_tomato" selectedImage="ic_tomato" id="IfX-2p-YWq"/>
|
<tabBarItem key="tabBarItem" title="Menu" image="ic_tomato" selectedImage="ic_tomato" id="IfX-2p-YWq"/>
|
||||||
|
<connections>
|
||||||
|
<outlet property="collectionView" destination="GXo-AH-UZe" id="S49-xr-MOj"/>
|
||||||
|
</connections>
|
||||||
</viewController>
|
</viewController>
|
||||||
<placeholder placeholderIdentifier="IBFirstResponder" id="8Cd-nN-1G8" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
<placeholder placeholderIdentifier="IBFirstResponder" id="8Cd-nN-1G8" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
</objects>
|
</objects>
|
||||||
<point key="canvasLocation" x="1486" y="347"/>
|
<point key="canvasLocation" x="1485.5072463768117" y="346.875"/>
|
||||||
</scene>
|
</scene>
|
||||||
<!--AvH Plan-->
|
<!--AvH Plan-->
|
||||||
<scene sceneID="yl2-sM-qoP">
|
<scene sceneID="yl2-sM-qoP">
|
||||||
|
|||||||
+171
-8
@@ -7,15 +7,19 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
import Foundation
|
||||||
import Alamofire
|
import Alamofire
|
||||||
import SwiftSoup
|
import SwiftSoup
|
||||||
import SQLite
|
import SQLite
|
||||||
|
|
||||||
class DataFetcher {
|
class DataFetcher {
|
||||||
|
|
||||||
let path = Bundle.main.path(forResource: "db", ofType: "sqlite3")
|
let path = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first!
|
||||||
|
|
||||||
let substitutions = Table("substitutions")
|
let substitutions = Table("substitutions")
|
||||||
|
let personal = Table("personal")
|
||||||
|
let information = Table("information")
|
||||||
|
let foodmenu = Table("foodmenu")
|
||||||
let id = Expression<Int64>("id")
|
let id = Expression<Int64>("id")
|
||||||
let group = Expression<String>("group")
|
let group = Expression<String>("group")
|
||||||
let course = Expression<String>("course")
|
let course = Expression<String>("course")
|
||||||
@@ -23,28 +27,46 @@ class DataFetcher {
|
|||||||
let date = Expression<String>("date")
|
let date = Expression<String>("date")
|
||||||
let time = Expression<String>("time")
|
let time = Expression<String>("time")
|
||||||
let room = Expression<String>("room")
|
let room = Expression<String>("room")
|
||||||
|
let text = Expression<String>("text")
|
||||||
|
|
||||||
func doAsync(completionHandler: @escaping (_ substitutions: Array<SubstModel>) -> ()) {
|
func doAsync(do task: String, completionHandler: @escaping (_ substitutions: Array<Any>) -> ()) {
|
||||||
DispatchQueue(label: "work-queue").async {
|
DispatchQueue(label: "work-queue").async {
|
||||||
let url = "https://djd4rkn355.github.io/subst_test.html"
|
var url = ""
|
||||||
|
switch task {
|
||||||
|
case "menu": url = "https://djd4rkn355.github.io/food_test.html"
|
||||||
|
default: url = "https://djd4rkn355.github.io/subst_test.html"
|
||||||
|
}
|
||||||
Alamofire.request(url).responseString { response in
|
Alamofire.request(url).responseString { response in
|
||||||
if let html = response.result.value {
|
if let html = response.result.value {
|
||||||
completionHandler(self.parseHTML(html: html))
|
switch task {
|
||||||
|
case "plan": completionHandler(self.parseHTML(html: html, isPersonal: false))
|
||||||
|
case "personal": completionHandler(self.parseHTML(html: html, isPersonal: true))
|
||||||
|
case "info": completionHandler(self.parseInformation(html: html))
|
||||||
|
default: completionHandler(self.parseMenu(html: html))
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseHTML(html: String) -> Array<SubstModel> {
|
func parseHTML(html: String, isPersonal: Bool) -> Array<SubstModel> {
|
||||||
var subst = Array<SubstModel>()
|
var subst = Array<SubstModel>()
|
||||||
|
var personalSubst = Array<SubstModel>()
|
||||||
do {
|
do {
|
||||||
let doc: Document = try SwiftSoup.parse(html)
|
let doc: Document = try SwiftSoup.parse(html)
|
||||||
let rows: Elements = try doc.select("tr")
|
let rows: Elements = try doc.select("tr")
|
||||||
|
|
||||||
let db = try Connection(path!)
|
// let prefs = UserDefaults.standard
|
||||||
|
// let courses = prefs.string(forKey: "courses")
|
||||||
|
// let classes = prefs.string(forKey: "classes")
|
||||||
|
let courses: String? = "GES7"
|
||||||
|
let classes: String? = "17"
|
||||||
|
|
||||||
try db.run(substitutions.create { t in
|
let db = try Connection("\(path)/db.sqlite3")
|
||||||
|
|
||||||
|
try db.run(substitutions.create(ifNotExists: true) { t in
|
||||||
t.column(id, primaryKey: true)
|
t.column(id, primaryKey: true)
|
||||||
t.column(group)
|
t.column(group)
|
||||||
t.column(course)
|
t.column(course)
|
||||||
@@ -54,6 +76,19 @@ class DataFetcher {
|
|||||||
t.column(room)
|
t.column(room)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
try db.run(personal.create(ifNotExists: true) { t in
|
||||||
|
t.column(id, primaryKey: true)
|
||||||
|
t.column(group)
|
||||||
|
t.column(course)
|
||||||
|
t.column(additional)
|
||||||
|
t.column(date)
|
||||||
|
t.column(time)
|
||||||
|
t.column(room)
|
||||||
|
})
|
||||||
|
|
||||||
|
try db.run(substitutions.delete())
|
||||||
|
try db.run(personal.delete())
|
||||||
|
|
||||||
for i in (0..<rows.size()) {
|
for i in (0..<rows.size()) {
|
||||||
let row = rows.get(i)
|
let row = rows.get(i)
|
||||||
let cols = try row.select("th")
|
let cols = try row.select("th")
|
||||||
@@ -70,6 +105,33 @@ class DataFetcher {
|
|||||||
let insert = substitutions.insert(group <- mGroup, course <- mCourse, additional <- mAdditional,
|
let insert = substitutions.insert(group <- mGroup, course <- mCourse, additional <- mAdditional,
|
||||||
date <- mDate, time <- mTime, room <- mRoom)
|
date <- mDate, time <- mTime, room <- mRoom)
|
||||||
_ = try db.run(insert)
|
_ = try db.run(insert)
|
||||||
|
|
||||||
|
if courses == nil || courses == "", classes != nil && classes != "" {
|
||||||
|
if !mGroup.isEmpty && mGroup != "" {
|
||||||
|
if classes!.contains(mGroup) || mGroup.contains(classes!) {
|
||||||
|
personalSubst.append(SubstModel(group: mGroup, course: mCourse, additional: mAdditional,
|
||||||
|
date: mDate, time: mTime, room: mRoom))
|
||||||
|
let insertPersonal = personal.insert(group <- mGroup, course <- mCourse, additional <- mAdditional,
|
||||||
|
date <- mDate, time <- mTime, room <- mRoom)
|
||||||
|
_ = try db.run(insertPersonal)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if courses != nil && courses != "" && classes != nil && classes != "" {
|
||||||
|
if mGroup != "" && mCourse != "" {
|
||||||
|
if courses!.contains(mCourse) {
|
||||||
|
if classes!.contains(mGroup) || mGroup.contains(classes!) {
|
||||||
|
personalSubst.append(SubstModel(group: mGroup, course: mCourse, additional: mAdditional,
|
||||||
|
date: mDate, time: mTime, room: mRoom))
|
||||||
|
let insertPersonal = personal.insert(group <- mGroup, course <- mCourse, additional <- mAdditional,
|
||||||
|
date <- mDate, time <- mTime, room <- mRoom)
|
||||||
|
_ = try db.run(insertPersonal)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch Exception.Error(let type, let message) {
|
} catch Exception.Error(let type, let message) {
|
||||||
@@ -78,13 +140,17 @@ class DataFetcher {
|
|||||||
} catch {
|
} catch {
|
||||||
print("error")
|
print("error")
|
||||||
}
|
}
|
||||||
|
if isPersonal {
|
||||||
|
return personalSubst
|
||||||
|
} else {
|
||||||
return subst
|
return subst
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func getFromDatabase() -> [SubstModel] {
|
func getFromDatabase() -> [SubstModel] {
|
||||||
var substs = [SubstModel]()
|
var substs = [SubstModel]()
|
||||||
do {
|
do {
|
||||||
let db = try Connection(path!)
|
let db = try Connection("\(path)/db.sqlite3")
|
||||||
for subst in try db.prepare(substitutions) {
|
for subst in try db.prepare(substitutions) {
|
||||||
substs.append(SubstModel(group: subst[group], course: subst[course], additional: subst[additional], date: subst[date], time: subst[time], room: subst[room]))
|
substs.append(SubstModel(group: subst[group], course: subst[course], additional: subst[additional], date: subst[date], time: subst[time], room: subst[room]))
|
||||||
}
|
}
|
||||||
@@ -92,6 +158,103 @@ class DataFetcher {
|
|||||||
return substs
|
return substs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getPersonalFromDatabase() -> [SubstModel] {
|
||||||
|
var substs = [SubstModel]()
|
||||||
|
do {
|
||||||
|
let db = try Connection("\(path)/db.sqlite3")
|
||||||
|
for subst in try db.prepare(personal) {
|
||||||
|
substs.append(SubstModel(group: subst[group], course: subst[course], additional: subst[additional], date: subst[date], time: subst[time], room: subst[room]))
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
return substs
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseInformation(html: String) -> [String] {
|
||||||
|
var list = [String]()
|
||||||
|
do {
|
||||||
|
let doc: Document = try SwiftSoup.parse(html)
|
||||||
|
let p: Elements = try doc.select("p")
|
||||||
|
|
||||||
|
let db = try Connection("\(path)/db.sqlite3")
|
||||||
|
|
||||||
|
try db.run(information.create(ifNotExists: true) { t in
|
||||||
|
t.column(id, primaryKey: true)
|
||||||
|
t.column(text)
|
||||||
|
})
|
||||||
|
|
||||||
|
try db.run(information.delete())
|
||||||
|
|
||||||
|
for item in p {
|
||||||
|
|
||||||
|
let t = try item.text()
|
||||||
|
|
||||||
|
list.append(t)
|
||||||
|
|
||||||
|
let insert = information.insert(text <- t)
|
||||||
|
_ = try db.run(insert)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch Exception.Error(let type, let message) {
|
||||||
|
print(type)
|
||||||
|
print(message)
|
||||||
|
} catch {
|
||||||
|
print("error")
|
||||||
|
}
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
|
||||||
|
func readInformation() -> [String] {
|
||||||
|
var list = [String]()
|
||||||
|
do {
|
||||||
|
let db = try Connection("\(path)/db.sqlite3")
|
||||||
|
for item in try db.prepare(information) {
|
||||||
|
list.append(item[text])
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseMenu(html: String) -> [String] {
|
||||||
|
|
||||||
|
var items = [String]()
|
||||||
|
do {
|
||||||
|
let doc: Document = try SwiftSoup.parse(html)
|
||||||
|
let e: Elements = try doc.select("th")
|
||||||
|
|
||||||
|
let db = try Connection("\(path)/db.sqlite3")
|
||||||
|
|
||||||
|
try db.run(foodmenu.create(ifNotExists: true) { t in
|
||||||
|
t.column(id, primaryKey: true)
|
||||||
|
t.column(text)
|
||||||
|
})
|
||||||
|
|
||||||
|
try db.run(foodmenu.delete())
|
||||||
|
|
||||||
|
for i in 0..<e.size() {
|
||||||
|
items.append(try e.get(i).text())
|
||||||
|
let insert = foodmenu.insert(text <- try e.get(i).text())
|
||||||
|
_ = try db.run(insert)
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch {}
|
||||||
|
|
||||||
|
return items
|
||||||
|
}
|
||||||
|
|
||||||
|
func readMenu() -> [String] {
|
||||||
|
var menu = [String]()
|
||||||
|
do {
|
||||||
|
let db = try Connection("\(path)/db.sqlite3")
|
||||||
|
for item in try db.prepare(foodmenu) {
|
||||||
|
menu.append(item[text])
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
return menu
|
||||||
|
}
|
||||||
|
|
||||||
func getImage(from icon: String) -> UIImage? {
|
func getImage(from icon: String) -> UIImage? {
|
||||||
var imagePath = ""
|
var imagePath = ""
|
||||||
let i = icon.lowercased()
|
let i = icon.lowercased()
|
||||||
|
|||||||
@@ -2,12 +2,68 @@
|
|||||||
// MenuViewController.swift
|
// MenuViewController.swift
|
||||||
// AvH Plan
|
// AvH Plan
|
||||||
//
|
//
|
||||||
// Created by Deniz Duezgoeren on 10.07.19.
|
// Created by Deniz Duezgoeren on 11.07.19.
|
||||||
// Copyright © 2019 Deniz Duezgoeren. All rights reserved.
|
// Copyright © 2019 Deniz Duezgoeren. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
class MenuViewController : UIViewController {
|
class MenuViewController : UIViewController, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
|
||||||
|
|
||||||
|
let reuseIdentifier = "cell"
|
||||||
|
@IBOutlet weak var collectionView: UICollectionView!
|
||||||
|
var items = [String]()
|
||||||
|
private let refreshControl = UIRefreshControl()
|
||||||
|
let df = DataFetcher()
|
||||||
|
|
||||||
|
override func viewWillAppear(_ animated: Bool) {
|
||||||
|
super.viewWillAppear(animated)
|
||||||
|
if #available(iOS 10.0, *) {
|
||||||
|
collectionView.refreshControl = refreshControl
|
||||||
|
} else {
|
||||||
|
collectionView.addSubview(refreshControl)
|
||||||
|
}
|
||||||
|
refreshControl.addTarget(self, action: #selector(objDoAsync(_:)), for: .valueChanged)
|
||||||
|
refreshControl.tintColor = UIColor(red: 0.39, green: 0.71, blue: 0.96, alpha: 1.0)
|
||||||
|
refreshControl.attributedTitle = NSAttributedString(string: "Fetching the food menu...")
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func objDoAsync(_ sender: Any) {
|
||||||
|
df.doAsync(do: "menu") { menuItems in
|
||||||
|
self.items = menuItems as! [String]
|
||||||
|
self.collectionView.reloadData()
|
||||||
|
self.refreshControl.endRefreshing()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
collectionView.backgroundColor = UIColor(red: 0.8, green: 0.8, blue: 0.8, alpha: 1.0)
|
||||||
|
|
||||||
|
self.items = self.df.readMenu()
|
||||||
|
self.collectionView.reloadData()
|
||||||
|
}
|
||||||
|
|
||||||
|
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
||||||
|
return self.items.count
|
||||||
|
}
|
||||||
|
|
||||||
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
||||||
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath as IndexPath) as! MenuViewCell
|
||||||
|
if self.items.count != 0 {
|
||||||
|
cell.content.text = self.items[indexPath.item]
|
||||||
|
}
|
||||||
|
|
||||||
|
cell.backgroundColor = UIColor(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)!")
|
||||||
|
}
|
||||||
|
|
||||||
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
||||||
|
return CGSize(width: view.frame.size.width, height: 64)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,91 @@
|
|||||||
//
|
//
|
||||||
// SecondViewController.swift
|
// PersonalViewController.swift
|
||||||
// AvH Plan
|
// AvH Plan
|
||||||
//
|
//
|
||||||
// Created by Deniz Duezgoeren on 25.05.19.
|
// Created by Deniz Duezgoeren on 11.07.19.
|
||||||
// Copyright © 2019 Deniz Duezgoeren. All rights reserved.
|
// Copyright © 2019 Deniz Duezgoeren. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
class PersonalViewController: UIViewController {
|
class PersonalViewController : UIViewController, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
|
||||||
|
|
||||||
|
let reuseIdentifier = "cell"
|
||||||
|
@IBOutlet weak var collectionView: UICollectionView!
|
||||||
|
var substs = Array<SubstModel>()
|
||||||
|
private let refreshControl = UIRefreshControl()
|
||||||
|
let df = DataFetcher()
|
||||||
|
|
||||||
|
override func viewWillAppear(_ animated: Bool) {
|
||||||
|
super.viewWillAppear(animated)
|
||||||
|
if #available(iOS 10.0, *) {
|
||||||
|
collectionView.refreshControl = refreshControl
|
||||||
|
} else {
|
||||||
|
collectionView.addSubview(refreshControl)
|
||||||
|
}
|
||||||
|
refreshControl.addTarget(self, action: #selector(objDoAsync(_:)), for: .valueChanged)
|
||||||
|
refreshControl.tintColor = UIColor(red: 0.39, green: 0.71, blue: 0.96, alpha: 1.0)
|
||||||
|
refreshControl.attributedTitle = NSAttributedString(string: "Fetching your plan...")
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func objDoAsync(_ sender: Any) {
|
||||||
|
df.doAsync(do: "personal") { substitutions in
|
||||||
|
self.substs = substitutions as! [SubstModel]
|
||||||
|
self.collectionView.reloadData()
|
||||||
|
self.refreshControl.endRefreshing()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
// Do any additional setup after loading the view.
|
collectionView.backgroundColor = UIColor(red: 0.8, green: 0.8, blue: 0.8, alpha: 1.0)
|
||||||
|
|
||||||
|
self.substs = self.df.getPersonalFromDatabase()
|
||||||
|
self.collectionView.reloadData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
||||||
|
return self.substs.count
|
||||||
|
}
|
||||||
|
|
||||||
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
||||||
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath as IndexPath) as! CollectionViewCell
|
||||||
|
if self.substs.count != 0 {
|
||||||
|
cell.group.text = self.substs[indexPath.item].group
|
||||||
|
cell.additional.text = self.substs[indexPath.item].additional
|
||||||
|
cell.date.text = self.substs[indexPath.item].date
|
||||||
|
cell.time.text = self.substs[indexPath.item].time
|
||||||
|
cell.room.text = self.substs[indexPath.item].room
|
||||||
|
|
||||||
|
let course = self.substs[indexPath.item].course
|
||||||
|
let image = df.getImage(from: course)
|
||||||
|
|
||||||
|
if image != nil {
|
||||||
|
let attachment: NSTextAttachment = NSTextAttachment()
|
||||||
|
attachment.bounds = CGRect(x: 0, y: 0, width: cell.course.frame.height - 6, height: cell.course.frame.height - 6)
|
||||||
|
attachment.image = image
|
||||||
|
|
||||||
|
let courseImage = NSMutableAttributedString(attachment: attachment)
|
||||||
|
let courseString = NSAttributedString(string: " " + course)
|
||||||
|
courseImage.append(courseString)
|
||||||
|
|
||||||
|
cell.course.attributedText = courseImage
|
||||||
|
} else {
|
||||||
|
cell.course.text = course
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cell.backgroundColor = UIColor(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)
|
||||||
|
cell.tintView.backgroundColor = cell.backgroundColor
|
||||||
|
return cell
|
||||||
|
}
|
||||||
|
|
||||||
|
// func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||||
|
// print("You selected cell#\(indexPath.item)!")
|
||||||
|
// }
|
||||||
|
|
||||||
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
||||||
|
return CGSize(width: view.frame.size.width, height: 108)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ class PlanViewController : UIViewController, UICollectionViewDataSource, UIColle
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc private func objDoAsync(_ sender: Any) {
|
@objc private func objDoAsync(_ sender: Any) {
|
||||||
df.doAsync() { substitutions in
|
df.doAsync(do: "plan") { substitutions in
|
||||||
self.substs = substitutions
|
self.substs = substitutions as! [SubstModel]
|
||||||
self.collectionView.reloadData()
|
self.collectionView.reloadData()
|
||||||
self.refreshControl.endRefreshing()
|
self.refreshControl.endRefreshing()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user