Skip to content

Commit 4dea41b

Browse files
author
Maurice Breit
committed
update participation count on update
1 parent d213875 commit 4dea41b

File tree

8 files changed

+80
-31
lines changed

8 files changed

+80
-31
lines changed

CoachPlus/CoachPlusInfo.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
<key>CFBundlePackageType</key>
1818
<string>APPL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>0.1.2</string>
20+
<string>0.1.3</string>
2121
<key>CFBundleVersion</key>
22-
<string>22</string>
22+
<string>24</string>
2323
<key>LSRequiresIPhoneOS</key>
2424
<true/>
2525
<key>NSCameraUsageDescription</key>

CoachPlus/CoachPlusInfoDev.plist

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,30 @@
1717
<key>CFBundlePackageType</key>
1818
<string>APPL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>0.1.2</string>
20+
<string>0.1.3</string>
2121
<key>CFBundleVersion</key>
22-
<string>23</string>
22+
<string>24</string>
2323
<key>LSRequiresIPhoneOS</key>
2424
<true/>
2525
<key>NSCameraUsageDescription</key>
2626
<string>Used to select team and user images</string>
2727
<key>NSPhotoLibraryUsageDescription</key>
2828
<string>Used to select team and user images</string>
29+
<key>UIAppFonts</key>
30+
<array>
31+
<string>Roboto-Black</string>
32+
<string>Roboto-BlackItalic</string>
33+
<string>Roboto-Bold.ttf</string>
34+
<string>Roboto-BoldItalic.ttf</string>
35+
<string>Roboto-Italic.ttf</string>
36+
<string>Roboto-Light.ttf</string>
37+
<string>Roboto-LightItalic.ttf</string>
38+
<string>Roboto-Medium.ttf</string>
39+
<string>Roboto-MediumItalic.ttf</string>
40+
<string>Roboto-Regular.ttf</string>
41+
<string>Roboto-Thin.ttf</string>
42+
<string>Roboto-ThinItalic.ttf</string>
43+
</array>
2944
<key>UILaunchStoryboardName</key>
3045
<string>LaunchScreen</string>
3146
<key>UIMainStoryboardFile</key>
@@ -47,20 +62,5 @@
4762
<string>UIInterfaceOrientationLandscapeLeft</string>
4863
<string>UIInterfaceOrientationLandscapeRight</string>
4964
</array>
50-
<key>UIAppFonts</key>
51-
<array>
52-
<string>Roboto-Black</string>
53-
<string>Roboto-BlackItalic</string>
54-
<string>Roboto-Bold.ttf</string>
55-
<string>Roboto-BoldItalic.ttf</string>
56-
<string>Roboto-Italic.ttf</string>
57-
<string>Roboto-Light.ttf</string>
58-
<string>Roboto-LightItalic.ttf</string>
59-
<string>Roboto-Medium.ttf</string>
60-
<string>Roboto-MediumItalic.ttf</string>
61-
<string>Roboto-Regular.ttf</string>
62-
<string>Roboto-Thin.ttf</string>
63-
<string>Roboto-ThinItalic.ttf</string>
64-
</array>
6565
</dict>
6666
</plist>

CoachPlus/app/events/EventDetailViewController.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import Foundation
1010
import UIKit
1111

