Skip to content

Commit

Permalink
Merge pull request #87 from mash-up-kr/feature/#86-report-problem-hye…
Browse files Browse the repository at this point in the history
…rjang

feat: 밈 신고하기 기능 추가
  • Loading branch information
hryeong66 authored Oct 3, 2024
2 parents a59086a + 4fb27ed commit 4b3ab59
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 25 deletions.
10 changes: 6 additions & 4 deletions Projects/Core/DesignSystem/Sources/PlainNavigationBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public struct PlainNavigationBar: View {
Spacer()

if hasConfigureButton {
ResourceKitAsset.Icon.setting.swiftUIImage
ResourceKitAsset.Icon.moreItem.swiftUIImage
}
}
.padding(.horizontal, 16)
Expand Down Expand Up @@ -84,9 +84,11 @@ public struct PlainNavigationBarModifier: ViewModifier {
HStack {
Spacer()
if hasConfigureButton {
ResourceKitAsset.Icon.setting.swiftUIImage
.resizable()
.frame(width: 20, height: 20)
Button(action: { self.rightActionHandler?() }) {
ResourceKitAsset.Icon.moreItem.swiftUIImage
.resizable()
.frame(width: 20, height: 20)
}
}
}
}
Expand Down
78 changes: 59 additions & 19 deletions Projects/Features/MemeDetail/Sources/MemeDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,44 @@ public struct MemeDetailView: View {
// MARK: - UI

public var body: some View {
ZStack {
memeDetailCardView
if viewModel.state.isSheetPresented {
Color.black.opacity(0.4)
}
}
.onAppear {
viewModel.logMemeDetail(interaction: .view, event: .meme)
}
.plainNavigationBar(
backHandler: { viewModel.dispatch(type: .naviBackButtonTapped) },
rightActionHandler: { viewModel.dispatch(type: .naviMoreButtonTapped) },
hasConfigureButton: true,
title: viewModel.state.meme.title
)
.popup(
isActive: $viewModel.state.isCopied,
image: ResourceKitAsset.Icon.copyFilled.swiftUIImage,
text: "이미지를 클립보드에 복사했어요"
)
.popup(
isActive: $viewModel.state.isFarmemeChanged,
image: viewModel.state.meme.isFarmemed ? ResourceKitAsset.Icon.copyFilled.swiftUIImage : nil,
text: viewModel.state.meme.isFarmemed ? "파밈 완료!" : "파밈을 취소했어요"
)
.sheet(isPresented: $viewModel.state.isSheetPresented) {
ZStack(alignment: .bottom) {
bottomSheetView
.presentationDetents([.height(66)])
}
}
.sheet(isPresented: $viewModel.state.isWebViewPresented) {
WebView(url: viewModel.state.reportProblemUrl)
.presentationDetents([.large])
}
}

private var memeDetailCardView: some View {
ZStack {
VStack(spacing: 0) {
Spacer()
Expand Down Expand Up @@ -74,7 +112,6 @@ public struct MemeDetailView: View {

VStack(spacing: 0) {
Spacer()

EmptyView()
.memeDetailTabBar(
isFarmemed: $viewModel.state.meme.isFarmemed
Expand Down Expand Up @@ -107,25 +144,27 @@ public struct MemeDetailView: View {
.clipped()
.edgesIgnoringSafeArea(.top)
)
.onAppear {
viewModel.logMemeDetail(interaction: .view, event: .meme)
}

private var bottomSheetView: some View {
VStack {
Rectangle()
.cornerRadius(20, corners: [.topLeft, .topRight])
.frame(height: 16)
.foregroundStyle(Color.Background.white)
reportProblembutton
}
.padding(.bottom, 10)
.onTapGesture {
viewModel.dispatch(type: .reportProblemButtonTapped)
}
.plainNavigationBar(
backHandler: { viewModel.dispatch(type: .naviBackButtonTapped) },
rightActionHandler: nil,
hasConfigureButton: false,
title: "밈 자세히 보기"
)
.popup(
isActive: $viewModel.state.isCopied,
image: ResourceKitAsset.Icon.copyFilled.swiftUIImage,
text: "이미지를 클립보드에 복사했어요"
)
.popup(
isActive: $viewModel.state.isFarmemeChanged,
image: viewModel.state.meme.isFarmemed ? ResourceKitAsset.Icon.copyFilled.swiftUIImage : nil,
text: viewModel.state.meme.isFarmemed ? "파밈 완료!" : "파밈을 취소했어요"
)
}

private var reportProblembutton: some View {
Text("신고하기")
.font(Font.Body.Xlarge.medium)
.foregroundStyle(Color.Text.primary)
.padding(.vertical, 16)
}

@MainActor
Expand All @@ -139,6 +178,7 @@ public struct MemeDetailView: View {
viewModel.dispatch(type: .shreButtonTapped)
}
}

}

#Preview {
Expand Down
14 changes: 14 additions & 0 deletions Projects/Features/MemeDetail/Sources/MemeDetailViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,18 @@ public final class MemeDetailViewModel: ViewModelType, ObservableObject {
case shreButtonTapped
case farmemeButtonTapped
case naviBackButtonTapped
case naviMoreButtonTapped
case reportProblemButtonTapped
}

public struct State {
var meme: MemeDetail
var isCopied: Bool = false
var isFarmemeChanged: Bool = false
var isSheetPresented: Bool = false
var isWebViewPresented: Bool = false

let reportProblemUrl: URL? = URL(string: "https://forms.gle/a5QkMnLD8AANtYCo7")
}

// MARK: - Properties
Expand All @@ -49,6 +55,8 @@ public final class MemeDetailViewModel: ViewModelType, ObservableObject {

private var reactionCount = 0
private var reactionTask: Task<Void, Never>?



// MARK: - Initializers

Expand Down Expand Up @@ -94,6 +102,12 @@ public final class MemeDetailViewModel: ViewModelType, ObservableObject {
}
case .naviBackButtonTapped:
router?.popView()
case .naviMoreButtonTapped:
state.isSheetPresented = true
case .reportProblemButtonTapped:
state.isSheetPresented = false
state.isWebViewPresented = true
print("reportProblemButtonTapped")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ public final class RecommendViewModel: ViewModelType, ObservableObject {
isSuccessFetch: false
)
bind()

UserInfo.shared.deviceId = "uni-test4"
}

public func dispatch(type: Action) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "More_Item.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4b3ab59

Please sign in to comment.