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

[Style] 네비게이션 로직 추가 및 칩 네비게이션 추가 #57

Open
wants to merge 4 commits into
base: juri
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,29 @@ struct CustomNavigationBar: View {
}

var body: some View {
ZStack {
if style.showsBackButton {
backButton
}
switch style {
case .primary:
primaryContent
case .search:
searchContent
case .locationDetail:
locationDetailContent
case .locationTitle:
locationTitleContent
case .detail(let isLiked):
detailContent(isLiked: isLiked)
case .detailWithChip(let count):
detailWithChipContent(count: count)
}
}
.frame(height: 56.adjusted)
.background(.white)
}
ZStack {
if style.showsBackButton {
backButton
}

switch style {
case .primary:
primaryContent
case .search:
searchContent
case .locationDetail:
locationDetailContent
case .locationTitle:
locationTitleContent
case .detail(let isLiked):
detailContent(isLiked: isLiked)
case .detailWithChip(let count):
detailWithChipContent(count: count)
}
}
.frame(height: 56.adjusted)
.background(.clear)
}

private var backButtonView: some View {
Button(action: onBackTapped) {
Expand All @@ -70,7 +70,7 @@ struct CustomNavigationBar: View {
}
.padding(.horizontal, 16)
}

private var primaryContent: some View {
HStack {
if !title.isEmpty {
Expand All @@ -80,37 +80,31 @@ struct CustomNavigationBar: View {
Spacer()
}
}

private var searchContent: some View {
HStack(spacing: 12) {
if style.showsBackButton {
backButtonView
}
LogoChip(type: .small, count: 10)

HStack(spacing: 8) {
Image(.icSearchGray600)

TextField("", text: $searchText)
.frame(height: 44.adjusted)
.placeholder(when: searchText.isEmpty) {
Text("플레이스 홀더")
.foregroundColor(Color(.gray600))
}

if !searchText.isEmpty {
Button(action: { searchText = "" }) {
Image(.icCloseGray400)
.foregroundColor(Color(.gray600))
}
}
Text("오늘은 어디서 먹어볼까요?")
.foregroundColor(Color(.gray500))
.frame(maxWidth: .infinity, alignment: .leading)
}
.padding(.horizontal, 12)
.background(Color.white)
.overlay(
RoundedRectangle(cornerRadius: 8)
.stroke(Color(.gray600), lineWidth: 1)
.frame(height: 44.adjustedH)
.background(
RoundedRectangle(cornerRadius: 10)
.fill(Color.white)
.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(Color(.gray200), lineWidth: 1)
)
)
.frame(height: 44.adjusted)
.onTapGesture {
onSearchSubmit?()
}
}
.padding(.horizontal, 16)
}
Expand Down Expand Up @@ -181,3 +175,7 @@ struct CustomNavigationBar: View {
.padding(.horizontal, 16)
}
}

#Preview {
Home()
}
17 changes: 12 additions & 5 deletions Spoony-iOS/Spoony-iOS/Resource/Tab/NavigationManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import SwiftUI
final class NavigationManager: ObservableObject {

@Published var selectedTab: TabType = .map
@Published var isTabBarVisible: Bool = true

@Published var mapPath: [ViewType] = []
@Published var explorePath: [ViewType] = []
Expand All @@ -20,33 +21,39 @@ final class NavigationManager: ObservableObject {
switch view {
case .test:
Explore()

case .searchView:
Home()
SearchView()
case .locationView:
Home()

case .detailView:
Home()

}
}

func push(_ view: ViewType) {
switch selectedTab {
case .map:
if view == .searchView {
isTabBarVisible = false
Copy link
Member

Choose a reason for hiding this comment

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

isTabBarVisible에 따라서 탭뷰가 없어지는 로직이 어딨나용

}
mapPath.append(view)
case .explore:
explorePath.append(view)
case .register:
registerPath.append(view)
}
}

func pop(_ depth: Int) {
switch selectedTab {
case .map:
mapPath.removeLast(depth)
if mapPath.isEmpty || !mapPath.contains(.searchView) {
isTabBarVisible = true
}
case .explore:
explorePath.removeLast(depth)
case .register:
Expand Down
4 changes: 3 additions & 1 deletion Spoony-iOS/Spoony-iOS/Source/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ struct ContentView: View {
TabView(selection: $navigationManager.selectedTab) {
NavigationStack(path: $navigationManager.mapPath) {
Home()
.navigationDestination(for: ViewType.self) { viewType in
navigationManager.build(viewType)
}
}

}
.environmentObject(navigationManager)
}
Expand Down
10 changes: 8 additions & 2 deletions Spoony-iOS/Spoony-iOS/Source/Feature/Home/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ struct Home: View {
style: .search(showBackButton: false),
searchText: $searchText,
onBackTapped: {},
onSearchSubmit: nil,
onSearchSubmit: {
navigationManager.push(.searchView)
},
Comment on lines +24 to +26
Copy link
Member

Choose a reason for hiding this comment

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

push 할때 TabView 히든 처리 해야 할거 같아여!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

수정햇습니다

onLikeTapped: nil
)
.padding(.top, 44)

Spacer()
}
Expand All @@ -34,3 +35,8 @@ struct Home: View {
}
}
}

#Preview {
Home()
.environmentObject(NavigationManager())
}
27 changes: 27 additions & 0 deletions Spoony-iOS/Spoony-iOS/Source/Feature/Search/SearchView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// SearchView.swift
// Spoony-iOS
//
// Created by 이지훈 on 1/16/25.
//

import SwiftUI

struct SearchView: View {
@EnvironmentObject private var navigationManager: NavigationManager
@State private var searchText = ""

var body: some View {
VStack(spacing: 0) {
CustomNavigationBar(
style: .search(showBackButton: true),
searchText: $searchText,
onBackTapped: {
navigationManager.pop(1)
},
onSearchSubmit: nil
)
}
.toolbar(.hidden, for: .tabBar)
}
}