Skip to content

Commit

Permalink
πŸ”€ feature/#129
Browse files Browse the repository at this point in the history
Feature/#129
  • Loading branch information
hansolnoh95 authored Dec 27, 2021
2 parents aa18dd0 + deb25dd commit 61ef74d
Show file tree
Hide file tree
Showing 45 changed files with 288 additions and 78 deletions.
4 changes: 2 additions & 2 deletions CA-PIN_IOS/CA-PIN_IOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,7 @@
BASE_URL = "http://3.37.75.200:6000";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 4;
CURRENT_PROJECT_VERSION = 5;
DEVELOPMENT_TEAM = VTJLBZ2Q3F;
INFOPLIST_FILE = "CA-PIN_IOS/Supports/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
Expand All @@ -1545,7 +1545,7 @@
BASE_URL = "http://3.37.75.200:6000";
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 4;
CURRENT_PROJECT_VERSION = 5;
DEVELOPMENT_TEAM = VTJLBZ2Q3F;
INFOPLIST_FILE = "CA-PIN_IOS/Supports/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
Expand Down
4 changes: 4 additions & 0 deletions CA-PIN_IOS/CA-PIN_IOS/Configuration/KeyChainStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ enum KeychainStorage {
static var userCafeTI: String {
return "userCafeTI"
}

static var nickname: String {
return "nickname"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import UIKit

import SnapKit
import Then
import SwiftKeychainWrapper

// MARK: - DetailReviewTableViewCell
class DetailReviewTableViewCell: UITableViewCell {
Expand Down Expand Up @@ -64,6 +65,7 @@ class DetailReviewTableViewCell: UITableViewCell {
override func prepareForReuse() {
super.prepareForReuse()
profileImageView.image = nil
reviewModel = nil
}
}

Expand Down Expand Up @@ -208,10 +210,57 @@ extension DetailReviewTableViewCell {

// μ„œν˜„μ΄κ°€ μΌμ–΄μš” ~
@objc func editButtonClicked() {
let reportPopUpVC = ReportReviewPopUpViewController()
reportPopUpVC.modalPresentationStyle = .overCurrentContext
reportPopUpVC.reviewId = self.reviewId
self.rootViewController?.present(reportPopUpVC, animated: translatesAutoresizingMaskIntoConstraints, completion: nil)
if let model = reviewModel {
if model.writer.nickname == KeychainWrapper.standard.string(forKey: KeychainStorage.nickname) {
let alertController: UIAlertController
alertController = UIAlertController(title: "리뷰 νŽΈμ§‘", message: nil, preferredStyle: .actionSheet)

let editAction: UIAlertAction
editAction = UIAlertAction(title: "리뷰 μˆ˜μ •", style: UIAlertAction.Style.default, handler: { (action: UIAlertAction) in
/// 리뷰 μˆ˜μ • 뷰둜 이동
let writeVC = WriteReviewViewController()
writeVC.titleContent = "λ¦¬λ·°μˆ˜μ •ν•˜κΈ°"
writeVC.confirmTitle = "λ¦¬λ·°μˆ˜μ •ν•˜κΈ°"
writeVC.content = (self.reviewModel?.content)!
writeVC.ratingValue = self.reviewModel!.rating
writeVC.reviewId = self.reviewModel!.id
if self.reviewModel?.imgs == [] {
for imagePath in (self.reviewModel!.imgs)! {
let image = UIImageView()
image.setImage(from: imagePath, UIImage(named: "capinLogo")!)
writeVC.canAccessImages.append((image.image)!)
}
}
writeVC.recommend = self.reviewModel?.recommend ?? []
self.rootViewController?.navigationController?.pushViewController(writeVC, animated: false)
})
let deleteAction: UIAlertAction
deleteAction = UIAlertAction(title: "리뷰 μ‚­μ œ", style: .destructive, handler: { (action: UIAlertAction) in
let deleteReviewVC = DeleteReviewViewController()
deleteReviewVC.modalPresentationStyle = .overCurrentContext
deleteReviewVC.reviewId = self.reviewModel?.id ?? ""
self.rootViewController?.present(deleteReviewVC, animated: false, completion: nil)
})

let cancelAction: UIAlertAction
cancelAction = UIAlertAction(title: "μ·¨μ†Œ", style: UIAlertAction.Style.cancel, handler: nil)

alertController.addAction(editAction)
alertController.addAction(deleteAction)
alertController.addAction(cancelAction)

alertController.view.tintColor = .maincolor1

self.rootViewController?.present(alertController, animated: true, completion: nil)

}
else {
let reportPopUpVC = ReportReviewPopUpViewController()
reportPopUpVC.modalPresentationStyle = .overCurrentContext
reportPopUpVC.reviewId = self.reviewId
self.rootViewController?.present(reportPopUpVC, animated: translatesAutoresizingMaskIntoConstraints, completion: nil)
}
}
}

// MARK: - General Helpers
Expand All @@ -226,7 +275,11 @@ extension DetailReviewTableViewCell {

func reviewDataBind(nickName: String, date: String, rating: Float, content: String, profileImg: String) {
titleLabel.setupLabel(text: nickName, color: .black, font: .notoSansKRMediumFont(fontSize: 12))
dateLabel.setupLabel(text: date, color: .gray4, font: .notoSansKRRegularFont(fontSize: 12))

let dateStringArray = date.split(separator: "T")
let dateString = String(dateStringArray[0])
let dateResult = dateString.replacingOccurrences(of: "-", with: ".")
dateLabel.setupLabel(text: dateResult, color: .gray4, font: .notoSansKRRegularFont(fontSize: 12))
ratingLabel.setupLabel(text: "\(rating)",
color: .pointcolorYellow,
font: .notoSansKRRegularFont(fontSize: 12))
Expand Down Expand Up @@ -331,7 +384,7 @@ extension DetailReviewTableViewCell: UICollectionViewDataSource {
photoCell.dataBind(imageName: reviewModel?.imgs?[indexPath.item], moreNumber: moreNumber)
photoCell.awakeFromNib()
if indexPath.item == 2 && moreNumber > 0 {
photoCell.photoImageView.isHidden = true
photoCell.alphaView.isHidden = false
photoCell.moreLabel.isHidden = false
}
return photoCell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ class PhotoCollectionViewCell: UICollectionViewCell {
// MARK: - Components
let containerView = UIView()
let photoImageView = UIImageView()
let alphaView = UIView()
let moreLabel = UILabel()
let alphaView = UIView().then {
$0.isHidden = true
}
let moreLabel = UILabel().then {
$0.isHidden = true
}

var rootViewController: UIViewController?

Expand All @@ -28,6 +32,12 @@ class PhotoCollectionViewCell: UICollectionViewCell {
self.backgroundColor = .clear
layout()
}

override func prepareForReuse() {
super.prepareForReuse()
alphaView.isHidden = true
moreLabel.isHidden = true
}

}

Expand All @@ -37,6 +47,7 @@ extension PhotoCollectionViewCell {
contentView.backgroundColor = .clear
layoutContainerView()
layoutPhotoImageView()
layoutAlphaView()
layoutMoreLabel()
}
func layoutContainerView() {
Expand All @@ -58,7 +69,6 @@ extension PhotoCollectionViewCell {
}
func layoutAlphaView() {
containerView.add(alphaView) {
$0.isHidden = true
$0.backgroundColor = .photoCover
$0.setRounded(radius: 5)
$0.snp.makeConstraints {
Expand All @@ -68,7 +78,6 @@ extension PhotoCollectionViewCell {
}
func layoutMoreLabel() {
alphaView.add(moreLabel) {
$0.isHidden = true
$0.snp.makeConstraints {
$0.center.equalToSuperview()
}
Expand All @@ -81,7 +90,7 @@ extension PhotoCollectionViewCell {
photoImageView.imageFromUrl(image, defaultImgPath: "")
}
moreLabel.setupLabel(text: "+\(moreNumber)",
color: .gray3,
color: .white,
font: .notoSansKRRegularFont(fontSize: 14))
}
func updateLayout() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ class CafeDetailViewController: UIViewController {
let cafeTitleLabel = UILabel()
let starImageView = UIImageView()
let starRatingLabel = UILabel()
let addressLabel = UILabel()
let addressLabel = UILabel().then {
$0.isUserInteractionEnabled = true
}

let tagCollectionView: UICollectionView = {
let layout = CollectionViewCenteredFlowLayout()
layout.scrollDirection = .vertical
Expand Down Expand Up @@ -100,6 +103,16 @@ class CafeDetailViewController: UIViewController {
)
}

private let emptyLabel = UILabel().then {
$0.setupLabel(
text: "아직 λ“±λ‘λœ 리뷰가 μ—†μ–΄μš”.\nκ°€μž₯ λ¨Όμ € 리뷰λ₯Ό μž‘μ„±ν•΄λ³΄μ„Έμš”.",
color: .gray4,
font: .notoSansKRRegularFont(fontSize: 14)
)
$0.isHidden = true
$0.numberOfLines = 2
}

let gradationBlackColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.3)
let gradationWhiteColor = UIColor(red: 1, green: 1, blue: 1, alpha: 0.3)

Expand All @@ -108,7 +121,7 @@ class CafeDetailViewController: UIViewController {
var threshold = true

let disposeBag = DisposeBag()
let reviewProvider = MoyaProvider<ReviewService>()
let reviewProvider = MoyaProvider<ReviewService>(plugins: [NetworkLoggerPlugin(verbose: true)])
let userProvider = MoyaProvider<UserService>(plugins: [NetworkLoggerPlugin(verbose: true)])
var cafeModel: CafeServerDetail?
var reviewModel: [ServerReview]?
Expand All @@ -127,6 +140,7 @@ class CafeDetailViewController: UIViewController {
var count160 = 0
var count218 = 0
var count240 = 0
var isInit = true


// MARK: - LifeCycles
Expand Down Expand Up @@ -154,6 +168,14 @@ class CafeDetailViewController: UIViewController {
super.updateViewConstraints()
self.reviewTableView.heightConstraint?.constant = self.reviewTableView.contentSize.height
}

override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
if isInit {
bottomView.layer.applyShadow(color: 0xC5C5C5.color, alpha: 0.1, x: 0, y: -4, blur: 4)
isInit = false
}
}
}

// MARK: - Extensions
Expand Down Expand Up @@ -587,6 +609,15 @@ extension CafeDetailViewController {
}
}

func layoutEmptyLabel() {
cafeScrollContainerView.add(emptyLabel) {
$0.snp.makeConstraints {
$0.centerX.equalToSuperview()
$0.top.equalTo(self.reviewTitleLabel.snp.bottom).offset(63)
}
}
}

// MARK: - General Helpers
func dataBind() {
if self.cafeModel?.img == nil {
Expand All @@ -599,7 +630,7 @@ extension CafeDetailViewController {
self.cafeTitleLabel.setupLabel(text: self.cafeModel?.name ?? "", color: .black, font: .notoSansKRMediumFont(fontSize: 26))
self.starRatingLabel.setupLabel(text: "\(self.cafeModel?.rating ?? 0)", color: .pointcolorYellow, font: .notoSansKRMediumFont(fontSize: 20))
self.addressLabel.setupLabel(text: self.cafeModel?.address ?? "", color: .gray4, font: .notoSansKRRegularFont(fontSize: 12))
self.instagramLabel.setupLabel(text: "@\(self.cafeModel?.instagram ?? "")", color: .gray4, font: .notoSansKRRegularFont(fontSize: 14))
self.instagramLabel.setupLabel(text: "\(self.cafeModel?.instagram ?? "")", color: .gray4, font: .notoSansKRRegularFont(fontSize: 14))
if let model = cafeModel {
var offdayString = ""
if let offday = model.offday {
Expand Down Expand Up @@ -628,6 +659,10 @@ extension CafeDetailViewController {
)
}
}
validateIsSaved()
}

func validateIsSaved() {
if let isSaved = isSaved {
if isSaved {
savePinView.backgroundColor = .pointcolor1
Expand All @@ -652,6 +687,10 @@ extension CafeDetailViewController {
let reviewGesutre = UITapGestureRecognizer()
reviewGesutre.addTarget(self, action: #selector(clickedWriteReviewButton))
reviewView.addGestureRecognizer(reviewGesutre)

let addressGesture = UITapGestureRecognizer()
addressGesture.addTarget(self, action: #selector(touchupAddressLabel))
addressLabel.addGestureRecognizer(addressGesture)
}

func register() {
Expand Down Expand Up @@ -680,13 +719,18 @@ extension CafeDetailViewController {
}
@objc func clickedEntireReviewButton() {
let entireVC = EntireReviewViewController()
entireVC.reviewModel = self.reviewModel!
self.navigationController?.pushViewController(entireVC, animated: false)
if let reviewModel = reviewModel {
entireVC.reviewModel = self.reviewModel!
self.navigationController?.pushViewController(entireVC, animated: false)
}
else {
showGrayToast(message: "리뷰가 μ—†μŠ΅λ‹ˆλ‹€.")
}
}
@objc func clickedAddPinButton() {
if let isSaved = isSaved {
if isSaved {
showGrayToast(message: "이미 μ €μž₯된 μΉ΄νŽ˜μž…λ‹ˆλ‹€.")
setupCategory()
}
else {
setupCategory()
Expand All @@ -698,6 +742,15 @@ extension CafeDetailViewController {
writeReviewVC.cafeId = (self.cafeModel?.id)!
self.navigationController?.pushViewController(writeReviewVC, animated: false)
}

@objc
private func touchupAddressLabel() {
if let text = addressLabel.text {
UIPasteboard.general.string = text
showGreenToast(message: "μ£Όμ†Œκ°€ λ³΅μ‚¬λ˜μ—ˆμŠ΅λ‹ˆλ‹€.")
}
}

func setupReviewData(cafeId: String) {
reviewProvider.rx.request(.reviewList(cafeId: cafeId))
.asObservable()
Expand All @@ -714,12 +767,21 @@ extension CafeDetailViewController {
self.reviewIdArray.append(self.reviewModel![i].id)
}
self.layout()
if let review = data.reviews {
self.emptyLabel.isHidden = true
self.reviewTableView.separatorStyle = .singleLine
}
self.tagCollectionView.reloadData()
self.reviewTableView.reloadData()
} catch {
print(error)
}
}
if response.statusCode == 204 {
self.emptyLabel.isHidden = false
self.layoutEmptyLabel()
self.reviewTableView.separatorStyle = .none
}
}, onError: { error in
print(error)
}, onCompleted: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ extension LoginViewController {
let decoder = JSONDecoder()
let data = try decoder.decode(ResponseType<LoginData>.self,
from: response.data)
if let loginData = data.loginData {
KeychainWrapper.standard.set(loginData.nickname, forKey: "nickname")
}
KeychainWrapper.standard.set(emailText, forKey: "loginEmail")
KeychainWrapper.standard.set(passwordText, forKey: "loginPassword")
KeychainWrapper.standard.set(data.loginData!.tokenAccess, forKey: "tokenAccess")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ extension SplashViewController {
let decoder = JSONDecoder()
let data = try decoder.decode(ResponseType<LoginData>.self,
from: response.data)
if let loginData = data.loginData {
KeychainWrapper.standard.set(loginData.nickname, forKey: "nickname")
}
KeychainWrapper.standard.set(ID, forKey: "loginEmail")
KeychainWrapper.standard.set(PW, forKey: "loginPassword")
KeychainWrapper.standard.set(data.loginData!.tokenAccess, forKey: "tokenAccess")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class PinPopupTableViewCell: UITableViewCell {
layout()
}


override func prepareForReuse() {
super.prepareForReuse()
selectbutton.isHidden = false
}
}

// MARK: - Extensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ class TermsGeneralTableViewCell: UITableViewCell {
// MARK: - Components
let containerView = UIView()
let titleLabel = UILabel()
let nextButton = UIButton()
let nextButton = UIButton().then {
$0.isUserInteractionEnabled = false
}

var titleText: String?

Expand Down
Loading

0 comments on commit 61ef74d

Please sign in to comment.