set fontsize and token on localstorage for apple web embed
This commit is contained in:
@ -275,8 +275,7 @@ struct WebReader: UIViewRepresentable {
|
||||
item: item,
|
||||
authToken: authToken,
|
||||
isDark: UITraitCollection.current.userInterfaceStyle == .dark,
|
||||
fontSize: "\(fontSize())px",
|
||||
margin: "0"
|
||||
fontSize: fontSize()
|
||||
)
|
||||
.styledContent,
|
||||
baseURL: ViewsPackage.bundleURL
|
||||
|
||||
@ -3,12 +3,7 @@ import Models
|
||||
import Utils
|
||||
|
||||
struct WebReaderContent {
|
||||
let textFontSize: String
|
||||
let fontColor: String
|
||||
let fontColorTransparent: String
|
||||
let tableHeaderColor: String
|
||||
let headerColor: String
|
||||
let margin: String
|
||||
let textFontSize: Int
|
||||
let content: String
|
||||
let item: FeedItem
|
||||
let themeKey: String
|
||||
@ -18,29 +13,17 @@ struct WebReaderContent {
|
||||
htmlContent: String,
|
||||
item: FeedItem,
|
||||
authToken: String,
|
||||
isDark: Bool = false,
|
||||
fontSize: String = "16px",
|
||||
margin: String = "24px"
|
||||
isDark: Bool,
|
||||
fontSize: Int
|
||||
) {
|
||||
self.textFontSize = fontSize
|
||||
self.fontColor = isDark ? "#B9B9B9" : "#3D3D3D"
|
||||
self.fontColorTransparent = isDark ? "rgba(185,185,185,0.65)" : "rgba(185,185,185,0.65)"
|
||||
self.tableHeaderColor = "#FFFFFF"
|
||||
self.headerColor = isDark ? "#B9B9B9" : "#3D3D3D"
|
||||
self.margin = margin
|
||||
self.content = htmlContent
|
||||
self.item = item
|
||||
self.themeKey = isDark ? "Gray" : "LightGray"
|
||||
self.authToken = authToken
|
||||
}
|
||||
|
||||
var styleString: String {
|
||||
// swiftlint:disable line_length
|
||||
"--text-font-size:\(textFontSize);--font-color:\(fontColor);--font-color-transparent\(fontColorTransparent);--table-header-color:\(tableHeaderColor);--headers-color:\(headerColor);--app-margin:\(margin);"
|
||||
}
|
||||
|
||||
// TODO: pass in fontSize and theme
|
||||
|
||||
// swiftlint:disable line_length
|
||||
var styledContent: String {
|
||||
"""
|
||||
<!DOCTYPE html>
|
||||
@ -53,7 +36,7 @@ struct WebReaderContent {
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root" style="\(styleString)">
|
||||
<div id="root">
|
||||
<script type="text/javascript">
|
||||
function loadArticle() {
|
||||
window.omnivoreArticle = {
|
||||
@ -74,7 +57,9 @@ struct WebReaderContent {
|
||||
}
|
||||
|
||||
loadArticle()
|
||||
window.fontSize = \(textFontSize)
|
||||
window.localStorage.setItem("authToken", "\(authToken)")
|
||||
window.localStorage.setItem("theme", "\(themeKey)")
|
||||
</script>
|
||||
</div>
|
||||
<script src="bundle.js"></script>
|
||||
|
||||
@ -15,5 +15,5 @@ public enum FeatureFlag {
|
||||
public static let enableShareButton = false
|
||||
public static let enableSnooze = false
|
||||
public static let showFeedItemTags = false
|
||||
public static let useLocalWebView = true
|
||||
public static let useLocalWebView = false
|
||||
}
|
||||
|
||||
@ -1,3 +1,25 @@
|
||||
html,
|
||||
body {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
|
||||
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
line-height: 1.6;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.disable-webkit-callout {
|
||||
-webkit-touch-callout: none;
|
||||
}
|
||||
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Inter';
|
||||
font-weight: 200;
|
||||
|
||||
Reference in New Issue
Block a user