From b04100f5c3d5b372921b3a22acaf4c58fccb1889 Mon Sep 17 00:00:00 2001 From: Park Seo Yeon Date: Thu, 13 Jun 2024 15:48:30 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9C=A8[Feat]=20Routert=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Projects/App/Sources/ContentView.swift | 6 +- .../Router/Ex+View+Navigation.swift | 40 ++++++++++++ .../Tabbar+Navigation/Router/Router.swift | 62 +++++++++++++++++++ .../Tabbar+Navigation/Router/RouterView.swift | 38 ++++++++++++ .../Tabbar/Sample/AnotherView.swift | 19 ++++++ .../Tabbar/Sample/SampleView.swift | 62 +++++++++++++++++++ .../Tabbar+Navigation/Tabbar/Tabbar.swift | 58 +++++++++++++++++ .../Tabbar/TabbarMainView.swift | 35 +++++++++++ .../Tabbar+Navigation/Tabbar/TabbarView.swift | 40 ++++++++++++ .../Tabbar/ViewModel/TabbarViewModel.swift | 13 ++++ 10 files changed, 370 insertions(+), 3 deletions(-) create mode 100644 Projects/App/Sources/Presentation/Tabbar+Navigation/Router/Ex+View+Navigation.swift create mode 100644 Projects/App/Sources/Presentation/Tabbar+Navigation/Router/Router.swift create mode 100644 Projects/App/Sources/Presentation/Tabbar+Navigation/Router/RouterView.swift create mode 100644 Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Sample/AnotherView.swift create mode 100644 Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Sample/SampleView.swift create mode 100644 Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Tabbar.swift create mode 100644 Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/TabbarMainView.swift create mode 100644 Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/TabbarView.swift create mode 100644 Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/ViewModel/TabbarViewModel.swift diff --git a/Projects/App/Sources/ContentView.swift b/Projects/App/Sources/ContentView.swift index 46e5cbe..1ad63b8 100644 --- a/Projects/App/Sources/ContentView.swift +++ b/Projects/App/Sources/ContentView.swift @@ -11,9 +11,9 @@ import DesignSystem struct ContentView: View { var body: some View { - Text("Hello, World!") - .applyFont(font: .heading1) - Text("Hello, World!") + RouterView { + TabbarMainView() + } } } diff --git a/Projects/App/Sources/Presentation/Tabbar+Navigation/Router/Ex+View+Navigation.swift b/Projects/App/Sources/Presentation/Tabbar+Navigation/Router/Ex+View+Navigation.swift new file mode 100644 index 0000000..844f441 --- /dev/null +++ b/Projects/App/Sources/Presentation/Tabbar+Navigation/Router/Ex+View+Navigation.swift @@ -0,0 +1,40 @@ +// +// Ex+View+Navigation.swift +// DesignSystem +// +// Created by 박서연 on 2024/06/12. +// Copyright © 2024 iOS. All rights reserved. +// + +import SwiftUI + +public extension View { + func navigationBackButton(_ action: @escaping () -> Void) -> some View { + self.navigationBarBackButtonHidden() + .toolbar { + ToolbarItem(placement: .topBarLeading) { + Button(action: action, label: { + // TODO: - 백버튼 이미지 수정 + + Image("arrowBack") + .resizable() + .frame(width: 24, height: 24) + }) + } + } + } + + func navigationTitle(with text: Text) -> some View { + VStack(spacing: 31) { + HStack(spacing: 0) { + text + .applyFont(font: .heading1) + .frame(height: 47) + .frame(maxWidth: .infinity, alignment: .leading) + .padding(.init(top: 10, leading: 22, bottom: 10, trailing: 0)) + Spacer() + } + self + } + } +} diff --git a/Projects/App/Sources/Presentation/Tabbar+Navigation/Router/Router.swift b/Projects/App/Sources/Presentation/Tabbar+Navigation/Router/Router.swift new file mode 100644 index 0000000..97e6e96 --- /dev/null +++ b/Projects/App/Sources/Presentation/Tabbar+Navigation/Router/Router.swift @@ -0,0 +1,62 @@ +// +// Router.swift +// DesignSystem +// +// Created by 박서연 on 2024/06/12. +// Copyright © 2024 iOS. All rights reserved. +// + +import Foundation +import SwiftUI + +public class Router: ObservableObject { + public enum Route: Hashable, Identifiable { + public var id: Self { self } + + case tabView + case login + case home + case category + case mypage + case review + case setting + } + + @Published public var path: NavigationPath = NavigationPath() + + @ViewBuilder public func view(for route: Route) -> some View { + switch route { + case .tabView: + TabbarMainView() + case .login: + Text("login") + case .home: + HomeView() + case .category: + CategoryView() + case .mypage: + MypageView() + case .review: + AnotherView() + case .setting: + Text("setting") + } + } + + public func navigateTo(_ page: Route) { + path.append(page) + } + + public func navigateBack() { + path.removeLast() + } + + public func popToRoot() { + path.removeLast(path.count) + } + + public func replaceNavigationStack(_ page: Route) { + path.removeLast(path.count) + path.append(page) + } +} diff --git a/Projects/App/Sources/Presentation/Tabbar+Navigation/Router/RouterView.swift b/Projects/App/Sources/Presentation/Tabbar+Navigation/Router/RouterView.swift new file mode 100644 index 0000000..0ff8be9 --- /dev/null +++ b/Projects/App/Sources/Presentation/Tabbar+Navigation/Router/RouterView.swift @@ -0,0 +1,38 @@ +// +// RouterView.swift +// DesignSystem +// +// Created by 박서연 on 2024/06/12. +// Copyright © 2024 iOS. All rights reserved. +// + +import SwiftUI + +struct RouterView: View { + @StateObject var router: Router = Router() + private let content: Content + + init(@ViewBuilder content: @escaping () -> Content) { + self.content = content() + } + + var body: some View { + NavigationStack(path: $router.path) { + VStack { + content + } + .navigationDestination(for: Router.Route.self) { route in + router.view(for: route) + } + .onAppear { + router.navigateTo(.tabView) + } + .navigationBarTitle("", displayMode: .inline) + } + .environmentObject(router) + } +} + +//#Preview { +// RouterView() +//} diff --git a/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Sample/AnotherView.swift b/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Sample/AnotherView.swift new file mode 100644 index 0000000..4db7482 --- /dev/null +++ b/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Sample/AnotherView.swift @@ -0,0 +1,19 @@ +// +// AnotherView.swift +// App +// +// Created by 박서연 on 2024/06/13. +// Copyright © 2024 iOS. All rights reserved. +// + +import SwiftUI + +struct AnotherView: View { + var body: some View { + Text("Saaaaample Viewwwwww") + } +} + +#Preview { + AnotherView() +} diff --git a/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Sample/SampleView.swift b/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Sample/SampleView.swift new file mode 100644 index 0000000..a4c8db8 --- /dev/null +++ b/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Sample/SampleView.swift @@ -0,0 +1,62 @@ +// +// HomeView.swift +// DesignSystem +// +// Created by 박서연 on 2024/06/12. +// Copyright © 2024 iOS. All rights reserved. +// + +import SwiftUI + +struct HomeView: View { + @EnvironmentObject var router: Router + @EnvironmentObject var viewModel: TabbarViewModel + + var body: some View { + ZStack { + Color.red + .ignoresSafeArea() + Text("Go TO CATEGORY VIEW") + .onTapGesture { + viewModel.selected = .category + } + .foregroundStyle(.white) + } + } +} + +struct CategoryView: View { + @EnvironmentObject var router: Router + @EnvironmentObject var viewModel: TabbarViewModel + + var body: some View { + ZStack { + Color.yellow + .ignoresSafeArea() + Text("GO TO MYPAGEVIEW") + .onTapGesture { + viewModel.selected = .mypage + } + } + } +} + +struct MypageView: View { + @EnvironmentObject var router: Router + @EnvironmentObject var viewModel: TabbarViewModel + + var body: some View { + ZStack { + Color.green + .ignoresSafeArea() + Text("GO TO Another View") + .onTapGesture { + router.replaceNavigationStack(.review) + } + } + } +} + +#Preview { + HomeView() +} diff --git a/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Tabbar.swift b/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Tabbar.swift new file mode 100644 index 0000000..ded8fd4 --- /dev/null +++ b/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Tabbar.swift @@ -0,0 +1,58 @@ +// +// Tabbar.swift +// DesignSystem +// +// Created by 박서연 on 2024/06/12. +// Copyright © 2024 iOS. All rights reserved. +// + +import SwiftUI + +enum Tabbar: CaseIterable { + case home, category, mypage + + @ViewBuilder + var view: some View { + switch self { + case .home: + HomeView() + case .category: + CategoryView() + case .mypage: + MypageView() + } + } + + var title: String { + switch self { + case .home: + "홈" + case .category: + "키테고리 검색" + case .mypage: + "마이페이지" + } + } + +// var image: Image { +// switch self { +// case .home: +// <#code#> +// case .category: +// <#code#> +// case .mypage: +// <#code#> +// } +// } + +// var image_fill: Image { +// switch self { +// case .home: +// <#code#> +// case .category: +// <#code#> +// case .mypage: +// <#code#> +// } +// } +} diff --git a/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/TabbarMainView.swift b/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/TabbarMainView.swift new file mode 100644 index 0000000..8a9bf04 --- /dev/null +++ b/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/TabbarMainView.swift @@ -0,0 +1,35 @@ +// +// TabbarMainView.swift +// DesignSystem +// +// Created by 박서연 on 2024/06/12. +// Copyright © 2024 iOS. All rights reserved. +// + +import SwiftUI + +struct TabbarMainView: View { + @StateObject public var viewModel = TabbarViewModel() + + var body: some View { + NavigationStack { + TabView(selection: $viewModel.selected) { + ForEach(Tabbar.allCases, id: \.self) { tab in + tab.view + } + .toolbarBackground(.hidden, for: .tabBar) + } + } + .overlay { + VStack { + Spacer() + TabbarView(viewModel: viewModel) + } + } + .environmentObject(viewModel) + } +} + +#Preview { + TabbarMainView() +} diff --git a/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/TabbarView.swift b/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/TabbarView.swift new file mode 100644 index 0000000..29db16c --- /dev/null +++ b/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/TabbarView.swift @@ -0,0 +1,40 @@ +// +// TabbarView.swift +// DesignSystem +// +// Created by 박서연 on 2024/06/12. +// Copyright © 2024 iOS. All rights reserved. +// + +import SwiftUI + +struct TabbarView: View { + @ObservedObject var viewModel: TabbarViewModel + + var body: some View { + HStack { + ForEach(Tabbar.allCases, id: \.self) { item in + Button { + viewModel.selected = item + } label: { + VStack(spacing: 0) { + Image(systemName: "house") + .frame(width: 39, height: 39) + Text(item.title) + .applyFont(font: .label1) + .foregroundStyle(Color.neutral400) + } + } + .frame(maxWidth: .infinity, alignment: .center) + .padding(.bottom, 10) + .onTapGesture { + viewModel.selected = item + } + } + } + } +} + +#Preview { + TabbarView(viewModel: TabbarViewModel()) +} diff --git a/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/ViewModel/TabbarViewModel.swift b/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/ViewModel/TabbarViewModel.swift new file mode 100644 index 0000000..d5f0869 --- /dev/null +++ b/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/ViewModel/TabbarViewModel.swift @@ -0,0 +1,13 @@ +// +// TabbarViewModel.swift +// App +// +// Created by 박서연 on 2024/06/13. +// Copyright © 2024 iOS. All rights reserved. +// + +import SwiftUI + +final class TabbarViewModel: ObservableObject { + @Published var selected: Tabbar = .home +} From c66a2f36fd7d68725d5a2dcb0817d115f0db688e Mon Sep 17 00:00:00 2001 From: Park Seo Yeon Date: Tue, 18 Jun 2024 02:13:34 +0900 Subject: [PATCH 2/3] :art: [Improve] Router Develop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Router 적용 수정 - 디자인 미적용 --- Projects/App/Sources/ContentView.swift | 4 +- .../Tabbar+Navigation/Router/Router.swift | 51 ++++++++----------- .../Tabbar+Navigation/Router/RouterView.swift | 7 --- .../Tabbar/Sample/SampleView.swift | 22 ++++---- .../Tabbar+Navigation/Tabbar/Tabbar.swift | 43 +++++++--------- .../Tabbar/TabbarMainView.swift | 32 +++++++++--- .../Tabbar+Navigation/Tabbar/TabbarView.swift | 20 ++++---- Projects/App/Sources/ZerosomeApp.swift | 2 +- 8 files changed, 86 insertions(+), 95 deletions(-) diff --git a/Projects/App/Sources/ContentView.swift b/Projects/App/Sources/ContentView.swift index 1ad63b8..9bff19b 100644 --- a/Projects/App/Sources/ContentView.swift +++ b/Projects/App/Sources/ContentView.swift @@ -11,8 +11,8 @@ import DesignSystem struct ContentView: View { var body: some View { - RouterView { - TabbarMainView() + VStack { + Text("dd") } } } diff --git a/Projects/App/Sources/Presentation/Tabbar+Navigation/Router/Router.swift b/Projects/App/Sources/Presentation/Tabbar+Navigation/Router/Router.swift index 97e6e96..5b3f44f 100644 --- a/Projects/App/Sources/Presentation/Tabbar+Navigation/Router/Router.swift +++ b/Projects/App/Sources/Presentation/Tabbar+Navigation/Router/Router.swift @@ -9,53 +9,42 @@ import Foundation import SwiftUI -public class Router: ObservableObject { - public enum Route: Hashable, Identifiable { - public var id: Self { self } - - case tabView - case login - case home - case category - case mypage - case review - case setting +final class Router: ObservableObject { + enum Route: Hashable, Identifiable { + var id: Self { self } + + case productDetail + case productReview + case categoryFilter } - @Published public var path: NavigationPath = NavigationPath() + @Published var path: NavigationPath = NavigationPath() + @Published var defaultView: Tabbar = .home - @ViewBuilder public func view(for route: Route) -> some View { + @ViewBuilder func view(for route: Route) -> some View { switch route { - case .tabView: - TabbarMainView() - case .login: - Text("login") - case .home: - HomeView() - case .category: - CategoryView() - case .mypage: - MypageView() - case .review: - AnotherView() - case .setting: - Text("setting") + case .productDetail: + Text("제품 상세뷰") + case .productReview: + Text("제품 리뷰뷰") + case .categoryFilter: + Text("카테고리 선택뷰") } } - public func navigateTo(_ page: Route) { + func navigateTo(_ page: Route) { path.append(page) } - public func navigateBack() { + func navigateBack() { path.removeLast() } - public func popToRoot() { + func popToRoot() { path.removeLast(path.count) } - public func replaceNavigationStack(_ page: Route) { + func replaceNavigationStack(_ page: Route) { path.removeLast(path.count) path.append(page) } diff --git a/Projects/App/Sources/Presentation/Tabbar+Navigation/Router/RouterView.swift b/Projects/App/Sources/Presentation/Tabbar+Navigation/Router/RouterView.swift index 0ff8be9..354a5d0 100644 --- a/Projects/App/Sources/Presentation/Tabbar+Navigation/Router/RouterView.swift +++ b/Projects/App/Sources/Presentation/Tabbar+Navigation/Router/RouterView.swift @@ -24,15 +24,8 @@ struct RouterView: View { .navigationDestination(for: Router.Route.self) { route in router.view(for: route) } - .onAppear { - router.navigateTo(.tabView) - } .navigationBarTitle("", displayMode: .inline) } .environmentObject(router) } } - -//#Preview { -// RouterView() -//} diff --git a/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Sample/SampleView.swift b/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Sample/SampleView.swift index a4c8db8..95cd6d1 100644 --- a/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Sample/SampleView.swift +++ b/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Sample/SampleView.swift @@ -10,32 +10,31 @@ import SwiftUI struct HomeView: View { @EnvironmentObject var router: Router - @EnvironmentObject var viewModel: TabbarViewModel var body: some View { ZStack { - Color.red - .ignoresSafeArea() - Text("Go TO CATEGORY VIEW") +// Color.red +// .ignoresSafeArea() + Text("GO TO ANOTHERVIEW") +// .foregroundStyle(.white) + .font(.largeTitle) .onTapGesture { - viewModel.selected = .category + router.navigateTo(.categoryFilter) } - .foregroundStyle(.white) } } } struct CategoryView: View { @EnvironmentObject var router: Router - @EnvironmentObject var viewModel: TabbarViewModel var body: some View { ZStack { Color.yellow .ignoresSafeArea() - Text("GO TO MYPAGEVIEW") + Text("GO TO ANOTHERVIEW") .onTapGesture { - viewModel.selected = .mypage + router.navigateTo(.productDetail) } } } @@ -43,15 +42,14 @@ struct CategoryView: View { struct MypageView: View { @EnvironmentObject var router: Router - @EnvironmentObject var viewModel: TabbarViewModel var body: some View { ZStack { Color.green .ignoresSafeArea() - Text("GO TO Another View") + Text("GO TO PRODUCTDETAIL") .onTapGesture { - router.replaceNavigationStack(.review) + router.replaceNavigationStack(.productDetail) } } } diff --git a/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Tabbar.swift b/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Tabbar.swift index ded8fd4..97c6e57 100644 --- a/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Tabbar.swift +++ b/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Tabbar.swift @@ -15,11 +15,17 @@ enum Tabbar: CaseIterable { var view: some View { switch self { case .home: - HomeView() + RouterView { + HomeView() + } case .category: - CategoryView() + RouterView { + CategoryView() + } case .mypage: - MypageView() + RouterView { + MypageView() + } } } @@ -34,25 +40,14 @@ enum Tabbar: CaseIterable { } } -// var image: Image { -// switch self { -// case .home: -// <#code#> -// case .category: -// <#code#> -// case .mypage: -// <#code#> -// } -// } - -// var image_fill: Image { -// switch self { -// case .home: -// <#code#> -// case .category: -// <#code#> -// case .mypage: -// <#code#> -// } -// } + var image: String { + switch self { + case .home: + "house" + case .category: + "star.fill" + case .mypage: + "heart.fill" + } + } } diff --git a/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/TabbarMainView.swift b/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/TabbarMainView.swift index 8a9bf04..cbdd51c 100644 --- a/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/TabbarMainView.swift +++ b/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/TabbarMainView.swift @@ -12,21 +12,37 @@ struct TabbarMainView: View { @StateObject public var viewModel = TabbarViewModel() var body: some View { - NavigationStack { - TabView(selection: $viewModel.selected) { - ForEach(Tabbar.allCases, id: \.self) { tab in - tab.view - } - .toolbarBackground(.hidden, for: .tabBar) + TabView(selection: $viewModel.selected) { + ForEach(Tabbar.allCases, id: \.self) { tab in + tab.view } + .toolbarBackground(.hidden, for: .tabBar) } .overlay { VStack { Spacer() - TabbarView(viewModel: viewModel) + HStack { + ForEach(Tabbar.allCases, id: \.self) { item in + VStack(spacing: 5) { + Image(systemName: item.image) + .frame(width: 24, height: 24) + Text(item.title) + .applyFont(font: .label1) + .foregroundStyle(Color.neutral400) + } + .frame(maxWidth: .infinity, alignment: .center) + .contentShape(Rectangle()) + .padding(.bottom, 10) + .onTapGesture { + viewModel.selected = item + print("item \(item)") + } + } + } + .padding(.top, 10) + .background(.white) } } - .environmentObject(viewModel) } } diff --git a/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/TabbarView.swift b/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/TabbarView.swift index 29db16c..c0fd702 100644 --- a/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/TabbarView.swift +++ b/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/TabbarView.swift @@ -14,24 +14,24 @@ struct TabbarView: View { var body: some View { HStack { ForEach(Tabbar.allCases, id: \.self) { item in - Button { - viewModel.selected = item - } label: { - VStack(spacing: 0) { - Image(systemName: "house") - .frame(width: 39, height: 39) - Text(item.title) - .applyFont(font: .label1) - .foregroundStyle(Color.neutral400) - } + VStack(spacing: 5) { + Image(systemName: item.image) + .frame(width: 24, height: 24) + Text(item.title) + .applyFont(font: .label1) + .foregroundStyle(Color.neutral400) } .frame(maxWidth: .infinity, alignment: .center) + .contentShape(Rectangle()) .padding(.bottom, 10) .onTapGesture { viewModel.selected = item + print("item \(item)") } } } + .padding(.top, 10) + .background(.white) } } diff --git a/Projects/App/Sources/ZerosomeApp.swift b/Projects/App/Sources/ZerosomeApp.swift index 68f45e7..581dbfb 100644 --- a/Projects/App/Sources/ZerosomeApp.swift +++ b/Projects/App/Sources/ZerosomeApp.swift @@ -14,7 +14,7 @@ import KakaoSDKAuth struct ZerosomeApp: App { var body: some Scene { WindowGroup { - ContentView() + TabbarMainView() } } } From 16bc92d199e05ae18f9b666f29310aae97bb2739 Mon Sep 17 00:00:00 2001 From: Park Seo Yeon Date: Tue, 18 Jun 2024 02:51:29 +0900 Subject: [PATCH 3/3] =?UTF-8?q?:lipstick:=20[Design]=20Tabbar=20=EB=94=94?= =?UTF-8?q?=EC=9E=90=EC=9D=B8=201=EC=B0=A8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tabbar/Sample/AnotherView.swift | 19 -------- .../Tabbar/Sample/SampleView.swift | 3 -- .../Tabbar/TabbarMainView.swift | 23 +-------- .../Tabbar+Navigation/Tabbar/TabbarView.swift | 48 ++++++++++++------- 4 files changed, 32 insertions(+), 61 deletions(-) delete mode 100644 Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Sample/AnotherView.swift diff --git a/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Sample/AnotherView.swift b/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Sample/AnotherView.swift deleted file mode 100644 index 4db7482..0000000 --- a/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Sample/AnotherView.swift +++ /dev/null @@ -1,19 +0,0 @@ -// -// AnotherView.swift -// App -// -// Created by 박서연 on 2024/06/13. -// Copyright © 2024 iOS. All rights reserved. -// - -import SwiftUI - -struct AnotherView: View { - var body: some View { - Text("Saaaaample Viewwwwww") - } -} - -#Preview { - AnotherView() -} diff --git a/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Sample/SampleView.swift b/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Sample/SampleView.swift index 95cd6d1..114180a 100644 --- a/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Sample/SampleView.swift +++ b/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/Sample/SampleView.swift @@ -13,10 +13,7 @@ struct HomeView: View { var body: some View { ZStack { -// Color.red -// .ignoresSafeArea() Text("GO TO ANOTHERVIEW") -// .foregroundStyle(.white) .font(.largeTitle) .onTapGesture { router.navigateTo(.categoryFilter) diff --git a/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/TabbarMainView.swift b/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/TabbarMainView.swift index cbdd51c..f86bb4f 100644 --- a/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/TabbarMainView.swift +++ b/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/TabbarMainView.swift @@ -10,7 +10,7 @@ import SwiftUI struct TabbarMainView: View { @StateObject public var viewModel = TabbarViewModel() - + var body: some View { TabView(selection: $viewModel.selected) { ForEach(Tabbar.allCases, id: \.self) { tab in @@ -21,26 +21,7 @@ struct TabbarMainView: View { .overlay { VStack { Spacer() - HStack { - ForEach(Tabbar.allCases, id: \.self) { item in - VStack(spacing: 5) { - Image(systemName: item.image) - .frame(width: 24, height: 24) - Text(item.title) - .applyFont(font: .label1) - .foregroundStyle(Color.neutral400) - } - .frame(maxWidth: .infinity, alignment: .center) - .contentShape(Rectangle()) - .padding(.bottom, 10) - .onTapGesture { - viewModel.selected = item - print("item \(item)") - } - } - } - .padding(.top, 10) - .background(.white) + TabbarView(viewModel: viewModel) } } } diff --git a/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/TabbarView.swift b/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/TabbarView.swift index c0fd702..2b3f2c5 100644 --- a/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/TabbarView.swift +++ b/Projects/App/Sources/Presentation/Tabbar+Navigation/Tabbar/TabbarView.swift @@ -10,28 +10,40 @@ import SwiftUI struct TabbarView: View { @ObservedObject var viewModel: TabbarViewModel + @EnvironmentObject var router: Router var body: some View { - HStack { - ForEach(Tabbar.allCases, id: \.self) { item in - VStack(spacing: 5) { - Image(systemName: item.image) - .frame(width: 24, height: 24) - Text(item.title) - .applyFont(font: .label1) - .foregroundStyle(Color.neutral400) - } - .frame(maxWidth: .infinity, alignment: .center) - .contentShape(Rectangle()) - .padding(.bottom, 10) - .onTapGesture { - viewModel.selected = item - print("item \(item)") + Rectangle() + .fill(Color.white) + .shadow(color: .black.opacity(0.01), radius: 1, y: -2.0) + .blur(radius: 8) + .shadow(radius: 10) + .frame(height: 66) + .overlay { + HStack { + ForEach(Tabbar.allCases, id: \.self) { item in + VStack(spacing: 5) { + Image(systemName: item.image) + .frame(width: 24, height: 24) + Text(item.title) + .applyFont(font: .label1) + .foregroundStyle(Color.neutral400) + } + .frame(maxWidth: .infinity, alignment: .center) + .contentShape(Rectangle()) + .padding(.bottom, 10) + .onTapGesture { + viewModel.selected = item + } +// .simultaneousGesture(TapGesture(count: 2).onEnded { +// router.popToRoot() +// }) + } } + .padding(.top, 10) + .background(.white) } - } - .padding(.top, 10) - .background(.white) + } }