fix(main): 추천 홈 후속 검증을 보완한다
This commit is contained in:
@@ -22,6 +22,7 @@ struct BannerCarousel: View {
|
||||
@GestureState private var dragOffset: CGFloat = 0
|
||||
@State private var autoScrollTimer: Timer?
|
||||
@State private var isSwiping = false
|
||||
@State private var itemsRevision = 0
|
||||
|
||||
init(
|
||||
items: [BannerCarouselItem],
|
||||
@@ -70,6 +71,7 @@ struct BannerCarousel: View {
|
||||
.contentShape(Rectangle())
|
||||
.simultaneousGesture(dragGesture(step: step))
|
||||
.onChange(of: items) { _ in
|
||||
itemsRevision += 1
|
||||
displayIndex = items.count > 1 ? 1 : 0
|
||||
restartAutoScrollTimer()
|
||||
}
|
||||
@@ -179,8 +181,15 @@ struct BannerCarousel: View {
|
||||
private func wrapIfNeeded() {
|
||||
guard items.count > 1 else { return }
|
||||
|
||||
displayIndex = min(max(displayIndex, 0), items.count + 1)
|
||||
|
||||
let scheduledIndex = displayIndex
|
||||
let scheduledRevision = itemsRevision
|
||||
|
||||
if displayIndex == 0 {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + BannerCarousel.transitionDuration) {
|
||||
guard displayIndex == scheduledIndex, itemsRevision == scheduledRevision else { return }
|
||||
|
||||
var transaction = Transaction()
|
||||
transaction.disablesAnimations = true
|
||||
withTransaction(transaction) {
|
||||
@@ -189,6 +198,8 @@ struct BannerCarousel: View {
|
||||
}
|
||||
} else if displayIndex == items.count + 1 {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + BannerCarousel.transitionDuration) {
|
||||
guard displayIndex == scheduledIndex, itemsRevision == scheduledRevision else { return }
|
||||
|
||||
var transaction = Transaction()
|
||||
transaction.disablesAnimations = true
|
||||
withTransaction(transaction) {
|
||||
|
||||
@@ -69,6 +69,8 @@ struct CommunityPostCard: View {
|
||||
|
||||
if hasImage {
|
||||
imageContent
|
||||
} else if isLocked {
|
||||
lockedTextPurchaseButton
|
||||
}
|
||||
|
||||
if isAccessiblePost {
|
||||
@@ -172,6 +174,31 @@ struct CommunityPostCard: View {
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
|
||||
private var lockedTextPurchaseButton: some View {
|
||||
Button(action: onTapPurchase) {
|
||||
HStack(spacing: SodaSpacing.s6) {
|
||||
Image("ic_new_community_lock")
|
||||
.resizable()
|
||||
.renderingMode(.template)
|
||||
.foregroundColor(.white)
|
||||
.frame(width: 18, height: 18)
|
||||
|
||||
Image("ic_bar_cash")
|
||||
.resizable()
|
||||
.frame(width: 20, height: 20)
|
||||
|
||||
Text("\(price)")
|
||||
.appFont(.body2)
|
||||
.foregroundColor(.black)
|
||||
}
|
||||
.padding(.vertical, SodaSpacing.s8)
|
||||
.padding(.horizontal, SodaSpacing.s12)
|
||||
.background(Color.white)
|
||||
.clipShape(Capsule())
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
|
||||
private var audioPlayButton: some View {
|
||||
Button {
|
||||
guard let audioUrl, !audioUrl.isEmpty else { return }
|
||||
@@ -232,7 +259,7 @@ struct CommunityPostCard: View {
|
||||
}
|
||||
|
||||
private var isAccessiblePost: Bool {
|
||||
price == 0 || existOrdered
|
||||
price <= 0 || existOrdered
|
||||
}
|
||||
|
||||
private func toggleLike() {
|
||||
@@ -293,6 +320,21 @@ struct CommunityPostCard_Previews: PreviewProvider {
|
||||
likeCount: 5,
|
||||
commentCount: 6
|
||||
)
|
||||
|
||||
CommunityPostCard(
|
||||
postId: 4,
|
||||
creatorNickname: "크리에이터 이름",
|
||||
creatorProfileImageUrl: previewImageUrl,
|
||||
content: "이미지 없는 유료 커뮤니티 게시글입니다.",
|
||||
imageUrl: nil,
|
||||
audioUrl: nil,
|
||||
price: 30,
|
||||
existOrdered: false,
|
||||
createdAt: "2분 전",
|
||||
isLike: false,
|
||||
likeCount: 5,
|
||||
commentCount: 6
|
||||
)
|
||||
}
|
||||
.padding(SodaSpacing.s14)
|
||||
.background(Color.black)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SwiftUI
|
||||
|
||||
struct ExpandableTextView: View {
|
||||
struct V2ExpandableTextView: View {
|
||||
let text: String
|
||||
let lineLimit: Int
|
||||
let moreTitle: String
|
||||
@@ -71,9 +71,9 @@ struct ExpandableTextView: View {
|
||||
}
|
||||
}
|
||||
|
||||
struct ExpandableTextView_Previews: PreviewProvider {
|
||||
struct V2ExpandableTextView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
ExpandableTextView(text: "긴 사업자 정보 텍스트가 들어가는 영역입니다. 세 줄을 넘어가면 더보기 버튼이 표시되고, 더보기 버튼을 누르면 전체 문구가 표시됩니다.")
|
||||
V2ExpandableTextView(text: "긴 사업자 정보 텍스트가 들어가는 영역입니다. 세 줄을 넘어가면 더보기 버튼이 표시되고, 더보기 버튼을 누르면 전체 문구가 표시됩니다.")
|
||||
.padding(SodaSpacing.s20)
|
||||
.background(Color.black)
|
||||
.previewLayout(.sizeThatFits)
|
||||
Reference in New Issue
Block a user