aboutsummaryrefslogtreecommitdiff
path: root/foray/ForayTableViewController.swift
diff options
context:
space:
mode:
Diffstat (limited to 'foray/ForayTableViewController.swift')
-rw-r--r--foray/ForayTableViewController.swift59
1 files changed, 59 insertions, 0 deletions
diff --git a/foray/ForayTableViewController.swift b/foray/ForayTableViewController.swift
new file mode 100644
index 0000000..66e9274
--- /dev/null
+++ b/foray/ForayTableViewController.swift
@@ -0,0 +1,59 @@
+//
+// ForayTableViewController.swift
+// foray
+//
+// Created by Nicholas Tay on 14/3/2022.
+//
+
+import UIKit
+
+struct MyItem {
+ var id: String
+ var name: String
+}
+
+class ForayTableViewCell: UITableViewCell {
+ @IBOutlet weak var cellItemName: UILabel!
+ @IBOutlet weak var cellItemSubtitle: UILabel!
+ @IBOutlet weak var cellItemImage: UIImageView!
+}
+
+class ForayTableViewController: UITableViewController {
+
+ // MARK: - Static data TEMP
+
+ let items = [
+ MyItem(id: "mh", name: "Miners Helmet"),
+ MyItem(id: "it", name: "Inner Tube"),
+ MyItem(id: "tbg", name: "Toboggan"),
+ MyItem(id: "spy", name: "Spy Phone"),
+ MyItem(id: "bnb", name: "Black Ninja Belt"),
+ ]
+
+ // MARK: - Table view data source
+
+ override func numberOfSections(in tableView: UITableView) -> Int {
+ // Returns number of sections for table
+ return 1
+ }
+
+ override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+ // Returns number of rows for table
+ return items.count
+ }
+
+ override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+ let cell = tableView.dequeueReusableCell(withIdentifier: "ForayCell", for: indexPath) as! ForayTableViewCell
+
+ let item = items[indexPath.row]
+ cell.cellItemName?.text = item.name
+ cell.cellItemSubtitle?.text = "Item ID: \(item.id)"
+ cell.cellItemImage?.image = UIImage(named: item.id)
+
+ return cell
+ }
+
+ override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
+ return "Section \(section)"
+ }
+}