aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Tay <nick@windblume.net>2022-03-16 10:15:27 +1100
committerNicholas Tay <nick@windblume.net>2022-03-16 10:15:27 +1100
commit5fbe87e25c1136e29494d181edbdbf6d6dbba6e1 (patch)
tree1a8f2f735b586db536ed68e57a3995cc35b629be
parentaa5c132c3bccaf4103c74b95393cd80db79f92f1 (diff)
downloadforayios-5fbe87e25c1136e29494d181edbdbf6d6dbba6e1.tar.gz
forayios-5fbe87e25c1136e29494d181edbdbf6d6dbba6e1.tar.bz2
forayios-5fbe87e25c1136e29494d181edbdbf6d6dbba6e1.zip
Add a detail view
Resources: - https://guides.codepath.com/ios/Using-UITableView (was a bit dated)
Diffstat (limited to '')
-rw-r--r--foray.xcodeproj/project.pbxproj4
-rw-r--r--foray/Base.lproj/Main.storyboard84
-rw-r--r--foray/ForayDetailViewController.swift33
-rw-r--r--foray/ForayTableViewController.swift10
4 files changed, 129 insertions, 2 deletions
diff --git a/foray.xcodeproj/project.pbxproj b/foray.xcodeproj/project.pbxproj
index 6df1a30..42e2a75 100644
--- a/foray.xcodeproj/project.pbxproj
+++ b/foray.xcodeproj/project.pbxproj
@@ -13,6 +13,7 @@
C04B45AD27DEF118001451A3 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C04B45AC27DEF118001451A3 /* Assets.xcassets */; };
C04B45B027DEF118001451A3 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C04B45AE27DEF118001451A3 /* LaunchScreen.storyboard */; };
C04B45B827DEF2ED001451A3 /* ForayTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04B45B727DEF2ED001451A3 /* ForayTableViewController.swift */; };
+ C0FEAF5F27E14C52000A7648 /* ForayDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0FEAF5E27E14C52000A7648 /* ForayDetailViewController.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -24,6 +25,7 @@
C04B45AF27DEF118001451A3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
C04B45B127DEF118001451A3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
C04B45B727DEF2ED001451A3 /* ForayTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForayTableViewController.swift; sourceTree = "<group>"; };
+ C0FEAF5E27E14C52000A7648 /* ForayDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForayDetailViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -59,6 +61,7 @@
C04B45A327DEF117001451A3 /* AppDelegate.swift */,
C04B45A527DEF117001451A3 /* SceneDelegate.swift */,
C04B45A927DEF117001451A3 /* Main.storyboard */,
+ C0FEAF5E27E14C52000A7648 /* ForayDetailViewController.swift */,
C04B45B727DEF2ED001451A3 /* ForayTableViewController.swift */,
C04B45AC27DEF118001451A3 /* Assets.xcassets */,
C04B45AE27DEF118001451A3 /* LaunchScreen.storyboard */,
@@ -139,6 +142,7 @@
buildActionMask = 2147483647;
files = (
C04B45B827DEF2ED001451A3 /* ForayTableViewController.swift in Sources */,
+ C0FEAF5F27E14C52000A7648 /* ForayDetailViewController.swift in Sources */,
C04B45A427DEF117001451A3 /* AppDelegate.swift in Sources */,
C04B45A627DEF117001451A3 /* SceneDelegate.swift in Sources */,
);
diff --git a/foray/Base.lproj/Main.storyboard b/foray/Base.lproj/Main.storyboard
index c5181ad..1212265 100644
--- a/foray/Base.lproj/Main.storyboard
+++ b/foray/Base.lproj/Main.storyboard
@@ -1,13 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="wzT-eD-ghF">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="c0a-IT-Aiw">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
+ <capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
- <!--Foray Table View Controller-->
+ <!--Foray-->
<scene sceneID="YPJ-bK-iaL">
<objects>
<tableViewController id="wzT-eD-ghF" customClass="ForayTableViewController" customModule="foray" customModuleProvider="target" sceneMemberID="viewController">
@@ -56,6 +57,7 @@
<outlet property="cellItemImage" destination="z5f-A4-Dya" id="NTq-uY-NQQ"/>
<outlet property="cellItemName" destination="jKN-aM-nKf" id="G3W-mL-GPh"/>
<outlet property="cellItemSubtitle" destination="M3N-lx-IrZ" id="cXh-X9-bBs"/>
+ <segue destination="8GL-ME-btj" kind="show" id="jtV-rb-2Wu"/>
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="ForayQuestCell" id="sac-28-Cry" customClass="ForayTableViewCell" customModule="foray" customModuleProvider="target">
@@ -109,6 +111,7 @@
<outlet property="cellItemImage" destination="ZpN-1x-wiY" id="ydK-D6-Kii"/>
<outlet property="cellItemName" destination="Nba-Kh-67y" id="lOq-hq-b38"/>
<outlet property="cellItemSubtitle" destination="n6u-bY-nfG" id="sJh-Cy-jKm"/>
+ <segue destination="8GL-ME-btj" kind="show" id="dWq-Z4-mZP"/>
</connections>
</tableViewCell>
</prototypes>
@@ -118,14 +121,91 @@
<outlet property="delegate" destination="wzT-eD-ghF" id="Pqi-RZ-Q7p"/>
</connections>
</tableView>
+ <navigationItem key="navigationItem" title="Foray" id="UHk-DR-0EX"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="pPD-Wc-Rc9" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
+ <point key="canvasLocation" x="447.82608695652175" y="51.5625"/>
+ </scene>
+ <!--Details-->
+ <scene sceneID="bHL-Pf-Ers">
+ <objects>
+ <viewController id="8GL-ME-btj" customClass="ForayDetailViewController" customModule="foray" customModuleProvider="target" sceneMemberID="viewController">
+ <view key="view" contentMode="scaleToFill" id="xcn-ik-xzR">
+ <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ <subviews>
+ <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="aBf-Zs-Jkz">
+ <rect key="frame" x="0.0" y="178" width="414" height="200"/>
+ <constraints>
+ <constraint firstAttribute="height" constant="200" id="hSS-D1-lO9"/>
+ </constraints>
+ </imageView>
+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="aP2-hq-U5p">
+ <rect key="frame" x="16" y="104" width="382" height="42"/>
+ <fontDescription key="fontDescription" type="boldSystem" pointSize="35"/>
+ <nil key="textColor"/>
+ <nil key="highlightedColor"/>
+ </label>
+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="odL-rc-3m5">
+ <rect key="frame" x="16" y="410" width="382" height="21"/>
+ <fontDescription key="fontDescription" type="system" pointSize="17"/>
+ <nil key="textColor"/>
+ <nil key="highlightedColor"/>
+ </label>
+ </subviews>
+ <viewLayoutGuide key="safeArea" id="w1j-x8-sDP"/>
+ <color key="backgroundColor" systemColor="systemBackgroundColor"/>
+ <constraints>
+ <constraint firstItem="w1j-x8-sDP" firstAttribute="trailing" secondItem="odL-rc-3m5" secondAttribute="trailing" constant="16" id="2fw-Ji-Nhl"/>
+ <constraint firstItem="aBf-Zs-Jkz" firstAttribute="top" secondItem="aP2-hq-U5p" secondAttribute="bottom" constant="32" id="2gC-T0-uyU"/>
+ <constraint firstItem="odL-rc-3m5" firstAttribute="leading" secondItem="w1j-x8-sDP" secondAttribute="leading" constant="16" id="4GW-Aj-ulz"/>
+ <constraint firstItem="odL-rc-3m5" firstAttribute="top" secondItem="aBf-Zs-Jkz" secondAttribute="bottom" constant="32" id="C26-Lc-Ghw"/>
+ <constraint firstItem="aBf-Zs-Jkz" firstAttribute="trailing" secondItem="w1j-x8-sDP" secondAttribute="trailing" id="CYY-Ga-lIM"/>
+ <constraint firstItem="aBf-Zs-Jkz" firstAttribute="leading" secondItem="w1j-x8-sDP" secondAttribute="leading" id="Pat-F1-1hL"/>
+ <constraint firstItem="aP2-hq-U5p" firstAttribute="leading" secondItem="w1j-x8-sDP" secondAttribute="leading" constant="16" id="YsS-R7-Ov5"/>
+ <constraint firstItem="w1j-x8-sDP" firstAttribute="trailing" secondItem="aP2-hq-U5p" secondAttribute="trailing" constant="16" id="i7K-yP-UW1"/>
+ <constraint firstItem="aP2-hq-U5p" firstAttribute="top" secondItem="w1j-x8-sDP" secondAttribute="top" constant="16" id="lT8-FD-Axc"/>
+ </constraints>
+ </view>
+ <navigationItem key="navigationItem" title="Details" id="bIX-Sf-Bkw"/>
+ <connections>
+ <outlet property="detailLabel" destination="odL-rc-3m5" id="07Y-K3-w9b"/>
+ <outlet property="imageView" destination="aBf-Zs-Jkz" id="qiy-cQ-1sV"/>
+ <outlet property="titleLabel" destination="aP2-hq-U5p" id="6r0-Xo-1WF"/>
+ </connections>
+ </viewController>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="MQj-7U-nIV" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
+ </objects>
+ <point key="canvasLocation" x="1155.072463768116" y="51.5625"/>
+ </scene>
+ <!--Foray-->
+ <scene sceneID="Yrg-KY-tVC">
+ <objects>
+ <navigationController title="Foray" automaticallyAdjustsScrollViewInsets="NO" id="c0a-IT-Aiw" sceneMemberID="viewController">
+ <toolbarItems/>
+ <navigationBar key="navigationBar" contentMode="scaleToFill" id="YMv-Mh-Wv2">
+ <rect key="frame" x="0.0" y="44" width="414" height="44"/>
+ <autoresizingMask key="autoresizingMask"/>
+ </navigationBar>
+ <nil name="viewControllers"/>
+ <connections>
+ <segue destination="wzT-eD-ghF" kind="relationship" relationship="rootViewController" id="N4z-jp-m3v"/>
+ </connections>
+ </navigationController>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="iF1-cp-txh" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
+ </objects>
<point key="canvasLocation" x="-462.31884057971018" y="51.5625"/>
</scene>
</scenes>
+ <inferredMetricsTieBreakers>
+ <segue reference="dWq-Z4-mZP"/>
+ </inferredMetricsTieBreakers>
<resources>
<image name="spy" width="700" height="490"/>
+ <systemColor name="systemBackgroundColor">
+ <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+ </systemColor>
<systemColor name="systemOrangeColor">
<color red="1" green="0.58431372549019611" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
diff --git a/foray/ForayDetailViewController.swift b/foray/ForayDetailViewController.swift
new file mode 100644
index 0000000..2e5cceb
--- /dev/null
+++ b/foray/ForayDetailViewController.swift
@@ -0,0 +1,33 @@
+//
+// ForayDetailViewController.swift
+// foray
+//
+// Created by Nicholas Tay on 16/3/2022.
+//
+
+import UIKit
+
+class ForayDetailViewController: UIViewController {
+
+ var selectedItem: MyItem!
+
+ @IBOutlet weak var titleLabel: UILabel!
+ @IBOutlet weak var imageView: UIImageView!
+ @IBOutlet weak var detailLabel: UILabel!
+
+ override func viewDidLoad() {
+ super.viewDidLoad()
+
+ titleLabel.text = selectedItem.name
+ imageView.image = UIImage(named: selectedItem.id)
+ switch selectedItem.type {
+ case .item:
+ detailLabel.text = "Item"
+ case .quest:
+ detailLabel.text = "Quest"
+ imageView.image = UIImage(named: "spy")
+ }
+ detailLabel.text! += " ID: " + selectedItem.id
+ }
+
+}
diff --git a/foray/ForayTableViewController.swift b/foray/ForayTableViewController.swift
index a5c367a..fd4854e 100644
--- a/foray/ForayTableViewController.swift
+++ b/foray/ForayTableViewController.swift
@@ -142,4 +142,14 @@ class ForayTableViewController: UITableViewController {
dateFormatter.dateFormat = "yyyy"
return "Released in " + dateFormatter.string(from: section.year)
}
+
+ // MARK: - Navigation
+
+ override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
+ let indexPath = tableView.indexPathForSelectedRow!
+ let item = self.sections[indexPath.section].items[indexPath.row]
+
+ let dvc = segue.destination as! ForayDetailViewController
+ dvc.selectedItem = item
+ }
}