-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[FEAT] #140 - νλ‘ν μμ νκΈ° λ·° λ μμ΄μ
- Loading branch information
Showing
11 changed files
with
329 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
Fillin-iOS/Fillin-iOS/Resources/Assets/Assets.xcassets/btnAddProfile.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
Binary file added
BIN
+2.17 KB
...iOS/Resources/Assets/Assets.xcassets/btnAddProfile.imageset/btn_add_profile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.35 KB
.../Resources/Assets/Assets.xcassets/btnAddProfile.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.2 KB
.../Resources/Assets/Assets.xcassets/btnAddProfile.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions
23
Fillin-iOS/Fillin-iOS/Resources/Assets/Assets.xcassets/btnClear.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
Binary file added
BIN
+229 Bytes
...iOS/Fillin-iOS/Resources/Assets/Assets.xcassets/btnClear.imageset/btn_clear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+262 Bytes
.../Fillin-iOS/Resources/Assets/Assets.xcassets/btnClear.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+403 Bytes
.../Fillin-iOS/Resources/Assets/Assets.xcassets/btnClear.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
277 changes: 277 additions & 0 deletions
277
...S/Fillin-iOS/Sources/ViewControllers/MyPageViewController/EditProfileViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} | ||
} | ||
} | ||
} |