Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

Commit

Permalink
resolved #196 join Ministry team button functionality to send a text …
Browse files Browse the repository at this point in the history
…to leaders of the team
  • Loading branch information
cstock123 committed Oct 2, 2018
1 parent 3b1b9da commit 3f54800
Showing 1 changed file with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@
//

import UIKit
import MessageUI

class MinistryTeamDetailsVC: UIViewController {
class MinistryTeamDetailsVC: UIViewController, MFMessageComposeViewControllerDelegate{

@IBOutlet weak var bannerImageView: UIImageView!
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var movementLabel: UILabel!
@IBOutlet weak var leaderNamesLabel: UILabel!
@IBOutlet weak var summaryLabel: UILabel!

var leaderPhoneNumbers : [String] = []

override var prefersStatusBarHidden: Bool { return true }

override func viewDidLoad() {
Expand All @@ -29,8 +32,23 @@ class MinistryTeamDetailsVC: UIViewController {
}

@IBAction func joinMinistryTeam() {
// TODO
self.presentAlert(title: "Join Ministry Team", message: "Coming Soon...")
if MFMessageComposeViewController.canSendText() {
if self.leaderPhoneNumbers.isEmpty {
self.presentAlert(title: "Can't contact Leader", message: "Sorry, there is no phone number listed for this Ministry Team")
} else {
let controller = MFMessageComposeViewController()
controller.body = "Hey I'm interested in joining your Ministry Team!"
controller.recipients = self.leaderPhoneNumbers
controller.messageComposeDelegate = self
self.present(controller, animated: true, completion: nil)
}
} else {
print("error can't send text")
}
}

func messageComposeViewController(_ controller: MFMessageComposeViewController, didFinishWith result: MessageComposeResult) {
controller.dismiss(animated: true, completion: nil)
}

func configure(with ministryTeam: MinistryTeam) {
Expand All @@ -40,6 +58,8 @@ class MinistryTeamDetailsVC: UIViewController {
self.leaderNamesLabel.text = "Leaders: \(ministryTeam.leaderNames ?? "N/A")"
self.summaryLabel.text = ministryTeam.summary
self.bannerImageView.downloadedFrom(link: ministryTeam.imageLink, contentMode: .scaleAspectFill)

self.leaderPhoneNumbers = ministryTeam.leaders.filter({ $0.phone != nil }).compactMap({ $0.phone! })
}
}
}

0 comments on commit 3f54800

Please sign in to comment.