Skip to content

Commit

Permalink
Finished accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
hardyrz committed Jul 5, 2017
1 parent 09cadc0 commit 291cd3d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
30 changes: 29 additions & 1 deletion iExpense/AccountsViewController.swift
Original file line number Diff line number Diff line change
@@ -1,17 +1,45 @@
import UIKit
import RealmSwift

class AccountsViewController: UIViewController {
class AccountsViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {

@IBOutlet weak var tableView: UITableView!
var accountsTable : Results<AccountDTO>?
var realm : Realm!

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.

self.realm = try! Realm()
self.accountsTable = self.realm.objects(AccountDTO.self)
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

override func viewWillAppear(_ animated: Bool) {
self.accountsTable = realm.objects(AccountDTO.self)
tableView.reloadData()
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
//if let table = self.expensesTable {
// return table.count
//}
return (self.accountsTable?.count)!
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "accountCell", for: indexPath) as! AccountCell

cell.accountLabel.text = self.accountsTable?[indexPath.row].name
cell.accountImage.image = UIImage(named: "food_icon") //accountsTable[indexPath.row].image

return cell
}

}

15 changes: 11 additions & 4 deletions iExpense/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@
<rect key="frame" x="16" y="44" width="343" height="574"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="GtT-TN-w7d" customClass="AccountCell" customModule="iExpense" customModuleProvider="target">
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="accountCell" id="GtT-TN-w7d" customClass="AccountCell" customModule="iExpense" customModuleProvider="target">
<rect key="frame" x="0.0" y="28" width="343" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="GtT-TN-w7d" id="Wbz-Rl-QIu">
<rect key="frame" x="0.0" y="0.0" width="343" height="43"/>
<rect key="frame" x="0.0" y="0.0" width="343" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="3Uw-VT-0eY">
Expand Down Expand Up @@ -93,6 +93,10 @@
</connections>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="ypM-7p-kKR" id="a1p-9f-Yeo"/>
<outlet property="delegate" destination="ypM-7p-kKR" id="xgH-ib-5Pn"/>
</connections>
</tableView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
Expand All @@ -107,6 +111,9 @@
</constraints>
</view>
<tabBarItem key="tabBarItem" title="Accounts" id="XE5-hS-198"/>
<connections>
<outlet property="tableView" destination="P0e-H8-xJG" id="zSS-Cv-1Mh"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="rff-kS-n5P" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
Expand Down Expand Up @@ -420,7 +427,7 @@
<rect key="frame" x="0.0" y="28" width="343" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="03s-69-ame" id="1Kh-OB-WqB">
<rect key="frame" x="0.0" y="0.0" width="343" height="43"/>
<rect key="frame" x="0.0" y="0.0" width="343" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Zfv-UP-PM5">
Expand Down Expand Up @@ -520,7 +527,7 @@
<rect key="frame" x="0.0" y="28" width="343" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="r2l-Gv-OJt" id="cPU-DV-k8s">
<rect key="frame" x="0.0" y="0.0" width="343" height="43"/>
<rect key="frame" x="0.0" y="0.0" width="343" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="MhT-y3-sbo">
Expand Down
3 changes: 0 additions & 3 deletions iExpense/NewAccountViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class NewAccountViewController: UIViewController {
var realm : Realm!



override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
Expand All @@ -31,8 +30,6 @@ class NewAccountViewController: UIViewController {
}
}



@IBAction func cancelAction(_ sender: Any) {
self.dismiss(animated: true, completion: nil)
}
Expand Down
1 change: 0 additions & 1 deletion iExpense/NewCategoryViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class NewCategoryViewController: UIViewController {
var realm : Realm!



override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
Expand Down

0 comments on commit 291cd3d

Please sign in to comment.