Skip to content

Commit

Permalink
feat: #26 feat TermsOfService view
Browse files Browse the repository at this point in the history
  • Loading branch information
mnbvcxzyj committed Jan 15, 2025
1 parent cfac658 commit e30a830
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct WithSuhyeonSmallChip: View {
}
}

struct ChipTestView: View {
struct ChipTestView2: View {
@State private var firstChipState: WithSuhyeonChipState = .unselected
@State private var secondChipState: WithSuhyeonChipState = .selected

Expand Down Expand Up @@ -78,5 +78,5 @@ struct ChipTestView: View {
}

#Preview {
ChipTestView()
ChipTestView2()
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,25 @@ struct SignUpContent: View {
}

var body: some View {
HStack(spacing: 0) {
TabView(selection: $selectedTab) {
TermsOfServiceView()
.tag(SignUpContentCase.termsOfServiceView)
PhoneAuthenticationView()
.tag(SignUpContentCase.authenticationView)
WriteNickNameView()
.tag(SignUpContentCase.nickNameView)
SelectBirthYearView()
.tag(SignUpContentCase.birthYearView)
SelectGenderView()
.tag(SignUpContentCase.genderView)
ProfileImageView()
.tag(SignUpContentCase.profileImageView)
ActiveAreaView()
.tag(SignUpContentCase.activeAreaView)
}
.tabViewStyle(PageTabViewStyle())
.onAppear {
UIScrollView.appearance().isScrollEnabled = false
}
TabView(selection: $selectedTab) {
TermsOfServiceView()
.tag(SignUpContentCase.termsOfServiceView)
PhoneAuthenticationView()
.tag(SignUpContentCase.authenticationView)
WriteNickNameView()
.tag(SignUpContentCase.nickNameView)
SelectBirthYearView()
.tag(SignUpContentCase.birthYearView)
SelectGenderView()
.tag(SignUpContentCase.genderView)
ProfileImageView()
.tag(SignUpContentCase.profileImageView)
ActiveAreaView()
.tag(SignUpContentCase.activeAreaView)
}
.tabViewStyle(PageTabViewStyle())
.onAppear {
UIScrollView.appearance().isScrollEnabled = false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import Combine
class SignUpFeature: Feature {
struct State {
var progress: Double = 0.0
var isAgree: Bool = false // 약관 동의

var isAgree: Bool = false
}

enum Intent {
Expand Down Expand Up @@ -57,7 +56,6 @@ class SignUpFeature: Feature {
private func moveToNextStep() {
if let currentIndex = SignUpContentCase.allCases.firstIndex(of: currentContent),
currentIndex < SignUpContentCase.allCases.count - 1 {
print(currentIndex, "-" , currentContent)
currentContent = SignUpContentCase.allCases[currentIndex + 1]
updateProgress()
}
Expand All @@ -77,10 +75,11 @@ class SignUpFeature: Feature {
}
}


func changeSelectedContent(signUpContentCase: SignUpContentCase) {
currentContent = signUpContentCase
}

func updateIsAgree(_ newValue: Bool) {
state.isAgree = newValue
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct SignUpView: View {
@StateObject private var signUpFeature = SignUpFeature()

var body: some View {
VStack(alignment: .leading) {
VStack(alignment: .leading, spacing: 0) {
WithSuhyeonTopNavigationBar(title: "", onTapLeft: {})

WithSuhyeonProgressBar(progress: signUpFeature.state.progress)
Expand All @@ -24,10 +24,24 @@ struct SignUpView: View {

SignUpContent(selectedTab: $signUpFeature.currentContent)

WithSuhyeonButton(title: "버튼", buttonState: .disabled, onTapButton: {
signUpFeature.send(.nextStep)
})
WithSuhyeonButton(
title: "다음",
buttonState: isNextStepEnabled() ? .enabled : .disabled,
clickable: isNextStepEnabled(),
onTapButton: {
signUpFeature.send(.nextStep)
}
)
.padding(.horizontal, 16)
}.environmentObject(signUpFeature)
}

private func isNextStepEnabled() -> Bool {
switch signUpFeature.currentContent {
case .termsOfServiceView:
return signUpFeature.state.isAgree
default:
return true
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,67 @@
import SwiftUI

struct TermsOfServiceView: View {
@EnvironmentObject var signUpFeature: SignUpFeature
@State private var agreeStatus: [Bool] = [false, false, false]

var body: some View {
Text("이용약관")
VStack(alignment: .leading) {
WithSuhyeonCheckbox(
state: agreeStatus.allSatisfy { $0 } ? .checked : .unchecked,
placeholder: "모두 동의",
hasBackground: true
) {
toggleAllChecks()
}
.padding(.bottom, 16)

VStack(alignment: .leading, spacing: 16) {
ForEach(agreeStatus.indices, id: \.self) { index in
HStack(alignment: .top, spacing: 12) {
WithSuhyeonCheckbox(
state: agreeStatus[index] ? .checked : .unchecked,
placeholder: getPlaceholder(for: index),
hasBackground: false
) {
toggleAgreeCheck(at: index)
}
WithSuhyeonUnderlineButton(title: "보기") {}
}
}
}
.padding(.horizontal, 20)
.padding(.vertical, 24)
.frame(maxWidth: .infinity, alignment: .topLeading)
.cornerRadius(20)
.overlay(
RoundedRectangle(cornerRadius: 20)
.stroke(Color.gray200, lineWidth: 1)
)
Spacer()
}
.padding(.horizontal, 16)
.onChange(of: agreeStatus) { newStatus in
let allSelected = newStatus.allSatisfy { $0 }
signUpFeature.updateIsAgree(allSelected)
}
}

private func toggleAllChecks() {
let newState = !agreeStatus.allSatisfy { $0 }
agreeStatus = Array(repeating: newState, count: agreeStatus.count)
}

private func toggleAgreeCheck(at index: Int) {
agreeStatus[index].toggle()
}

private func getPlaceholder(for index: Int) -> String {
switch index {
case 0: return "[필수] 만 18세 이상"
case 1: return "[필수] 이용약관 동의"
case 2: return "[필수] 개인정보 처리방침 동의"
default: return ""
}
}
}

Expand Down

0 comments on commit e30a830

Please sign in to comment.