Skip to content

Commit

Permalink
Merge pull request #144 from TeamFILL-IN/feature/#140
Browse files Browse the repository at this point in the history
[FEAT] #140 - ν”„λ‘œν•„ μˆ˜μ •ν•˜κΈ° λ·° λ ˆμ•„μ΄μ›ƒ
  • Loading branch information
Kim-jisoo11 authored Oct 20, 2022
2 parents 83ba214 + 90b0a9f commit e0dc477
Show file tree
Hide file tree
Showing 11 changed files with 329 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Fillin-iOS/Fillin-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
E89934F727CD1EDE00DCB1A8 /* OnboardingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E89934F627CD1EDE00DCB1A8 /* OnboardingViewController.swift */; };
E89934FA27CD2AA600DCB1A8 /* OnboardingDataModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = E89934F927CD2AA600DCB1A8 /* OnboardingDataModel.swift */; };
E89934FD27CD2BCB00DCB1A8 /* OnboardingCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E89934FC27CD2BCB00DCB1A8 /* OnboardingCollectionViewCell.swift */; };
E8C1E0D028EABCEB006AB2C7 /* EditProfileViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8C1E0CF28EABCEB006AB2C7 /* EditProfileViewController.swift */; };
E8DDE18528DEDECF00CC000D /* ReportPopUpViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8DDE18428DEDECF00CC000D /* ReportPopUpViewController.swift */; };
E8EB7A5628C090AB0091DA22 /* TermsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8EB7A5528C090AB0091DA22 /* TermsViewController.swift */; };
E8EB7A5828C093080091DA22 /* TermTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8EB7A5728C093080091DA22 /* TermTableViewCell.swift */; };
Expand Down Expand Up @@ -253,6 +254,7 @@
E89934F627CD1EDE00DCB1A8 /* OnboardingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingViewController.swift; sourceTree = "<group>"; };
E89934F927CD2AA600DCB1A8 /* OnboardingDataModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingDataModel.swift; sourceTree = "<group>"; };
E89934FC27CD2BCB00DCB1A8 /* OnboardingCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingCollectionViewCell.swift; sourceTree = "<group>"; };
E8C1E0CF28EABCEB006AB2C7 /* EditProfileViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditProfileViewController.swift; sourceTree = "<group>"; };
E8DDE18428DEDECF00CC000D /* ReportPopUpViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportPopUpViewController.swift; sourceTree = "<group>"; };
E8EB7A5528C090AB0091DA22 /* TermsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TermsViewController.swift; sourceTree = "<group>"; };
E8EB7A5728C093080091DA22 /* TermTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TermTableViewCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -540,6 +542,7 @@
6F3B872B27968AEB00A4BD07 /* MyPageViewController.swift */,
E8EB7A5528C090AB0091DA22 /* TermsViewController.swift */,
E8EB7A5728C093080091DA22 /* TermTableViewCell.swift */,
E8C1E0CF28EABCEB006AB2C7 /* EditProfileViewController.swift */,
);
path = MyPageViewController;
sourceTree = "<group>";
Expand Down Expand Up @@ -1050,6 +1053,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
E8C1E0D028EABCEB006AB2C7 /* EditProfileViewController.swift in Sources */,
6F3B87CB27968AEB00A4BD07 /* LoginViewController.swift in Sources */,
6F3B878927968AEB00A4BD07 /* GenericResponse.swift in Sources */,
77EB42212797D17600C726D8 /* FlimSelectAPI.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "btn_add_profile.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "btn_clear.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ internal enum Asset {
internal static let accentColor = ColorAsset(name: "AccentColor")
internal static let appleLogo = ImageAsset(name: "AppleLogo")
internal static let basicProfile = ImageAsset(name: "basicProfile")
internal static let btnAddProfile = ImageAsset(name: "btnAddProfile")
internal static let btnAddphhoto = ImageAsset(name: "btnAddphhoto")
internal static let btnBack = ImageAsset(name: "btnBack")
internal static let btnClear = ImageAsset(name: "btnClear")
internal static let btnHome = ImageAsset(name: "btnHome")
internal static let btnHomeFloating = ImageAsset(name: "btnHomeFloating")
internal static let btnLike = ImageAsset(name: "btnLike")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,277 @@
//
// EditProfileViewController.swift
// Fillin-iOS
//
// Created by κΉ€μ§€μˆ˜ on 2022/10/03.
//

import UIKit

import SnapKit
import Then

// MARK: - EditProfileViewController
class EditProfileViewController: UIViewController {

// MARK: - Components
let navigationBar = FilinNavigationBar()
let profileImage = UIImageView()
let editProfileButtonImage = UIButton()
let editProfileLabel = UILabel()
let nicknameLabel = UILabel()
let nicknameTextField = UITextField()
let nicknameBorder = UIView()
let cameraLabel = UILabel()
let cameraTextField = UITextField()
let cameraBorder = UIView()
let changeProfileButton = UIButton()
final let maxLength = 10

// MARK: - LifeCycle
override func viewDidLoad() {
super.viewDidLoad()
layout()
setUI()
attribute()
attributePlaceholder()
NotificationCenter.default.addObserver(self,
selector: #selector(textDidChange(_:)),
name: UITextField.textDidChangeNotification,
object: nicknameTextField)
NotificationCenter.default.addObserver(self,
selector: #selector(textDidChange(_:)),
name: UITextField.textDidChangeNotification,
object: cameraTextField)

}
}
// MARK: - Extensions
extension EditProfileViewController {
func layout() {
layoutNavigaionBar()
layoutProfileImage()
layoutEditProfileButtonImage()
layoutEditProfileLabel()
layoutNicknameLabel()
layoutNicknameTextField()
layoutNicknameBorder()
layoutCameraLabel()
layoutCameraTextField()
layoutCameraBorder()
layoutChangeProfileButton()
}
func layoutNavigaionBar() {
self.view.add(navigationBar) {
self.navigationBar.popViewController = {
self.navigationController?.popViewController(animated: true)
}
$0.snp.makeConstraints { make in
make.top.equalTo(self.view.safeAreaLayoutGuide.snp.top)
make.leading.trailing.equalToSuperview()
make.height.equalTo(50)
}
}
}
func layoutProfileImage() {
self.view.add(profileImage) {
$0.setBorder(borderColor: .fillinWhite, borderWidth: 1)
$0.setRounded(radius: 27.5)
$0.image = Asset.noSearch.image
$0.contentMode = .scaleAspectFill
$0.clipsToBounds = true
$0.snp.makeConstraints { make in
make.top.equalTo(self.navigationBar.snp.bottom).offset(21)
make.centerX.equalToSuperview()
make.width.height.equalTo(55)
}
}
}
func layoutEditProfileButtonImage() {
self.view.add(editProfileButtonImage) {
$0.setImage(Asset.btnAddProfile.image, for: .normal)
$0.addTarget(self, action: #selector(self.profileChangeButtonClicked), for: .touchUpInside)
$0.snp.makeConstraints { make in
make.top.leading.trailing.bottom.equalTo(self.profileImage)
make.width.height.equalTo(55)
}
}
}
func layoutEditProfileLabel() {
self.view.add(editProfileLabel) {
$0.setupLabel(text: "ν”„λ‘œν•„ 사진 λ°”κΎΈκΈ°", color: .grey3, font: .body1)
$0.snp.makeConstraints { make in
make.top.equalTo(self.editProfileButtonImage.snp.bottom).offset(12)
make.centerX.equalToSuperview()
}
}
}
func layoutNicknameLabel() {
self.view.add(nicknameLabel) {
$0.setupLabel(text: "λ‹‰λ„€μž„", color: .fillinWhite, font: .subhead3)
$0.snp.makeConstraints { make in
make.top.equalTo(self.editProfileLabel.snp.bottom).offset(28)
make.leading.equalToSuperview().offset(18)
}
}
}
func layoutNicknameTextField() {
self.view.add(nicknameTextField) {
$0.placeholder = "λ‹‰λ„€μž„μ„ μž…λ ₯ν•΄μ£Όμ„Έμš”. (10자 μ΄ν•˜)"
$0.font = .subhead1
$0.textColor = .fillinWhite
$0.autocorrectionType = .no
$0.autocapitalizationType = .none
$0.clearButtonMode = .always
if let clearButton = self.nicknameTextField.value(forKeyPath: "_clearButton") as? UIButton {
clearButton.setImage(Asset.btnClear.image, for: .normal)
$0.snp.makeConstraints { make in
make.top.equalTo(self.nicknameLabel.snp.bottom).offset(16)
make.centerX.equalToSuperview()
make.leading.equalToSuperview().offset(18)
}
}
}
}
func layoutNicknameBorder() {
self.view.add(nicknameBorder) {
$0.backgroundColor = .darkGrey1
$0.snp.makeConstraints { make in
make.top.equalTo(self.nicknameTextField.snp.bottom).offset(6)
make.centerX.equalToSuperview()
make.leading.equalToSuperview().offset(18)
make.height.equalTo(1)
}
}
}
func layoutCameraLabel() {
self.view.add(cameraLabel) {
$0.setupLabel(text: "카메라", color: .fillinWhite, font: .subhead3)
$0.snp.makeConstraints { make in
make.top.equalTo(self.nicknameBorder.snp.bottom).offset(40)
make.leading.equalToSuperview().offset(18)
}
}
}
func layoutCameraTextField() {
self.view.add(cameraTextField) {
$0.placeholder = "μ‚¬μš© 쀑인 카메라 이름을 μž…λ ₯ν•΄μ£Όμ„Έμš”."
$0.font = .subhead1
$0.textColor = .fillinWhite
$0.autocorrectionType = .no
$0.autocapitalizationType = .none
$0.clearButtonMode = .always
if let clearButton = self.cameraTextField.value(forKeyPath: "_clearButton") as? UIButton {
clearButton.setImage(Asset.btnClear.image, for: .normal)
$0.snp.makeConstraints { make in
make.top.equalTo(self.cameraLabel.snp.bottom).offset(16)
make.centerX.equalToSuperview()
make.leading.equalToSuperview().offset(18)
}
}
}
}
func layoutCameraBorder() {
self.view.add(cameraBorder) {
$0.backgroundColor = .darkGrey1
$0.snp.makeConstraints { make in
make.top.equalTo(self.cameraTextField.snp.bottom).offset(6)
make.centerX.equalToSuperview()
make.leading.equalToSuperview().offset(18)
make.height.equalTo(1)
}
}
}
func layoutChangeProfileButton() {
self.view.add(changeProfileButton) {
$0.setupButton(title: "ν”„λ‘œν•„ λ³€κ²½",
color: .grey4,
font: .headline,
backgroundColor: .textviewGrey,
state: .normal,
radius: 0)
$0.isUserInteractionEnabled = false
$0.addTarget(self, action: #selector(self.sendButtonClicked), for: .touchUpInside)
$0.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.leading.trailing.equalToSuperview()
make.bottom.equalToSuperview()
make.height.equalTo(80)
}
}
}
func setUI() {
self.view.backgroundColor = .fillinBlack
}
func attribute() {
self.nicknameTextField.delegate = self
self.cameraTextField.delegate = self
}
func attributePlaceholder() {
nicknameTextField.attributedPlaceholder = NSAttributedString(string : "λ‹‰λ„€μž„μ„ μž…λ ₯ν•΄μ£Όμ„Έμš”. (10자 μ΄ν•˜)",
attributes : [NSAttributedString.Key.foregroundColor: UIColor.grey4,
NSAttributedString.Key.font : UIFont.body1])
cameraTextField.attributedPlaceholder = NSAttributedString(string : "μ‚¬μš© 쀑인 카메라 이름을 μž…λ ₯ν•΄μ£Όμ„Έμš”.",
attributes : [NSAttributedString.Key.foregroundColor: UIColor.grey4,
NSAttributedString.Key.font :UIFont.body1])
}
@objc func profileChangeButtonClicked() {
print("ν”„λ‘œν•„ 이미지 λ³€κ²½ν•˜κΈ°")
}
@objc func sendButtonClicked() {
print("ν”„λ‘œν•„ λ³€κ²½ν•˜κΈ°")
}
/// 빈 곡간 ν„°μΉ˜ν•˜λ©΄ ν‚€λ³΄λ“œ λ‚΄λ €κ°€κ²Œ
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
self.view.endEditing(true)
}
}

// MARK: - UITextFieldDelegate
extension EditProfileViewController: UITextFieldDelegate {

/// Return λˆŒλ €μ„ λ•Œ ν‚€λ³΄λ“œ 내리기
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.resignFirstResponder()
return true
}
/// nicknameTextField κΈ€μžμˆ˜ μ„ΈκΈ°, μ œν•œ
@objc private func textDidChange(_ notification: Notification) {
if let textField = notification.object as? UITextField {
if let nicknametext = nicknameTextField.text {

if nicknametext.count > maxLength {
// 6κΈ€μž λ„˜μ–΄κ°€λ©΄ μžλ™μœΌλ‘œ ν‚€λ³΄λ“œ 내렀감
// textField.resignFirstResponder()
let countNum = nicknameTextField.text?.count ?? 0
// countTextLabel.text = "\(countNum)/6"
}
// μ΄ˆκ³Όλ˜λŠ” ν…μŠ€νŠΈ 제거
if nicknametext.count >= maxLength {
let index = nicknametext.index(nicknametext.startIndex, offsetBy: maxLength)
let newString = nicknametext[nicknametext.startIndex..<index]
textField.text = String(newString)
let countNum = nicknameTextField.text?.count ?? 0
// countTextLabel.text = "\(countNum)/6"
if let clearButton = self.nicknameTextField.value(forKeyPath: "_clearButton") as? UIButton {
clearButton.setImage(Asset.btnClear.image, for: .normal)
}
}
if nicknametext.isEmpty == true {
self.changeProfileButton.setupButton(title: "ν”„λ‘œν•„ λ³€κ²½",
color: .grey4,
font: .headline,
backgroundColor: .textviewGrey,
state: .normal,
radius: 0)
} else {
self.changeProfileButton.setupButton(title: "ν”„λ‘œν•„ λ³€κ²½",
color: .fillinBlack,
font: .headline,
backgroundColor: .fillinRed,
state: .normal,
radius: 0)
}
}
}
}
}

0 comments on commit e0dc477

Please sign in to comment.