Skip to content

Commit

Permalink
Merge pull request #14 from mazurio/release-122
Browse files Browse the repository at this point in the history
1.3.0
  • Loading branch information
mazurio authored Oct 8, 2016
2 parents a702c47 + e6cdeb9 commit 1808729
Show file tree
Hide file tree
Showing 212 changed files with 4,570 additions and 4,867 deletions.
777 changes: 414 additions & 363 deletions BodyweightFitness.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

32 changes: 14 additions & 18 deletions BodyweightFitness/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,28 @@ import Crashlytics
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


var main: UINavigationController? = nil

var sideNavigationViewController: SideNavigationController?

let sideViewController: UIViewController =
SideViewController()

let rootViewController: UINavigationController =
UINavigationController(rootViewController: RootViewController())

let workoutLogViewController =
UINavigationController(rootViewController: WorkoutLogViewController())

let supportDeveloperViewController =
UINavigationController(rootViewController: SupportDeveloperViewController())

let settingsViewController =
UINavigationController(rootViewController: SettingsViewController())
let sideViewController = SideViewController()

let homeViewController = HomeViewController()
let workoutViewController = WorkoutViewController()
let workoutLogViewController = WorkoutLogViewController()
let supportDeveloperViewController = SupportDeveloperViewController()
let settingsViewController = SettingsViewController()

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
Fabric.with([Crashlytics.self])


self.main = UINavigationController(rootViewController: homeViewController)

self.migrateSchemaIfNeeded()
self.setDefaultSettings()

self.sideNavigationViewController = SideNavigationController(
rootViewController: self.rootViewController,
rootViewController: self.main!,
leftViewController: self.sideViewController
)

Expand Down
4 changes: 2 additions & 2 deletions BodyweightFitness/Bodyweight Fitness.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.2.0</string>
<string>1.3.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>121</string>
<string>130</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
Expand Down
19 changes: 19 additions & 0 deletions BodyweightFitness/Controller/Cell/SideViewHeaderCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import UIKit

class SideViewHeaderCell: UITableViewCell {
@IBOutlet weak var title: UILabel!
@IBOutlet weak var subtitle: UILabel!

override func awakeFromNib() {
super.awakeFromNib()

_ = RoutineStream.sharedInstance.routineObservable().subscribe(onNext: {
self.title.text = $0.title
self.subtitle.text = $0.subtitle
})
}

override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
}
4 changes: 4 additions & 0 deletions BodyweightFitness/Controller/Cell/WorkoutLogCardCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ func getWeightUnit() -> String {
class WorkoutLogCardCell: UITableViewCell, MFMailComposeViewControllerDelegate {
@IBOutlet weak var title: UILabel!
@IBOutlet weak var subtitle: UILabel!
@IBOutlet weak var progressView: ProgressView!
@IBOutlet weak var progressRate: UILabel!

var parentController: UIViewController?
var date: NSDate?
Expand Down Expand Up @@ -165,6 +167,8 @@ class WorkoutLogCardCell: UITableViewCell, MFMailComposeViewControllerDelegate {
parent.showOrHideCardViewForDate(date)
}
}

RoutineStream.sharedInstance.setRepository()
}))

self.parentController?.presentViewController(alertController, animated: true, completion: nil)
Expand Down
2 changes: 1 addition & 1 deletion BodyweightFitness/Controller/DashboardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class DashboardViewController: UIViewController, UITableViewDelegate, UITableVie
var currentIndexPath: NSIndexPath?

var currentExercise: Exercise?
var rootViewController: RootViewController?
var rootViewController: WorkoutViewController?

