Fix issue with justify-text not being set on iOS

This commit is contained in:
Jackson Harper
2023-05-26 18:02:06 +08:00
parent df27d2eb44
commit 4d801a7cec
2 changed files with 16 additions and 2 deletions

View File

@ -180,6 +180,15 @@ struct WebReader: PlatformViewRepresentable {
}
}()
let justifyText: Bool = {
let key = UserDefaultKey.justifyText.rawValue
if UserDefaults.standard.object(forKey: key) != nil {
return UserDefaults.standard.bool(forKey: key)
} else {
return false
}
}()
let fontFamily = fontFamilyValue.flatMap { WebFont(rawValue: $0) } ?? .system
let htmlString = WebReaderContent(
@ -191,7 +200,8 @@ struct WebReader: PlatformViewRepresentable {
maxWidthPercentage: maxWidthPercentage(),
fontFamily: fontFamily,
prefersHighContrastText: prefersHighContrastText,
enableHighlightOnRelease: enableHighlightOnRelease
enableHighlightOnRelease: enableHighlightOnRelease,
justifyText: justifyText
)
.styledContent

View File

@ -14,6 +14,7 @@ struct WebReaderContent {
let articleContent: ArticleContent
let prefersHighContrastText: Bool
let enableHighlightOnRelease: Bool
let justifyText: Bool
init(
item: LinkedItem,
@ -24,7 +25,8 @@ struct WebReaderContent {
maxWidthPercentage: Int,
fontFamily: WebFont,
prefersHighContrastText: Bool,
enableHighlightOnRelease: Bool
enableHighlightOnRelease: Bool,
justifyText: Bool
) {
self.textFontSize = fontSize
self.lineHeight = lineHeight
@ -36,6 +38,7 @@ struct WebReaderContent {
self.articleContent = articleContent
self.prefersHighContrastText = prefersHighContrastText
self.enableHighlightOnRelease = enableHighlightOnRelease
self.justifyText = justifyText
}
// swiftlint:disable line_length
@ -91,6 +94,7 @@ struct WebReaderContent {
window.fontFamily = "\(fontFamily.rawValue)"
window.maxWidthPercentage = \(maxWidthPercentage)
window.lineHeight = \(lineHeight)
window.justifyText = \(justifyText)
window.prefersHighContrastFont = \(prefersHighContrastText)
window.enableHighlightBar = \(isMacApp)
window.highlightOnRelease = \(enableHighlightOnRelease)