From 26a8ac0dd341f6ddc604697e8461468b4e467198 Mon Sep 17 00:00:00 2001 From: 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 Date: Mon, 30 Dec 2024 09:11:46 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9C=A8=20::=20[#36]=20EmptyView=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MainFeature/Sources/EmptyView.swift | 48 +++++++++++++++++++ .../MainFeature/Sources/MainView.swift | 17 +++++-- 2 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 Projects/App/Sources/Feature/MainFeature/Sources/EmptyView.swift diff --git a/Projects/App/Sources/Feature/MainFeature/Sources/EmptyView.swift b/Projects/App/Sources/Feature/MainFeature/Sources/EmptyView.swift new file mode 100644 index 0000000..c52eb83 --- /dev/null +++ b/Projects/App/Sources/Feature/MainFeature/Sources/EmptyView.swift @@ -0,0 +1,48 @@ +import SwiftUI + +struct EmptyView: View { + var body: some View { + NavigationView { + NavigationStack { + ZStack { + GPleAsset.Color.back.swiftUIColor + .ignoresSafeArea() + + VStack(spacing: 0) { + Text("아무것도 없어요...") + .foregroundStyle(GPleAsset.Color.white.swiftUIColor) + .font(GPleFontFamily.Pretendard.semiBold.swiftUIFont(size: 24)) + + Text("재밌는 사진을 모두와 공유해요!") + .foregroundStyle(GPleAsset.Color.gray400.swiftUIColor) + .padding(.top, 4) + + NavigationLink { + PostCreateView(viewModel: PostViewModel()) + } label: { + imageUploadButton() + .padding(.top, 20) + } + } + } + } + } + } + + @ViewBuilder + func imageUploadButton() -> some View { + HStack { + GPleAsset.Assets.download.swiftUIImage + + Text("사진 업로드") + .foregroundStyle(GPleAsset.Color.white.swiftUIColor) + } + .padding(.all, 12) + .background(GPleAsset.Color.gray1000.swiftUIColor) + .cornerRadius(8) + } +} + +#Preview { + EmptyView() +} diff --git a/Projects/App/Sources/Feature/MainFeature/Sources/MainView.swift b/Projects/App/Sources/Feature/MainFeature/Sources/MainView.swift index 90eb7a9..c8db5ea 100644 --- a/Projects/App/Sources/Feature/MainFeature/Sources/MainView.swift +++ b/Projects/App/Sources/Feature/MainFeature/Sources/MainView.swift @@ -213,10 +213,19 @@ struct MainView: View { .font(GPleFontFamily.Pretendard.regular.swiftUIFont(size: 14)) .padding(.top, 12) - Text(date) - .foregroundStyle(GPleAsset.Color.gray800.swiftUIColor) - .font(GPleFontFamily.Pretendard.regular.swiftUIFont(size: 14)) - .padding(.top, 4) + let dateString = date.split(separator: "T").first + if let dateString = dateString { + let components = dateString.split(separator: "-") + if components.count >= 3 { + var month = String(components[1]) + var day = String(components[2]) + + Text("\(month)월 \(day)일") + .foregroundStyle(GPleAsset.Color.gray800.swiftUIColor) + .font(GPleFontFamily.Pretendard.regular.swiftUIFont(size: 14)) + .padding(.top, 6) + } + } } .padding(.vertical, 20) From 015b1a5f6554afdc6062d99176497ae105b8caf8 Mon Sep 17 00:00:00 2001 From: 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 Date: Mon, 30 Dec 2024 09:20:05 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=E2=9C=A8=20::=20[#36]=20EmptyView=20?= =?UTF-8?q?=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/LocationPostView.swift | 272 ++++++++++-------- .../{EmptyView.swift => PostEmptyView.swift} | 10 +- 2 files changed, 149 insertions(+), 133 deletions(-) rename Projects/App/Sources/Feature/MainFeature/Sources/{EmptyView.swift => PostEmptyView.swift} (89%) diff --git a/Projects/App/Sources/Feature/MainFeature/Sources/LocationPostView.swift b/Projects/App/Sources/Feature/MainFeature/Sources/LocationPostView.swift index 7a442cb..260eb12 100644 --- a/Projects/App/Sources/Feature/MainFeature/Sources/LocationPostView.swift +++ b/Projects/App/Sources/Feature/MainFeature/Sources/LocationPostView.swift @@ -32,142 +32,162 @@ struct LocationPostView: View { ScrollView { switch locationType { case "GYM": - ForEach(viewModel.gymPostList) { post in - DetailView( - postViewModel: PostViewModel(), - postId: post.id, - title: post.title, - name: post.author.name, - grade: post.author.grade, - imageUrl: post.imageUrl, - tagList: post.tagList.map{ ($0.name, $0.id) }, - emojiList: [ - post.emojiList.chinaCount, - post.emojiList.congCount, - post.emojiList.heartCount, - post.emojiList.poopCount, - post.emojiList.thinkCount, - post.emojiList.thumbsCount - ], - checkEmojiList: post.checkEmoji, - createTime: post.createdTime - ) - - Rectangle() - .foregroundStyle(GPleAsset.Color.gray900.swiftUIColor) - .frame(height: 3) - .padding(.vertical, 10) + if viewModel.gymPostList.isEmpty { + PostEmptyView() + } else { + ForEach(viewModel.gymPostList) { post in + DetailView( + postViewModel: PostViewModel(), + postId: post.id, + title: post.title, + name: post.author.name, + grade: post.author.grade, + imageUrl: post.imageUrl, + tagList: post.tagList.map{ ($0.name, $0.id) }, + emojiList: [ + post.emojiList.chinaCount, + post.emojiList.congCount, + post.emojiList.heartCount, + post.emojiList.poopCount, + post.emojiList.thinkCount, + post.emojiList.thumbsCount + ], + checkEmojiList: post.checkEmoji, + createTime: post.createdTime + ) + + Rectangle() + .foregroundStyle(GPleAsset.Color.gray900.swiftUIColor) + .frame(height: 3) + .padding(.vertical, 10) + } } case "HOME": - ForEach(viewModel.homePostList) { post in - DetailView( - postViewModel: PostViewModel(), - postId: post.id, - title: post.title, - name: post.author.name, - grade: post.author.grade, - imageUrl: post.imageUrl, - tagList: post.tagList.map{ ($0.name, $0.id) }, - emojiList: [ - post.emojiList.chinaCount, - post.emojiList.congCount, - post.emojiList.heartCount, - post.emojiList.poopCount, - post.emojiList.thinkCount, - post.emojiList.thumbsCount - ], - checkEmojiList: post.checkEmoji, - createTime: post.createdTime - ) - - Rectangle() - .foregroundStyle(GPleAsset.Color.gray900.swiftUIColor) - .frame(height: 3) - .padding(.vertical, 10) + if viewModel.homePostList.isEmpty { + PostEmptyView() + } else { + ForEach(viewModel.homePostList) { post in + DetailView( + postViewModel: PostViewModel(), + postId: post.id, + title: post.title, + name: post.author.name, + grade: post.author.grade, + imageUrl: post.imageUrl, + tagList: post.tagList.map{ ($0.name, $0.id) }, + emojiList: [ + post.emojiList.chinaCount, + post.emojiList.congCount, + post.emojiList.heartCount, + post.emojiList.poopCount, + post.emojiList.thinkCount, + post.emojiList.thumbsCount + ], + checkEmojiList: post.checkEmoji, + createTime: post.createdTime + ) + + Rectangle() + .foregroundStyle(GPleAsset.Color.gray900.swiftUIColor) + .frame(height: 3) + .padding(.vertical, 10) + } } case "PLAYGROUND": - ForEach(viewModel.playgroundPostList) { post in - DetailView( - postViewModel: PostViewModel(), - postId: post.id, - title: post.title, - name: post.author.name, - grade: post.author.grade, - imageUrl: post.imageUrl, - tagList: post.tagList.map{ ($0.name, $0.id) }, - emojiList: [ - post.emojiList.chinaCount, - post.emojiList.congCount, - post.emojiList.heartCount, - post.emojiList.poopCount, - post.emojiList.thinkCount, - post.emojiList.thumbsCount - ], - checkEmojiList: post.checkEmoji, - createTime: post.createdTime - ) - - Rectangle() - .foregroundStyle(GPleAsset.Color.gray900.swiftUIColor) - .frame(height: 3) - .padding(.vertical, 10) + if viewModel.playgroundPostList.isEmpty { + PostEmptyView() + } else { + ForEach(viewModel.playgroundPostList) { post in + DetailView( + postViewModel: PostViewModel(), + postId: post.id, + title: post.title, + name: post.author.name, + grade: post.author.grade, + imageUrl: post.imageUrl, + tagList: post.tagList.map{ ($0.name, $0.id) }, + emojiList: [ + post.emojiList.chinaCount, + post.emojiList.congCount, + post.emojiList.heartCount, + post.emojiList.poopCount, + post.emojiList.thinkCount, + post.emojiList.thumbsCount + ], + checkEmojiList: post.checkEmoji, + createTime: post.createdTime + ) + + Rectangle() + .foregroundStyle(GPleAsset.Color.gray900.swiftUIColor) + .frame(height: 3) + .padding(.vertical, 10) + } } case "DOMITORY": - ForEach(viewModel.domitoryPostList) { post in - DetailView( - postViewModel: PostViewModel(), - postId: post.id, - title: post.title, - name: post.author.name, - grade: post.author.grade, - imageUrl: post.imageUrl, - tagList: post.tagList.map{ ($0.name, $0.id) }, - emojiList: [ - post.emojiList.chinaCount, - post.emojiList.congCount, - post.emojiList.heartCount, - post.emojiList.poopCount, - post.emojiList.thinkCount, - post.emojiList.thumbsCount - ], - checkEmojiList: post.checkEmoji, - createTime: post.createdTime - ) - - Rectangle() - .foregroundStyle(GPleAsset.Color.gray900.swiftUIColor) - .frame(height: 3) - .padding(.vertical, 10) + if viewModel.domitoryPostList.isEmpty { + PostEmptyView() + } else { + ForEach(viewModel.domitoryPostList) { post in + DetailView( + postViewModel: PostViewModel(), + postId: post.id, + title: post.title, + name: post.author.name, + grade: post.author.grade, + imageUrl: post.imageUrl, + tagList: post.tagList.map{ ($0.name, $0.id) }, + emojiList: [ + post.emojiList.chinaCount, + post.emojiList.congCount, + post.emojiList.heartCount, + post.emojiList.poopCount, + post.emojiList.thinkCount, + post.emojiList.thumbsCount + ], + checkEmojiList: post.checkEmoji, + createTime: post.createdTime + ) + + Rectangle() + .foregroundStyle(GPleAsset.Color.gray900.swiftUIColor) + .frame(height: 3) + .padding(.vertical, 10) + } } case "WALKING_TRAIL": - ForEach(viewModel.walkingTrailPostList) { post in - DetailView( - postViewModel: PostViewModel(), - postId: post.id, - title: post.title, - name: post.author.name, - grade: post.author.grade, - imageUrl: post.imageUrl, - tagList: post.tagList.map{ ($0.name, $0.id) }, - emojiList: [ - post.emojiList.chinaCount, - post.emojiList.congCount, - post.emojiList.heartCount, - post.emojiList.poopCount, - post.emojiList.thinkCount, - post.emojiList.thumbsCount - ], - checkEmojiList: post.checkEmoji, - createTime: post.createdTime - ) - - Rectangle() - .foregroundStyle(GPleAsset.Color.gray900.swiftUIColor) - .frame(height: 3) - .padding(.vertical, 10) + if viewModel.walkingTrailPostList.isEmpty { + PostEmptyView() + } else { + ForEach(viewModel.walkingTrailPostList) { post in + DetailView( + postViewModel: PostViewModel(), + postId: post.id, + title: post.title, + name: post.author.name, + grade: post.author.grade, + imageUrl: post.imageUrl, + tagList: post.tagList.map{ ($0.name, $0.id) }, + emojiList: [ + post.emojiList.chinaCount, + post.emojiList.congCount, + post.emojiList.heartCount, + post.emojiList.poopCount, + post.emojiList.thinkCount, + post.emojiList.thumbsCount + ], + checkEmojiList: post.checkEmoji, + createTime: post.createdTime + ) + + Rectangle() + .foregroundStyle(GPleAsset.Color.gray900.swiftUIColor) + .frame(height: 3) + .padding(.vertical, 10) + } } default: - EmptyView() + PostEmptyView() } } .padding(.top, 8) diff --git a/Projects/App/Sources/Feature/MainFeature/Sources/EmptyView.swift b/Projects/App/Sources/Feature/MainFeature/Sources/PostEmptyView.swift similarity index 89% rename from Projects/App/Sources/Feature/MainFeature/Sources/EmptyView.swift rename to Projects/App/Sources/Feature/MainFeature/Sources/PostEmptyView.swift index c52eb83..9cacdca 100644 --- a/Projects/App/Sources/Feature/MainFeature/Sources/EmptyView.swift +++ b/Projects/App/Sources/Feature/MainFeature/Sources/PostEmptyView.swift @@ -1,12 +1,12 @@ import SwiftUI -struct EmptyView: View { +struct PostEmptyView: View { var body: some View { NavigationView { NavigationStack { ZStack { - GPleAsset.Color.back.swiftUIColor - .ignoresSafeArea() + GPleAsset.Color.back.swiftUIColor + .ignoresSafeArea() VStack(spacing: 0) { Text("아무것도 없어요...") @@ -42,7 +42,3 @@ struct EmptyView: View { .cornerRadius(8) } } - -#Preview { - EmptyView() -} From c22c911ed7b9a7d0018efe834a4eb958e5ff7e16 Mon Sep 17 00:00:00 2001 From: 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 Date: Mon, 30 Dec 2024 09:36:49 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20[#36]=20MainView?= =?UTF-8?q?=20/=20Image=20=ED=98=95=EC=8B=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MainFeature/Sources/MainView.swift | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/Projects/App/Sources/Feature/MainFeature/Sources/MainView.swift b/Projects/App/Sources/Feature/MainFeature/Sources/MainView.swift index c8db5ea..95514dd 100644 --- a/Projects/App/Sources/Feature/MainFeature/Sources/MainView.swift +++ b/Projects/App/Sources/Feature/MainFeature/Sources/MainView.swift @@ -3,6 +3,7 @@ import SwiftUI struct MainView: View { @StateObject var viewModel = MainViewModel() @StateObject var postViewModel: PostViewModel + @State private var selectedIndex = 0 var body: some View { NavigationView { @@ -166,38 +167,38 @@ struct MainView: View { .foregroundStyle(GPleAsset.Color.gray800.swiftUIColor) .font(GPleFontFamily.Pretendard.regular.swiftUIFont(size: 14)) } + .padding(.leading, 8) Text(title) .foregroundStyle(GPleAsset.Color.white.swiftUIColor) .font(GPleFontFamily.Pretendard.semiBold.swiftUIFont(size: 18)) .padding(.top, 16) + .padding(.leading, 8) Text(place) .foregroundStyle(GPleAsset.Color.gray600.swiftUIColor) .font(GPleFontFamily.Pretendard.regular.swiftUIFont(size: 14)) .padding(.top, 4) - - ForEach(imageURL, id: \.self) { imageURL in - AsyncImage(url: URL(string: imageURL)) { phase in - switch phase { - case .empty: - ProgressView() - .frame(width: 318, height: 318) - case .success(let image): - image - .resizable() - .scaledToFit() - .frame(width: 318) - .cornerRadius(8) - case .failure: - Image(systemName: "exclamationmark.triangle.fill") - .foregroundColor(.red) - .frame(width: 318, height: 318) - @unknown default: - EmptyView() + .padding(.leading, 8) + + TabView(selection: $selectedIndex) { + ForEach(imageURL.indices, id: \.self) { index in + if let imageUrl = URL(string: imageURL[index]) { + AsyncImage(url: imageUrl) { image in + image + .resizable() + .padding(.top, 12) + } placeholder: { + ProgressView() + .progressViewStyle(CircularProgressViewStyle()) + } + .tag(index) } } } + .padding(.horizontal, 8) + .frame(height: 381) + .tabViewStyle(.page) .padding(.top, 16) HStack(spacing: 8) { @@ -212,6 +213,7 @@ struct MainView: View { .foregroundStyle(GPleAsset.Color.gray600.swiftUIColor) .font(GPleFontFamily.Pretendard.regular.swiftUIFont(size: 14)) .padding(.top, 12) + .padding(.leading, 8) let dateString = date.split(separator: "T").first if let dateString = dateString { @@ -224,13 +226,15 @@ struct MainView: View { .foregroundStyle(GPleAsset.Color.gray800.swiftUIColor) .font(GPleFontFamily.Pretendard.regular.swiftUIFont(size: 14)) .padding(.top, 6) + .padding(.leading, 8) } } } + .padding(.horizontal, 10) .padding(.vertical, 20) - .padding(.horizontal, 16) .background(GPleAsset.Color.gray1000.swiftUIColor) .cornerRadius(12) + .padding(.horizontal, 20) } }