-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Crois0509/crois-Lv2
[Lv2 ~ Lv3] 필수기능 구현
- Loading branch information
Showing
12 changed files
with
244 additions
and
20 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
Binary file modified
BIN
+46.8 KB
(190%)
...project.xcworkspace/xcuserdata/jangsang-gyeong.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions
20
PokemonPhoneBook/PokemonPhoneBook/PhoneBookData/PhoneBookData+CoreDataClass.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,20 @@ | ||
// | ||
// PhoneBookData+CoreDataClass.swift | ||
// PokemonPhoneBook | ||
// | ||
// Created by 장상경 on 12/8/24. | ||
// | ||
// | ||
|
||
import Foundation | ||
import CoreData | ||
|
||
@objc(PhoneBookData) | ||
public class PhoneBookData: NSManagedObject { | ||
static let className: String = "PhoneBookData" | ||
enum Key { | ||
static let name: String = "name" | ||
static let number: String = "number" | ||
static let profile: String = "profile" | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
PokemonPhoneBook/PokemonPhoneBook/PhoneBookData/PhoneBookData+CoreDataProperties.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,27 @@ | ||
// | ||
// PhoneBookData+CoreDataProperties.swift | ||
// PokemonPhoneBook | ||
// | ||
// Created by 장상경 on 12/8/24. | ||
// | ||
// | ||
|
||
import Foundation | ||
import CoreData | ||
|
||
|
||
extension PhoneBookData { | ||
|
||
@nonobjc public class func fetchRequest() -> NSFetchRequest<PhoneBookData> { | ||
return NSFetchRequest<PhoneBookData>(entityName: "PhoneBookData") | ||
} | ||
|
||
@NSManaged public var name: String? | ||
@NSManaged public var number: String? | ||
@NSManaged public var profile: Data? | ||
|
||
} | ||
|
||
extension PhoneBookData : Identifiable { | ||
|
||
} |
8 changes: 6 additions & 2 deletions
8
...Book/PokemonPhoneBook/PokemonPhoneBook.xcdatamodeld/PokemonPhoneBook.xcdatamodel/contents
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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="1" systemVersion="11A491" minimumToolsVersion="Automatic" sourceLanguage="Swift" usedWithCloudKit="false" userDefinedModelVersionIdentifier=""> | ||
<elements/> | ||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="23507" systemVersion="24B91" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier=""> | ||
<entity name="PhoneBookData" representedClassName="PhoneBookData" syncable="YES"> | ||
<attribute name="name" optional="YES" attributeType="String"/> | ||
<attribute name="number" optional="YES" attributeType="String"/> | ||
<attribute name="profile" optional="YES" attributeType="Binary"/> | ||
</entity> | ||
</model> |
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
141 changes: 141 additions & 0 deletions
141
PokemonPhoneBook/PokemonPhoneBook/ViewControllers/PhoneBookViewController.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,141 @@ | ||
// | ||
// PhoneBookViewController.swift | ||
// PokemonPhoneBook | ||
// | ||
// Created by 장상경 on 12/6/24. | ||
// | ||
|
||
import UIKit | ||
import SnapKit | ||
|
||
// SubViewController | ||
final class PhoneBookViewController: UIViewController { | ||
|
||
// MARK: - PhoneBookViewController UI | ||
private let profileImageView = UIImageView() | ||
private let profileImageRandomChangeButton = UIButton() | ||
private let nameTextField = UITextField() | ||
private let numberTextField = UITextField() | ||
|
||
// MARK: - PhoneBookViewController Life Cycle | ||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
configUI() | ||
} | ||
} | ||
|
||
// MARK: - PhoneBookViewController Private Method | ||
private extension PhoneBookViewController { | ||
/// 서브 뷰의 모든 UI 요소를 배치 및 설정 | ||
func configUI() { | ||
view.backgroundColor = .white | ||
|
||
[self.profileImageView, | ||
self.profileImageRandomChangeButton, | ||
self.nameTextField, | ||
self.numberTextField].forEach { view.addSubview($0) } | ||
|
||
setupImageView() | ||
setupChangeButton() | ||
setupTextField() | ||
setupNavigationTitle() | ||
setupNavigationRightButton() | ||
setupUILayout() | ||
} | ||
|
||
/// 프로필 이미지를 세팅하는 메소드 | ||
func setupImageView() { | ||
self.profileImageView.contentMode = .scaleAspectFit | ||
self.profileImageView.backgroundColor = .clear | ||
self.profileImageView.layer.cornerRadius = 100 | ||
self.profileImageView.clipsToBounds = true | ||
self.profileImageView.layer.borderColor = UIColor.gray.cgColor | ||
self.profileImageView.layer.borderWidth = 2 | ||
} | ||
|
||
/// 텍스트필드를 세팅하는 메소드 | ||
func setupTextField() { | ||
[self.nameTextField, self.numberTextField].forEach { | ||
$0.font = UIFont.systemFont(ofSize: 15, weight: .light) | ||
$0.borderStyle = .roundedRect | ||
$0.textColor = .black | ||
$0.keyboardType = .default | ||
} | ||
self.nameTextField.placeholder = "이름을 입력해 주세요" | ||
self.numberTextField.placeholder = "전화번호를 입력해 주세요" | ||
} | ||
|
||
/// 프로필 이미지 변경 버튼을 세팅하는 메소드 | ||
func setupChangeButton() { | ||
var config = UIButton.Configuration.plain() | ||
|
||
var titleAttr = AttributedString.init("랜덤 이미지 생성") | ||
titleAttr.font = .systemFont(ofSize: 20, weight: .medium) | ||
|
||
config.attributedTitle = titleAttr | ||
config.baseForegroundColor = .gray | ||
|
||
self.profileImageRandomChangeButton.configuration = config | ||
self.profileImageRandomChangeButton.backgroundColor = .clear | ||
self.profileImageRandomChangeButton.addTarget(self, action: #selector(changeProfileImage), for: .touchDown) | ||
} | ||
|
||
/// 프로필 이미지를 랜덤으로 변경하는 메소드 | ||
@objc func changeProfileImage() { | ||
|
||
} | ||
|
||
/// 서브 뷰의 모든 UI 레이아웃을 설정하는 메소드 | ||
func setupUILayout() { | ||
self.profileImageView.snp.makeConstraints { | ||
$0.top.equalTo(view.safeAreaLayoutGuide).offset(10) | ||
$0.centerX.equalToSuperview() | ||
$0.width.height.equalTo(200) | ||
} | ||
|
||
self.profileImageRandomChangeButton.snp.makeConstraints { | ||
$0.top.equalTo(self.profileImageView.snp.bottom).offset(10) | ||
$0.centerX.equalToSuperview() | ||
$0.width.equalTo(200) | ||
$0.height.equalTo(50) | ||
} | ||
|
||
self.nameTextField.snp.makeConstraints { | ||
$0.top.equalTo(self.profileImageRandomChangeButton.snp.bottom).offset(10) | ||
$0.centerX.equalToSuperview() | ||
$0.width.equalTo(300) | ||
$0.height.equalTo(40) | ||
} | ||
|
||
self.numberTextField.snp.makeConstraints { | ||
$0.top.equalTo(self.nameTextField.snp.bottom).offset(15) | ||
$0.centerX.equalToSuperview() | ||
$0.width.equalTo(300) | ||
$0.height.equalTo(40) | ||
} | ||
} | ||
|
||
/// 네비게이션 타이틀을 설정하는 메소드 | ||
func setupNavigationTitle() { | ||
let title = UILabel() | ||
title.text = "연락처 추가" | ||
title.textColor = .black | ||
title.font = UIFont.systemFont(ofSize: 25, weight: .bold) | ||
title.textAlignment = .center | ||
title.backgroundColor = .clear | ||
|
||
self.navigationItem.titleView = title | ||
} | ||
|
||
/// 네비게이션바의 오른쪽 버튼을 세팅하는 메소드 | ||
func setupNavigationRightButton() { | ||
let rightButton = UIBarButtonItem(title: "적용", style: .plain, target: self, action: #selector(savePhoneNumber)) | ||
self.navigationItem.rightBarButtonItem = rightButton | ||
} | ||
|
||
/// 현재 입력한 정보를 저장하는 메소드 | ||
@objc func savePhoneNumber() { | ||
|
||
} | ||
} |
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