diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..4bb211d3 Binary files /dev/null and b/.DS_Store differ diff --git a/fit-a-pet-client/.DS_Store b/fit-a-pet-client/.DS_Store index 8c9697ee..fffbc298 100644 Binary files a/fit-a-pet-client/.DS_Store and b/fit-a-pet-client/.DS_Store differ diff --git a/fit-a-pet-client/fit-a-pet-client.xcodeproj/project.pbxproj b/fit-a-pet-client/fit-a-pet-client.xcodeproj/project.pbxproj index 3ec95dc8..5a8d2615 100644 --- a/fit-a-pet-client/fit-a-pet-client.xcodeproj/project.pbxproj +++ b/fit-a-pet-client/fit-a-pet-client.xcodeproj/project.pbxproj @@ -37,6 +37,7 @@ 4ACDD4A52AD9B3DC00CD8F1A /* InputGenderVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4ACDD4A42AD9B3DC00CD8F1A /* InputGenderVC.swift */; }; 4ACDD4A72AD9B3F600CD8F1A /* CheckCareVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4ACDD4A62AD9B3F600CD8F1A /* CheckCareVC.swift */; }; 4ACDD4A92ADAFFD100CD8F1A /* InputPetBirthVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4ACDD4A82ADAFFD100CD8F1A /* InputPetBirthVC.swift */; }; + 4AD0896A2AFBFD9400E79E52 /* CheckCareCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AD089692AFBFD9400E79E52 /* CheckCareCollectionViewCell.swift */; }; 4AD354152AACD390004A47B3 /* LoginVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AD354142AACD390004A47B3 /* LoginVC.swift */; }; 4AD354202AAF7CD6004A47B3 /* MainVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AD3541F2AAF7CD6004A47B3 /* MainVC.swift */; }; 4AD354222AAF7E62004A47B3 /* TabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AD354212AAF7E62004A47B3 /* TabBarController.swift */; }; @@ -81,6 +82,7 @@ 4ACDD4A42AD9B3DC00CD8F1A /* InputGenderVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputGenderVC.swift; sourceTree = ""; }; 4ACDD4A62AD9B3F600CD8F1A /* CheckCareVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckCareVC.swift; sourceTree = ""; }; 4ACDD4A82ADAFFD100CD8F1A /* InputPetBirthVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputPetBirthVC.swift; sourceTree = ""; }; + 4AD089692AFBFD9400E79E52 /* CheckCareCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckCareCollectionViewCell.swift; sourceTree = ""; }; 4AD354142AACD390004A47B3 /* LoginVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginVC.swift; sourceTree = ""; }; 4AD3541F2AAF7CD6004A47B3 /* MainVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainVC.swift; sourceTree = ""; }; 4AD354212AAF7E62004A47B3 /* TabBarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarController.swift; sourceTree = ""; }; @@ -172,6 +174,7 @@ isa = PBXGroup; children = ( 4A9088752AC1681B000C7878 /* PetCollectViewCell.swift */, + 4AD089692AFBFD9400E79E52 /* CheckCareCollectionViewCell.swift */, ); path = View; sourceTree = ""; @@ -410,6 +413,7 @@ 4AD354152AACD390004A47B3 /* LoginVC.swift in Sources */, 4A15F2162AA8B4CA0098F2F7 /* InputNickVC.swift in Sources */, 4ACDD4A12AD9B37E00CD8F1A /* InputSpeciesVC.swift in Sources */, + 4AD0896A2AFBFD9400E79E52 /* CheckCareCollectionViewCell.swift in Sources */, 4ACDD49E2AD9ACC400CD8F1A /* PetModel.swift in Sources */, 4A8B9B462AD443C9009236EC /* AlamofireManager.swift in Sources */, 4A15F20B2AA799C50098F2F7 /* ConstomLabel.swift in Sources */, diff --git a/fit-a-pet-client/fit-a-pet-client.xcworkspace/xcuserdata/maclove.xcuserdatad/UserInterfaceState.xcuserstate b/fit-a-pet-client/fit-a-pet-client.xcworkspace/xcuserdata/maclove.xcuserdatad/UserInterfaceState.xcuserstate index e7588e21..21d3e291 100644 Binary files a/fit-a-pet-client/fit-a-pet-client.xcworkspace/xcuserdata/maclove.xcuserdatad/UserInterfaceState.xcuserstate and b/fit-a-pet-client/fit-a-pet-client.xcworkspace/xcuserdata/maclove.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/fit-a-pet-client/fit-a-pet-client/Base.lproj/Main.storyboard b/fit-a-pet-client/fit-a-pet-client/Base.lproj/Main.storyboard index 5e9723e5..6cf42b5f 100644 --- a/fit-a-pet-client/fit-a-pet-client/Base.lproj/Main.storyboard +++ b/fit-a-pet-client/fit-a-pet-client/Base.lproj/Main.storyboard @@ -40,82 +40,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/fit-a-pet-client/fit-a-pet-client/Model/PetModel.swift b/fit-a-pet-client/fit-a-pet-client/Model/PetModel.swift index 365ae85c..9289d7b0 100644 --- a/fit-a-pet-client/fit-a-pet-client/Model/PetModel.swift +++ b/fit-a-pet-client/fit-a-pet-client/Model/PetModel.swift @@ -1,8 +1,18 @@ -// -// PetModel.swift -// fit-a-pet-client -// -// Created by 최희진 on 2023/10/14. -// -import Foundation + +struct PetModel{ + let id: Int + let pet_name: String + let gender: String + //let birth: Date + let age: Int + let species: String +} + +class PetDataStorage { + static var petList: [PetModel] = [] + + static func addPer(pet: PetModel) { + petList.append(pet) + } +} diff --git a/fit-a-pet-client/fit-a-pet-client/Model/UserModel.swift b/fit-a-pet-client/fit-a-pet-client/Model/UserModel.swift index a5ced7e3..7bca7896 100644 --- a/fit-a-pet-client/fit-a-pet-client/Model/UserModel.swift +++ b/fit-a-pet-client/fit-a-pet-client/Model/UserModel.swift @@ -10,12 +10,6 @@ struct UserModel{ let profile_img: UIImage } -//extension UserModel{ -// static let list: [UserModel] = [ -// UserModel(id: 1, uid: "heejin", pw: "heejin123", phone: 01012341234, email: "fit@example.com", profile_img: UIImage(systemName: "person")!) -// ] -//} - class CentralDataStorage { static var userList: [UserModel] = [] diff --git a/fit-a-pet-client/fit-a-pet-client/Utils/KeyChainHelper.swift b/fit-a-pet-client/fit-a-pet-client/Utils/KeyChainHelper.swift index 418c95cd..1128c12a 100644 --- a/fit-a-pet-client/fit-a-pet-client/Utils/KeyChainHelper.swift +++ b/fit-a-pet-client/fit-a-pet-client/Utils/KeyChainHelper.swift @@ -10,7 +10,7 @@ class KeychainHelper { ] let status = SecItemAdd(keychainQuery as CFDictionary, nil) - if status == errSecDuplicateItem { + if status == errSecDuplicateItem {//값이 존재한다면 새로운 값으로 업데이트 SecItemUpdate(keychainQuery as CFDictionary, [kSecValueData: accessToken.data(using: .utf8)!] as CFDictionary) } else if status != noErr { print("Failed to save AccessToken to Keychain") diff --git a/fit-a-pet-client/fit-a-pet-client/View/CheckCareCollectionViewCell.swift b/fit-a-pet-client/fit-a-pet-client/View/CheckCareCollectionViewCell.swift new file mode 100644 index 00000000..15ec87df --- /dev/null +++ b/fit-a-pet-client/fit-a-pet-client/View/CheckCareCollectionViewCell.swift @@ -0,0 +1,41 @@ + +import UIKit + +class CheckCareCollectionViewCell: UICollectionViewCell { + + let careName = UILabel() + + override init(frame: CGRect) { + super.init(frame: frame) + + contentView.addSubview(careName) + careName.font = UIFont.systemFont(ofSize: 14.0) + careName.adjustsFontSizeToFitWidth = true // 텍스트 크기를 셀에 맞게 조절 + careName.textAlignment = .center // 가운데 정렬 + + careName.snp.makeConstraints { make in + make.edges.equalTo(contentView).inset(UIEdgeInsets(top: 5, left: 5, bottom: 5, right: 5)) // 여백 없이 가득 채우도록 설정 + } + } + + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + func configure(_ name: String) { + careName.text = name + } + + override var isSelected: Bool { + didSet { + if isSelected { + contentView.backgroundColor = UIColor(named: "Secondary") + + careName.textColor = UIColor(named: "PrimaryColor") + } else { + contentView.backgroundColor = UIColor.clear + careName.textColor = UIColor.black + } + } + } +} diff --git a/fit-a-pet-client/fit-a-pet-client/ViewControllers/RegistPet/CheckCareVC.swift b/fit-a-pet-client/fit-a-pet-client/ViewControllers/RegistPet/CheckCareVC.swift index d98b3e12..fbe84a17 100644 --- a/fit-a-pet-client/fit-a-pet-client/ViewControllers/RegistPet/CheckCareVC.swift +++ b/fit-a-pet-client/fit-a-pet-client/ViewControllers/RegistPet/CheckCareVC.swift @@ -3,23 +3,34 @@ import UIKit import SnapKit import Alamofire -//TODO: CollectionView 추가 class CheckCareVC : UIViewController { - let nextBirthBtn = CustomNextBtn(title: "반려동물 등록하기") + let registCompleteBtn = CustomNextBtn(title: "반려동물 등록하기") let progressBar = CustomProgressBar.shared let customLabel = ConstomLabel() + let checkCareCollectionView: UICollectionView = { + let layout = UICollectionViewFlowLayout() + layout.minimumLineSpacing = 20 + layout.scrollDirection = .vertical + layout.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) + + let cv = UICollectionView(frame: .zero, collectionViewLayout: layout) + cv.register(CheckCareCollectionViewCell.self, forCellWithReuseIdentifier: "CheckCareCollectionViewCell") // Cell 등록 + return cv + }() + + let careList = ["밥", "목욕", "산책", "간식","약복용"] + override func viewDidLoad() { super.viewDidLoad() initView() + collectionViewInit() - //nextBirthBtn.addTarget(self, action: #selector(changeInputPetBirthVC(_:)), for: .touchUpInside) } private func initView(){ - //titleView 만들기 let titleLabel = UILabel() titleLabel.text = "반려동물 등록하기" titleLabel.textColor = .black @@ -31,7 +42,7 @@ class CheckCareVC : UIViewController { self.navigationItem.titleView = titleView - self.view.addSubview(nextBirthBtn) + self.view.addSubview(registCompleteBtn) self.view.addSubview(customLabel) view.backgroundColor = .white @@ -57,13 +68,29 @@ class CheckCareVC : UIViewController { make.left.equalTo(view.snp.left).offset(16) } - nextBirthBtn.snp.makeConstraints{make in + registCompleteBtn.snp.makeConstraints{make in make.bottom.equalTo(view.snp.bottom).offset(-65) make.left.equalTo(view.snp.left).offset(16) make.right.equalTo(view.snp.right).offset(-16) } } + + private func collectionViewInit(){ + checkCareCollectionView.allowsMultipleSelection = true//여러개 선택 가능 + + checkCareCollectionView.delegate = self + checkCareCollectionView.dataSource = self + + self.view.addSubview(checkCareCollectionView) + + checkCareCollectionView.snp.makeConstraints{make in + make.top.equalTo(customLabel.snp.bottom).offset(30) + make.left.equalTo(view.snp.left).offset(16) + make.right.equalTo(view.snp.right).offset(-16) + make.bottom.equalTo(registCompleteBtn.snp.top).offset(-10) + } + } private func progressBarInit(){ @@ -88,12 +115,51 @@ class CheckCareVC : UIViewController { } } -// @objc func changeInputPetBirthVC(_ sender: UIButton){ -// let nextVC = InputPetBirthVC() -// self.navigationController?.pushViewController(nextVC, animated: false) -// } + +} + +extension CheckCareVC: UICollectionViewDataSource{ + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return careList.count + } + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CheckCareCollectionViewCell", for: indexPath) as! CheckCareCollectionViewCell + let data = careList[indexPath.item] + cell.configure(data) + + cell.layer.borderWidth = 1 + cell.layer.borderColor = UIColor(named: "Gray2")?.cgColor + cell.layer.cornerRadius = 5 + + return cell + } +} + +extension CheckCareVC: UICollectionViewDelegate { + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + let cell = collectionView.cellForItem(at: indexPath) as? CheckCareCollectionViewCell + cell?.isSelected = true + cell!.layer.borderColor = UIColor(named: "PrimaryColor")?.cgColor + } + + func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) { + let cell = collectionView.cellForItem(at: indexPath) as? CheckCareCollectionViewCell + cell?.isSelected = false + cell!.layer.borderColor = UIColor(named: "Gray2")?.cgColor + } } +extension CheckCareVC: UICollectionViewDelegateFlowLayout { + + //텍스트의 크기에 따라 셀의 크기 지정 + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + + return CGSize(width: 165, height: 55) // 원하는 높이로 설정 + } +} + + + diff --git a/fit-a-pet-client/fit-a-pet-client/ViewControllers/RegistPet/InputPetBirthVC.swift b/fit-a-pet-client/fit-a-pet-client/ViewControllers/RegistPet/InputPetBirthVC.swift index f80ab39d..d6ebcd31 100644 --- a/fit-a-pet-client/fit-a-pet-client/ViewControllers/RegistPet/InputPetBirthVC.swift +++ b/fit-a-pet-client/fit-a-pet-client/ViewControllers/RegistPet/InputPetBirthVC.swift @@ -13,6 +13,10 @@ class InputPetBirthVC : UIViewController { let agecheckboxButton = UIButton() let agecheckLabel = UILabel() + let ageInputStackView = UIStackView() + let ageInputField = UITextField() + let ageLabel = UILabel() + let progressBar = CustomProgressBar.shared let customLabel = ConstomLabel() @@ -24,6 +28,7 @@ class InputPetBirthVC : UIViewController { setupTextField() setupTapGestureRecognizer() setupAgeStakView() + setupAgeInputStackView() nextCheckCareBtn.addTarget(self, action: #selector(changeCheckCareVC(_:)), for: .touchUpInside) } @@ -50,7 +55,7 @@ class InputPetBirthVC : UIViewController { let attributedText = NSMutableAttributedString(string: text) let boldFont = UIFont.boldSystemFont(ofSize: 20) - let range = (text as NSString).range(of: "이름") + let range = (text as NSString).range(of: "생일") attributedText.addAttribute(.font, value: boldFont, range: range) @@ -147,6 +152,48 @@ class InputPetBirthVC : UIViewController { } } + private func setupAgeInputStackView(){ + + ageInputStackView.axis = .horizontal + ageInputStackView.spacing = 20 + ageInputStackView.alignment = .center + ageInputStackView.distribution = .fillProportionally + + ageInputField.placeholder = "1" + ageInputField.font = UIFont.systemFont(ofSize: 14) + ageInputField.layer.borderWidth = 1 + ageInputField.layer.cornerRadius = 5 + ageInputField.layer.borderColor = UIColor(named: "Gray2")?.cgColor + ageInputField.leftView = UIView(frame: CGRect(x: 0.0, y: 0.0, width: 16.0, height: 0.0)) + ageInputField.leftViewMode = .always + + ageInputField.isEnabled = false + ageInputField.backgroundColor = UIColor(named: "Gray2") + + ageLabel.text = "살" + ageLabel.font = UIFont.systemFont(ofSize: 14) + + + ageInputStackView.addArrangedSubview(ageInputField) + ageInputStackView.addArrangedSubview(ageLabel) + + view.addSubview(ageInputStackView) + + ageInputStackView.snp.makeConstraints{make in + make.top.equalTo(ageStackView.snp.bottom).offset(20) + make.left.equalTo(view.snp.left).offset(16) + make.right.equalTo(view.snp.right).offset(-16) + } + + ageInputField.snp.makeConstraints{make in + make.height.equalTo(55) + make.width.equalTo(80) + } + ageLabel.snp.makeConstraints{make in + make.height.equalTo(55) + } + } + private func progressBarInit(){ self.view.addSubview(progressBar) progressBar.snp.makeConstraints{make in @@ -192,8 +239,22 @@ class InputPetBirthVC : UIViewController { @objc func checkboxButtonTapped(_ sender: UIButton) { sender.isSelected = !sender.isSelected - birthDatePicker.isUserInteractionEnabled = !agecheckboxButton.isSelected // 선택 상태에 따라 DatePicker 활성화/비활성화 + updateCheckboxColor() + + if sender.isSelected { + inputPetBirth.isEnabled = false + ageInputField.isEnabled = true + inputPetBirth.backgroundColor = UIColor(named: "Gray2") + ageInputField.backgroundColor = UIColor.clear + + } else { + + inputPetBirth.isEnabled = true + ageInputField.isEnabled = false + inputPetBirth.backgroundColor = UIColor.clear + ageInputField.backgroundColor = UIColor(named: "Gray2") + } } private func updateCheckboxColor(){ diff --git a/fit-a-pet-client/fit-a-pet-client/ViewControllers/SignUpVC/InputPhoneNumVC.swift b/fit-a-pet-client/fit-a-pet-client/ViewControllers/SignUpVC/InputPhoneNumVC.swift index 09690836..0996db60 100644 --- a/fit-a-pet-client/fit-a-pet-client/ViewControllers/SignUpVC/InputPhoneNumVC.swift +++ b/fit-a-pet-client/fit-a-pet-client/ViewControllers/SignUpVC/InputPhoneNumVC.swift @@ -127,44 +127,42 @@ class InputPhoneNumVC : UIViewController { } extension InputPhoneNumVC: UITextFieldDelegate{ - // 입력값이 변경되면 버튼의 색상을 업데이트 func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { - - let updatedText = (inputPhoneNum.text! as NSString).replacingCharacters(in: range, with: string) + var updatedText = (inputPhoneNum.text! as NSString).replacingCharacters(in: range, with: string) nextAutnNumBtn.updateButtonColor(updatedText, false) - - if updatedText.isEmpty{ + + if updatedText.isEmpty { inputPhoneNum.layer.borderColor = UIColor(named: "Gray2")?.cgColor - }else{ + } else { inputPhoneNum.layer.borderColor = UIColor(named: "PrimaryColor")?.cgColor } - if let text = inputPhoneNum.text { - print("[INFO] text : " + text) - let strippedPhoneNumber = text.replacingOccurrences(of: "-", with: "") - print("[INFO] strippedPhoneNumber : " + strippedPhoneNumber) + if !updatedText.isEmpty { + let strippedPhoneNumber = updatedText.replacingOccurrences(of: "-", with: "") var formattedText: String = "" let hippen: Character = "-" - if strippedPhoneNumber.count == 11 { - formattedText = String(strippedPhoneNumber.prefix(10)) - phone = strippedPhoneNumber - print("phone: \(phone)") - return false - } else { - formattedText = strippedPhoneNumber - } + formattedText = strippedPhoneNumber - if strippedPhoneNumber.count >= 3 && text.count != 4 { + if strippedPhoneNumber.count >= 3 && updatedText.count != 4 { formattedText.insert(hippen, at: formattedText.index(formattedText.startIndex, offsetBy: 3)) } - if strippedPhoneNumber.count >= 7 && text.count != 9 { + if strippedPhoneNumber.count >= 7 && updatedText.count != 9 { formattedText.insert(hippen, at: formattedText.index(formattedText.startIndex, offsetBy: 8)) } - inputPhoneNum.text = formattedText + if strippedPhoneNumber.count > 11 { + return false + + }else{ + inputPhoneNum.text = formattedText + phone = formattedText.replacingOccurrences(of: "-", with: "") + print(phone) + } } - - return true + + return false } + + }