Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.

Commit

Permalink
Finished refresh control on both user and team invite lists
Browse files Browse the repository at this point in the history
  • Loading branch information
Troy Ebert committed Jun 2, 2021
1 parent 39a4ae2 commit d333ac7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Sluggo/Storyboards/PendingInvites.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
<scene sceneID="JQZ-R2-Zc7">
<objects>
<tableViewController id="J7t-uV-EQA" customClass="PendingInvitesViewController" customModule="Sluggo" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="45" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="T72-92-ffa">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" allowsSelection="NO" rowHeight="45" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="T72-92-ffa">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationLevel="1" indentationWidth="10" reuseIdentifier="pInviteCell" rowHeight="44" id="pyK-ed-07x" customClass="InviteTableCell" customModule="Sluggo" customModuleProvider="target">
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="gray" indentationLevel="1" indentationWidth="10" reuseIdentifier="pInviteCell" rowHeight="44" id="pyK-ed-07x" customClass="InviteTableCell" customModule="Sluggo" customModuleProvider="target">
<rect key="frame" x="0.0" y="28" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="pyK-ed-07x" id="XaT-gg-Tsn">
Expand Down
2 changes: 2 additions & 0 deletions Sluggo/View Controllers/AdminInviteViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class AdminInviteViewController: UITableViewController {
override func viewDidLoad() {
self.configureRefreshControl()
self.handleRefreshAction()
NotificationCenter.default.addObserver(self, selector: #selector(handleRefreshAction),
name: .refreshTeamInvites, object: nil)

}

Expand Down
15 changes: 11 additions & 4 deletions Sluggo/View Controllers/PendingInvitesViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class PendingInvitesViewController: UITableViewController {
override func viewDidLoad() {
self.configureRefreshControl()
self.handleRefreshAction()

self.tableView.allowsSelection = (generateSegueableController != nil)
NotificationCenter.default.addObserver(self, selector: #selector(handleRefreshAction),
name: .refreshInvites, object: nil)
}

func configureRefreshControl() {
Expand All @@ -46,8 +46,10 @@ class PendingInvitesViewController: UITableViewController {
as? InviteTableCell else {fatalError("Could not load InviteTableCell")}
let inviteeTeam = self.inviteeTeams[indexPath.row]
cell.textLabel?.text = inviteeTeam.team.name

cell.acceptButton.tag = indexPath.row
cell.acceptButton.addTarget(self, action: #selector(doAcceptInvitation(sender:)), for: .touchUpInside)

cell.rejectButton.tag = indexPath.row
cell.rejectButton.addTarget(self, action: #selector(doRejectInvitation(sender:)), for: .touchUpInside)

Expand Down Expand Up @@ -84,7 +86,8 @@ class PendingInvitesViewController: UITableViewController {
inviteManager.acceptUserInvite(invite: invite) { result in
self.processResult(result: result) { _ in
DispatchQueue.main.async {
NotificationCenter.default.post(name: .refreshTrigger, object: self)
NotificationCenter.default.post(name: .refreshInvites, object: self)
NotificationCenter.default.post(name: .refreshTeams, object: self)
self.navigationController?.popViewController(animated: false)
}
}
Expand All @@ -99,7 +102,7 @@ class PendingInvitesViewController: UITableViewController {
inviteManager.rejectUserInvite(invite: invite) { result in
self.processResult(result: result) { _ in
DispatchQueue.main.async {
NotificationCenter.default.post(name: .refreshTrigger, object: self)
NotificationCenter.default.post(name: .refreshInvites, object: self)
self.navigationController?.popViewController(animated: false)
}
}
Expand All @@ -111,6 +114,10 @@ class PendingInvitesViewController: UITableViewController {
}
}

extension Notification.Name {
static let refreshInvites = Notification.Name(rawValue: "SLGRefreshInvitesNotification")
}

// MARK: Invite Table Cell
class InviteTableCell: UITableViewCell {

Expand Down
6 changes: 6 additions & 0 deletions Sluggo/View Controllers/TeamTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class TeamTableViewController: UITableViewController {
override func viewDidLoad() {
self.configureRefreshControl()
self.handleRefreshAction()
NotificationCenter.default.addObserver(self, selector: #selector(handleRefreshAction),
name: .refreshTeams, object: nil)
}

func configureRefreshControl() {
Expand Down Expand Up @@ -97,3 +99,7 @@ class TeamTableViewController: UITableViewController {
}
}
}

extension Notification.Name {
static let refreshTeams = Notification.Name(rawValue: "SLGRefreshTeamsNotification")
}

0 comments on commit d333ac7

Please sign in to comment.