Skip to content

Commit

Permalink
improve ux
Browse files Browse the repository at this point in the history
  • Loading branch information
Maurice Breit committed Oct 3, 2018
1 parent f201e7d commit 47a90a9
Show file tree
Hide file tree
Showing 283 changed files with 13,009 additions and 8,031 deletions.
152 changes: 56 additions & 96 deletions CoachPlus.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CoachPlus/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

IQKeyboardManager.sharedManager().enable = true
IQKeyboardManager.shared.enable = true

self.setupStyling()

Expand Down
2 changes: 1 addition & 1 deletion CoachPlus/UrlHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class UrlHandler {

verificationVC.token = token

let rootVc = UIApplication.shared.keyWindow?.currentViewController()
let rootVc = UIApplication.shared.keyWindow?.rootViewController

print(rootVc)

Expand Down
7 changes: 4 additions & 3 deletions CoachPlus/app/events/CreateEventViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,11 @@ class CreateEventViewController: CoachPlusViewController, UITextViewDelegate {
"end": end
] as [String : Any]

DataHandler.def.createEvent(team: (self.membership?.team!)!, createEvent: createEvent, successHandler: { response in

self.loadData(text: "CREATE_EVENT", promise: DataHandler.def.createEvent(team: (self.membership?.team!)!, createEvent: createEvent)).done({response in
self.navigationController?.popViewController(animated: true)
}, failHandler: { error in
print(error)
}).catch({ err in
print(err)
})

}
Expand Down
75 changes: 51 additions & 24 deletions CoachPlus/app/events/EventDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
import UIKit

class EventDetailViewController: CoachPlusViewController, UITableViewDelegate, UITableViewDataSource, TableHeaderViewButtonDelegate, NewNewsDelegate, ParticipationTableViewCellDelegate {
class EventDetailViewController: CoachPlusViewController, UITableViewDelegate, UITableViewDataSource, TableHeaderViewButtonDelegate, NewNewsDelegate, ParticipationTableViewCellDelegate, EventDetailCellActions {

enum Section:Int {
case general = 0
Expand All @@ -23,16 +23,6 @@ class EventDetailViewController: CoachPlusViewController, UITableViewDelegate, U

@IBOutlet weak var tableView: UITableView!

/**
@IBAction func reminderBtnTapped(_ sender: Any) {
_ = DataHandler.def.sendReminder(teamId: (self.event?.teamId)!, eventId: (self.event?.id)!, successHandler: { res in

}, failHandler: { err in

})
}**/


override func viewDidLoad() {
super.viewDidLoad()

Expand All @@ -41,6 +31,7 @@ class EventDetailViewController: CoachPlusViewController, UITableViewDelegate, U
self.tableView.register(nib: "ParticipationTableViewCell", reuseIdentifier: "ParticipationTableViewCell")
self.tableView.register(nib: "NewsTableViewCell", reuseIdentifier: "NewsTableViewCell")
self.tableView.register(nib: "EventDetailCell", reuseIdentifier: "EventDetailCell")
self.tableView.register(nib: "BannerTableViewCell", reuseIdentifier: "BannerTableViewCell")

let nib = UINib(nibName: "ReusableTableHeader", bundle: nil)
self.tableView.register(nib, forHeaderFooterViewReuseIdentifier: "TableHeader")
Expand All @@ -56,19 +47,19 @@ class EventDetailViewController: CoachPlusViewController, UITableViewDelegate, U
}

func loadParticipations() {
_ = DataHandler.def.getParticipations(event: self.event!, successHandler: { participationItems in
DataHandler.def.getParticipations(event: self.event!).done({ participationItems in
self.participationItems = participationItems
self.tableView.reloadData()
}, failHandler: { err in
}).catch({ err in
print(err)
});
}

func loadNews() {
_ = DataHandler.def.getNews(event: self.event!, successHandler: { news in
DataHandler.def.getNews(event: self.event!).done({ news in
self.news = news
self.tableView.reloadData()
}, failHandler: { err in
}).catch({ err in
print(err)
});
}
Expand Down Expand Up @@ -96,7 +87,10 @@ class EventDetailViewController: CoachPlusViewController, UITableViewDelegate, U
}
return self.news.count
case .participation:
return self.participationItems.count
if (self.participationItems.count > 0) {
return self.participationItems.count + 1
}
return 0
}
}

Expand All @@ -107,13 +101,37 @@ class EventDetailViewController: CoachPlusViewController, UITableViewDelegate, U
case .news:
return self.newsCell(indexPath: indexPath)
case .participation:
return self.participationCell(indexPath: indexPath)
if (indexPath.row == 0) {
return self.bannerCell(indexPath: indexPath)
} else {
return self.participationCell(indexPath: indexPath)
}
}
}

func bannerCell(indexPath: IndexPath) -> BannerTableViewCell {
let cell = self.tableView.dequeueReusableCell(withIdentifier: "BannerTableViewCell", for: indexPath) as! BannerTableViewCell

var text = "MAINTAIN_WILL"
var bgColor = UIColor.coachPlusBannerBackgroundColor
var textColor = UIColor.coachPlusBlue

if (self.userIsCoach() && event!.startedInPast()) {
text = "MAINTAIN_DID"
textColor = UIColor.coachPlusParticipationNoColor
}


cell.configure(text: text.localize(), bgColor: bgColor, textColor: textColor)

cell.separatorInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: .greatestFiniteMagnitude)

return cell
}

func participationCell(indexPath:IndexPath) -> ParticipationTableViewCell {
let cell = self.tableView.dequeueReusableCell(withIdentifier: "ParticipationTableViewCell", for: indexPath) as! ParticipationTableViewCell
let participationItem = self.participationItems[indexPath.row]
let participationItem = self.participationItems[indexPath.row - 1]
cell.configure(delegate: self, participationItem: participationItem, event: self.event!)
return cell
}
Expand All @@ -133,7 +151,7 @@ class EventDetailViewController: CoachPlusViewController, UITableViewDelegate, U

func generalCell(indexPath:IndexPath) -> UITableViewCell {
let cell = self.tableView.dequeueReusableCell(withIdentifier: "EventDetailCell", for: indexPath) as! EventDetailCell
cell.configure(event: self.event!, isCoach: self.membership?.isCoach(), vc: self)
cell.configure(event: self.event!, team: self.membership!.team!, isCoach: self.membership?.isCoach(), vc: self)
return cell
}

Expand All @@ -147,8 +165,7 @@ class EventDetailViewController: CoachPlusViewController, UITableViewDelegate, U
let cell = self.tableView.dequeueReusableHeaderFooterView(withIdentifier: "TableHeader")
let view = cell as! ReusableTableHeader

if (self.membership?.team?.id == self.event?.teamId &&
(self.membership?.isCoach())!) {
if (self.userIsCoach()) {

view.tableHeader.btn.tag = Section.news.rawValue
view.tableHeader.delegate = self
Expand All @@ -167,6 +184,7 @@ class EventDetailViewController: CoachPlusViewController, UITableViewDelegate, U

view.tableHeader.setTitle(title: "PARTICIPATION".localize())

view.tableHeader.eventIsInPast = self.event!.isInPast()
view.tableHeader.setLabels(participations: self.participationItems)

return view
Expand Down Expand Up @@ -229,22 +247,31 @@ class EventDetailViewController: CoachPlusViewController, UITableViewDelegate, U

let news = self.news[indexPath.row]

DataHandler.def.deleteNews(teamId: (self.event?.teamId)!, news: news, successHandler: { response in
DataHandler.def.deleteNews(teamId: (self.event?.teamId)!, news: news).done({ response in
if (self.news.count > 1) {
self.news.remove(at: indexPath.row)
self.tableView.deleteRows(at: [indexPath], with: .fade)
}
self.loadNews()
}, failHandler: { err in
}).catch({ err in

})


}

func participationChanged() {
if let headerView = self.tableView.headerView(forSection: Section.participation.rawValue) as? ReusableParticipationHeaderView {
headerView.tableHeader.refresh()
}
}

func delete(event: Event) {
if let delegate = self.previousVC as? EventDetailCellActions {
delegate.delete(event: self.event!)
}
}

func userIsCoach() -> Bool {
return (self.membership?.team?.id == self.event?.teamId && (self.membership?.isCoach())!)
}
}
10 changes: 8 additions & 2 deletions CoachPlus/app/events/EventListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import XLPagerTabStrip
import DZNEmptyDataSet
import SwiftIcons

class EventListViewController: CoachPlusViewController, UITableViewDelegate, UITableViewDataSource, IndicatorInfoProvider, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate {
class EventListViewController: CoachPlusViewController, UITableViewDelegate, UITableViewDataSource, IndicatorInfoProvider, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate, EventDetailCellActions {


enum Selection {
Expand Down Expand Up @@ -53,7 +53,7 @@ class EventListViewController: CoachPlusViewController, UITableViewDelegate, UIT

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let event = self.events[indexPath.row]
self.pushToEventDetail(event: event)
self.pushToEventDetail(currentVC: self, event: event)
}

func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {
Expand Down Expand Up @@ -85,4 +85,10 @@ class EventListViewController: CoachPlusViewController, UITableViewDelegate, UIT
return attributedString
}

func delete(event: Event) {
self.events = self.events.filter({ e in
return e.id != event.id
})
self.tableView.reloadData()
}
}
8 changes: 6 additions & 2 deletions CoachPlus/app/events/EventsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ class EventsViewController: ButtonBarPagerTabStripViewController {
self.upcomingEventsViewController?.selection = EventListViewController.Selection.upcoming
self.pastEventsViewController?.selection = EventListViewController.Selection.past

self.upcomingEventsViewController?.events = self.filterEvents(selection: .upcoming)
self.pastEventsViewController?.events = self.filterEvents(selection: .past)
self.upcomingEventsViewController?.events = self.filterEvents(selection: .upcoming).sorted(by: {(eventA, eventB) in
return eventA.start < eventB.start
})
self.pastEventsViewController?.events = self.filterEvents(selection: .past).sorted(by: {(eventA, eventB) in
return eventA.end > eventB.end
})

self.settings.style.buttonBarBackgroundColor = UIColor.white
self.settings.style.selectedBarBackgroundColor = UIColor.coachPlusBlue
Expand Down
22 changes: 19 additions & 3 deletions CoachPlus/app/events/cells/EventDetailCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@

import UIKit

protocol EventDetailCellActions {
func delete(event: Event)
}

class EventDetailCell: UITableViewCell {



@IBOutlet weak var nameL: UILabel!

@IBOutlet weak var dateL: UILabel!
Expand All @@ -30,12 +36,14 @@ class EventDetailCell: UITableViewCell {


var event: Event?
var team: Team?
var isCoach = false
var vc: UIViewController?

func configure(event: Event, isCoach: Bool?, vc: UIViewController) {
func configure(event: Event, team: Team, isCoach: Bool?, vc: UIViewController) {

self.event = event
self.team = team
self.isCoach = isCoach != nil && isCoach == true
self.vc = vc

Expand Down Expand Up @@ -63,19 +71,27 @@ class EventDetailCell: UITableViewCell {
func showActions() {
let alertController = UIAlertController(title: "ACTIONS".localize(), message: "ACTIONS_WHAT_TO_DO".localize(), preferredStyle: .actionSheet)

/*
let sendButton = UIAlertAction(title: "EDIT".localize(), style: .default, handler: { (action) -> Void in
})
})*/

let deleteButton = UIAlertAction(title: "DELETE".localize(), style: .destructive, handler: { (action) -> Void in

self.vc?.loadData(text: "DELETE_EVENT", promise: DataHandler.def.deleteEvent(team: self.team!, event: self.event!)).done({ apiResponse in

if let delegate = self.vc as? EventDetailCellActions {
delegate.delete(event: self.event!)
}
self.vc?.navigationController?.popViewController(animated: true)
})
})

let cancelButton = UIAlertAction(title: "CANCEL".localize(), style: .cancel, handler: { (action) -> Void in

})


alertController.addAction(sendButton)
//alertController.addAction(sendButton)
alertController.addAction(deleteButton)
alertController.addAction(cancelButton)

Expand Down
13 changes: 6 additions & 7 deletions CoachPlus/app/home/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,24 @@ class HomeViewController: UIViewController {


func getMyTeams() {
_ = DataHandler.def.getMyTeams(successHandler: { teams in

}, failHandler: { err in
self.loadData(text: "LOAD_DATA", promise: DataHandler.def.getMyTeams()).done({ apiResponse in
}).catch({ err in
print(err)
})
}

func createTeam(name:String, isPublic:Bool) {

_ = DataHandler.def.createTeam(name: name, isPublic: isPublic, successHandler: { apiResponse in
print("success")
}, failHandler: { err in
self.loadData(text: "LOAD_DATA", promise: DataHandler.def.createTeam(name: name, isPublic: isPublic)).done({ apiResponse in
}).catch({ err in
print(err)
})

}

func createInvitationLink(teamId:String, validDays:Int?) {
_ = DataHandler.def.createInviteLink(teamId: teamId, validDays: validDays, failHandler: { err in
self.loadData(text: "LOAD_DATA", promise: DataHandler.def.createInviteLink(teamId: teamId, validDays: validDays)).done({ apiResponse in
}).catch({ err in
print(err)
})
}
Expand Down
4 changes: 2 additions & 2 deletions CoachPlus/app/memberships/MembershipsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class MembershipsController: UIViewController, UITableViewDelegate, UITableViewD


func loadTeams() {
_ = DataHandler.def.getMyMemberships(successHandler: { memberships in
DataHandler.def.getMyMemberships().done({ memberships in
self.memberships = memberships
self.setSeparator()
self.tableView.reloadData()
Expand All @@ -81,7 +81,7 @@ class MembershipsController: UIViewController, UITableViewDelegate, UITableViewD

}
self.refreshControl.endRefreshing()
}, failHandler: { err in
}).catch({ err in
print(err)
self.setSeparator()
self.refreshControl.endRefreshing()
Expand Down
4 changes: 2 additions & 2 deletions CoachPlus/app/shared/events/EventTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ class EventTableViewCell: UITableViewCell {

func setup(event:Event) {

self.heroID = "event\(event.id)"
//self.heroID = "event\(event.id)"

let name = event.name

self.nameLbl.text = name
self.nameLbl.heroID = "\(self.heroID!)/name"
//self.nameLbl.heroID = "\(self.heroID!)/name"

self.dateTimeLbl.text = event.fromToString()
self.locationLbl.text = event.getLocationString()
Expand Down
9 changes: 3 additions & 6 deletions CoachPlus/app/shared/members/MemberTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,15 @@ class MemberTableViewCell: UITableViewCell {
let alertController = UIAlertController(title: "ACTIONS".localize(), message: "ACTIONS_WHAT_TO_DO".localize(), preferredStyle: .actionSheet)

let makeCoach = UIAlertAction(title: "ACTION_MAKE_COACH".localize(), style: .default, handler: { (action) -> Void in
_ = DataHandler.def.setRole(membershipId: self.membership!.id, role: Membership.Role.coach.rawValue, successHandler: { response in

self.vc?.loadData(text: "LOAD_DATA", promise: DataHandler.def.setRole(membershipId: self.membership!.id, role: Membership.Role.coach.rawValue)).done({ response in
self.delegate?.dataChanged()
}, failHandler: {err in

})
})

let makeUser = UIAlertAction(title: "ACTION_MAKE_USER".localize(), style: .default, handler: { (action) -> Void in
_ = DataHandler.def.setRole(membershipId: self.membership!.id, role: Membership.Role.user.rawValue, successHandler: { response in
self.vc?.loadData(text: "LOAD_DATA", promise: DataHandler.def.setRole(membershipId: self.membership!.id, role: Membership.Role.user.rawValue)).done({ response in
self.delegate?.dataChanged()
}, failHandler: {err in

})
})

Expand Down
Loading

0 comments on commit 47a90a9

Please sign in to comment.