Skip to content

Commit

Permalink
[feat] #26 feat signUpTab Content
Browse files Browse the repository at this point in the history
  • Loading branch information
mnbvcxzyj committed Jan 15, 2025
1 parent dacb2db commit cfac658
Show file tree
Hide file tree
Showing 12 changed files with 328 additions and 0 deletions.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// SignUpContent.swift
// WithSuhyeon-iOS
//
// Created by 김예지 on 1/15/25.
//

import SwiftUI

struct SignUpContent: View {
@Binding var selectedTab: SignUpContentCase
init(selectedTab: Binding<SignUpContentCase>) {
self._selectedTab = selectedTab
UITabBar.appearance().isHidden = true
}

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
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// SignUpContentCase.swift
// WithSuhyeon-iOS
//
// Created by 김예지 on 1/15/25.
//

import Foundation

public enum SignUpContentCase: CaseIterable {
case termsOfServiceView
case authenticationView
case nickNameView
case birthYearView
case genderView
case profileImageView
case activeAreaView

var title: String {
switch self {
case .termsOfServiceView:
return "수현이랑\n서비스 이용약관"
case .authenticationView:
return "본인인증을 위한\n휴대폰 번호 인증이 필요해요"
case .nickNameView:
return "수현이랑에서 사용할\n닉네임을 입력해주세요"
case .birthYearView:
return "태어난 년도를\n선택해주세요"
case .genderView:
return "성별을\n선택해주세요"
case .profileImageView:
return "프로필 이미지를\n등록해주세요"
case .activeAreaView:
return "자주 활동하는\n지역을 선택해주세요"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
//
// SignUpFeature.swift
// WithSuhyeon-iOS
//
// Created by 김예지 on 1/15/25.
//

import Foundation
import Combine

class SignUpFeature: Feature {
struct State {
var progress: Double = 0.0
var isAgree: Bool = false // 약관 동의

}

enum Intent {
case nextStep
case previousStep
}

enum SideEffect {

}

@Published private(set) var state = State()
@Published var currentContent: SignUpContentCase = .termsOfServiceView
private var cancellables = Set<AnyCancellable>()
private let intentSubject = PassthroughSubject<Intent, Never>()
let sideEffectSubject = PassthroughSubject<SideEffect, Never>()

init() {
bindIntents()
updateProgress()
}

private func bindIntents() {
intentSubject.sink { [weak self] intent in
self?.handleIntent(intent)
}.store(in: &cancellables)
}

func send(_ intent: Intent) {
intentSubject.send(intent)
}

func handleIntent(_ intent: Intent) {
switch intent {
case .nextStep:
moveToNextStep()
case .previousStep:
moveToPreviousStep()
}
}

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()
}
}

private func moveToPreviousStep() {
if let currentIndex = SignUpContentCase.allCases.firstIndex(of: currentContent),
currentIndex > 0 {
currentContent = SignUpContentCase.allCases[currentIndex - 1]
updateProgress()
}
}

private func updateProgress() {
if let currentIndex = SignUpContentCase.allCases.firstIndex(of: currentContent) {
state.progress = Double(currentIndex + 1) / Double(SignUpContentCase.allCases.count) * 100
}
}


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


Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// SignUpView.swift
// WithSuhyeon-iOS
//
// Created by 김예지 on 1/15/25.
//

import SwiftUI

struct SignUpView: View {
@EnvironmentObject private var router: RouterRegistry
@StateObject private var signUpFeature = SignUpFeature()

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

WithSuhyeonProgressBar(progress: signUpFeature.state.progress)

Text(signUpFeature.currentContent.title)
.font(.title02B)
.padding(.leading, 16)
.padding(.vertical, 20)

SignUpContent(selectedTab: $signUpFeature.currentContent)

WithSuhyeonButton(title: "버튼", buttonState: .disabled, onTapButton: {
signUpFeature.send(.nextStep)
})
.padding(.horizontal, 16)
}
}
}

#Preview {
SignUpView()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// ActiveAreaView.swift
// WithSuhyeon-iOS
//
// Created by 김예지 on 1/15/25.
//

import SwiftUI

struct ActiveAreaView: View {
var body: some View {
Text("활동 지역 선택")
}
}

#Preview {
ActiveAreaView()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// PhoneAuthenticationView.swift
// WithSuhyeon-iOS
//
// Created by 김예지 on 1/15/25.
//

import SwiftUI

struct PhoneAuthenticationView: View {
var body: some View {
Text("핸드폰 인증")
}
}

#Preview {
PhoneAuthenticationView()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// ProfileImageView.swift
// WithSuhyeon-iOS
//
// Created by 김예지 on 1/15/25.
//

import SwiftUI

struct ProfileImageView: View {
var body: some View {
Text("프로필 이미지 선택")
}
}

#Preview {
ProfileImageView()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// SelectBirthYearView.swift
// WithSuhyeon-iOS
//
// Created by 김예지 on 1/15/25.
//

import SwiftUI

struct SelectBirthYearView: View {
var body: some View {
Text("태어난 년도 선택")
}
}

#Preview {
SelectBirthYearView()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// SelectGenderView.swift
// WithSuhyeon-iOS
//
// Created by 김예지 on 1/15/25.
//

import SwiftUI

struct SelectGenderView: View {
var body: some View {
Text("성별 선택 뷰")
.navigationBarBackButtonHidden(true)
}
}

#Preview {
SelectGenderView()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// TermsOfServiceView.swift
// WithSuhyeon-iOS
//
// Created by 김예지 on 1/15/25.
//

import SwiftUI

struct TermsOfServiceView: View {
var body: some View {
Text("이용약관")
}
}

#Preview {
TermsOfServiceView()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// WriteNickNameView.swift
// WithSuhyeon-iOS
//
// Created by 김예지 on 1/15/25.
//

import SwiftUI

struct WriteNickNameView: View {
var body: some View {
Text("닉네임 입력")
}
}

#Preview {
WriteNickNameView()
}

0 comments on commit cfac658

Please sign in to comment.