Skip to content

Commit

Permalink
Merge pull request #40 from Student-Center/feature/WEAV-118
Browse files Browse the repository at this point in the history
[WEAV-118] 홈 메인 뷰 - 프로필 탭 구현
  • Loading branch information
jisu15-kim authored Nov 5, 2024
2 parents 21ee044 + 018f5ab commit 7321184
Show file tree
Hide file tree
Showing 34 changed files with 1,114 additions and 65 deletions.
4 changes: 2 additions & 2 deletions Projects/App/Sources/Navigation/NavigationStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ extension PathType {
SplashAnimatedView()

// features
case .home:
HomeView()
case .home(let userInfo):
HomeMainView(userInfo: userInfo)

case .signUp(let subView):
switch subView {
Expand Down
4 changes: 3 additions & 1 deletion Projects/App/Sources/Splash/SplashAnimatedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ struct SplashAnimatedView: View {

@MainActor
private func pushToHomeView() {
AppCoordinator.shared.changeRootView(.authDebug)
if let userInfo = AppCoordinator.shared.userInfo {
AppCoordinator.shared.changeRootView(.home(userInfo))
}
}

private func updateIconStates(for step: SplashAnimationStep) {
Expand Down
10 changes: 9 additions & 1 deletion Projects/Core/CommonKit/Sources/Path/PathTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,21 @@ import Foundation
import Model

public enum PathType: Hashable {
public static func == (lhs: PathType, rhs: PathType) -> Bool {
return lhs.hashValue == rhs.hashValue
}

public func hash(into hasher: inout Hasher) {
hasher.combine(self.name)
}

// App
case designPreview
case authDebug
case intro

// Features
case home
case home(UserInfo?)
case signUp(SignUpSubViewType)

#if STAGING || DEBUG
Expand Down
15 changes: 15 additions & 0 deletions Projects/Core/CoreKit/Sources/Int+Ext.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// Int+Ext.swift
// CoreKit
//
// Created by 김지수 on 11/3/24.
// Copyright © 2024 com.weave. All rights reserved.
//

import Foundation

extension Int {
public func toString() -> String {
return String(self)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "building_fill.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "building_fill@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "building_fill@3x.png",
"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
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "business_fill.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "business_fill@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "business_fill@3x.png",
"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
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "location_fill.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "location_fill@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "location_fill@3x.png",
"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 @@ -8,43 +8,43 @@

import SwiftUI

public enum JobOccupation: CaseIterable {
public enum JobOccupation: String, CaseIterable {
/// 경영관리
case business
case business = "BUSINESS_ADMIN"
/// 영업 마케팅
case marketing
case marketing = "SALES_MARKETING"
/// 연구개발
case research
case research = "RESEARCH_DEVELOPMENT"
/// IT 정보통신
case IT
case IT = "IT_INFORMATION"
/// 금융 회계
case financial
case financial = "FINANCE_ACCOUNTING"
/// 생산 제조
case manufacture
case manufacture = "MANUFACTURING_PRODUCTION"
/// 교육 학술
case education
case education = "EDUCATION_ACADEMIA"
/// 법률 행정
case law
case law = "LAW_ADMINISTRATION"
/// 경찰 소방 군인
case policeFirefighterMilitary
case policeFirefighterMilitary = "MILITARY_SECURITY"
/// 의료 보건
case medical
case medical = "HEALTHCARE_MEDICAL"
/// 미디어 언론
case mediaPress
case mediaPress = "MEDIA_ENTERTAINMENT"
/// 예술 문화
case artCulture
case artCulture = "ARTS_DESIGN"
/// 스포츠
case sports
case sports = "SPORTS"
/// 건설 토목
case construction
case construction = "CONSTRUCTION_ENGINEERING"
/// 운송 물류
case transport
case transport = "TRANSPORTATION_LOGISTICS"
/// 농림 어업
case farming
case farming = "AGRICULTURE_FARMING"
/// 서비스
case service
case service = "SERVICE_INDUSTRY"
/// 기타
case etc
case etc = "OTHER"
}

extension JobOccupation {
Expand Down Expand Up @@ -97,25 +97,6 @@ extension JobOccupation {

extension JobOccupation {
public var requestValue: String {
switch self {
case .business: return "BUSINESS_ADMIN"
case .marketing: return "SALES_MARKETING"
case .research: return "RESEARCH_DEVELOPMENT"
case .IT: return "IT_INFORMATION"
case .financial: return "FINANCE_ACCOUNTING"
case .manufacture: return "MANUFACTURING_PRODUCTION"
case .education: return "EDUCATION_ACADEMIA"
case .law: return "LAW_ADMINISTRATION"
case .policeFirefighterMilitary: return "MILITARY_SECURITY"
case .medical: return "HEALTHCARE_MEDICAL"
case .mediaPress: return "MEDIA_ENTERTAINMENT"
case .artCulture: return "ARTS_DESIGN"
case .sports: return "SPORTS"
case .construction: return "CONSTRUCTION_ENGINEERING"
case .transport: return "TRANSPORTATION_LOGISTICS"
case .farming: return "AGRICULTURE_FARMING"
case .service: return "SERVICE_INDUSTRY"
case .etc: return "OTHER"
}
return self.rawValue
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,37 @@ extension TagListCollectionView: UICollectionViewDataSource, UICollectionViewDel
height: 40
)
}

//MARK: - Constants
private static let rowHeight: CGFloat = 40 + 8
private static let horizontalSpacing: CGFloat = 8
private static let horizontalInsets: CGFloat = 0
private static let verticalInsets: CGFloat = 20

//MARK: - 동적 높이 계산
public static func calculateHeight(tags: [TagModel], deviceWidth: CGFloat) -> CGFloat {
var currentLineWidth: CGFloat = 0
var totalHeight: CGFloat = verticalInsets
var currentLineCount: Int = 1

for tag in tags {
let label = UILabel()
label.font = UIFont.pretendard(._500, size: 14)
label.text = tag.name
label.sizeToFit()

let cellWidth = label.frame.size.width + 24

if currentLineWidth + cellWidth + horizontalSpacing <= deviceWidth - horizontalInsets {
currentLineWidth += cellWidth + horizontalSpacing
} else {
currentLineCount += 1
currentLineWidth = cellWidth + horizontalSpacing
}
}

totalHeight += CGFloat(currentLineCount) * rowHeight - 8

return totalHeight
}
}
72 changes: 72 additions & 0 deletions Projects/Features/Home/Sources/HomeMain/HomeMainIntent.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//
// HomeMainIntent.swift
// DesignPreview
//
// Created by 김지수 on 11/2/24.
// Copyright © 2024 com.weave. All rights reserved.
//

import Foundation
import CommonKit
import CoreKit
import Model
import NetworkKit

//MARK: - Intent
class HomeMainIntent {
private weak var model: HomeMainModelActionable?
private let input: DataModel
private let authService: AuthServiceProtocol

// MARK: Life cycle
init(
model: HomeMainModelActionable,
input: DataModel,
service: AuthServiceProtocol = AuthService.shared
) {
self.input = input
self.model = model
self.authService = service
}
}

//MARK: - Intentable
extension HomeMainIntent {
protocol Intentable {
// content
func onTapTab(_ tab: HomeMainTab)
func onTapNextButton()

// default
func onAppear()
func task() async
}

struct DataModel {
let userInfo: UserInfo?
}
}

//MARK: - Intentable
extension HomeMainIntent: HomeMainIntent.Intentable {
// default
func onTapTab(_ tab: HomeMainTab) {
model?.setSelectedTab(tab: tab)
}
func onAppear() {
Task {
if let userInfo = input.userInfo {
model?.setUserInfo(userInfo: userInfo)
} else {
let userInfo = try await authService.requestMyUserInfo()
AppCoordinator.shared.userInfo = userInfo
model?.setUserInfo(userInfo: userInfo)
}
}
}

func task() async {}

// content
func onTapNextButton() {}
}
Loading

0 comments on commit 7321184

Please sign in to comment.