Commit 94fc4dc6 authored by tybrandt's avatar tybrandt
Browse files

Delete functionality implemented

parent b337c3a7
......@@ -147,14 +147,14 @@
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="allTransactions" id="e68-D8-BFK" customClass="TransactionTableViewCell" customModule="Budget_Tracker" customModuleProvider="target">
<rect key="frame" x="0.0" y="28" width="414" height="44"/>
<rect key="frame" x="0.0" y="28" width="414" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="e68-D8-BFK" id="Q12-f8-IYE">
<rect key="frame" x="0.0" y="0.0" width="414" height="44"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ZQh-dN-pAc">
<rect key="frame" x="20" y="11" width="42" height="21.5"/>
<rect key="frame" x="20" y="11" width="42" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
......@@ -221,11 +221,16 @@
<barButtonItem key="rightBarButtonItem" title="Confirm" id="foO-CN-S4s">
<connections>
<action selector="confirm:" destination="2i0-KG-j1T" id="Ubw-cj-tI6"/>
<segue destination="b7c-FZ-HVQ" kind="unwind" unwindAction="deleteDataWithSender:" id="FNS-Z8-p7X"/>
</connections>
</barButtonItem>
</navigationItem>
<connections>
<outlet property="confirmButton" destination="foO-CN-S4s" id="7pi-si-SMG"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="qmn-NT-Tu8" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
<exit id="b7c-FZ-HVQ" userLabel="Exit" sceneMemberID="exit"/>
</objects>
<point key="canvasLocation" x="2811.594202898551" y="906.69642857142856"/>
</scene>
......
......@@ -51,6 +51,17 @@ class CategoryViewController: UIViewController, UITableViewDelegate, UITableView
}
}
@IBAction func deleteData(sender: UIStoryboardSegue) {
if let sourceView = sender.source as? DeletionViewController {
if sourceView.confirmed {
categories = [Category]()
}
saveCategories()
categoryTable.reloadData()
totalLabel.text = "Total: $0.00"
}
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
super.prepare(for: segue, sender: sender)
switch (segue.identifier ?? "") {
......
......@@ -8,13 +8,17 @@
import UIKit
class DeletionViewController: UIViewController {
var confirmed = false
@IBOutlet weak var confirmButton: UIBarButtonItem!
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func confirm(_ sender: UIBarButtonItem) {
dismiss(animated: true, completion: nil)
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
super.prepare(for: segue, sender: sender)
guard let button = sender as? UIBarButtonItem, button === confirmButton else {return}
confirmed = true
}
@IBAction func cancel(_ sender: UIBarButtonItem) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment