fix(main): 추천 홈 후속 검증을 보완한다
This commit is contained in:
@@ -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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user