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

DMVM-192(feat): navigation 구현 #22

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
Open
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
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,21 @@
{
"images" : [
{
"filename" : "ChatTabItem.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "ChatTabItemSelected.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
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,21 @@
{
"images" : [
{
"filename" : "HomeTabItem.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "HomeTabItemSelected.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "MyTabItem.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "MyTabItemSelected.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "ReservationTabItem.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "ReservationTabItemSelected.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"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.
47 changes: 34 additions & 13 deletions Mongle/Projects/App/Sources/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,49 @@
// Copyright © 2024 Mongle-iOS. All rights reserved.
//

import Core
import CalendarFeature
import ChatFeature
import OnBoardingFeature
import Core
import HomeFeature
import OnBoardingFeature
import ProfileFeature
import SwiftUI

struct MainView: View {
@StateObject var navigationVM = NavigationViewModel()

@EnvironmentObject var kakaoAuth: KaKaoAuthCore

@State var selectedTabItem = 0

var body: some View {
if kakaoAuth.customer.accessToken != nil {
TabView {
HomeView()
.tabItem {
Image(systemName: "house.fill")
Text("Home")
NavigationStack(path: $navigationVM.path) {
TabView(selection: $selectedTabItem) {
ForEach(TabItem.allCases, id: \.self) { tab in
tab.view
.tabItem {
Image(selectedTabItem == tab.rawValue ? tab.selectedImage : tab.defaultImage)
Text(tab.title)
}
.tag(tab.rawValue)
}

ChatView()
.tabItem {
Image(systemName: "message.fill")
Text("Chat")
} // TabView
.navigationDestination(for: Screen.self) { route in
switch route {
case .home:
HomeView()
case .searchCompany:
SearchView()
case .storeDetail:
Text("test")
case .notification:
NotificationView()
}
} // navigationDestination
.environmentObject(navigationVM)
.onOpenURL { url in
navigationVM.handleDeeplink(url: url)
} // openURL
Comment on lines +36 to +51
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이건 개인의 생각에 따라 다를 것 같은데 가독성을 봤을 때 긴 modifier를 맨 밑으로 가면 어떨까요?
저희가 modifier 규칙을 정하면 좋을 것 같아요!

Suggested change
.navigationDestination(for: Screen.self) { route in
switch route {
case .home:
HomeView()
case .searchCompany:
SearchView()
case .storeDetail:
Text("test")
case .notification:
NotificationView()
}
} // navigationDestination
.environmentObject(navigationVM)
.onOpenURL { url in
navigationVM.handleDeeplink(url: url)
} // openURL
.environmentObject(navigationVM)
.onOpenURL { url in
navigationVM.handleDeeplink(url: url)
} // openURL
.navigationDestination(for: Screen.self) { route in
switch route {
case .home:
HomeView()
case .searchCompany:
SearchView()
case .storeDetail:
Text("test")
case .notification:
NotificationView()
}
} // navigationDestination

}
} else {
LoginView()
Expand All @@ -38,4 +58,5 @@ struct MainView: View {

#Preview {
MainView()
.environmentObject(KaKaoAuthCore())
}
60 changes: 60 additions & 0 deletions Mongle/Projects/App/Sources/TabItem.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//
// TabItem.swift
// Core
//
// Created by Bokyung on 11/24/24.
// Copyright © 2024 Mongle. All rights reserved.
//

import CalendarFeature
import ChatFeature
import HomeFeature
import ProfileFeature
import SwiftUI

enum TabItem: Int, CaseIterable {
case home
case calendar
case chat
case profile

var view: some View {
switch self {
case .home:
return AnyView(HomeView())
case .calendar:
return AnyView(CalendarView())
case .chat:
return AnyView(ChatView())
case .profile:
return AnyView(ProfileView())
}
}

var title: String {
switch self {
case .home: return "홈"
case .calendar: return "예약내역"
case .chat: return "채팅"
case .profile: return "마이"
}
}

var defaultImage: String {
switch self {
case .home: return "HomeTabItem"
case .calendar: return "ReservationTabItem"
case .chat: return "ChatTabItem"
case .profile: return "MyTabItem"
}
}

var selectedImage: String {
switch self {
case .home: return "HomeTabItemSelected"
case .calendar: return "ReservationTabItemSelected"
case .chat: return "ChatTabItemSelected"
case .profile: return "MyTabItemSelected"
}
}
}
16 changes: 16 additions & 0 deletions Mongle/Projects/Core/Sources/Model/Screen.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// Screen.swift
// Core
//
// Created by Bokyung on 11/19/24.
// Copyright © 2024 Mongle. All rights reserved.
//

import Foundation

public enum Screen: String {
case home
case searchCompany
case notification
case storeDetail
}
Loading