@@ -105,40 +105,46 @@ struct Webview : UIViewRepresentable {
105105
106106 }
107107
108+ private let lightTextColor = " #1C1C1E "
109+ private let darkTextColor = " #F2F2F7 "
110+
108111 func css( colorScheme: colorScheme ) -> String {
112+ let imgStyle = " img{max-height: 100%; min-height: 100%; height:auto; max-width: 100%; width:auto;margin-bottom:5px; border-radius: \( imageRadius) px;} "
113+ let iframeStyle = " iframe{width:100%; height:250px;} "
114+ let textStyleBase = " h1, h2, h3, h4, h5, h6, p, dl, ol, ul, pre, blockquote {text-align:left|right|center; line-height: \( lineHeight) %; font-family: ' \( fontName ( fontType: self . fontType) ) '; color: "
115+ let importantSuffix = colorImportant == false ? " " : " !important "
116+
109117 switch colorScheme {
110118 case . light:
111119 return """
112120 <style type='text/css'>
113- img{max-height: 100%; min-height: 100%; height:auto; max-width: 100%; width:auto;margin-bottom:5px; border-radius: \( imageRadius) px;}
114- h1, h2, h3, h4, h5, h6, p, dl, ol, ul, pre, blockquote {text-align:left|right|center; line-height: \( lineHeight) %; font-family: ' \( fontName ( fontType: self . fontType) ) '; color: #1C1C1E \( colorImportant == false ? " " : " !important " ) ; }
115- iframe{width:100%; height:250px;}
116-
121+ \( imgStyle)
122+ \( textStyleBase) \( lightTextColor) \( importantSuffix) ; }
123+ \( iframeStyle)
117124 </style>
118125 <BODY>
119126 """
120- case . dark :
127+ case . dark:
121128 return """
122129 <style type='text/css'>
123- img{max-height: 100%; min-height: 100%; height:auto; max-width: 100%; width:auto;margin-bottom:5px; border-radius: \( imageRadius) px;}
124- h1, h2, h3, h4, h5, h6, p, dl, ol, ul, pre, blockquote {text-align:left|right|center; line-height: \( lineHeight) %; font-family: ' \( fontName ( fontType: self . fontType) ) '; color: #F2F2F7 \( colorImportant == false ? " " : " !important " ) ; }
125- iframe{width:100%; height:250px;}
126-
130+ \( imgStyle)
131+ \( textStyleBase) \( darkTextColor) \( importantSuffix) ; }
132+ \( iframeStyle)
127133 </style>
128134 <BODY>
129135 """
130136 case . automatic:
131137 return """
132138 <style type='text/css'>
133139 @media (prefers-color-scheme: light) {
134- img{max-height: 100%; min-height: 100%; height:auto; max-width: 100%; width:auto;margin-bottom:5px; border-radius: \( imageRadius ) px;}
135- h1, h2, h3, h4, h5, h6, p, dl, ol, ul, pre, blockquote {text-align:left|right|center; line-height: \( lineHeight ) %; font-family: ' \( fontName ( fontType : self . fontType ) ) '; color: #1C1C1E \( colorImportant == false ? " " : " !important " ) ; }
136- iframe{width:100%; height:250px;}
140+ \( imgStyle )
141+ \( textStyleBase ) \( lightTextColor ) \( importantSuffix ) ; }
142+ \( iframeStyle )
137143 }
138144 @media (prefers-color-scheme: dark) {
139- img{max-height: 100%; min-height: 100%; height:auto; max-width: 100%; width:auto;margin-bottom:5px; border-radius: \( imageRadius ) px;}
140- h1, h2, h3, h4, h5, h6, p, dl, ol, ul, pre, blockquote {text-align:left|right|center; line-height: \( lineHeight ) %; font-family: ' \( fontName ( fontType : self . fontType ) ) '; color: #F2F2F7 \( colorImportant == false ? " " : " !important " ) ; }
141- iframe{width:100%; height:250px;}
145+ \( imgStyle )
146+ \( textStyleBase ) \( darkTextColor ) \( importantSuffix ) ; }
147+ \( iframeStyle )
142148 }
143149 </style>
144150 <BODY>
0 commit comments