Skip to content

Commit

Permalink
added rate app feature, added bolded items if children, fixed collaps…
Browse files Browse the repository at this point in the history
…e on delete completed, tested prod ads, updated version to 2.0.1, set release to true, side menu left justified, shake to delete completed, 5 space indent,
  • Loading branch information
ethanneff committed Jun 21, 2016
1 parent e5d0d12 commit 8f19952
Show file tree
Hide file tree
Showing 15 changed files with 350 additions and 52 deletions.
4 changes: 4 additions & 0 deletions Organize.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
675038091CD178F30061EC6E /* SignupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 675038031CD178F30061EC6E /* SignupViewController.swift */; };
6750380A1CD178F30061EC6E /* ForgotViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 675038041CD178F30061EC6E /* ForgotViewController.swift */; };
67A6E5611D0640B000ABB2BC /* Modal+Confirmation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67A6E5601D0640B000ABB2BC /* Modal+Confirmation.swift */; };
67CD7B691D198B460019E771 /* Modal+Review.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67CD7B681D198B460019E771 /* Modal+Review.swift */; };
67CEDF531D0225C1000B6D43 /* Modal+Error.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67CEDF521D0225C1000B6D43 /* Modal+Error.swift */; };
67CEDF551D022964000B6D43 /* Modal+TextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67CEDF541D022964000B6D43 /* Modal+TextField.swift */; };
67D267F81D0E380E004DEB9A /* UIDevice+Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67D267F71D0E380E004DEB9A /* UIDevice+Config.swift */; };
Expand Down Expand Up @@ -119,6 +120,7 @@
675038031CD178F30061EC6E /* SignupViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SignupViewController.swift; sourceTree = "<group>"; };
675038041CD178F30061EC6E /* ForgotViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ForgotViewController.swift; sourceTree = "<group>"; };
67A6E5601D0640B000ABB2BC /* Modal+Confirmation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Modal+Confirmation.swift"; sourceTree = "<group>"; };
67CD7B681D198B460019E771 /* Modal+Review.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Modal+Review.swift"; sourceTree = "<group>"; };
67CEDF521D0225C1000B6D43 /* Modal+Error.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Modal+Error.swift"; sourceTree = "<group>"; };
67CEDF541D022964000B6D43 /* Modal+TextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Modal+TextField.swift"; sourceTree = "<group>"; };
67D267F71D0E380E004DEB9A /* UIDevice+Config.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIDevice+Config.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -353,6 +355,7 @@
67CEDF521D0225C1000B6D43 /* Modal+Error.swift */,
67CEDF541D022964000B6D43 /* Modal+TextField.swift */,
67A6E5601D0640B000ABB2BC /* Modal+Confirmation.swift */,
67CD7B681D198B460019E771 /* Modal+Review.swift */,
);
name = modals;
sourceTree = "<group>";
Expand Down Expand Up @@ -535,6 +538,7 @@
675037DD1CD176570061EC6E /* Modal+Reminder.swift in Sources */,
675038071CD178F30061EC6E /* Access+Business+Logic.swift in Sources */,
670963051CEC0DC80043D2A5 /* Modal+Tutorial.swift in Sources */,
67CD7B691D198B460019E771 /* Modal+Review.swift in Sources */,
67A6E5611D0640B000ABB2BC /* Modal+Confirmation.swift in Sources */,
675037E51CD176570061EC6E /* ListViewController.swift in Sources */,
675037DB1CD176570061EC6E /* Modal.swift in Sources */,
Expand Down
8 changes: 8 additions & 0 deletions Organize/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// load (install or updated)
configureFirebase()
configureReviewApp()
navigateToFirstController()
return true
}
Expand Down Expand Up @@ -55,6 +56,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
window.makeKeyAndVisible()
}
}
// MARK: - review app
func configureReviewApp() {
Constant.UserDefault.set(key: Constant.UserDefault.Key.ReviewCount, val: 0)
Constant.UserDefault.set(key: Constant.UserDefault.Key.ReviewApp, val: false)
Constant.UserDefault.set(key: Constant.UserDefault.Key.FeedbackApp, val: false)
}

