-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
25 changed files
with
366 additions
and
139 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
15 changes: 15 additions & 0 deletions
15
HongikYeolgong2/Data/DTO/Auth/ProfileEditResponseDTO.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,15 @@ | ||
// | ||
// ProfileEditResponseDTO.swift | ||
// HongikYeolgong2 | ||
// | ||
// Created by 권석기 on 1/14/25. | ||
// | ||
|
||
import Foundation | ||
|
||
struct ProfileEditResponseDTO: Decodable { | ||
let id: Int | ||
let username: String | ||
let nickname: String | ||
let department: String | ||
} |
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
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
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
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
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 |
---|---|---|
|
@@ -9,5 +9,6 @@ import Foundation | |
|
||
enum Page: Hashable { | ||
case webView(title: String, url: String) | ||
case profile | ||
case signUp | ||
} |
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
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
196 changes: 196 additions & 0 deletions
196
HongikYeolgong2/Presentation/Auth/SignUp/ProfileEditView.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,196 @@ | ||
// | ||
// SignInView.swift | ||
// HongikYeolgong2 | ||
// | ||
// Created by 권석기 on 10/3/24. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct ProfileEditView: View { | ||
@Environment(\.injected.interactors.userDataInteractor) var userDataInteractor | ||
|
||
@State private var nickname: Nickname = .none | ||
@State private var department: Department = .none | ||
@State private var inputNickname = "" | ||
@State private var inputDepartment = "" | ||
@State private var loadState: Loadable<Bool> = .notRequest | ||
@State private var isPresented: Bool = false | ||
@State private var isEditing = false | ||
@Environment(\.presentationMode) var dismiss | ||
|
||
let isEdit: Bool | ||
|
||
@FocusState private var focused | ||
|
||
private var isDepartmentSelecte: Bool { | ||
(Department.allDepartments.contains(department.rawValue) || Department.allDepartments.contains(inputDepartment)) | ||
} | ||
|
||
private var isNicknameCheked: Bool { | ||
nickname == .available | ||
} | ||
|
||
private var isEditCompleted: Bool { | ||
isEdit && isEditing | ||
} | ||
|
||
init(nickname: String, department: String) { | ||
self.inputNickname = nickname | ||
self.inputDepartment = department | ||
self.department = Department(rawValue: department) ?? .none | ||
self.nickname = .none | ||
self.isEdit = true | ||
} | ||
|
||
init() { | ||
self.isEdit = false | ||
} | ||
|
||
var body: some View { | ||
VStack(spacing: 0) { | ||
VStack(spacing: 0) { | ||
Spacer() | ||
.frame(maxHeight: 52 + 23.adjustToScreenHeight) | ||
|
||
VStack(alignment: .leading, spacing: 0) { | ||
FormLabel(title: "닉네임") | ||
|
||
Spacer() | ||
.frame(height: 8.adjustToScreenHeight) | ||
|
||
HStack(spacing: 10.adjustToScreenHeight) { | ||
BaseTextField( | ||
text: $inputNickname, | ||
placeholder: "닉네임을 입력해주세요.", | ||
isError: nickname.isError | ||
) | ||
|
||
DuplicateCheckButton( | ||
action: { userDataInteractor.checkUserNickname(inputNickname: inputNickname, nickname: $nickname) }, | ||
disabled: nickname.isCheckable | ||
) | ||
.disabled(!(nickname == .checkAvailable)) | ||
} | ||
|
||
Spacer() | ||
.frame(height: 4.adjustToScreenHeight) | ||
|
||
FormDescription( | ||
message: nickname.message, | ||
color: nickname.textColor | ||
) | ||
} | ||
.layoutPriority(1) | ||
|
||
Spacer() | ||
.frame(height: 12.adjustToScreenHeight) | ||
|
||
VStack(alignment: .leading, spacing: 8.adjustToScreenHeight) { | ||
FormLabel(title: "학과") | ||
|
||
DropDownPicker( | ||
text: $inputDepartment, | ||
seletedItem: Binding( | ||
get: { department.rawValue }, | ||
set: { department = .init(rawValue: $0) ?? .none } | ||
), | ||
placeholder: "", | ||
items: Department.allDepartments | ||
) | ||
} | ||
.layoutPriority(2) | ||
} | ||
|
||
Spacer() | ||
|
||
SubmitButton( | ||
isEdit: isEdit, | ||
action: editButtonTap, | ||
disabled: !((isNicknameCheked && isDepartmentSelecte) || isEditCompleted) | ||
) | ||
.padding(.bottom, 20.adjustToScreenHeight) | ||
} | ||
.overlay(alignment: .topLeading, content: { | ||
if isEdit { | ||
HStack { | ||
Button(action: { | ||
dismiss.wrappedValue.dismiss() | ||
}, label: { | ||
Image(.icProfileLeft) | ||
Text("프로필 변경") | ||
.font(.suite(size: 18, weight: .bold)) | ||
.foregroundStyle(.gray100) | ||
}) | ||
Spacer() | ||
} | ||
.frame( | ||
maxWidth: .infinity, | ||
maxHeight: 52.adjustToScreenHeight, | ||
alignment: .leading | ||
) | ||
.background(Color.black) | ||
} else { | ||
Text("회원가입") | ||
.font(.suite(size: 18, weight: .bold)) | ||
.foregroundStyle(.gray100) | ||
.frame( | ||
maxWidth: .infinity, | ||
maxHeight: 52.adjustToScreenHeight, | ||
alignment: .leading | ||
) | ||
.background(Color.black) | ||
} | ||
}) | ||
.toolbar(.hidden, for: .navigationBar) | ||
.padding(.horizontal, 32.adjustToScreenWidth) | ||
.systemOverlay(isPresented: $isPresented) { | ||
ModalView(isPresented: $isPresented, | ||
title: "프로필 변경을 진행하실건가요?", | ||
confirmButtonText: "변경하기", | ||
cancleButtonText: "돌아가기", | ||
confirmAction: performUpdate ) | ||
} | ||
.onTapGesture { | ||
UIApplication.shared.hideKeyboard() | ||
} | ||
.onChange(of: inputNickname) { | ||
userDataInteractor.validateUserNickname(inputNickname: $0, nickname: $nickname) | ||
} | ||
.onChange(of: nickname) { nickname in | ||
if isEdit && nickname == .available { | ||
isEditing = true | ||
} | ||
} | ||
.onChange(of: inputDepartment) { department in | ||
guard Department.allDepartments.contains(department) else { return } | ||
isEditing = true | ||
} | ||
.onChange(of: department) { department in | ||
guard department != .none else { | ||
isEditing = false | ||
return | ||
} | ||
isEditing = true | ||
} | ||
.onChange(of: loadState.value) { value in | ||
guard let isSuccess = value else { return } | ||
if isSuccess { | ||
dismiss.wrappedValue.dismiss() | ||
} | ||
} | ||
|
||
} | ||
|
||
func editButtonTap() { | ||
if isEdit { | ||
isPresented = true | ||
} else { | ||
userDataInteractor.signUp(nickname: inputNickname, department: department, loadbleSubject: $loadState) | ||
} | ||
} | ||
|
||
func performUpdate() { | ||
userDataInteractor.profileEdit(nickname: inputNickname, department: department, loadbleSubject: $loadState) | ||
} | ||
} |
Oops, something went wrong.