aboutsummaryrefslogtreecommitdiff
path: root/foray
diff options
context:
space:
mode:
Diffstat (limited to 'foray')
-rw-r--r--foray/Base.lproj/Main.storyboard51
-rw-r--r--foray/ForayDetailViewController.swift28
-rw-r--r--foray/ForayNewDetailView.swift85
3 files changed, 94 insertions, 70 deletions
diff --git a/foray/Base.lproj/Main.storyboard b/foray/Base.lproj/Main.storyboard
index a655965..6e8fa72 100644
--- a/foray/Base.lproj/Main.storyboard
+++ b/foray/Base.lproj/Main.storyboard
@@ -3,8 +3,6 @@
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
- <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>
@@ -48,49 +46,7 @@
<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" numberOfLines="6" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="odL-rc-3m5">
- <rect key="frame" x="16" y="410" width="382" height="20.5"/>
- <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>
@@ -99,7 +55,7 @@
<!--Foray-->
<scene sceneID="Yrg-KY-tVC">
<objects>
- <navigationController title="Foray" automaticallyAdjustsScrollViewInsets="NO" id="c0a-IT-Aiw" sceneMemberID="viewController">
+ <navigationController title="Foray" extendedLayoutIncludesOpaqueBars="YES" 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"/>
@@ -115,9 +71,4 @@
<point key="canvasLocation" x="-462.31884057971018" y="51.5625"/>
</scene>
</scenes>
- <resources>
- <systemColor name="systemBackgroundColor">
- <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
- </systemColor>
- </resources>
</document>
diff --git a/foray/ForayDetailViewController.swift b/foray/ForayDetailViewController.swift
index eb5b577..bac2dfd 100644
--- a/foray/ForayDetailViewController.swift
+++ b/foray/ForayDetailViewController.swift
@@ -10,31 +10,19 @@ import UIKit
class ForayDetailViewController: UIViewController {
var selectedItem: PenguinItem!
-
- @IBOutlet weak var titleLabel: UILabel!
- @IBOutlet weak var imageView: UIImageView!
- @IBOutlet weak var detailLabel: UILabel!
+
+ let detailView: ForayNewDetailView = ForayNewDetailView(frame: CGRect.zero)
override func viewDidLoad() {
super.viewDidLoad()
-
- titleLabel.text = selectedItem.name
- imageView.image = UIImage(named: selectedItem.id)
- detailLabel.text = "Type: "
- switch selectedItem.type {
- case .item:
- detailLabel.text! += "Item"
- case .quest:
- detailLabel.text! += "Quest"
- imageView.image = UIImage(named: "spy")
- }
-
- detailLabel.text! += "\nID: " + selectedItem.id
+ self.view.backgroundColor = .systemBackground
- let dateFormatter = DateFormatter()
- dateFormatter.dateFormat = "yyyy-MM-dd"
- detailLabel.text! += "\nReleased: " + dateFormatter.string(from: selectedItem.releaseDate)
+ detailView.setSelectedItem(selectedItem: selectedItem)
+ self.view.addSubview(detailView)
+ detailView.snp.makeConstraints { (make) in
+ make.edges.equalTo(self.view.snp.margins)
+ }
}
}
diff --git a/foray/ForayNewDetailView.swift b/foray/ForayNewDetailView.swift
new file mode 100644
index 0000000..e7d7dbf
--- /dev/null
+++ b/foray/ForayNewDetailView.swift
@@ -0,0 +1,85 @@
+//
+// ForayNewDetailView.swift
+// foray
+//
+// Created by Nicholas Tay on 18/3/2022.
+//
+
+import UIKit
+
+class ForayNewDetailView: UIView {
+
+ let nameLabel: UILabel = {
+ let l = UILabel()
+ l.font = UIFont.preferredFont(forTextStyle: .largeTitle)
+ l.adjustsFontForContentSizeCategory = true
+ l.numberOfLines = 3
+ l.textAlignment = .center
+ return l
+ }()
+
+ let itemImageView: UIImageView = {
+ let iv = UIImageView()
+ iv.contentMode = .scaleAspectFit
+ return iv
+ }()
+
+ let descLabel: UILabel = {
+ let l = UILabel()
+ l.font = UIFont.preferredFont(forTextStyle: .body)
+ l.adjustsFontForContentSizeCategory = true
+ return l
+ }()
+
+ override init(frame: CGRect) {
+ super.init(frame: frame)
+ initialiseViews()
+ }
+
+ required init?(coder: NSCoder) {
+ fatalError("unreachable")
+ }
+
+ private func initialiseViews() {
+ addSubview(nameLabel)
+ addSubview(itemImageView)
+ addSubview(descLabel)
+ setupConstraints()
+ }
+
+ private func setupConstraints() {
+ nameLabel.snp.makeConstraints { (make) in
+ make.top.equalToSuperview().inset(8)
+ make.leading.trailing.equalToSuperview().inset(8)
+ }
+ itemImageView.snp.makeConstraints { (make) in
+ make.top.equalTo(nameLabel.snp.bottom).offset(8)
+ make.leading.trailing.equalToSuperview()
+ make.height.equalTo(150)
+ }
+ descLabel.snp.makeConstraints { (make) in
+ make.top.equalTo(itemImageView.snp.bottom).offset(8)
+ make.leading.trailing.equalToSuperview()
+ }
+ }
+
+ public func setSelectedItem(selectedItem: PenguinItem) {
+ nameLabel.text = selectedItem.name
+ itemImageView.image = UIImage(named: selectedItem.id)
+
+ descLabel.text = "Type: "
+ switch selectedItem.type {
+ case .item:
+ descLabel.text! += "Item"
+ case .quest:
+ descLabel.text! += "Quest"
+ itemImageView.image = UIImage(named: "spy")
+ }
+
+ descLabel.text! += "\nID: " + selectedItem.id
+
+ let dateFormatter = DateFormatter()
+ dateFormatter.dateFormat = "yyyy-MM-dd"
+ descLabel.text! += "\nReleased: " + dateFormatter.string(from: selectedItem.releaseDate)
+ }
+}