이것은 편집 버튼을 눌렀을 경우
이것은 편집 버튼이 눌리지 않은 경우
문제의 코드
if selectedButton == "투표" {
ScrollView(showsIndicators: false) {
ForEach(bookmarkStore.currentUserVotesBookmark) { bookmark in
if isEdit {
VotesBookmarkCell(categoryStore: categoryStore, voteStore: voteStore, bookmarkStore: bookmarkStore, isEdit: $isEdit, bookmark: bookmark)
.padding(.horizontal, 20)
} else {
NavigationLink {
VoteDetailView(voteId: bookmark.voteId, voteStore: voteStore, bookmarkStore: bookmarkStore)
} label: {
VotesBookmarkCell(categoryStore: categoryStore, voteStore: voteStore, bookmarkStore: bookmarkStore, isEdit: $isEdit, bookmark: bookmark)
.padding(.horizontal, 20)
}
.buttonStyle(PlainButtonStyle())
}
}
}
ZStack {
ZStack {
RoundedRectangle(cornerRadius: 8)
.frame(height: 66)
.foregroundStyle(CustomColor.GrayScaleColor.white)
HStack(spacing: 0) {
if isEdit {
Image("checkCircle_\(isTap)")
.frame(width: 16, height: 16)
.padding(.leading, 16)
}
VStack(alignment: .leading, spacing: 0) {
HStack(spacing: 0) {
Text(bookmark.title)
.font(.createFont(weight: .bold, size: 14))
.foregroundStyle(CustomColor.GrayScaleColor.black)
.lineLimit(1)
Spacer()
}
.padding(.bottom, 10)
HStack(spacing: 0) {
Text(bookmark.description)
.font(.createFont(weight: .bold, size: 12))
.foregroundStyle(CustomColor.GrayScaleColor.gs6)
.lineLimit(1)
Spacer()
}
}
.padding(.horizontal, 16)
}
}
.onTapGesture {
if isEdit {
isTap.toggle()
}
}
}
//
// VotesBookmarkCell.swift
// Sachosaeng
//
// Created by LJh on 9/11/24.
//
import SwiftUI
struct VotesBookmarkCell: View {
@StateObject var categoryStore: CategoryStore
@StateObject var voteStore: VoteStore
@StateObject var bookmarkStore: BookmarkStore
@Binding var isEdit: Bool
@State var isTap: Bool = false
var bookmark: Bookmark
var body: some View {
ZStack {
if isEdit {
cellContent
.onTapGesture {
isTap.toggle()
}
} else {
NavigationLink {
VoteDetailView(voteId: bookmark.voteId, voteStore: voteStore, bookmarkStore: bookmarkStore)
} label: {
cellContent
} //: navigation
}
} //: ZSTACK
}
@ViewBuilder
var cellContent: some View {
RoundedRectangle(cornerRadius: 8)
.frame(height: 66)
.foregroundStyle(CustomColor.GrayScaleColor.white)
.overlay {
HStack(spacing: 0) {
if isEdit {
Image("checkCircle_\(isTap)")
.frame(width: 16, height: 16)
.padding(.leading, 16)
}
VStack(alignment: .leading, spacing: 0) {
HStack(spacing: 0) {
Text(bookmark.title)
.font(.createFont(weight: .bold, size: 14))
.foregroundStyle(CustomColor.GrayScaleColor.black)
.lineLimit(1)
Spacer()
}
.padding(.bottom, 10)
HStack(spacing: 0) {
Text(bookmark.description)
.font(.createFont(weight: .bold, size: 12))
.foregroundStyle(CustomColor.GrayScaleColor.gs6)
.lineLimit(1)
Spacer()
}
}
.padding(.horizontal, 16)
}
}
}
}