This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import Firebase | |
| class Reviews { | |
| var reviewArray: [Review] = [] | |
| var db: Firestore! | |
| init() { | |
| db = Firestore.firestore() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| class SpotReviewsTableViewCell: UITableViewCell { | |
| @IBOutlet weak var reviewTitleLabel: UILabel! | |
| @IBOutlet weak var reviewTextLabel: UILabel! | |
| @IBOutlet var starImageCollection: [UIImageView]! | |
| var review: Review! { | |
| didSet { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
| let cell = tableView.dequeueReusableCell(withIdentifier: "ReviewCell", for: indexPath) as! SpotReviewsTableViewCell | |
| cell.review = reviews.reviewArray[indexPath.row] | |
| return cell | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func cameraOrLibraryAlert() { | |
| let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) | |
| let cameraAction = UIAlertAction(title: "Camera", style: .default) { _ in | |
| self.accessCamera() | |
| } | |
| let photoLibraryAction = UIAlertAction(title: "Photo Library", style: .default) { _ in | |
| self.accessLibrary() | |
| } | |
| let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) | |
| alertController.addAction(cameraAction) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func saveData(spot: Spot, completed: @escaping (Bool) -> ()) { | |
| let db = Firestore.firestore() | |
| let storage = Storage.storage() | |
| // convert photo.image to a Data type so it can be saved by Firebase Storage | |
| guard let photoData = self.image.jpegData(compressionQuality: 0.5) else { | |
| print("*** ERROR: couuld not convert image to data format") | |
| return completed(false) | |
| } | |
| let uploadMetadata = StorageMetadata() | |
| uploadMetadata.contentType = "image/jpeg" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func loadData(spot: Spot, completed: @escaping () -> ()) { | |
| guard spot.documentID != "" else { | |
| return | |
| } | |
| let storage = Storage.storage() | |
| db.collection("spots").document(spot.documentID).collection("photos").addSnapshotListener { (querySnapshot, error) in | |
| guard error == nil else { | |
| print("*** ERROR: adding the snapshot listener \(error!.localizedDescription)") | |
| return completed() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| convenience init(dictionary: [String: Any]) { | |
| let description = dictionary["description"] as! String? ?? "" | |
| let postedBy = dictionary["postedBy"] as! String? ?? "" | |
| let date = dictionary["date"] as! Date? ?? Date() | |
| self.init(image: UIImage(), description: description, postedBy: postedBy, date: date, documentUUID: "") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func updateUserInterface() { | |
| nameLabel.text = spot.name | |
| addressLabel.text = spot.address | |
| rating = review.rating | |
| reviewTitleField.text = review.title | |
| enableDisableSaveButton() | |
| reviewTextView.text = review.text | |
| dateFormatter.dateStyle = .medium | |
| dateFormatter.timeStyle = .none | |
| reviewDateLabel.text = "posted: \(dateFormatter.string(from: review.date))" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func addBordersToEditableObjects() { | |
| reviewTitleField.addBorder(width: 0.5, radius: 5.0, color: .black) | |
| reviewTextView.addBorder(width: 0.5, radius: 5.0, color: .black) | |
| buttonsBackgroundView.addBorder(width: 0.5, radius: 5.0, color: .black) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| RGBLedExample.ino | |
| */ | |
| #include <Easyuino.h> // Include the library in order to the compiler know you want Easyuino library | |
| using Easyuino::RGBLed; // Necessary in order to use RGBLed | |
| using Easyuino::Color; // Necessary for some method calls | |
| int red_pin = 3; // Arduino pin connected to led red pin |