-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
139 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// | ||
// EventsTableViewController.swift | ||
// GeofenceTester | ||
// | ||
// Created by Alexander von Below on 27.06.22. | ||
// | ||
|
||
import UIKit | ||
|
||
class EventsTableViewController: UITableViewController { | ||
|
||
var storage: PersistantStorage<EventRecord>! | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
self.title = "Events" | ||
// Uncomment the following line to preserve selection between presentations | ||
// self.clearsSelectionOnViewWillAppear = false | ||
|
||
// Uncomment the following line to display an Edit button in the navigation bar for this view controller. | ||
// self.navigationItem.rightBarButtonItem = self.editButtonItem | ||
self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "Event Cell") | ||
} | ||
|
||
@IBAction func share() { | ||
let text = storage.storage.reduce("") { partialResult, event in | ||
partialResult + event.debugDescription + "\n" | ||
} | ||
let activityController = UIActivityViewController(activityItems: [text], applicationActivities: nil) | ||
self.present(activityController, animated: true) | ||
} | ||
|
||
// MARK: - Table view data source | ||
|
||
override func numberOfSections(in tableView: UITableView) -> Int { | ||
return 1 | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
return storage.storage.count | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
let cell = tableView.dequeueReusableCell(withIdentifier: "Event Cell", for: indexPath) | ||
|
||
var config = cell.defaultContentConfiguration() | ||
let event = storage.storage[indexPath.row] | ||
config.text = event.debugDescription | ||
cell.contentConfiguration = config | ||
return cell | ||
} | ||
|
||
/* | ||
// Override to support conditional editing of the table view. | ||
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { | ||
// Return false if you do not want the specified item to be editable. | ||
return true | ||
} | ||
*/ | ||
|
||
/* | ||
// Override to support editing the table view. | ||
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) { | ||
if editingStyle == .delete { | ||
// Delete the row from the data source | ||
tableView.deleteRows(at: [indexPath], with: .fade) | ||
} else if editingStyle == .insert { | ||
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view | ||
} | ||
} | ||
*/ | ||
|
||
|
||
/* | ||
// MARK: - Navigation | ||
|
||
// In a storyboard-based application, you will often want to do a little preparation before navigation | ||
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { | ||
// Get the new view controller using segue.destination. | ||
// Pass the selected object to the new view controller. | ||
} | ||
*/ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters