Merge branch 'main' into iOS-18

This commit is contained in:
Thomas Ricouard 2024-07-10 16:18:25 +02:00
commit a73bebce77
5 changed files with 77 additions and 28 deletions

View file

@ -3097,7 +3097,7 @@
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "包含动画 GIF"
"value" : "动画 GIF"
}
},
"zh-Hant" : {
@ -8570,7 +8570,7 @@
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "动时间线。"
"value" : "动时间线。"
}
},
"zh-Hant" : {
@ -8969,7 +8969,7 @@
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "Account"
"value" : "账户"
}
}
}
@ -13503,6 +13503,12 @@
"state" : "translated",
"value" : "Supprimer l'avatar"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "删除头像"
}
}
}
},
@ -13733,7 +13739,7 @@
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "保存个人资料时出错, 请重试。"
"value" : "保存个人资料时出错请重试。"
}
},
"zh-Hant" : {
@ -13971,7 +13977,7 @@
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "编辑横幅图片"
"value" : "编辑横幅"
}
},
"zh-Hant" : {
@ -14002,6 +14008,12 @@
"state" : "translated",
"value" : "Supprimer la bannière"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "删除横幅"
}
}
}
},
@ -16720,13 +16732,13 @@
"one" : {
"stringUnit" : {
"state" : "translated",
"value" : "%2$@粉丝"
"value" : "%2$@ 粉丝"
}
},
"other" : {
"stringUnit" : {
"state" : "translated",
"value" : "%2$@粉丝"
"value" : "%2$@ 粉丝"
}
}
}
@ -19368,7 +19380,7 @@
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "标签组图标SFSymbol"
"value" : "标签组图标SFSymbol"
}
},
"zh-Hant" : {
@ -20755,7 +20767,7 @@
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "AppAccount"
"value" : "App 账户"
}
}
}
@ -28571,8 +28583,8 @@
},
"zh-Hans" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "当下流行的网页"
"state" : "translated",
"value" : "新闻"
}
},
"zh-Hant" : {
@ -33129,7 +33141,7 @@
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "Key"
"value" : "密钥"
}
}
}
@ -45583,7 +45595,7 @@
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "Require Alt Text to Post"
"value" : "有 ALT 才能发布"
}
},
"zh-Hant" : {
@ -82259,7 +82271,7 @@
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "TimelineFilter"
"value" : "时间线过滤器"
}
}
}

View file

@ -137,13 +137,6 @@ public struct StatusDetailView: View {
}
}
}
#if !os(visionOS)
.listRowBackground(viewModel.highlightRowColor)
#endif
.listRowInsets(.init(top: 12,
leading: .layoutPadding,
bottom: 12,
trailing: .layoutPadding))
}
}

View file

@ -15,6 +15,8 @@ public struct StatusRowView: View {
@Environment(\.accessibilityVoiceOverEnabled) private var accessibilityVoiceOverEnabled
@Environment(\.isStatusFocused) private var isFocused
@Environment(\.indentationLevel) private var indentationLevel
@Environment(\.isHomeTimeline) private var isHomeTimeline
@Environment(RouterPath.self) private var routerPath: RouterPath
@Environment(QuickLook.self) private var quickLook
@ -151,7 +153,7 @@ public struct StatusRowView: View {
.foregroundStyle(.background).hoverEffect())
.listRowHoverEffectDisabled()
#else
.listRowBackground(viewModel.highlightRowColor)
.listRowBackground(viewModel.makeBackgroundColor(isHomeTimeline: isHomeTimeline))
#endif
.listRowInsets(.init(top: 0,
leading: .layoutPadding,

View file

@ -18,6 +18,8 @@ import SwiftUI
let client: Client
let routerPath: RouterPath
let userFollowedTag: HTMLString.Link?
private let theme = Theme.shared
private let userMentionned: Bool
@ -103,8 +105,35 @@ import SwiftUI
status.reblog?.inReplyToId != nil || status.reblog?.inReplyToAccountId != nil ||
status.inReplyToId != nil || status.inReplyToAccountId != nil
}
@ViewBuilder
func makeBackgroundColor(isHomeTimeline: Bool) -> some View {
if isHomeTimeline {
homeBackgroundColor
} else {
backgroundColor
}
}
@ViewBuilder
var homeBackgroundColor: some View {
if status.visibility == .direct {
theme.tintColor.opacity(0.15)
} else if userMentionned {
theme.secondaryBackgroundColor
} else {
if userFollowedTag != nil {
makeDecorativeGradient(startColor: .teal, endColor: theme.primaryBackgroundColor)
} else if status.reblog != nil {
makeDecorativeGradient(startColor: theme.tintColor, endColor: theme.primaryBackgroundColor)
} else {
theme.primaryBackgroundColor
}
}
}
var highlightRowColor: Color {
@ViewBuilder
var backgroundColor: some View {
if status.visibility == .direct {
theme.tintColor.opacity(0.15)
} else if userMentionned {
@ -113,6 +142,18 @@ import SwiftUI
theme.primaryBackgroundColor
}
}
func makeDecorativeGradient(startColor: Color, endColor: Color) -> some View {
LinearGradient(stops: [
.init(color: startColor.opacity(0.3), location: 0.03),
.init(color: startColor.opacity(0.2), location: 0.06),
.init(color: startColor.opacity(0.1), location: 0.09),
.init(color: startColor.opacity(0.05), location: 0.15),
.init(color: endColor, location: 0.25),
],
startPoint: .topLeading,
endPoint: .bottomTrailing)
}
public init(status: Status,
client: Client,
@ -146,6 +187,10 @@ import SwiftUI
} else {
userMentionned = false
}
userFollowedTag = finalStatus.content.links.first(where: { link in
link.type == .hashtag && CurrentAccount.shared.tags.contains(where: { $0.name.lowercased() == link.title.lowercased() })
})
isFiltered = filter != nil

View file

@ -5,17 +5,14 @@ import SwiftUI
struct StatusRowTagView: View {
@Environment(CurrentAccount.self) private var currentAccount
@Environment(RouterPath.self) private var routerPath
@Environment(Theme.self) private var theme
@Environment(\.isHomeTimeline) private var isHomeTimeline
let viewModel: StatusRowViewModel
var body: some View {
if isHomeTimeline,
let tag = viewModel.finalStatus.content.links.first(where: { link in
link.type == .hashtag && currentAccount.tags.contains(where: { $0.name.lowercased() == link.title.lowercased() })
})
{
if isHomeTimeline, let tag = viewModel.userFollowedTag {
Text("#\(tag.title)")
.font(.scaledFootnote)
.foregroundStyle(.secondary)