init() {
super.init(nibName: "DashboardView", bundle: nil)
Expand Down
159 changes: 159 additions & 0 deletions BodyweightFitness/Controller/HomeViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import Foundation
import UIKit
import RxSwift

class HomeViewController: UIViewController {
@IBOutlet weak var stackView: UIStackView!
@IBOutlet weak var cardView: UIView!

@IBOutlet weak var totalWorkouts: UILabel!
@IBOutlet weak var lastWorkout: UILabel!
@IBOutlet weak var last7Days: UILabel!
@IBOutlet weak var last31Days: UILabel!

init() {
super.init(nibName: "HomeView", bundle: nil)
}

required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func viewDidLoad() {
super.viewDidLoad()

self.setNavigationBar()

self.navigationItem.leftBarButtonItem = UIBarButtonItem(
image: UIImage(named: "menu"),
landscapeImagePhone: nil,
style: .Plain,
target: self,
action: #selector(dismiss)
)

self.navigationItem.rightBarButtonItem = UIBarButtonItem(
image: UIImage(named: "plus"),
landscapeImagePhone: nil,
style: .Plain,
target: self,
action: #selector(routine)
)

self.navigationItem.title = "Bodyweight Fitness"

self.stackView.axis = UILayoutConstraintAxis.Vertical;
self.stackView.distribution = UIStackViewDistribution.EqualSpacing;
self.stackView.alignment = UIStackViewAlignment.Top;
self.stackView.spacing = 0;

_ = RoutineStream.sharedInstance.repositoryObservable().subscribeNext({ (it) in
self.renderWorkoutProgressView()
self.renderStatisticsView()
})

_ = RoutineStream.sharedInstance.routineObservable().subscribeNext({ (it) in
self.renderWorkoutProgressView()
self.renderStatisticsView()
})
}

func renderWorkoutProgressView() {
let routine = RoutineStream.sharedInstance.routine

self.stackView.removeAllSubviews()
self.navigationItem.title = routine.title

if (RepositoryStream.sharedInstance.repositoryRoutineForTodayExists()) {
let repositoryRoutine = RepositoryStream.sharedInstance.getRepositoryRoutineForToday()

for category in repositoryRoutine.categories {
let completionRate = RepositoryCategoryHelper.getCompletionRate(category)
let homeBarView = HomeBarView()

homeBarView.categoryTitle.text = category.title
homeBarView.progressView.setCompletionRate(completionRate)
homeBarView.progressRate.text = completionRate.label

self.stackView.addArrangedSubview(homeBarView)
}
} else {
for category in routine.categories {
if let c = category as? Category {
let completionRate = CompletionRate(percentage: 0, label: "0%")
let homeBarView = HomeBarView()

homeBarView.categoryTitle.text = c.title
homeBarView.progressView.setCompletionRate(completionRate)
homeBarView.progressRate.text = completionRate.label

self.stackView.addArrangedSubview(homeBarView)
}
}
}
}

func renderStatisticsView() {
let numberOfWorkouts = RepositoryStream.sharedInstance.getNumberOfWorkouts()
let lastWorkout = RepositoryStream.sharedInstance.getLastWorkout()

let numberOfWorkoutsLast7Days = RepositoryStream.sharedInstance.getNumberOfWorkouts(-7)
let numberOfWorkoutsLast31Days = RepositoryStream.sharedInstance.getNumberOfWorkouts(-31)

self.totalWorkouts.text = String(numberOfWorkouts) + getNumberOfWorkoutsPostfix(numberOfWorkouts)

if let w = lastWorkout {
self.lastWorkout.text = String(NSDate.timeAgoSince(w.startTime))
} else {
self.lastWorkout.text = String("Never")
}

self.last7Days.text = String(numberOfWorkoutsLast7Days) + getNumberOfWorkoutsPostfix(numberOfWorkoutsLast7Days)
self.last31Days.text = String(numberOfWorkoutsLast31Days) + getNumberOfWorkoutsPostfix(numberOfWorkoutsLast31Days)
}

func getNumberOfWorkoutsPostfix(count: Int) -> String {
if (count == 1) {
return " Workout"
} else {
return " Workouts"
}
}

func dismiss(sender: UIBarButtonItem) {
self.sideNavigationController?.toggleLeftView()
}

func routine(sender: UIBarButtonItem) {
let alertController = UIAlertController(
title: "Choose Workout Routine",
message: nil,
preferredStyle: .ActionSheet)

alertController.modalPresentationStyle = .Popover
alertController.popoverPresentationController?.barButtonItem = sender;

alertController.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: nil))

alertController.addAction(UIAlertAction(title: "Bodyweight Fitness", style: .Default) { (action) in
RoutineStream.sharedInstance.setRoutine("routine0")
})

alertController.addAction(UIAlertAction(title: "Molding Mobility", style: .Default) { (action) in
RoutineStream.sharedInstance.setRoutine("e73593f4-ee17-4b9b-912a-87fa3625f63d")
})

self.presentViewController(alertController, animated: true, completion: nil)
}

@IBAction func startWorkout(sender: AnyObject) {
let appDelegate = UIApplication.sharedApplication().delegate as? AppDelegate

appDelegate?.sideViewController.tableView.selectRowAtIndexPath(
NSIndexPath(forRow: 1, inSection: 0),
animated: false,
scrollPosition: UITableViewScrollPosition.None)

appDelegate?.main!.setViewControllers([(appDelegate?.workoutViewController)!], animated: false)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ class LogWorkoutController: UIViewController {

if let sideNavigationController = self.parentController as? SideNavigationController {
if let navigationController = sideNavigationController.rootViewController as? UINavigationController {
if let rootViewController = navigationController.viewControllers.first as? RootViewController {
if let rootViewController = navigationController.viewControllers.first as? WorkoutViewController {
rootViewController.weightedViewController.updateLabels()
}
}
Expand Down
3 changes: 2 additions & 1 deletion BodyweightFitness/Controller/ProgressViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ class ProgressViewController: UIViewController {

self.setNavigationBar()
self.navigationItem.backBarButtonItem?.tintColor = UIColor.primaryDark()

if let routine = repositoryRoutine {
self.navigationItem.title = CVDate(date: routine.startTime).commonDescription
self.navigationItem.title = routine.startTime.commonDescription
}

let generalViewController: ProgressGeneralViewController = ProgressGeneralViewController(
Expand Down
22 changes: 0 additions & 22 deletions BodyweightFitness/Controller/Service/RoutineStream.swift

This file was deleted.

Loading

0 comments on commit 1808729

Please sign in to comment.