Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,6 @@ DEPENDENCIES
motion-cocoapods
nano-store
rake

BUNDLED WITH
1.10.4
2 changes: 1 addition & 1 deletion app/app_delegate.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
documents_path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true)[0]
NanoStore.shared_store = NanoStore.store(:file, documents_path + "/nano.db")
NanoStore.shared_store = NanoStore.store(:file, documents_path + "/nano1.db")

@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)

Expand Down
1 change: 1 addition & 0 deletions app/controllers/list_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class ListController < UIViewController
def viewDidLoad
super
self.title = "Todo"
self.view.backgroundColor = UIColor.whiteColor
list_view = ListView.alloc.initWithFrame(self.view.frame)
self.view.addSubview(list_view)
Expand Down
29 changes: 23 additions & 6 deletions app/views/list_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ def add_task
end

def add_task_list
table_view = UITableView.alloc.initWithFrame(CGRectMake(0, 70, self.frame.size.width, 200))
table_view = UITableView.alloc.initWithFrame([[0, 70], [self.bounds.size.width, self.bounds.size.height - 70]], style: UITableViewStyleGrouped)
table_view.dataSource = self
table_view.delegate = self
table_view.clipsToBounds = false
table_view.clipsToBounds = true
self.task_list = table_view
self.addSubview table_view
end
Expand All @@ -81,16 +81,22 @@ def tableView(tableView, cellForRowAtIndexPath: indexPath)

@reuseIdentifier ||= "cell"
cell = tableView.dequeueReusableCellWithIdentifier(@reuseIdentifier)
cell ||= UITableViewCell.alloc.initWithStyle(UITableViewCellStyleDefault, reuseIdentifier: @reuseIdentifier)
cell ||= UITableViewCell.alloc.initWithStyle(UITableViewCellStyleSubtitle, reuseIdentifier: @reuseIdentifier)

if indexPath.section == 0
cell.textLabel.text = "#{self.uncompleted_tasks[indexPath.row].name}"
cell.detailTextLabel.text = format_time self.uncompleted_tasks[indexPath.row].created_at
elsif indexPath.section == 1
cell.textLabel.text = "#{self.completed_tasks[indexPath.row].name}"
cell.detailTextLabel.text = format_time self.completed_tasks[indexPath.row].created_at
end
cell
end

def format_time time
timestamp = time.strftime("Created on %m/%d/%Y") + time.strftime(" at %I:%M:%S%p")
end

def tableView(tableView, numberOfRowsInSection: section)
if section == 0
Task.find(:completed, NSFEqualTo, 0).count
Expand All @@ -105,12 +111,23 @@ def tableView(tableView, numberOfRowsInSection: section)
def tableView(tableView, didSelectRowAtIndexPath: indexPath)
tableView.deselectRowAtIndexPath(indexPath, animated: true)
cell = tableView.cellForRowAtIndexPath(indexPath)
self.mark_as_done(cell)
self.mark_as_done(cell, indexPath)
end


def mark_as_done cell
task = Task.find(:name, NSFEqualTo, cell.textLabel.text).first
def mark_as_done cell, indexPath
tasks = Task.find(:name, NSFEqualTo, cell.textLabel.text)
task = Task.new
if indexPath.section == 0
timestamp = self.uncompleted_tasks[indexPath.row].created_at
else
timestamp = self.completed_tasks[indexPath.row].created_at
end

tasks.each do |t|
task = t if t.created_at == timestamp
end

task.completed = !task.completed
task.save
self.reload_table_sections
Expand Down
5 changes: 3 additions & 2 deletions vendor/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
PODS:
- NanoStore (2.7.7)
- NanoStore (2.6.4)

DEPENDENCIES:
- NanoStore
- NanoStore (~> 2.6.0)

SPEC CHECKSUMS:
NanoStore: e4d261a90d33dc7e4e0582fd28241828ebe5eaf6
NanoStore: a79dfd7c141d9cc0fc826661f227edcf43375d10

COCOAPODS: 0.37.1
Binary file modified vendor/Pods/.build/libPods-NanoStore.a
Binary file not shown.
Binary file modified vendor/Pods/.build/libPods.a
Binary file not shown.
4 changes: 2 additions & 2 deletions vendor/Pods/Headers/Public/____Pods-environment.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions vendor/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/Pods/NanoStore/Classes/Advanced/NSFNanoEngine.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading