Skip to content

Commit

Permalink
fix: 고객 위치 정보 cell 반영 완료 #41
Browse files Browse the repository at this point in the history
  • Loading branch information
binisnil committed Feb 7, 2023
1 parent cba5f3c commit dc1f250
Show file tree
Hide file tree
Showing 19 changed files with 236 additions and 138 deletions.
8 changes: 4 additions & 4 deletions FITI-Trainer-iOS/FITI-Trainer-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
05A11DF8296F1570008D85A9 /* PreviewReviewTableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05A11DF7296F1570008D85A9 /* PreviewReviewTableCell.swift */; };
05A11DFA296F157E008D85A9 /* ReviewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05A11DF9296F157E008D85A9 /* ReviewModel.swift */; };
05A11DFC296F1589008D85A9 /* BottomPhotoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05A11DFB296F1589008D85A9 /* BottomPhotoView.swift */; };
05A11DFE296F1596008D85A9 /* BookCVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05A11DFD296F1596008D85A9 /* BookCVC.swift */; };
05A11DFE296F1596008D85A9 /* BottomCVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05A11DFD296F1596008D85A9 /* BottomCVC.swift */; };
05A11E01296F172F008D85A9 /* Then in Frameworks */ = {isa = PBXBuildFile; productRef = 05A11E00296F172F008D85A9 /* Then */; };
05A11E03296F17A0008D85A9 /* UIView+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05A11E02296F17A0008D85A9 /* UIView+.swift */; };
05A11E06296F1B99008D85A9 /* ReviewTableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05A11E05296F1B99008D85A9 /* ReviewTableCell.swift */; };
Expand Down Expand Up @@ -232,7 +232,7 @@
05A11DF7296F1570008D85A9 /* PreviewReviewTableCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviewReviewTableCell.swift; sourceTree = "<group>"; };
05A11DF9296F157E008D85A9 /* ReviewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReviewModel.swift; sourceTree = "<group>"; };
05A11DFB296F1589008D85A9 /* BottomPhotoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BottomPhotoView.swift; sourceTree = "<group>"; };
05A11DFD296F1596008D85A9 /* BookCVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookCVC.swift; sourceTree = "<group>"; };
05A11DFD296F1596008D85A9 /* BottomCVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BottomCVC.swift; sourceTree = "<group>"; };
05A11E02296F17A0008D85A9 /* UIView+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+.swift"; sourceTree = "<group>"; };
05A11E05296F1B99008D85A9 /* ReviewTableCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReviewTableCell.swift; sourceTree = "<group>"; };
05A11E07296F1BB6008D85A9 /* ReviewViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReviewViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -427,7 +427,7 @@
059D80752972B7820062C41A /* BottomPhoto */ = {
isa = PBXGroup;
children = (
05A11DFD296F1596008D85A9 /* BookCVC.swift */,
05A11DFD296F1596008D85A9 /* BottomCVC.swift */,
05A11DFB296F1589008D85A9 /* BottomPhotoView.swift */,
);
path = BottomPhoto;
Expand Down Expand Up @@ -947,7 +947,7 @@
059D80A02973F56F0062C41A /* SearchTVC.swift in Sources */,
05A11DDB296DBA6E008D85A9 /* CommunityViewController.swift in Sources */,
058403B32986E73F002272B1 /* GetTrainerInfoModel.swift in Sources */,
05A11DFE296F1596008D85A9 /* BookCVC.swift in Sources */,
05A11DFE296F1596008D85A9 /* BottomCVC.swift in Sources */,
05A11DE5296DEBF8008D85A9 /* PriceStackView.swift in Sources */,
0584038A298296DE002272B1 /* SignUpModel.swift in Sources */,
05A11DD0296DB5EF008D85A9 /* SignInViewController.swift in Sources */,
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ChatTableCell: UITableViewCell {

private lazy var reviewerImage : UIImageView = {
let imgView = UIImageView()
imgView.image = UIImage(named: "profile.svg")
imgView.image = UIImage(named: "customerProfile1.svg")
imgView.snp.makeConstraints { make in
make.height.equalTo(34)
make.width.equalTo(20)
Expand Down Expand Up @@ -111,15 +111,12 @@ extension ChatTableCell{
date.text = model.createdAt.substring(from: 0, to: 9)
id = model.matchingId
pickUp.text = model.pickUp
location.text = model.customerLocation ?? "제가 갈게요"


//MARK: - 트레이너 위치 받아오는 api 추가되면,
// if(model.customerLocation == "고객이 갈게요"){
// location.text = model.trainerLocation ?? "설정된 위치가 없습니다."
// } else{
// location.text = model.customerLocation ?? "설정된 위치가 없습니다."
// }
if(model.pickUp == "트레이너가 갈게요"){
location.text = model.customerLocation ?? "설정된 위치가 없습니다."
} else{
location.text = model.trainerLocation ?? "설정된 위치가 없습니다."
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class CommunityTableCell: UITableViewCell {

var reviewerImage : UIImageView = {
let imgView = UIImageView()
imgView.image = UIImage(named: "profile.svg")
imgView.image = UIImage(named: "customerProfile1.svg")
imgView.snp.makeConstraints { make in
make.height.equalTo(25.71)
make.width.equalTo(15)
Expand Down Expand Up @@ -90,6 +90,7 @@ extension CommunityTableCell{
name.text = model.name
// date.text = model.orderDate
id = model.matchingId
reviewerImage.image = UIImage(named: "\(model.profile).svg")
if(model.pickUpType == "TRAINER_GO"){
pickUpStyle.text = "트레이너님이 와주세요."
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class EditPhotoViewController: UIViewController {
var itemProviders: [NSItemProvider] = []
static var imageArray : [UIImage] = []
static var imageStringArray : [String] = []
let imageProvider = MoyaProvider<EditProfileServices>()
let ectImageProvider = MoyaProvider<EditProfileServices>()

// var bottomPhotoView = BottomPhotoView()

Expand Down Expand Up @@ -115,6 +115,7 @@ class EditPhotoViewController: UIViewController {

@objc func backTapped(sender: UIBarButtonItem) {
// self.postImageServer()
self.postEctImageServer(imageArray: EditPhotoViewController.imageArray)
navigationController?.popViewController(animated: true)
}

Expand Down Expand Up @@ -232,6 +233,26 @@ extension EditPhotoViewController: PHPickerViewControllerDelegate{
}
}
}
}
}
}

//MARK: - set Server
extension EditPhotoViewController{
func postEctImageServer(imageArray: [UIImage]){
ectImageProvider.request(.uploadEctImage(param: imageArray)) { response in
switch response{
case .success(let moyaResponse):
do{
print("EditPhotoVC - postEctImageServer ==============================================================")
let image = try JSONDecoder().decode(AddBottomImageResponse.self, from: moyaResponse.data)
print(image)
} catch(let err){
print(err.localizedDescription)
}
case .failure(let err):
print(err.localizedDescription)
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class TrainerDetailViewController: UIViewController {
// imageDecoding()
getTrainerServer()
changeBackAlertEvent()

changeProfileAlertEvent()
// print("====================================================")
// let backImg = UIImage(named: "blueScreen.svg")
// let imageData:NSData = backImg!.pngData()! as NSData
Expand All @@ -108,7 +108,6 @@ class TrainerDetailViewController: UIViewController {

override func viewWillAppear(_ animated: Bool) {
setServerDate()
// imageDecoding()
getTrainerServer()
bottomPhotoView.editerChoiceCV.reloadData()
}
Expand All @@ -121,6 +120,7 @@ class TrainerDetailViewController: UIViewController {
bodyIntroView.editBodyIntroButton.addTarget(self, action: #selector(editBodyIntroBtnEvent), for: .touchUpInside)
bodyIntroAboutService.editAboutServiceButton.addTarget(self, action: #selector(editAboutServiceBtnEvent), for: .touchUpInside)
bottomPhotoView.editPhotoButton.addTarget(self, action: #selector(editPhotoBtnEvent), for: .touchUpInside)
headView.reviewerImage.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.tappedProfile)))
}

func setViewLayer(){
Expand Down Expand Up @@ -178,7 +178,8 @@ class TrainerDetailViewController: UIViewController {
self.openBackAlbum() // 아래에서 설명 예정.
}
let normalImgAlertAction = UIAlertAction(title: "기본 이미지로 변경", style: .default) {(action) in
self.changeBackNormal() // 아래에서 설명 예정.
self.changeBackNormal()
self.patchBackgroundImage(image: UIImage(named: "blueScreen.svg")!)
}
let cancelAlertAction = UIAlertAction(title: "취소", style: .cancel, handler: nil)
self.backAlertController.addAction(photoLibraryAlertAction)
Expand All @@ -196,21 +197,61 @@ class TrainerDetailViewController: UIViewController {
present(self.imagePicker, animated: true, completion: nil)
}

func openProfileAlbum() {
// headView의 image에 대한 delegate는 headView의 image 선언부에 존재한다.
headView.imagePicker.allowsEditing = true
present(headView.imagePicker, animated: true, completion: nil)
}

@objc func tappedProfileTest(tapGestureRecognizer: UITapGestureRecognizer) {
print("akjfak;jfkasjflkasdklfjasdk;fjas;kldfaklsdfjklasdflkjasdf;jkasdfkjas;kdfjaskdfjjalskdf")

}

func changeProfileNormal() {
headView.reviewerImage.image = UIImage(named: "reviewerIcon.svg")

}

let profileAlertController = UIAlertController(title: "프로필 이미지 변경", message: "사진 앨범에서 선택 또는 기본 이미지", preferredStyle: .actionSheet)

func changeProfileAlertEvent() {
let photoLibraryAlertAction = UIAlertAction(title: "앨범에서 선택", style: .default) {
(action) in
self.openProfileAlbum() // 아래에서 설명 예정.
}
let normalImgAlertAction = UIAlertAction(title: "기본 이미지로 변경", style: .default) {(action) in
self.changeProfileNormal() // 아래에서 설명 예정.
}
let cancelAlertAction = UIAlertAction(title: "취소", style: .cancel, handler: nil)
self.profileAlertController.addAction(photoLibraryAlertAction)
self.profileAlertController.addAction(normalImgAlertAction)
self.profileAlertController.addAction(cancelAlertAction)
guard let alertControllerPopoverPresentationController
= profileAlertController.popoverPresentationController
else {return}
prepareForPopoverPresentation(alertControllerPopoverPresentationController)
}

func changeBackNormal() {
topView.image = UIImage(named: "blueScreen.svg")
}


@objc func tappedEditBtn(_ gesture: UITapGestureRecognizer) {
@objc func tappedEditBtn() {
self.present(backAlertController, animated: true, completion: nil)
}

@objc func tappedProfile(_ sender: UITapGestureRecognizer) {
print("klsjfakl;sfj;asdl")
self.present(profileAlertController, animated: true, completion: nil)
}

}

//MARK: - Extension

extension TrainerDetailViewController {

func setLayout() {

//MARK: addSubViews
Expand Down Expand Up @@ -340,19 +381,6 @@ extension TrainerDetailViewController {

return setCategory
}

// func imageDecoding() {
// switch TrainerDetailViewController.userInfo.backGround {
// case "blueScreen":
// self.topView.image = setBackGround
//
// default:
// let dataDecoded:NSData = NSData(base64Encoded: TrainerDetailViewController.userInfo.backGround, options: NSData.Base64DecodingOptions.ignoreUnknownCharacters)!
// let decodedimage:UIImage = UIImage(data: dataDecoded as Data)!
// print(decodedimage)
// self.topView.image = decodedimage
// }
// }
}

//MARK: - ServerData
Expand Down Expand Up @@ -391,6 +419,24 @@ extension TrainerDetailViewController{

}
}

func patchBackgroundImage(image: UIImage){
profileInfoProvider.request(.uploadBackground(param: image)) { response in
switch response{
case .success(let moyaResponse):
do{
print("TrainerDetailVC - patchBackgroundImage ==============================================================")
let image = try JSONDecoder().decode(ChangeProfileResponse.self, from: moyaResponse.data)
print(image)
} catch(let err){
print(err.localizedDescription)
}
case .failure(let err):
print(err.localizedDescription)

}
}
}
}

//MARK: - UIImagePicker Delegate
Expand All @@ -402,42 +448,7 @@ extension TrainerDetailViewController: UIImagePickerControllerDelegate, UINaviga
if let image = info[UIImagePickerController.InfoKey(rawValue: "UIImagePickerControllerEditedImage")] as? UIImage {
// topView.contentMode = .scaleAspectFit
topView.image = image

//MARK: - UIImage to String -> Encoding


let imageData:NSData = image.pngData()! as NSData
let strBase64:String = imageData.base64EncodedString(options: .endLineWithLineFeed)

// print(strBase64)
// print("================================")

// let param = ChangeBackgroundRequest(backgroundImage: strBase64)
// profileInfoProvider.request(.changeBackground(param: str)) { response in
// switch response {
// case .success(let moyaResponse):
// do{
// print("success")
// let responseData = try moyaResponse.map(ChangeBackgroundResponse.self)
//// let responseData = try moyaResponse.map(ChangeBackgroundResponse.self)
//
// } catch(let err) {
//
// print(err.localizedDescription)
// }
// case .failure(let err):
// print(err.localizedDescription)
//
// }
//
// }
// print(strBase64)

//MARK: - String to UIImage -> Decoding
let dataDecoded:NSData = NSData(base64Encoded: strBase64, options: NSData.Base64DecodingOptions.ignoreUnknownCharacters)!
let decodedimage:UIImage = UIImage(data: dataDecoded as Data)!
print(decodedimage)
topView.image = decodedimage
patchBackgroundImage(image: image)
}

func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import UIKit
import SnapKit
import Then

class BookCVC: UICollectionViewCell {
class BottomCVC: UICollectionViewCell {

static let identifier = "CustomCollectionCell"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class BottomPhotoView: UIView {
setViewHierarchy()
setLayout()
editerChoiceCV.backgroundColor = .clear
editerChoiceCV.register(BookCVC.self, forCellWithReuseIdentifier: BookCVC.identifier)
editerChoiceCV.register(BottomCVC.self, forCellWithReuseIdentifier: BottomCVC.identifier)
editerChoiceCV.delegate = self
editerChoiceCV.dataSource = self
editerChoiceCV.showsHorizontalScrollIndicator = false
Expand Down Expand Up @@ -136,7 +136,7 @@ extension BottomPhotoView: UICollectionViewDelegate, UICollectionViewDataSource{
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = editerChoiceCV.dequeueReusableCell(withReuseIdentifier: BookCVC.identifier, for: indexPath) as! BookCVC
let cell = editerChoiceCV.dequeueReusableCell(withReuseIdentifier: BottomCVC.identifier, for: indexPath) as! BottomCVC
cell.layer.cornerRadius = 10
cell.layer.masksToBounds = true
cell.editerChoiceImageView.image = EditPhotoViewController.imageArray[indexPath.row]
Expand Down
Loading

0 comments on commit dc1f250

Please sign in to comment.