diff --git a/iOSProject/pyunrihae/pyunrihae/Base.lproj/Main.storyboard b/iOSProject/pyunrihae/pyunrihae/Base.lproj/Main.storyboard index 18278763..a67422a2 100644 --- a/iOSProject/pyunrihae/pyunrihae/Base.lproj/Main.storyboard +++ b/iOSProject/pyunrihae/pyunrihae/Base.lproj/Main.storyboard @@ -545,7 +545,7 @@ - + @@ -566,7 +566,7 @@ - + @@ -576,7 +576,7 @@ - + @@ -586,7 +586,7 @@ - + @@ -614,9 +614,9 @@ - + @@ -744,10 +744,10 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + @@ -2836,22 +2810,11 @@ - + - - + @@ -2900,26 +2863,28 @@ - - - + - - - - + + + + + + diff --git a/iOSProject/pyunrihae/pyunrihae/DataManager.swift b/iOSProject/pyunrihae/pyunrihae/DataManager.swift index e7453875..2bfa4229 100644 --- a/iOSProject/pyunrihae/pyunrihae/DataManager.swift +++ b/iOSProject/pyunrihae/pyunrihae/DataManager.swift @@ -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 { // 에러가 난 경우 @@ -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 { diff --git a/iOSProject/pyunrihae/pyunrihae/Image.swift b/iOSProject/pyunrihae/pyunrihae/Image.swift index bccae5db..dc31a393 100644 --- a/iOSProject/pyunrihae/pyunrihae/Image.swift +++ b/iOSProject/pyunrihae/pyunrihae/Image.swift @@ -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.. 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?) { - } } diff --git a/iOSProject/pyunrihae/pyunrihae/MainViewController.swift b/iOSProject/pyunrihae/pyunrihae/MainViewController.swift index c242c5f2..bbef468e 100644 --- a/iOSProject/pyunrihae/pyunrihae/MainViewController.swift +++ b/iOSProject/pyunrihae/pyunrihae/MainViewController.swift @@ -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{ diff --git a/iOSProject/pyunrihae/pyunrihae/MypageViewController.swift b/iOSProject/pyunrihae/pyunrihae/MypageViewController.swift index 036d5b8c..12de5751 100644 --- a/iOSProject/pyunrihae/pyunrihae/MypageViewController.swift +++ b/iOSProject/pyunrihae/pyunrihae/MypageViewController.swift @@ -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) diff --git a/iOSProject/pyunrihae/pyunrihae/Popup.swift b/iOSProject/pyunrihae/pyunrihae/Popup.swift index bd1d1329..f798179e 100644 --- a/iOSProject/pyunrihae/pyunrihae/Popup.swift +++ b/iOSProject/pyunrihae/pyunrihae/Popup.swift @@ -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) diff --git a/iOSProject/pyunrihae/pyunrihae/ProductDetailViewController.swift b/iOSProject/pyunrihae/pyunrihae/ProductDetailViewController.swift index c7e0f313..8ab3bf3d 100644 --- a/iOSProject/pyunrihae/pyunrihae/ProductDetailViewController.swift +++ b/iOSProject/pyunrihae/pyunrihae/ProductDetailViewController.swift @@ -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)) @@ -65,6 +66,9 @@ class ProductDetailViewController: UIViewController { } } } + func showLoginPopup(_ notification: Notification) { + Pyunrihae.showLoginOptionPopup(_ : self) + } func handleTap(_ sender: UITapGestureRecognizer) { // 탭해주면 리뷰 작성 버튼 뜸 if hidden == true { writingReviewBtn.isHidden = false @@ -150,7 +154,7 @@ class ProductDetailViewController: UIViewController { } } func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer) { // 밑으로 내리면 리뷰작성 버튼 사라지고, 올리면 다시 뜸 - if velocity.y > 0 { + if velocity.y >= 0 { if hidden == false { hidden = true UIView.animate(withDuration: 0.7, delay: 0, animations: { @@ -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 != "" { diff --git a/iOSProject/pyunrihae/pyunrihae/ProductReviewTableViewCell.swift b/iOSProject/pyunrihae/pyunrihae/ProductReviewTableViewCell.swift index 021e3d8a..be4905d7 100644 --- a/iOSProject/pyunrihae/pyunrihae/ProductReviewTableViewCell.swift +++ b/iOSProject/pyunrihae/pyunrihae/ProductReviewTableViewCell.swift @@ -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) @@ -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 @@ -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 } } diff --git a/iOSProject/pyunrihae/pyunrihae/PyunrihaeInfoViewController.swift b/iOSProject/pyunrihae/pyunrihae/PyunrihaeInfoViewController.swift index b42368ef..3e1f1120 100644 --- a/iOSProject/pyunrihae/pyunrihae/PyunrihaeInfoViewController.swift +++ b/iOSProject/pyunrihae/pyunrihae/PyunrihaeInfoViewController.swift @@ -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 + } + } } } diff --git a/iOSProject/pyunrihae/pyunrihae/ReviewViewController.swift b/iOSProject/pyunrihae/pyunrihae/ReviewViewController.swift index 5c9444d0..99ffd14f 100644 --- a/iOSProject/pyunrihae/pyunrihae/ReviewViewController.swift +++ b/iOSProject/pyunrihae/pyunrihae/ReviewViewController.swift @@ -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() { @@ -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) diff --git a/iOSProject/pyunrihae/pyunrihae/TabBarViewController.swift b/iOSProject/pyunrihae/pyunrihae/TabBarViewController.swift index dca37465..e482159e 100644 --- a/iOSProject/pyunrihae/pyunrihae/TabBarViewController.swift +++ b/iOSProject/pyunrihae/pyunrihae/TabBarViewController.swift @@ -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에 넘겨주기 diff --git a/iOSProject/pyunrihae/pyunrihae/UsefulBadBtn.xib b/iOSProject/pyunrihae/pyunrihae/UsefulBadBtn.xib index 0b2b414e..7f0e2e4b 100644 --- a/iOSProject/pyunrihae/pyunrihae/UsefulBadBtn.xib +++ b/iOSProject/pyunrihae/pyunrihae/UsefulBadBtn.xib @@ -130,7 +130,7 @@ - - + + diff --git a/iOSProject/pyunrihae/pyunrihae/UsefulBadBtnView.swift b/iOSProject/pyunrihae/pyunrihae/UsefulBadBtnView.swift index 3012ca52..de4052c5 100644 --- a/iOSProject/pyunrihae/pyunrihae/UsefulBadBtnView.swift +++ b/iOSProject/pyunrihae/pyunrihae/UsefulBadBtnView.swift @@ -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 @@ -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] diff --git a/iOSProject/pyunrihae/pyunrihae/WritingReviewViewController.swift b/iOSProject/pyunrihae/pyunrihae/WritingReviewViewController.swift index 794d3298..f29d381f 100644 --- a/iOSProject/pyunrihae/pyunrihae/WritingReviewViewController.swift +++ b/iOSProject/pyunrihae/pyunrihae/WritingReviewViewController.swift @@ -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