Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
215 changes: 104 additions & 111 deletions SampoomManagement/App/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,141 +12,134 @@ enum Tabs {
}

struct ContentView: View {
// MARK: - Properties
let dependencies: AppDependencies
@StateObject private var partViewModel: PartViewModel
@State private var selectedTab: Tabs = .dashboard
@State private var ordersNavigationPath = NavigationPath()
@State private var partsNavigationPath = NavigationPath()

// MARK: - Initialization
init(dependencies: AppDependencies) {
self.dependencies = dependencies
_partViewModel = StateObject(wrappedValue: dependencies.makePartViewModel())
}

// MARK: - Body
var body: some View {
TabView(selection: $selectedTab) {
// Dashboard 탭 (임시)
Tab(value: .dashboard) {
NavigationStack {
VStack(spacing: 20) {
Spacer()
ZStack {
// 전체 백그라운드
Color.background
.ignoresSafeArea(.all)

TabView(selection: $selectedTab) {
// Dashboard 탭 (임시)
Tab(value: .dashboard) {
DashboardScreen(dependencies: dependencies)
} label: {
Label {
Text(StringResources.Tabs.dashboard)
.font(.largeTitle)
.fontWeight(.bold)
Text(StringResources.Placeholders.inventoryDescription)
.font(.body)
.foregroundColor(.secondary)
.multilineTextAlignment(.center)
.padding(.horizontal, 32)
Spacer()
.font(.gmarketSubheadline)
} icon: {
Image("dashboard")
.renderingMode(.template)
.foregroundStyle(.text)
}
.navigationTitle(StringResources.Tabs.dashboard)
.background(Color.background)
}
} label: {
Label {
Text(StringResources.Tabs.dashboard)
.font(.gmarketSubheadline)
} icon: {
Image("dashboard")
.renderingMode(.template)
.foregroundStyle(.text)
}
}

// Outbound 탭
Tab(value: .outbound) {
NavigationStack {
OutboundListView(viewModel: dependencies.makeOutboundListViewModel())
}
} label: {
Label {
Text(StringResources.Tabs.outbound)
.font(.gmarketSubheadline)
} icon: {
Image("outbound")
.renderingMode(.template)
.foregroundStyle(Color.text)
}
}

// Cart 탭
Tab(value: .cart) {
NavigationStack {
CartListView(viewModel: dependencies.makeCartListViewModel())
}
} label: {
Label {
Text(StringResources.Tabs.cart)
.font(.gmarketSubheadline)
} icon: {
Image("cart")
.renderingMode(.template)
.foregroundStyle(Color.text)

// Outbound 탭
Tab(value: .outbound) {
NavigationStack {
OutboundListView(viewModel: dependencies.makeOutboundListViewModel())
}
} label: {
Label {
Text(StringResources.Tabs.outbound)
.font(.gmarketSubheadline)
} icon: {
Image("outbound")
.renderingMode(.template)
.foregroundStyle(Color.text)
}
}
}

// Orders 탭
Tab(value: .orders) {
NavigationStack(path: $ordersNavigationPath) {
OrderListView(
viewModel: dependencies.makeOrderListViewModel(),
onNavigateOrderDetail: { orderId in
ordersNavigationPath.append(orderId)
}
)
.navigationDestination(for: Int.self) { orderId in
OrderDetailView(
orderId: orderId,
viewModel: dependencies.makeOrderDetailViewModel(orderId: orderId)

// Cart 탭
Tab(value: .cart) {
NavigationStack {
CartListView(
viewModel: dependencies.makeCartListViewModel(),
dependencies: dependencies
)
}
} label: {
Label {
Text(StringResources.Tabs.cart)
.font(.gmarketSubheadline)
} icon: {
Image("cart")
.renderingMode(.template)
.foregroundStyle(Color.text)
}
}
} label: {
Label {
Text(StringResources.Tabs.orders)
.font(.gmarketSubheadline)
} icon: {
Image("orders")
.renderingMode(.template)
.foregroundStyle(Color.text)
}
}

// PartView 탭
Tab(value: .parts, role: .search) {
NavigationStack(path: $partsNavigationPath) {
PartView(
onNavigatePartList: { group in
partsNavigationPath.append(group.id)
},
viewModel: partViewModel,
searchViewModel: dependencies.makeSearchViewModel()
)
.navigationDestination(for: Int.self) { groupId in
PartListView(
viewModel: PartListViewModel(
getPartUseCase: dependencies.getPartUseCase,
groupId: groupId
),
dependencies: dependencies

// Orders 탭
Tab(value: .orders) {
NavigationStack(path: $ordersNavigationPath) {
OrderListView(
viewModel: dependencies.makeOrderListViewModel(),
onNavigateOrderDetail: { orderId in
ordersNavigationPath.append(orderId)
}
)
.navigationDestination(for: Int.self) { orderId in
OrderDetailView(
orderId: orderId,
viewModel: dependencies.makeOrderDetailViewModel(orderId: orderId)
)
}
}
} label: {
Label {
Text(StringResources.Tabs.orders)
.font(.gmarketSubheadline)
} icon: {
Image("orders")
.renderingMode(.template)
.foregroundStyle(Color.text)
}
}
.environmentObject(partViewModel)
} label: {
Label {
Text(StringResources.Tabs.parts)
.font(.gmarketSubheadline)
} icon: {
Image("parts")
.renderingMode(.template)
.foregroundStyle(Color.text)

// PartView 탭
Tab(value: .parts, role: .search) {
NavigationStack(path: $partsNavigationPath) {
PartView(
onNavigatePartList: { group in
partsNavigationPath.append(group.id)
},
viewModel: partViewModel,
searchViewModel: dependencies.makeSearchViewModel()
)
.navigationDestination(for: Int.self) { groupId in
PartListView(
viewModel: dependencies.makePartListViewModel(groupId: groupId),
dependencies: dependencies
)
}
}
.environmentObject(partViewModel)
} label: {
Label {
Text(StringResources.Tabs.parts)
.font(.gmarketSubheadline)
} icon: {
Image("parts")
.renderingMode(.template)
.foregroundStyle(Color.text)
}
}
}
.accentColor(.accentColor)
.tabViewStyle(.automatic)
}
.accentColor(.blue)
.tabViewStyle(.automatic)
.background(Color.background)
}
}
92 changes: 48 additions & 44 deletions SampoomManagement/App/RootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,66 +12,70 @@ struct RootView: View {

@StateObject private var loginViewModel: LoginViewModel
@StateObject private var signUpViewModel: SignUpViewModel
@State private var isAuthenticated: Bool = false
@ObservedObject private var authViewModel: AuthViewModel
@State private var showSignUp: Bool = false

init(dependencies: AppDependencies) {
self.dependencies = dependencies
_loginViewModel = StateObject(wrappedValue: dependencies.makeLoginViewModel())
_signUpViewModel = StateObject(wrappedValue: dependencies.makeSignUpViewModel())
self.authViewModel = dependencies.authViewModel
}

var body: some View {
Group {
if !isAuthenticated {
// 로그인 되어있으면 메인 화면
ContentView(dependencies: dependencies)
} else {
// 로그인 안되어있으면 로그인/회원가입 화면
if showSignUp {
NavigationStack {
SignUpView(
viewModel: signUpViewModel,
onSuccess: {
// 회원가입 성공 시 자동 로그인 완료 → 메인 화면으로
isAuthenticated = true
}
)
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .navigationBarLeading) {
Button(action: {
showSignUp = false
}) {
Image(systemName: "chevron.left")
.foregroundColor(Color(red: 0.5, green: 0.2, blue: 0.8))
ZStack {
// 전체 백그라운드
Color.background
.ignoresSafeArea(.all)

Group {
if authViewModel.isLoggedIn {
// 로그인 되어있으면 메인 화면
ContentView(dependencies: dependencies)
} else {
// 로그인 안되어있으면 로그인/회원가입 화면
if showSignUp {
NavigationStack {
SignUpView(
viewModel: signUpViewModel,
onSuccess: {
// 회원가입 성공 시 자동 로그인 완료 → 메인 화면으로
authViewModel.updateLoginState()
}
)
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .navigationBarLeading) {
Button(action: {
showSignUp = false
}) {
Image(systemName: "chevron.left")
.foregroundColor(Color(red: 0.5, green: 0.2, blue: 0.8))
}
}
}
}
} else {
LoginView(
viewModel: loginViewModel,
onSuccess: {
// 로그인 성공 시 메인 화면으로
authViewModel.updateLoginState()
},
onNavigateSignUp: {
// 회원가입 화면으로
showSignUp = true
}
)
}
} else {
LoginView(
viewModel: loginViewModel,
onSuccess: {
// 로그인 성공 시 메인 화면으로
isAuthenticated = true
},
onNavigateSignUp: {
// 회원가입 화면으로
showSignUp = true
}
)
}
}
}
.background(Color.background)
.onAppear {
// 앱 시작 시 로그인 상태 확인
checkAuthenticationStatus()
.onChange(of: authViewModel.shouldNavigateToLogin) { _, shouldNavigate in
if shouldNavigate {
showSignUp = false
authViewModel.resetNavigationState()
}
}
}

private func checkAuthenticationStatus() {
isAuthenticated = dependencies.authPreferences.hasToken()
}
}
16 changes: 16 additions & 0 deletions SampoomManagement/App/SampoomManagementApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ struct SampoomManagementApp: App {
init() {
// 앱 전체 폰트 설정
setupGlobalFont()
// 앱 전체 백그라운드 설정
setupGlobalBackground()
}

var body: some Scene {
Expand All @@ -33,4 +35,18 @@ struct SampoomManagementApp: App {
UITextView.appearance().font = font
}
}

private func setupGlobalBackground() {
// UIKit 컴포넌트에 대한 기본 백그라운드 설정
UITableView.appearance().backgroundColor = UIColor.clear
UICollectionView.appearance().backgroundColor = UIColor.clear
UINavigationBar.appearance().backgroundColor = UIColor.clear
UITabBar.appearance().backgroundColor = UIColor.clear

// 시스템 배경색 설정
if let backgroundColor = UIColor(named: "Background") {
UINavigationBar.appearance().barTintColor = backgroundColor
UITabBar.appearance().barTintColor = backgroundColor
}
}
}
Loading