Editor: Forward theme colors

This commit is contained in:
Thomas Ricouard 2022-12-31 12:11:42 +01:00
parent 47afe2b653
commit 07a4ef856d
2 changed files with 5 additions and 3 deletions

View file

@ -52,6 +52,7 @@ public struct StatusEditorView: View {
.onAppear {
viewModel.client = client
viewModel.currentAccount = currentAccount.account
viewModel.theme = theme
viewModel.prepareStatusText()
if !client.isAuth {
dismiss()

View file

@ -18,6 +18,7 @@ public class StatusEditorViewModel: ObservableObject {
var client: Client?
var currentAccount: Account?
var theme: Theme?
@Published var statusText = NSMutableAttributedString(string: "") {
didSet {
@ -157,7 +158,7 @@ public class StatusEditorViewModel: ObservableObject {
var foundSuggestionRange: Bool = false
for nsRange in ranges {
statusText.addAttributes([.foregroundColor: UIColor(Color.brand)],
statusText.addAttributes([.foregroundColor: UIColor(theme?.tintColor ?? .brand)],
range: nsRange)
if selectedRange.location == (nsRange.location + nsRange.length),
let range = Range(nsRange, in: statusText.string) {
@ -172,9 +173,9 @@ public class StatusEditorViewModel: ObservableObject {
}
for range in urlRanges {
statusText.addAttributes([.foregroundColor: UIColor(Color.brand),
statusText.addAttributes([.foregroundColor: UIColor(theme?.tintColor ?? .brand),
.underlineStyle: NSUnderlineStyle.single,
.underlineColor: UIColor(Color.brand)],
.underlineColor: UIColor(theme?.tintColor ?? .brand)],
range: NSRange(location: range.location, length: range.length))
}
} catch {