Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PC-448] Feat: 홈 사용자 프로필 화면 구현 #25

Merged
merged 10 commits into from
Feb 8, 2025
Merged
47 changes: 47 additions & 0 deletions Domain/Entities/Sources/Profile/ProfileModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// ProfileModel.swift
// Entities
//
// Created by summercat on 1/30/25.
//

public struct ProfileModel {
public init(
nickname: String,
description: String,
age: Int,
birthdate: String,
height: Int,
weight: Int,
job: String,
location: String,
smokingStatus: String,
snsActivityLevel: String,
imageUrl: String
) {
self.nickname = nickname
self.description = description
self.age = age
self.birthdate = birthdate
self.height = height
self.weight = weight
self.job = job
self.location = location
self.smokingStatus = smokingStatus
self.snsActivityLevel = snsActivityLevel
self.imageUrl = imageUrl
}

public let nickname: String
public let description: String
public let age: Int
public let birthdate: String
public let height: Int
public let weight: Int
public let job: String
public let location: String
public let smokingStatus: String
public let snsActivityLevel: String
public let imageUrl: String
// public let contacts // TODO: - 스키마 이름이 안 정해진 것 같음...
}
31 changes: 31 additions & 0 deletions Domain/UseCases/Sources/Profile/GetProfileUseCase.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// GetProfileUseCase.swift
// UseCases
//
// Created by summercat on 1/30/25.
//

import Entities

public protocol GetProfileUseCase {
func execute() async throws -> ProfileModel
}

final class GetProfileUseCaseImpl: GetProfileUseCase {
func execute() async throws -> ProfileModel {
// TODO: - 네트워크 모듈 작업 후 수정
return ProfileModel(
nickname: "닉네임",
description: "소개글",
age: 25,
birthdate: "00",
height: 180,
weight: 72,
job: "프리랜서",
location: "세종특별자치시",
smokingStatus: "비흡연",
snsActivityLevel: "",
imageUrl: "https://www.thesprucepets.com/thmb/AyzHgPQM_X8OKhXEd8XTVIa-UT0=/750x0/filters:no_upscale():max_bytes(150000):strip_icc():format(webp)/GettyImages-145577979-d97e955b5d8043fd96747447451f78b7.jpg"
)
}
}
6 changes: 6 additions & 0 deletions Domain/UseCases/Sources/UseCaseFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
import Foundation

public struct UseCaseFactory {
// MARK: - 사용자 프로필
public static func createGetProfileUseCase() -> GetProfileUseCase {
GetProfileUseCaseImpl()
}

// MARK: - 매칭 상세
public static func createGetMatchProfileBasicUseCase() -> GetMatchProfileBasicUseCase {
GetMatchProfileBasicUseCaseImpl()
}
Expand Down
1 change: 1 addition & 0 deletions Presentation/Coordinator/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ let project = Project.dynamicFramework(
.domain(target: .UseCases),
.presentation(target: .Router),
.presentation(target: .Home),
.presentation(target: .Profile),
.presentation(target: .MatchingDetail),
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "talk-20.svg",
"idiom" : "universal"
}
],
"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.
49 changes: 49 additions & 0 deletions Presentation/DesignSystem/Sources/HomeNavigationBar.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// HomeNavigationBar.swift
// DesignSystem
//
// Created by summercat on 1/30/25.
//

import SwiftUI

public struct HomeNavigationBar: View {
public init(
title: String,
foregroundColor: Color,
rightIcon: Image? = nil,
rightIconTap: (() -> Void)? = nil
) {
self.title = title
self.foregroundColor = foregroundColor
self.rightIcon = rightIcon
self.rightIconTap = rightIconTap
}

public var body: some View {
HStack(alignment: .center, spacing: 20) {
Text(title)
.foregroundStyle(foregroundColor)
.wixMadeforDisplay(.branding)
.frame(maxWidth: .infinity, alignment: .leading)
if let rightIcon {
rightIcon
.renderingMode(.template)
.foregroundStyle(foregroundColor)
.onTapGesture {
rightIconTap?()
}
}
}
.frame(maxWidth: .infinity)
.frame(height: 60)
.padding(.horizontal, 20)
.padding(.vertical, 14)
.background(Color.clear)
}

public let title: String
public let foregroundColor: Color
public let rightIcon: Image?
public let rightIconTap: (() -> Void)?
}
1 change: 1 addition & 0 deletions Presentation/Feature/Home/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ let project = Project.staticLibrary(
dependencies: [
.presentation(target: .DesignSystem),
.presentation(target: .Router),
.presentation(target: .Profile),
.presentation(target: .MatchingMain),
]
)
18 changes: 13 additions & 5 deletions Presentation/Feature/Home/Sources/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@

import DesignSystem
import MatchingMain
import Router
import Profile
import SwiftUI
import UseCases

struct HomeView: View {
@State var viewModel: HomeViewModel
@State private var viewModel: HomeViewModel

init(getProfileUseCase: GetProfileUseCase) {
_viewModel = .init(wrappedValue: .init(getProfileUseCase: getProfileUseCase))
}
dev-summer marked this conversation as resolved.
Show resolved Hide resolved

var body: some View {
ZStack {
Expand All @@ -19,12 +26,13 @@ struct HomeView: View {
}
}

@ViewBuilder
private var content: some View {
switch viewModel.tabbarViewModel.selectedTab {
case .profile:
// TODO: - ProfileView
Rectangle()
.fill(Color.yellow)
ProfileViewFactory.createProfileView(
getProfileUseCase: viewModel.getProfileUseCase
)
case .home:
// TODO: - MatchingMainView
Rectangle()
Expand All @@ -38,5 +46,5 @@ struct HomeView: View {
}

#Preview {
HomeView(viewModel: HomeViewModel())
HomeView(getProfileUseCase: UseCaseFactory.createGetProfileUseCase())
}
8 changes: 7 additions & 1 deletion Presentation/Feature/Home/Sources/HomeViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@
import DesignSystem
import Observation
import SwiftUI
import UseCases

@Observable
final class HomeViewModel {
enum Action { }

init() { }
init(
getProfileUseCase: GetProfileUseCase
) {
self.getProfileUseCase = getProfileUseCase
}

let tabbarViewModel = TabBarViewModel()
private(set) var getProfileUseCase: GetProfileUseCase
}
18 changes: 18 additions & 0 deletions Presentation/Feature/Profile/Project.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Project.swift
// Profile
//
// Created by summercat on 2025/01/30.
//

import ProjectDescription
import ProjectDescriptionHelpers

let project = Project.staticLibrary(
name: Modules.Presentation.Profile.rawValue,
dependencies: [
.domain(target: .UseCases),
.presentation(target: .DesignSystem),
.presentation(target: .Router),
]
)
Loading