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] =?UTF-8?q?=E2=9C=A8=20::=20[#36]=20EmptyView=20=EC=97=B0?= =?UTF-8?q?=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() -}