Skip to content

Commit

Permalink
[WEAV-78] 나이 입력 뷰 구현 (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
jisu15-kim authored Oct 1, 2024
1 parent 4ec2d71 commit cbcd5cc
Show file tree
Hide file tree
Showing 12 changed files with 164 additions and 11 deletions.
2 changes: 2 additions & 0 deletions Projects/App/Sources/Navigation/NavigationStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ extension PathType {
AuthGreetingView()
case .authProfileGender:
AuthProfileGenderInputView()
case .authProfileAge:
AuthProfileAgeInputView()
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions Projects/Core/CommonKit/Sources/AppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public final class AppCoordinator: ObservableObject {
@Published public var navigationStack: [PathType] = [.main]

//MARK: - Methods
@MainActor
public func changeRootView(_ path: PathType) {
Task {
await MainActor.run {
navigationStack = [path]
}
push(path)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { // 애니메이션 시간에 맞춰 조정
self.navigationStack.removeFirst()
}
}

Expand Down
2 changes: 2 additions & 0 deletions Projects/Core/CommonKit/Sources/Path/PathTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public enum PathType: Hashable {

case .authGreeting: return "가입 후 환영"
case .authProfileGender: return "성별 입력"
case .authProfileAge: return "나이 입력"
}
}
}
Expand All @@ -45,4 +46,5 @@ public enum SignUpSubViewType: Hashable {

case authGreeting
case authProfileGender
case authProfileAge
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "icon-information.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 @@ -28,7 +28,7 @@ public struct AuthAgreementView: View {
Spacer()

CTABottomButton(title: "다음") {
AppCoordinator.shared.push(
AppCoordinator.shared.changeRootView(
.signUp(.authGreeting)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,35 @@ public struct VerifyCodeInputView: View {
@Binding var errorMessage: String?
var verifyCodeMaxCount: Int
@FocusState private var isTextFieldFocused: Bool
let boxHeight: CGFloat
let textColor: Color
let borderWidth: CGFloat
let borderColor: Color
let backColor: Color
let cornerRadius: CGFloat

public init(
verifyCode: Binding<String>,
errorMessage: Binding<String?>,
verifyCodeMaxCount: Int = 6,
boxHeight: CGFloat = 72,
textColor: Color = .black,
borderWidth: CGFloat = 0,
borderColor: Color = .white,
backColor: Color = .white,
cornerRadius: CGFloat = 10,
focused: FocusState<Bool>
) {
self._verifyCode = verifyCode
self._errorMessage = errorMessage
self.verifyCodeMaxCount = verifyCodeMaxCount
self._isTextFieldFocused = focused
self.boxHeight = boxHeight
self.textColor = textColor
self.borderWidth = borderWidth
self.borderColor = borderColor
self.backColor = backColor
self.cornerRadius = cornerRadius
}

public var body: some View {
Expand All @@ -109,20 +127,25 @@ public struct VerifyCodeInputView: View {
ForEach(0 ..< verifyCodeMaxCount, id: \.self) { index in
let text = getCharFromString(index: index)
getSingleTextBox(text: text)
.shadow(.default)
}
}
}

@ViewBuilder
private func getSingleTextBox(text: String) -> some View {
ZStack {
RoundedRectangle(cornerRadius: 10)
.foregroundStyle(.white)
.clipShape(RoundedRectangle(cornerRadius: 10))
RoundedRectangle(cornerRadius: cornerRadius)
.stroke(borderColor, lineWidth: borderWidth)
.background(backColor)
.clipShape(
RoundedRectangle(cornerRadius: cornerRadius)
)
Text(text)
.pretendard(weight: ._600, size: 32)
.foregroundStyle(textColor)
}
.frame(height: 72)
.frame(height: boxHeight)
}

private var clearTextFieldView: some View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,15 @@ public struct AuthGreetingView: View {

Spacer()
}
.setNavigation(
showLeftBackButton: false,
handler: {}
)
.ignoresSafeArea()
.padding(.top, 155)
.textureBackground()
.onAppear {
.task {
try? await Task.sleep(nanoseconds: 500_000_000)
withAnimation(.easeInOut(duration: 0.6)) {
isAppeared = true
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
//
// AuthProfileAgeView.swift
// DesignPreview
//
// Created by 김지수 on 10/1/24.
// Copyright © 2024 com.weave. All rights reserved.
//

import SwiftUI
import DesignCore
import CommonKit

public struct AuthProfileAgeInputView: View {

@State var birthYear = String()
@State var errorMessage: String? = "잘못 입력하셨어요"
@FocusState var isFocused

public init() {}

var targetGender: String {
let tempTarget = "여성"
return tempTarget
}

public var body: some View {
VStack {
ProfileInputTemplatedView(
currentPage: 2,
maxPage: 5,
subMessage: "좋은 \(targetGender) 소개시켜 드릴께요!",
mainMessage: "당신의 나이는 무엇인가요?"
) {
VStack {
HStack {
VerifyCodeInputView(
verifyCode: $birthYear,
errorMessage: $errorMessage,
verifyCodeMaxCount: 4,
boxHeight: 92,
textColor: .black,
borderWidth: 4,
borderColor: .white,
backColor: DesignCore.Colors.yellow50,
cornerRadius: 20,
focused: _isFocused
)
.padding(.horizontal, 6)

VStack {
Spacer()
Text("년생")
.typography(.semibold_18)
.foregroundStyle(DesignCore.Colors.grey300)
}
}
.frame(height: 92)

Button(action: {

}, label: {
HStack(spacing: 4) {
DesignCore.Images.iconInformation.image
Text("가입 연령 확인하기")
.typography(.regular_14)
.foregroundStyle(DesignCore.Colors.grey200)
}
})
.padding(.top, 20)
}
.padding(.top, 8)
}

Spacer()

CTABottomButton(
title: "다음",
isActive: birthYear.count > 3
) {

}
}
.ignoresSafeArea()
.padding(.top, 10)
.textureBackground()
.setNavigation(showLeftBackButton: false) {

}
}
}

#Preview {
NavigationView {
AuthProfileAgeInputView()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ public struct AuthProfileGenderInputView: View {
title: "다음",
isActive: selectedGender != nil
) {

AppCoordinator.shared.push(
.signUp(.authProfileAge)
)
}
}
.padding(.top, 10)
Expand Down

0 comments on commit cbcd5cc

Please sign in to comment.