// MARK: - firebase
private func configureFirebase() {
// Firebase dynamic links
Expand Down
12 changes: 12 additions & 0 deletions Organize/Assets.xcassets/icon-star.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "icon-star.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.
8 changes: 6 additions & 2 deletions Organize/Constant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ struct Constant {

struct App {
static let name: String = "Organize"
static let loadingDelay: Double = release ? 0.8 : 0
static let id: String = "1116178818"
static let loadingDelay: Double = release ? 0.2 : 0
static let release: Bool = true
static let logging: Bool = true
static let deepLink: String = "eneff.organize"
Expand All @@ -37,7 +38,7 @@ struct Constant {
struct Color {
// FIXME: this should be a class.sharedInstance
// toggle should change properties, then save
// get at beginning
// get at beginning
// no enum because need .color at end
private enum Item {
case Button
Expand Down Expand Up @@ -112,6 +113,9 @@ struct Constant {
enum Key: String {
case AskedLocalNotification
case DarkMode
case FeedbackApp
case ReviewApp
case ReviewCount
}

static func get(key key: UserDefault.Key) -> AnyObject? {
Expand Down
2 changes: 1 addition & 1 deletion Organize/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.0.0</string>
<string>2.0.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand Down
11 changes: 5 additions & 6 deletions Organize/ListTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class ListTableViewCell: UITableViewCell, SwipeCellDelegate {
private let titleLabelPadding: CGFloat = Constant.Button.padding
private let accessoryButtonWidth: CGFloat = Constant.Button.height
private let reminderViewWidth: CGFloat = 3
private let titleIndentSpace: String = " "

private let titleIndentSpace: String = " "

weak var delegate: ListTableViewCellDelegate?
// TODO: figure out why to make a property... swipe gets deinit otherwise
Expand Down Expand Up @@ -84,6 +85,8 @@ class ListTableViewCell: UITableViewCell, SwipeCellDelegate {
layoutMargins = UIEdgeInsetsZero
preservesSuperviewLayoutMargins = false
selectionStyle = .None
// TODO: test if fixes separator disappearance
textLabel?.backgroundColor = .clearColor()
}

private func setupViewConstraints() {
Expand Down Expand Up @@ -135,11 +138,7 @@ class ListTableViewCell: UITableViewCell, SwipeCellDelegate {
title = titleIndentSpace + title
}
// TODO: make important flag
if note.indent == 0 {
titleLabel?.font = UIFont.boldSystemFontOfSize(UIFont.systemFontSize())
} else {
titleLabel?.font = UIFont.systemFontOfSize(UIFont.systemFontSize())
}
titleLabel?.font = note.bolded ? .boldSystemFontOfSize(UIFont.systemFontSize()) : .systemFontOfSize(UIFont.systemFontSize())
titleLabel?.text = title

// complete
Expand Down
65 changes: 55 additions & 10 deletions Organize/ListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ListViewController: UIViewController, UITableViewDelegate, UITableViewData

// MARK: - init
init() {
notebook = Notebook(title: "init")
notebook = Notebook(title: "")
super.init(nibName: nil, bundle: nil)
initialize()
}
Expand Down Expand Up @@ -60,6 +60,8 @@ class ListViewController: UIViewController, UITableViewDelegate, UITableViewData
// MARK: - appear
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
// session
loadSession()
// config
loadRemoteConfig()
// title
Expand Down Expand Up @@ -105,12 +107,26 @@ class ListViewController: UIViewController, UITableViewDelegate, UITableViewData
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(applicationDidBecomeInactiveNotification), name: UIApplicationWillTerminateNotification, object: nil)
}

private func loadSession() {
let reviewCount = Constant.UserDefault.get(key: Constant.UserDefault.Key.ReviewCount) as? Int ?? 0
Constant.UserDefault.set(key: Constant.UserDefault.Key.ReviewCount, val: reviewCount+1)
}

private func loadRemoteConfig() {
Remote.Config.fetch { config in
if let config = config {
// ads
if config[Remote.Config.Keys.ShowAds.rawValue].boolValue {
self.loadBannerAd()
}
// review
let feedbackApp = Constant.UserDefault.get(key: Constant.UserDefault.Key.FeedbackApp) as? Bool ?? false
let reviewApp = Constant.UserDefault.get(key: Constant.UserDefault.Key.ReviewApp) as? Bool ?? false
let reviewCount = Constant.UserDefault.get(key: Constant.UserDefault.Key.ReviewCount) as? Int ?? 0
let reviewCountConfig = config[Remote.Config.Keys.ShowReview.rawValue].numberValue as? Int ?? 0
if !(reviewApp || feedbackApp) && reviewCount > reviewCountConfig {
self.displayReview()
}
}
}
}
Expand Down Expand Up @@ -235,7 +251,7 @@ class ListViewController: UIViewController, UITableViewDelegate, UITableViewData
}

internal func adView(bannerView: GADBannerView!, didFailToReceiveAdWithError error: GADRequestError!) {
print("adView:didFailToReceiveAdWithError: \(error.localizedDescription)")
Report.sharedInstance.log("adView:didFailToReceiveAdWithError: \(error.localizedDescription)")
}

private func displayBannerAd(show show: Bool) {
Expand Down Expand Up @@ -267,6 +283,13 @@ class ListViewController: UIViewController, UITableViewDelegate, UITableViewData
return cell
}

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
// TODO: test if fixes separator disappearing
tableView.deselectRowAtIndexPath(indexPath, animated: false)
tableView.separatorStyle = .None;
tableView.separatorStyle = .SingleLine
}

// MARK: - refresh
func tableViewRefresh(refreshControl: UIRefreshControl) {
refreshControl.endRefreshing()
Expand Down Expand Up @@ -356,8 +379,7 @@ class ListViewController: UIViewController, UITableViewDelegate, UITableViewData

override func motionEnded(motion: UIEventSubtype, withEvent event: UIEvent?) {
if let event = event where event.subtype == .MotionShake {
// FIXME: undo in v2
// displayUndo()
displayDeleteCompleted()
}
}

Expand Down Expand Up @@ -426,9 +448,6 @@ class ListViewController: UIViewController, UITableViewDelegate, UITableViewData

// MARK: - modals
private func displayNotebookTitle() {
// dismissViewControllerAnimated(true, completion: nil)
// PushNotification.sharedInstance.registerPermission()

let modal = ModalTextField()
modal.limit = 25
modal.placeholder = notebook.title
Expand All @@ -440,6 +459,30 @@ class ListViewController: UIViewController, UITableViewDelegate, UITableViewData
}
}

private func displayReview() {
Report.sharedInstance.track(event: "show_review")
let modal = ModalReview()
modal.show(controller: self) { output in
if let selection = output[ModalReview.OutputKeys.Selection.rawValue] as? Int {
Constant.UserDefault.set(key: Constant.UserDefault.Key.ReviewCount, val: 0)
let modal = ModalConfirmation()
if selection >= 3 {
modal.message = "Can you help us by leaving a review?"
modal.show(controller: self) { output in
Constant.UserDefault.set(key: Constant.UserDefault.Key.ReviewApp, val: true)
Report.sharedInstance.track(event: "sent_review")
UIApplication.sharedApplication().openURL(NSURL(string: "itms-apps://itunes.apple.com/app/?id=" + Constant.App.id)!)
}
} else {
modal.message = "Can you tell us how we can improve?"
modal.show(controller: self) { output in
self.displayAppFeedback()
}
}
}
}
}

private func displayAppTutorial() {
let modal = ModalTutorial()
modal.show(controller: self, dismissible: true)
Expand All @@ -455,7 +498,7 @@ class ListViewController: UIViewController, UITableViewDelegate, UITableViewData
let modal = ModalConfirmation()
modal.message = "Permanently delete all completed?"
modal.show(controller: self, dismissible: false) { (output) in
self.notebook.deleteAll(tableView: self.tableView)
self.notebook.deleteCompleted(tableView: self.tableView)
}
}
}
Expand Down Expand Up @@ -527,8 +570,10 @@ class ListViewController: UIViewController, UITableViewDelegate, UITableViewData

func mailComposeController(controller: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?) {
controller.dismissViewControllerAnimated(true, completion: nil)
switch result.rawValue {
default: Util.playSound(systemSound: .Tap)
Util.playSound(systemSound: .Tap)
if result.rawValue == 2 {
Constant.UserDefault.set(key: Constant.UserDefault.Key.FeedbackApp, val: true)
Report.sharedInstance.track(event: "sent_feedback")
}
}

Expand Down
3 changes: 1 addition & 2 deletions Organize/MenuViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ class MenuViewController: UIViewController, SettingsDelegate {
func initialize() {
// FIXME: memory leak... need to deinit all
sideMenu = SideMenu(parent: self, child: mainMenu!, left: leftMenu!, right: rightMenu!)
sideMenu!.rightWidth = 170
sideMenu!.rightWidth = 185
sideMenu!.leftWidth = 240
createNavButtons()
// /createNavTitle(title: Constant.App.name)
createDelegates()
}

Expand Down
2 changes: 1 addition & 1 deletion Organize/Modal+DatePicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class ModalDatePicker: Modal {
Util.animateButtonPress(button: button)
hide() {
if let completion = self.completion where button.tag == 1 {
completion(output: [ModalDatePicker.OutputKeys.Date.rawValue: self.picker.date])
completion(output: [OutputKeys.Date.rawValue: self.picker.date])
}
}
}
Expand Down
Loading

0 comments on commit 8f19952

Please sign in to comment.