fix(main): 추천 홈 후속 검증을 보완한다

This commit is contained in:
Yu Sung
2026-07-31 21:12:32 +09:00
parent 3ae2dc19d6
commit a8fe416cb5
38 changed files with 3161 additions and 163 deletions

View File

@@ -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) {

View File

@@ -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)

View File

@@ -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)

View File

@@ -534,7 +534,7 @@ struct CreatorChannelView: View {
if isKoreanCountry && auth == false {
pendingAction = {
startChat(characterId: characterId)
handleTalkTap()
}
isShowAuthConfirmView = true
return

View File

@@ -101,11 +101,11 @@ private enum MainHomeTab: CaseIterable, Hashable {
var title: String {
switch self {
case .recommendation:
return "추천"
return I18n.MainContentRecommendation.tabTitle
case .ranking:
return "랭킹"
return I18n.MainContentRanking.tabTitle
case .following:
return "팔로잉"
return I18n.HomeFollowing.tabTitle
}
}
}

View File

@@ -87,7 +87,7 @@ private struct MainHomeActiveCreatorItemView: View {
.clipShape(RoundedRectangle(cornerRadius: SodaSpacing.s4, style: .continuous))
}
Text(item.relativeActivityAtText())
Text(DateParser.relativeTimeText(fromUTC: item.activityAt, fallback: item.activityAt))
.appFont(.body4)
.foregroundColor(Color.gray500)
.lineLimit(1)
@@ -103,40 +103,6 @@ private struct MainHomeActiveCreatorItemView: View {
}
}
private extension HomeActiveCreatorItem {
func relativeActivityAtText(now: Date = Date()) -> String {
guard let activityDate = DateParser.parse(activityAt) else {
return activityAt
}
let interval = max(0, now.timeIntervalSince(activityDate))
let calendar = Calendar.current
let yearMonth = calendar.dateComponents([.year, .month], from: activityDate, to: now)
if let years = yearMonth.year, years >= 1 {
return I18n.Time.yearsAgo(years)
}
if let months = yearMonth.month, months >= 1 {
return I18n.Time.monthsAgo(months)
}
if interval < 60 {
return I18n.Time.justNow
}
if interval < 3600 {
return I18n.Time.minutesAgo(max(1, Int(interval / 60)))
}
if interval < 86_400 {
return I18n.Time.hoursAgo(max(1, Int(interval / 3600)))
}
return I18n.Time.daysAgo(max(1, Int(interval / 86_400)))
}
}
struct MainHomeActiveCreatorSection_Previews: PreviewProvider {
private static let previewImageUrl = "https://picsum.photos/500/500"

View File

@@ -21,7 +21,7 @@ struct MainHomeAiCharacterSection: View {
LazyHStack(alignment: .center, spacing: SodaSpacing.s4) {
ForEach(items, id: \.self) { item in
Button {
onTapCharacter(item.creatorId)
onTapCharacter(item.characterId)
} label: {
AiCharacterCard(
name: item.name,

View File

@@ -2,7 +2,7 @@ import SwiftUI
struct MainHomeBusinessInfoSection: View {
var body: some View {
BusinessInfoExpandableTextView(
V2ExpandableTextView(
text: I18n.Settings.companyInfo,
lineLimit: 3,
moreTitle: I18n.HomeRecommendation.more,
@@ -15,57 +15,6 @@ struct MainHomeBusinessInfoSection: View {
}
}
private struct BusinessInfoExpandableTextView: View {
let text: String
let lineLimit: Int
let moreTitle: String
let collapseTitle: String
let font: SodaTypography
let foregroundColor: Color
@State private var isExpanded = false
@State private var fullTextHeight: CGFloat = 0
@State private var limitedTextHeight: CGFloat = 0
var body: some View {
VStack(alignment: .leading, spacing: SodaSpacing.s8) {
Text(text)
.appFont(font)
.foregroundColor(foregroundColor)
.lineLimit(isExpanded ? nil : lineLimit)
.background(measuringText(lineLimit: nil, height: $fullTextHeight))
.background(measuringText(lineLimit: lineLimit, height: $limitedTextHeight))
if fullTextHeight > limitedTextHeight + 1 {
Button {
isExpanded.toggle()
} label: {
Text(isExpanded ? collapseTitle : moreTitle)
.appFont(.body5)
.foregroundColor(.white)
}
.buttonStyle(.plain)
}
}
}
private func measuringText(lineLimit: Int?, height: Binding<CGFloat>) -> some View {
Text(text)
.appFont(font)
.lineLimit(lineLimit)
.fixedSize(horizontal: false, vertical: true)
.hidden()
.background(
GeometryReader { proxy in
Color.clear
.onAppear { height.wrappedValue = proxy.size.height }
.onChange(of: proxy.size.height) { newHeight in height.wrappedValue = newHeight }
.onChange(of: text) { _ in height.wrappedValue = proxy.size.height }
}
)
}
}
struct MainHomeBusinessInfoSection_Previews: PreviewProvider {
static var previews: some View {
MainHomeBusinessInfoSection()

View File

@@ -48,6 +48,7 @@ final class MainHomeRecommendationViewModel: ObservableObject {
self.isShowPopup = true
}
} catch {
ERROR_LOG(error.localizedDescription)
self.errorMessage = I18n.Common.commonError
self.isShowPopup = true
}

View File

@@ -5,7 +5,6 @@ struct HomeRecommendationResponse: Decodable {
let banners: [RecommendationBannerResponse]
let recentlyActiveCreators: [HomeActiveCreatorItem]
let recentDebutCreators: [HomeCreatorItem]
let firstAudioContents: [HomeFirstAudioContentItem]
let aiCharacters: [HomeAiCharacterItem]
let genreCreators: [HomeGenreCreatorGroupItem]
let cheerCreators: [HomeCreatorItem]
@@ -67,17 +66,6 @@ struct HomeCreatorItem: Decodable, Hashable {
let creatorProfileImage: String
}
struct HomeFirstAudioContentItem: Decodable, Hashable {
let contentId: Int
let creatorId: Int
let creatorNickname: String
let creatorProfileImage: String
let title: String
let price: Int
let coverImage: String?
let isPointAvailable: Bool
}
struct HomeAiCharacterItem: Decodable, Hashable {
let characterId: Int
let creatorId: Int

View File

@@ -24,8 +24,10 @@ struct MainView: View {
@State private var isShowPlayer = false
@State private var isShowAuthView = false
@State private var isShowAuthConfirmView = false
@State private var isShowRecommendationFollowAllConfirmDialog = false
@State private var isCreatorActionMenuPresented = false
@State private var pendingAction: (() -> Void)? = nil
@State private var pendingRecommendationFollowAllAction: (() -> Void)? = nil
@State private var payload = Payload()
@State private var hasLoadedMainData = false
@@ -75,6 +77,10 @@ struct MainView: View {
authConfirmDialog
}
if isShowRecommendationFollowAllConfirmDialog {
recommendationFollowAllConfirmDialog
}
if liveViewModel.isShowPaymentDialog {
LivePaymentDialog(
title: liveViewModel.paymentDialogTitle,
@@ -177,7 +183,7 @@ struct MainView: View {
onTapLive: handleRecommendationLiveTap,
onTapCreator: handleRecommendationCreatorTap,
onTapContent: handleRecommendationContentTap,
onTapCharacter: handleRecommendationCreatorTap,
onTapCharacter: handleRecommendationCharacterTap,
onTapCommunityPost: handleRecommendationCommunityPostTap,
onTapBanner: handleRecommendationBannerTap,
onTapLiveAll: handleRecommendationLiveAllTap,
@@ -323,6 +329,34 @@ struct MainView: View {
pendingAction = nil
}
private var recommendationFollowAllConfirmDialog: some View {
SodaV2ActionModal(
title: I18n.HomeRecommendation.followAllConfirmTitle,
message: I18n.HomeRecommendation.followAllConfirmDescription,
button1: SodaV2ActionModalButton(
label: I18n.HomeRecommendation.followAllConfirmAction,
action: confirmRecommendationFollowAll
),
button2: SodaV2ActionModalButton(
label: I18n.Common.cancel,
action: dismissRecommendationFollowAllConfirmDialog
),
onDimmedTap: dismissRecommendationFollowAllConfirmDialog
)
}
private func confirmRecommendationFollowAll() {
let action = pendingRecommendationFollowAllAction
isShowRecommendationFollowAllConfirmDialog = false
pendingRecommendationFollowAllAction = nil
action?()
}
private func dismissRecommendationFollowAllConfirmDialog() {
isShowRecommendationFollowAllConfirmDialog = false
pendingRecommendationFollowAllAction = nil
}
private var authView: some View {
BootpayUI(payload: payload, requestType: BootpayRequest.TYPE_AUTHENTICATION)
.onConfirm { _ in true }
@@ -502,6 +536,13 @@ struct MainView: View {
}
}
private func handleRecommendationCharacterTap(characterId: Int) {
guard characterId > 0 else { return }
performRecommendationDetailAction(requiresAdultContent: true) {
appState.setAppStep(step: .characterDetail(characterId: characterId))
}
}
private func handleRecommendationCommunityPostTap(postId: Int) {
guard postId > 0 else { return }
performRecommendationDetailAction {
@@ -510,7 +551,14 @@ struct MainView: View {
}
private func handleRecommendationFollowAllTap(action: @escaping () -> Void) {
performRecommendationDetailAction(action: action)
let trimmed = token.trimmingCharacters(in: .whitespacesAndNewlines)
guard !trimmed.isEmpty else {
AppState.shared.setAppStep(step: .login)
return
}
pendingRecommendationFollowAllAction = action
isShowRecommendationFollowAllConfirmDialog = true
}
private func handleFollowingAllTap() {
@@ -681,7 +729,9 @@ struct MainView: View {
let isKoreanCountry = normalizedCountryCode.isEmpty || normalizedCountryCode == "KR"
if isKoreanCountry && auth == false {
pendingAction = action
pendingAction = {
performRecommendationDetailAction(requiresAdultContent: true, action: action)
}
isShowAuthConfirmView = true
return
}