12-
class EventDetailViewController: CoachPlusViewController, UITableViewDelegate, UITableViewDataSource, TableHeaderViewButtonDelegate, NewNewsDelegate {
12+
class EventDetailViewController: CoachPlusViewController, UITableViewDelegate, UITableViewDataSource, TableHeaderViewButtonDelegate, NewNewsDelegate, ParticipationTableViewCellDelegate {
1313

1414
enum Section:Int {
1515
case general = 0
@@ -114,7 +114,7 @@ class EventDetailViewController: CoachPlusViewController, UITableViewDelegate, U
114114
func participationCell(indexPath:IndexPath) -> ParticipationTableViewCell {
115115
let cell = self.tableView.dequeueReusableCell(withIdentifier: "ParticipationTableViewCell", for: indexPath) as! ParticipationTableViewCell
116116
let participationItem = self.participationItems[indexPath.row]
117-
cell.configure(participationItem: participationItem, event: self.event!)
117+
cell.configure(delegate: self, participationItem: participationItem, event: self.event!)
118118
return cell
119119
}
120120

@@ -241,4 +241,10 @@ class EventDetailViewController: CoachPlusViewController, UITableViewDelegate, U
241241

242242

243243
}
244+
245+
func participationChanged() {
246+
if let headerView = self.tableView.headerView(forSection: Section.participation.rawValue) as? ReusableParticipationHeaderView {
247+
headerView.tableHeader.refresh()
248+
}
249+
}
244250
}

CoachPlus/app/shared/participation/ParticipationTableViewCell.swift

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
import UIKit
1010

11+
protocol ParticipationTableViewCellDelegate {
12+
func participationChanged()
13+
}
14+
1115
class ParticipationTableViewCell: UITableViewCell, ParticipationViewDelegate {
1216

1317
@IBOutlet weak var imageV: UIImageView!
@@ -18,15 +22,18 @@ class ParticipationTableViewCell: UITableViewCell, ParticipationViewDelegate {
1822

1923
var participationItem:ParticipationItem?
2024
var event:Event?
25+
var delegate: ParticipationTableViewCellDelegate?
2126

22-
func configure(participationItem:ParticipationItem, event:Event) {
27+
func configure(delegate: ParticipationTableViewCellDelegate?, participationItem:ParticipationItem, event:Event) {
2328
self.participationItem = participationItem
24-
//self.participationView.delegate = self
29+
self.delegate = delegate
2530
self.participationView.configure(participationItem: participationItem, event: event)
31+
self.participationView.delegate = self
2632
self.imageV.setUserImage(user: (self.participationItem?.user)!)
2733
self.nameLbl.text = self.participationItem?.user?.fullname
2834
}
2935

36+
//not called
3037
func selected(attend: Bool) {
3138

3239
if let membership = MembershipManager.shared.selectedMembership {
@@ -39,7 +46,18 @@ class ParticipationTableViewCell: UITableViewCell, ParticipationViewDelegate {
3946
}
4047
}
4148
}
42-
self.configure(participationItem: self.participationItem!, event: self.event!)
49+
50+
self.reload()
51+
}
52+
53+
func reload() {
54+
self.configure(delegate: self.delegate, participationItem: self.participationItem!, event: self.event!)
55+
}
56+
57+
func dataChanged() {
58+
if self.delegate != nil {
59+
self.delegate!.participationChanged()
60+
}
4361
}
4462

4563

CoachPlus/localization/Base.lproj/MainLocalization.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@
2727

2828
"CANCEL" = "Abbrechen";
2929

30+
"MEMBERS" = "Mitglieder";
3031

3132
"AAAAAAAAAA" = "BBBBBB";

CoachPlus/localization/de.lproj/MainLocalization.strings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@
2727

2828
"CANCEL" = "Abbrechen";
2929

30+
"MEMBERS" = "Mitglieder";
31+

CoachPlus/ui/participationview/ParticipationView.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import NibDesignable
1313

1414
protocol ParticipationViewDelegate {
1515
func selected(attend:Bool)
16+
func dataChanged()
1617
}
1718

1819
class ParticipationView: NibDesignable {
@@ -160,6 +161,7 @@ class ParticipationView: NibDesignable {
160161
_ = DataHandler.def.willAttend(teamId: (self.event?.teamId)!, eventId: (self.event?.id)!, userId: (self.user?.id)!, willAttend: willAttend, successHandler: { res in
161162
self.participation?.willAttend = willAttend
162163
self.showData()
164+
self.dataChanged()
163165
}, failHandler: { err in
164166
self.showData()
165167
})
@@ -172,10 +174,18 @@ class ParticipationView: NibDesignable {
172174
_ = DataHandler.def.didAttend(event: (self.event)!, user: self.user!, didAttend: didAttend, successHandler: { res in
173175
self.participation?.didAttend = didAttend
174176
self.showData()
177+
self.dataChanged()
175178
}, failHandler: { err in
176179
self.showData()
177180
})
178181
}
179182

183+
func dataChanged() {
184+
guard self.delegate != nil else {
185+
return
186+
}
187+
188+
self.delegate!.dataChanged()
189+
}
180190

181191
}

CoachPlus/ui/tableheader/ParticipationTableHeaderView.swift

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class ParticipationTableHeaderView: NibDesignable {
2626
super.init(coder: aDecoder)
2727
}
2828

29+
var participations = [ParticipationItem]()
30+
2931
func initLabels() {
3032
self.unknownL.text = ""
3133
self.yesL.text = ""
@@ -42,29 +44,39 @@ class ParticipationTableHeaderView: NibDesignable {
4244
return
4345
}
4446

45-
let unknownCount = participations!.filter {
47+
self.participations = participations!
48+
49+
self.showParticipationNumbers()
50+
51+
}
52+
53+
func showParticipationNumbers() {
54+
let unknownCount = self.participations.filter {
4655
$0.participation == nil || $0.participation!.willAttend == nil
47-
}.count
56+
}.count
4857

49-
let yesCount = participations!.filter {
58+
let yesCount = self.participations.filter {
5059
$0.participation != nil && $0.participation!.willAttend == true
51-
}.count
60+
}.count
5261

53-
let noCount = participations!.filter {
62+
let noCount = self.participations.filter {
5463
$0.participation != nil && $0.participation!.willAttend == false
55-
}.count
64+
}.count
5665

5766
self.setLabel(label: self.unknownL, icon: .fontAwesome(.question), count: unknownCount, iconColor: self.titleL.textColor)
5867
self.setLabel(label: self.yesL, icon: .fontAwesome(.check), count: yesCount, iconColor: UIColor.coachPlusParticipationYesColor)
5968
self.setLabel(label: self.noL, icon: .fontAwesome(.times), count: noCount, iconColor: UIColor.coachPlusParticipationNoColor.darkerColor(percent: 0.25))
60-
6169
}
6270

6371
func setLabel(label: UILabel, icon: FontType, count: Int, iconColor: UIColor) {
6472
let color = self.titleL.textColor
6573
label.setIcon(prefixText: "", prefixTextColor: color!, icon: icon, iconColor: iconColor, postfixText:" \(count)", postfixTextColor: color!, size: 15, iconSize: 15)
6674
}
6775

76+
func refresh() {
77+
self.showParticipationNumbers()
78+
}
79+
6880

6981

7082
}

0 commit comments

Comments
 (0)