Skip to content

Commit

Permalink
Merge pull request #232 from woowahan-techcamp/jw
Browse files Browse the repository at this point in the history
170829 기타 이슈 처리
  • Loading branch information
JuneBuug authored Aug 29, 2017
2 parents 029bc53 + b2c1795 commit ca7e1a7
Show file tree
Hide file tree
Showing 15 changed files with 156 additions and 176 deletions.
191 changes: 78 additions & 113 deletions iOSProject/pyunrihae/pyunrihae/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions iOSProject/pyunrihae/pyunrihae/DataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ class DataManager{
let storageRef = storage.reference(forURL: "gs://pyeonrehae.appspot.com")
let imagesRef = storageRef.child("images/" + autoId + ".jpeg")
var update = ["bad": 0, "useful": 0, "user": user, "user_image": user_image, "brand": brand, "category": category, "comment": review, "grade": grade, "price": priceLevel, "flavor": flavorLevel, "quantity": quantityLevel, "product_image": product_image,"p_id": p_id, "p_name": p_name, "p_price": p_price, "timestamp": today, "id": autoId] as [String : Any]
if let data = UIImageJPEGRepresentation(p_image, 0.3) {
if let data = UIImageJPEGRepresentation(p_image, 0.1) {
imagesRef.putData(data, metadata: nil, completion: {
(metadata, error) in
if error != nil { // 에러가 난 경우
Expand Down Expand Up @@ -563,7 +563,7 @@ class DataManager{
let storageRef = storage.reference(forURL: "gs://pyeonrehae.appspot.com")
let imagesRef = storageRef.child("images/" + user.id + ".jpeg")

if let data = UIImageJPEGRepresentation(profile, 0.3) {
if let data = UIImageJPEGRepresentation(profile, 0.1) {
imagesRef.putData(data, metadata: nil, completion: {
(metadata, error) in
if error != nil {
Expand Down
57 changes: 24 additions & 33 deletions iOSProject/pyunrihae/pyunrihae/Image.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,36 @@ class Image {
image.layer.cornerRadius = image.layer.frame.height/2
image.clipsToBounds = true
}
static func drawStar(numberOfPlaces: Double, grade_avg: Double, gradeLabel: UILabel, starView: UIView) {
static func drawStar(numberOfPlaces: Double, grade_avg: Double, gradeLabel: UILabel, starView: UIImageView) {
for sub in starView.subviews {
sub.removeFromSuperview()
}
let multiplier = pow(10.0, numberOfPlaces)
let grade = round(Double(grade_avg) * multiplier) / multiplier
gradeLabel.text = String(grade)
if grade - Double(Int(grade)) >= 0.5 {
let starImage = UIImage(named: "stars.png")
let cgImage = starImage?.cgImage
let croppedCGImage: CGImage = cgImage!.cropping(to: CGRect(x: (starImage?.size.width)! * 4 / 5, y: 10, width: (starImage?.size.width)!, height: starImage!.size.height))!
let uiImage = UIImage(cgImage: croppedCGImage)
let imageView = UIImageView(image: uiImage)
imageView.frame = CGRect(x: Int(grade) * 18 - 3, y: 0, width: 17, height: 15)
starView.addSubview(imageView)
for i in (Int(grade) + 1)..<5 {
let emptyStarImage = UIImage(named: "empty_star.png")
let imageView = UIImageView(image: emptyStarImage)
imageView.contentMode = .scaleAspectFit
imageView.frame = CGRect(x: i * 18 - 3, y: 0, width: 17, height: 15)
starView.addSubview(imageView)
}
} else{
for i in Int(grade)..<5 {
let emptyStarImage = UIImage(named: "empty_star.png")
let imageView = UIImageView(image: emptyStarImage)
imageView.contentMode = .scaleAspectFit
imageView.frame = CGRect(x: i * 18 - 3, y: 0, width: 17, height: 15)
starView.addSubview(imageView)
}
}
for i in 0..<Int(grade) {
let starImage = UIImage(named: "stars.png")
let cgImage = starImage?.cgImage
let croppedCGImage: CGImage = cgImage!.cropping(to: CGRect(x: 0, y: 10, width: (starImage?.size.width)! / 5, height: starImage!.size.height))!
let uiImage = UIImage(cgImage: croppedCGImage)
let imageView = UIImageView(image: uiImage)
imageView.frame = CGRect(x: i * 18, y: 0, width: 17, height: 15)
starView.addSubview(imageView)
starView.contentMode = .scaleAspectFit
if grade < 0.5 {
starView.image = UIImage(named: "star0.png")
} else if grade < 1.0 {
starView.image = UIImage(named: "star5.png")
} else if grade < 1.5 {
starView.image = UIImage(named: "star1.png")
} else if grade < 2.0 {
starView.image = UIImage(named: "star15.png")
} else if grade < 2.5 {
starView.image = UIImage(named: "star2.png")
} else if grade < 3.0 {
starView.image = UIImage(named: "star25.png")
} else if grade < 3.5 {
starView.image = UIImage(named: "star3.png")
} else if grade < 4.0 {
starView.image = UIImage(named: "star35.png")
} else if grade < 4.5 {
starView.image = UIImage(named: "star4.png")
} else if grade < 5.0 {
starView.image = UIImage(named: "star45.png")
} else if grade == 5.0 {
starView.image = UIImage(named: "star5.png")
}
}
}
22 changes: 15 additions & 7 deletions iOSProject/pyunrihae/pyunrihae/LikeProductViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,24 @@ class LikeProductViewController: UIViewController {
tableView.dataSource = self
NotificationCenter.default.addObserver(self, selector: #selector(getLikeProductList), name: NSNotification.Name("likeListChanged"), object: nil)
// Do any additional setup after loading the view.
let swipeRight = UISwipeGestureRecognizer(target: self, action: #selector(self.respondToSwipeGesture))
swipeRight.direction = UISwipeGestureRecognizerDirection.right
self.view.addGestureRecognizer(swipeRight)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func respondToSwipeGesture(gesture: UIGestureRecognizer) {
if let swipeGesture = gesture as? UISwipeGestureRecognizer {
switch swipeGesture.direction {
case UISwipeGestureRecognizerDirection.right: self.navigationController?.popToRootViewController(animated: true)
default: break
}
}
}
@IBAction func onTouchCloseButton(_ sender: Any) {
navigationController?.popViewController(animated: true)
dismiss(animated: true, completion: nil)
self.navigationController?.popToRootViewController(animated: true)
}
func getLikeProductList(){
likeProductList = []
Expand Down Expand Up @@ -74,12 +84,10 @@ extension LikeProductViewController: UITableViewDataSource, UITableViewDelegate
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if likeProductList.count > 0 {
let product = likeProductList[indexPath.row]
NotificationCenter.default.post(name: NSNotification.Name("showProduct"), object: self, userInfo: ["product" : product])
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "mainNavigationController") as! UINavigationController
self.present(vc, animated: true, completion: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "ProductDetailViewController") as! ProductDetailViewController
vc.productId = product.id
self.navigationController?.pushViewController(vc, animated: true)
}
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
}
}
4 changes: 1 addition & 3 deletions iOSProject/pyunrihae/pyunrihae/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ class MainViewController: UIViewController {
// Dispose of any resources that can be recreated.
}
func showLoginPopup(_ notification: Notification) {
if notification.userInfo?["validator"] as! Int == 0{
Pyunrihae.showLoginOptionPopup(_ : self)
}
Pyunrihae.showLoginOptionPopup(_ : self)
}
func showDetailProduct(_ notification: Notification) {
if notification.userInfo?["validator"] as! Int == 0{
Expand Down
4 changes: 2 additions & 2 deletions iOSProject/pyunrihae/pyunrihae/MypageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,12 @@ extension MypageViewController: UITableViewDataSource, UITableViewDelegate {
// 내가 찜한 상품 뷰
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "LikeProductViewController") as! LikeProductViewController
self.present(vc, animated: true, completion: nil)
self.navigationController?.pushViewController(vc, animated: true)
}
} else if indexPath.row == 1 {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "PyunrihaeInfoViewController") as! PyunrihaeInfoViewController
self.present(vc, animated: true, completion: nil)
self.navigationController?.pushViewController(vc, animated: true)
} else if indexPath.row == 2 {
if labelList[2] == "회원가입 / 로그인" {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
Expand Down
3 changes: 2 additions & 1 deletion iOSProject/pyunrihae/pyunrihae/Popup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ class Popup{
}
popup.btnsView.addSubview(btns)
view.addSubview(popup)
btns.validator = validator
btns.badBtn.isEnabled = false
btns.usefulBtn.isEnabled = false
Button.deleteBorder(btn: btns.usefulBtn)
Button.deleteBorder(btn: btns.badBtn)
DataManager.getReviewBy(id: review.id){ (review) in
btns.badNumLabel.text = String(review.bad)
btns.usefulNumLabel.text = String(review.useful)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class ProductDetailViewController: UIViewController {
NotificationCenter.default.addObserver(self, selector: #selector(reviewUpload), name: NSNotification.Name("reviewUpload"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(startUploading), name: NSNotification.Name("startUploading"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(showAllergy), name: NSNotification.Name("showAllergy"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(showLoginPopup), name: NSNotification.Name("showLoginPopup"), object: nil)
let tap = UITapGestureRecognizer(target: self, action: #selector(self.handleTap(_:)))
self.view.addGestureRecognizer(tap)
let swipeRight = UISwipeGestureRecognizer(target: self, action: #selector(self.respondToSwipeGesture))
Expand All @@ -65,6 +66,9 @@ class ProductDetailViewController: UIViewController {
}
}
}
func showLoginPopup(_ notification: Notification) {
Pyunrihae.showLoginOptionPopup(_ : self)
}
func handleTap(_ sender: UITapGestureRecognizer) { // 탭해주면 리뷰 작성 버튼 뜸
if hidden == true {
writingReviewBtn.isHidden = false
Expand Down Expand Up @@ -150,7 +154,7 @@ class ProductDetailViewController: UIViewController {
}
}
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) { // 밑으로 내리면 리뷰작성 버튼 사라지고, 올리면 다시 뜸
if velocity.y > 0 {
if velocity.y >= 0 {
if hidden == false {
hidden = true
UIView.animate(withDuration: 0.7, delay: 0, animations: {
Expand Down Expand Up @@ -231,7 +235,7 @@ extension ProductDetailViewController: UITableViewDataSource, UITableViewDelegat
var returnHeight : CGFloat = 0.0
if reviewList.count > 0 {
let row = indexPath.row - 2
let font = UIFont(name: "AppleSDGothicNeo-Thin", size: 13)
let font = UIFont(name: "AppleSDGothicNeo-Regular", size: 13)
let width = (tableView.superview?.frame.size.width)! - 110
let height = Label.heightForView(text: reviewList[row].comment, font: font!, width: width)
if reviewList[row].p_image != "" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class ProductReviewTableViewCell: UITableViewCell {
btns.backgroundColor = UIColor.white.withAlphaComponent(0)
btns.badBtn.isEnabled = false
btns.usefulBtn.isEnabled = false
Button.deleteBorder(btn: btns.usefulBtn)
Button.deleteBorder(btn: btns.badBtn)
DataManager.getReviewBy(id: review.id){ (review) in
btns.badNumLabel.text = String(review.bad)
btns.usefulNumLabel.text = String(review.useful)
Expand Down Expand Up @@ -74,7 +76,7 @@ class ProductReviewTableViewCell: UITableViewCell {
self.uploadedFoodImageBtn.isHidden = false
self.uploadedFoodImage.isHidden = false
self.detailReviewLabel.isHidden = false
self.reviewBoxView.frame.size.height = self.detailReviewLabel.frame.height + 135
self.reviewBoxView.frame.size.height = height + 135
self.uploadedImageLoading.startAnimating()
self.uploadedFoodImage.contentMode = .scaleAspectFill
self.uploadedFoodImage.clipsToBounds = true
Expand All @@ -89,7 +91,7 @@ class ProductReviewTableViewCell: UITableViewCell {
self.reviewBoxView.frame.size.height = 90
}else { // 사진만 없는 경우
self.detailReviewLabel.isHidden = false
self.reviewBoxView.frame.size.height = self.detailReviewLabel.frame.height + 90
self.reviewBoxView.frame.size.height = height + 90
self.commentTopConstraint.constant -= 60
}
}
Expand Down
16 changes: 11 additions & 5 deletions iOSProject/pyunrihae/pyunrihae/PyunrihaeInfoViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,24 @@
import UIKit
class PyunrihaeInfoViewController: UIViewController {
@IBAction func onTouchCloseBtn(_ sender: Any) {
navigationController?.popViewController(animated: true)
dismissKeyboard()
dismiss(animated: true, completion: nil)
self.navigationController?.popToRootViewController(animated: true)
}
override func viewDidLoad() {
super.viewDidLoad()
let swipeRight = UISwipeGestureRecognizer(target: self, action: #selector(self.respondToSwipeGesture))
swipeRight.direction = UISwipeGestureRecognizerDirection.right
self.view.addGestureRecognizer(swipeRight)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func dismissKeyboard() {
view.endEditing(true)
func respondToSwipeGesture(gesture: UIGestureRecognizer) {
if let swipeGesture = gesture as? UISwipeGestureRecognizer {
switch swipeGesture.direction {
case UISwipeGestureRecognizerDirection.right: self.navigationController?.popToRootViewController(animated: true)
default: break
}
}
}
}
4 changes: 4 additions & 0 deletions iOSProject/pyunrihae/pyunrihae/ReviewViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class ReviewViewController: UIViewController {
NotificationCenter.default.addObserver(self, selector: #selector(showDetailProduct), name: NSNotification.Name("showDetailProduct"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(reloadReview), name: NSNotification.Name("reloadReview"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(getReviewList), name: NSNotification.Name("getReviewList"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(showLoginPopup), name: NSNotification.Name("showLoginPopup"), object: nil)
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
Expand All @@ -59,6 +60,9 @@ class ReviewViewController: UIViewController {
self.tableView.reloadData()
}
}
func showLoginPopup(_ notification: Notification) {
Pyunrihae.showLoginOptionPopup(_ : self)
}
func showDetailProduct(_ notification: Notification) {
if notification.userInfo?["validator"] as! Int == 1{
let storyboard = UIStoryboard(name: "Main", bundle: nil)
Expand Down
1 change: 1 addition & 0 deletions iOSProject/pyunrihae/pyunrihae/TabBarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class TabBarViewController: UIViewController,NVActivityIndicatorViewable {
brandBtns[previousBrandIndex].isSelected = false
Button.select(btn: sender) // 선택된 버튼에 따라 뷰 보여주기
mainViewController.selectedBrandIndexFromTab = selectedBrandIndex // 선택된 브랜드 index를 main에 넘겨주기
mainViewController.reviewScrollView.contentOffset.x = 0
reviewViewController.selectedBrandIndexFromTab = selectedBrandIndex // 선택된 브랜드 index를 review 에 넘겨주기
reviewViewController.tableView.contentOffset.y = 0
rankingViewController.selectedBrandIndexFromTab = selectedBrandIndex // 선택된 브랜드 index를 ranking에 넘겨주기
Expand Down
4 changes: 2 additions & 2 deletions iOSProject/pyunrihae/pyunrihae/UsefulBadBtn.xib
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
</view>
</objects>
<resources>
<image name="bad.png" width="512" height="512"/>
<image name="useful.png" width="512" height="512"/>
<image name="bad.png" width="50" height="50"/>
<image name="useful.png" width="50" height="50"/>
</resources>
</document>
5 changes: 2 additions & 3 deletions iOSProject/pyunrihae/pyunrihae/UsefulBadBtnView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ class UsefulBadBtnView: UIView {
@IBOutlet weak var badNumLabel: UILabel!
var reviewList = [Review]()
var reviewId = ""
var validator = 0
@IBAction func tabUsefulBtn(_ sender: UIButton) {
if User.sharedInstance.email == "" {
NotificationCenter.default.post(name: NSNotification.Name("showLoginPopup"), object: self, userInfo: ["validator": validator])
NotificationCenter.default.post(name: NSNotification.Name("showLoginPopup"), object: self)
} else {
var reviewStatus = User.sharedInstance.review_like_list[reviewId]
let uid = User.sharedInstance.id
Expand Down Expand Up @@ -78,7 +77,7 @@ class UsefulBadBtnView: UIView {
}
@IBAction func tabBadBtn(_ sender: UIButton) {
if User.sharedInstance.email == "" {
NotificationCenter.default.post(name: NSNotification.Name("showLoginPopup"), object: self, userInfo: ["validator": validator])
NotificationCenter.default.post(name: NSNotification.Name("showLoginPopup"), object: self)
} else {
let uid = User.sharedInstance.id
var reviewStatus = User.sharedInstance.review_like_list[reviewId]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ class WritingReviewViewController: UIViewController, FusumaDelegate{
extension WritingReviewViewController: UITextViewDelegate {
func textViewDidBeginEditing(_ textView: UITextView) {
UIView.animate(withDuration: 1.0, delay: 0.0, usingSpringWithDamping: 3.0, initialSpringVelocity: 3.0, options: UIViewAnimationOptions.curveEaseInOut, animations: ({
self.scrollView.frame.origin.y = self.scrollView.contentOffset.y - 350
self.scrollView.frame.origin.y = -self.reviewTextView.frame.origin.y
self.scrollView.contentOffset.y = 0
self.detailReview.frame.size.height = UIScreen.main.bounds.size.height * 3 / 11
}), completion: nil)
addedImageView.isHidden = true
Expand Down

0 comments on commit ca7e1a7

Please sign in to comment.