Skip to content

Commit 897e412

Browse files
committed
ready for phone/text button actions
1 parent 78d99db commit 897e412

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

NewTextExchange/Book.swift

+13-6
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ public final class Book: NSObject, ResponseObjectSerializable, ResponseCollectio
1313
var title: String?
1414
var course: String?
1515
var price: Int?
16-
var quality: Double?
17-
var coverPhotoURL: String?
1816
var thumbnailPhotoURL: String?
19-
var isbn: String?
17+
var coverPhotoURL: String?
2018
var author: String?
19+
var isbn: String?
20+
var quality: Double?
21+
var creator: User?
2122

2223
override init() {
2324
super.init()
@@ -30,11 +31,17 @@ public final class Book: NSObject, ResponseObjectSerializable, ResponseCollectio
3031
self.title = representation.valueForKeyPath("title") as? String
3132
self.course = representation.valueForKeyPath("course") as? String
3233
self.price = representation.valueForKeyPath("price") as? Int
33-
self.quality = representation.valueForKeyPath("quality") as? Double
34-
self.thumbnailPhotoURL = representation.valueForKeyPath("thumbnail_photo_URL") as? String
34+
self.thumbnailPhotoURL = representation.valueForKeyPath("book_thumbnail_photo_URL") as? String
3535
self.coverPhotoURL = representation.valueForKeyPath("cover_photo_URL") as? String
36-
self.isbn = representation.valueForKeyPath("isbn") as? String
3736
self.author = representation.valueForKeyPath("author") as? String
37+
self.isbn = representation.valueForKeyPath("isbn") as? String
38+
self.quality = representation.valueForKeyPath("quality") as? Double
39+
40+
if let creatorRepresentation = (representation.valueForKeyPath("creator") as? [String: AnyObject]) {
41+
if let creator = User(representation: creatorRepresentation) {
42+
self.creator = creator
43+
}
44+
}
3845
}
3946

4047
public static func collection(response response: NSHTTPURLResponse, representation: AnyObject) -> [Book] {

NewTextExchange/BookDetailsNEWController.swift

+11-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import Foundation
1010
import Cosmos
1111
import MessageUI
12+
import AFNetworking
1213

1314
class BookDetailsNEWController: UIViewController, UINavigationBarDelegate, MFMessageComposeViewControllerDelegate {
1415
var book: Book? {
@@ -17,7 +18,7 @@ class BookDetailsNEWController: UIViewController, UINavigationBarDelegate, MFMes
1718
}
1819
}
1920

20-
var bookImageView = UIImageView(image: UIImage(named: "RagtimeBookCover"))
21+
var bookImageView = UIImageView()
2122
var detailsView = UIView.newAutoLayoutView()
2223

2324
var thumbnailImageView = UIImageView(image: UIImage(named: "ProfilePic"))
@@ -72,6 +73,7 @@ class BookDetailsNEWController: UIViewController, UINavigationBarDelegate, MFMes
7273
phoneImageButton.setImage(UIImage(named: "PhoneIcon"), forState: .Normal)
7374

7475
messageImageButton.setImage(UIImage(named: "MessageIcon"), forState: .Normal)
76+
//payImageButton.setImage(UIImage(named: "PayIcon"), forState: .Normal)
7577

7678
payImageButton.backgroundColor = .orangeColor()
7779
payImageButton.setTitle("Purchase Book", forState: .Normal)
@@ -144,6 +146,14 @@ class BookDetailsNEWController: UIViewController, UINavigationBarDelegate, MFMes
144146
if let bookQuality = book.quality {
145147
ratingStarsView.rating = bookQuality
146148
}
149+
150+
if let bookCoverImageURL = book.coverPhotoURL {
151+
Database.getImageFromURL(bookCoverImageURL).then{ image -> Void in
152+
self.bookImageView.image = image
153+
}.error { error -> Void in
154+
print(error)
155+
}
156+
}
147157
}
148158

149159
func setupConstraints() {

NewTextExchange/BookListingCell.swift

-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ class BookListingCell: UICollectionViewCell {
8888
}
8989

9090
if let bookCoverPhotoURL = book.thumbnailPhotoURL as String! {
91-
print(bookCoverPhotoURL)
9291
Database.getImageFromURL(bookCoverPhotoURL).then { image -> Void in
9392
self.bookImageView.image = image
9493
}.error { error -> Void in

0 commit comments

Comments
 (0)