From adaf7e350a50b97e207bf07e5de451bdb124dccd Mon Sep 17 00:00:00 2001 From: HyeRyeong Jang <59547116+hryeong66@users.noreply.github.com> Date: Thu, 27 Jun 2024 22:53:58 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20main=20tab=20=EA=B5=AC=ED=98=84=20(#16)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 기본 탭 추가 (#13) * feat: tabItem 파라미터 수정 (#13) feat: tab 기본 화면들 background color 추가(#13) * feat: mainTab과 view 파일 분리 (#13) * feat: 코드리뷰 반영 - 부분 cornerRadius 함수 clipShape로 변경 * feat: feature 프로젝트 생성 후 파일 이동 (#13) * etc: dummy 파일 삭제 (#13) * feat: 코드리뷰 반영 - color값 사용 방식 변경 및 indent 수정(#13) * etc: 잘못 들어간 모듈 삭제 (#13) * feat: TabBarView 컴포넌트 stack 정리 --- Projects/App/Project.swift | 6 ++ Projects/App/Sources/FarmemeApp.swift | 9 +- .../PPACNetwork/Sources/NetworkService.swift | 2 +- Projects/Features/Home/Sources/Dummy.swift | 1 - .../Home/Sources/View/MainTab/MainTab.swift | 53 ++++++++++++ .../Sources/View/MainTab/MainTabView.swift | 83 +++++++++++++++++++ Projects/Features/MyPage/Project.swift | 26 ++++++ .../Features/MyPage/Resources/dummy.swift | 1 + .../MyPage/Sources/View/MyPageView.swift | 22 +++++ Projects/Features/Recommend/Project.swift | 26 ++++++ .../Features/Recommend/Resources/dummy.swift | 1 + .../Sources/View/RecommendView.swift | 24 ++++++ Projects/Features/Search/Project.swift | 26 ++++++ .../Features/Search/Resources/dummy.swift | 1 + .../Search/Sources/View/SearchView.swift | 22 +++++ .../TargetDependency+.swift | 3 + 16 files changed, 300 insertions(+), 6 deletions(-) delete mode 100644 Projects/Features/Home/Sources/Dummy.swift create mode 100644 Projects/Features/Home/Sources/View/MainTab/MainTab.swift create mode 100644 Projects/Features/Home/Sources/View/MainTab/MainTabView.swift create mode 100644 Projects/Features/MyPage/Project.swift create mode 100644 Projects/Features/MyPage/Resources/dummy.swift create mode 100644 Projects/Features/MyPage/Sources/View/MyPageView.swift create mode 100644 Projects/Features/Recommend/Project.swift create mode 100644 Projects/Features/Recommend/Resources/dummy.swift create mode 100644 Projects/Features/Recommend/Sources/View/RecommendView.swift create mode 100644 Projects/Features/Search/Project.swift create mode 100644 Projects/Features/Search/Resources/dummy.swift create mode 100644 Projects/Features/Search/Sources/View/SearchView.swift diff --git a/Projects/App/Project.swift b/Projects/App/Project.swift index 487568b..8dcf13b 100644 --- a/Projects/App/Project.swift +++ b/Projects/App/Project.swift @@ -22,6 +22,9 @@ let project = Project.configure( resources: "Resources/**", dependencies: [ .Feature.Home, + .Feature.Recommend, + .Feature.Search, + .Feature.MyPage, .ResourceKit, .Core.DesignSystem, .Core.PPACNetwork, @@ -47,6 +50,9 @@ let project = Project.configure( resources: "Resources/**", dependencies: [ .Feature.Home, + .Feature.Recommend, + .Feature.Search, + .Feature.MyPage, .ResourceKit, .Core.DesignSystem, .Core.PPACNetwork, diff --git a/Projects/App/Sources/FarmemeApp.swift b/Projects/App/Sources/FarmemeApp.swift index c62e65a..dc9c26c 100644 --- a/Projects/App/Sources/FarmemeApp.swift +++ b/Projects/App/Sources/FarmemeApp.swift @@ -7,12 +7,13 @@ // import SwiftUI +import Home @main struct FarmemeApp: App { - var body: some Scene { - WindowGroup { - ContentView() - } + var body: some Scene { + WindowGroup { + MainTabView() } + } } diff --git a/Projects/Core/PPACNetwork/Sources/NetworkService.swift b/Projects/Core/PPACNetwork/Sources/NetworkService.swift index 2ccf3a6..e2104c5 100644 --- a/Projects/Core/PPACNetwork/Sources/NetworkService.swift +++ b/Projects/Core/PPACNetwork/Sources/NetworkService.swift @@ -22,7 +22,7 @@ final public class NetworkService: NetworkServiceable { let (data, response): (Data, URLResponse) do { - (data, response) = try? await URLSession.shared.data(for: urlRequest) + (data, response) = try await URLSession.shared.data(for: urlRequest) } catch { NetworkLogger.logError(.invalidResponse) return .failure(.invalidResponse) diff --git a/Projects/Features/Home/Sources/Dummy.swift b/Projects/Features/Home/Sources/Dummy.swift deleted file mode 100644 index 8af4b57..0000000 --- a/Projects/Features/Home/Sources/Dummy.swift +++ /dev/null @@ -1 +0,0 @@ -// dummy임니다 diff --git a/Projects/Features/Home/Sources/View/MainTab/MainTab.swift b/Projects/Features/Home/Sources/View/MainTab/MainTab.swift new file mode 100644 index 0000000..e69a6a6 --- /dev/null +++ b/Projects/Features/Home/Sources/View/MainTab/MainTab.swift @@ -0,0 +1,53 @@ +// +// MainTab.swift +// DesignSystem +// +// Created by 장혜령 on 6/17/24. +// + +import SwiftUI +import Recommend +import Search +import MyPage + +enum MainTab: String, CaseIterable, Identifiable { + case recommend + case search + case mypage + + var id: String { rawValue } + + var image: String { + switch self { + case .recommend: + return "1.square.fill" + case .search: + return "2.square.fill" + case .mypage: + return "3.square.fill" + } + } + + var selectedImage: String { + switch self { + case .recommend: + return "1.square" + case .search: + return "2.square" + case .mypage: + return "3.square" + } + } + + var title: String { + switch self { + case .recommend: + return "추천" + case .search: + return "검색" + case .mypage: + return "마이" + } + } + +} diff --git a/Projects/Features/Home/Sources/View/MainTab/MainTabView.swift b/Projects/Features/Home/Sources/View/MainTab/MainTabView.swift new file mode 100644 index 0000000..ff9ec76 --- /dev/null +++ b/Projects/Features/Home/Sources/View/MainTab/MainTabView.swift @@ -0,0 +1,83 @@ +// +// MainTabView.swift +// DesignSystem +// +// Created by 장혜령 on 6/16/24. +// + +import SwiftUI +import Recommend +import Search +import MyPage + +public struct MainTabView: View { + @State private var selectedTab: MainTab = .recommend + + public init() {} + + public var body: some View { + ZStack { + TabView(selection: $selectedTab) { + RecommendView() + .tag(MainTab.recommend) + SearchView() + .tag(MainTab.search) + MyPageView() + .tag(MainTab.mypage) + } + VStack { + Spacer() + CustomTabBarView(selectedTab: $selectedTab) + } + } + .edgesIgnoringSafeArea(.bottom) + } +} + +struct CustomTabBarView: View { + @Binding var selectedTab: MainTab + + var body: some View { + VStack { + HStack { + ForEach(MainTab.allCases) { tab in + TabItemView(tab: tab, isSelected: selectedTab == tab) + .onTapGesture { + selectedTab = tab + } + } + } + Spacer(minLength: 20) + } + .frame(maxWidth: .infinity, maxHeight: 98) + .background(.white) + .clipShape( + .rect( + topLeadingRadius: 30, + topTrailingRadius: 30 + ) + ) + } +} + + +struct TabItemView: View { + + let tab: MainTab + let isSelected: Bool + + var body: some View { + VStack { + Image(systemName: isSelected ? tab.selectedImage : tab.image) + .frame(width: 20, height: 20) + Text(tab.title) + .font(.system(size: 11)) + } + .padding(40) + } +} + + +#Preview { + MainTabView() +} diff --git a/Projects/Features/MyPage/Project.swift b/Projects/Features/MyPage/Project.swift new file mode 100644 index 0000000..38c795f --- /dev/null +++ b/Projects/Features/MyPage/Project.swift @@ -0,0 +1,26 @@ +// +// Project.swift +// MyPage +// +// Created by hyeryeong on 6/18/24 +// + +import ProjectDescription +import ProjectDescriptionHelpers + +let project = Project( + name: "MyPage", + targets: [ + .configure( + name: "MyPage", + product: .framework, + infoPlist: .default, + sources: "Sources/**", + resources: "Resources/**", + dependencies: [ + + ] + ) + ] +) + diff --git a/Projects/Features/MyPage/Resources/dummy.swift b/Projects/Features/MyPage/Resources/dummy.swift new file mode 100644 index 0000000..2ad55c7 --- /dev/null +++ b/Projects/Features/MyPage/Resources/dummy.swift @@ -0,0 +1 @@ +더미임미다 \ No newline at end of file diff --git a/Projects/Features/MyPage/Sources/View/MyPageView.swift b/Projects/Features/MyPage/Sources/View/MyPageView.swift new file mode 100644 index 0000000..96fcc80 --- /dev/null +++ b/Projects/Features/MyPage/Sources/View/MyPageView.swift @@ -0,0 +1,22 @@ +// +// MyPageView.swift +// DesignSystem +// +// Created by 장혜령 on 6/16/24. +// + +import SwiftUI + +public struct MyPageView: View { + public init() { } + + public var body: some View { + Text("마이페이지 화면") + .frame(maxWidth: .infinity, maxHeight: .infinity) + .background(.blue) + } +} + +#Preview { + MyPageView() +} diff --git a/Projects/Features/Recommend/Project.swift b/Projects/Features/Recommend/Project.swift new file mode 100644 index 0000000..590e07d --- /dev/null +++ b/Projects/Features/Recommend/Project.swift @@ -0,0 +1,26 @@ +// +// Project.swift +// Recommend +// +// Created by hyeryeong on 6/18/24 +// + +import ProjectDescription +import ProjectDescriptionHelpers + +let project = Project( + name: "Recommend", + targets: [ + .configure( + name: "Recommend", + product: .framework, + infoPlist: .default, + sources: "Sources/**", + resources: "Resources/**", + dependencies: [ + + ] + ) + ] +) + diff --git a/Projects/Features/Recommend/Resources/dummy.swift b/Projects/Features/Recommend/Resources/dummy.swift new file mode 100644 index 0000000..2ad55c7 --- /dev/null +++ b/Projects/Features/Recommend/Resources/dummy.swift @@ -0,0 +1 @@ +더미임미다 \ No newline at end of file diff --git a/Projects/Features/Recommend/Sources/View/RecommendView.swift b/Projects/Features/Recommend/Sources/View/RecommendView.swift new file mode 100644 index 0000000..bb31e70 --- /dev/null +++ b/Projects/Features/Recommend/Sources/View/RecommendView.swift @@ -0,0 +1,24 @@ +// +// RecommendView.swift +// Home +// +// Created by 장혜령 on 6/16/24. +// + +import SwiftUI + +public struct RecommendView: View { + public init() { } + + public var body: some View { + VStack { + Text("추천 화면") + } + .frame(maxWidth: .infinity, maxHeight: .infinity) + .background(.yellow) + } +} + +#Preview { + RecommendView() +} diff --git a/Projects/Features/Search/Project.swift b/Projects/Features/Search/Project.swift new file mode 100644 index 0000000..4007555 --- /dev/null +++ b/Projects/Features/Search/Project.swift @@ -0,0 +1,26 @@ +// +// Project.swift +// Search +// +// Created by hyeryeong on 6/18/24 +// + +import ProjectDescription +import ProjectDescriptionHelpers + +let project = Project( + name: "Search", + targets: [ + .configure( + name: "Search", + product: .framework, + infoPlist: .default, + sources: "Sources/**", + resources: "Resources/**", + dependencies: [ + + ] + ) + ] +) + diff --git a/Projects/Features/Search/Resources/dummy.swift b/Projects/Features/Search/Resources/dummy.swift new file mode 100644 index 0000000..2ad55c7 --- /dev/null +++ b/Projects/Features/Search/Resources/dummy.swift @@ -0,0 +1 @@ +더미임미다 \ No newline at end of file diff --git a/Projects/Features/Search/Sources/View/SearchView.swift b/Projects/Features/Search/Sources/View/SearchView.swift new file mode 100644 index 0000000..86c3eee --- /dev/null +++ b/Projects/Features/Search/Sources/View/SearchView.swift @@ -0,0 +1,22 @@ +// +// SearchView.swift +// DesignSystem +// +// Created by 장혜령 on 6/16/24. +// + +import SwiftUI + +public struct SearchView: View { + public init() { } + + public var body: some View { + Text("검색 화면") + .frame(maxWidth: .infinity, maxHeight: .infinity) + .background(.pink) + } +} + +#Preview { + SearchView() +} diff --git a/Tuist/ProjectDescriptionHelpers/TargetDependency+.swift b/Tuist/ProjectDescriptionHelpers/TargetDependency+.swift index df97432..c056709 100644 --- a/Tuist/ProjectDescriptionHelpers/TargetDependency+.swift +++ b/Tuist/ProjectDescriptionHelpers/TargetDependency+.swift @@ -12,6 +12,9 @@ extension TargetDependency { public struct Feature { public static let Home = project(moduleName: "Home") + public static let Recommend = project(moduleName: "Recommend") + public static let Search = project(moduleName: "Search") + public static let MyPage = project(moduleName: "MyPage") } public struct Core {