@@ -4,13 +4,13 @@ import SwiftUI
44struct OSIABWebView : View {
55 /// View Model containing all the customisable elements.
66 @ObservedObject private var model : OSIABWebViewModel
7-
7+
88 /// Constructor method.
99 /// - Parameter model: View Model containing all the customisable elements.
1010 init ( _ model: OSIABWebViewModel ) {
1111 self . model = model
1212 }
13-
13+
1414 var body : some View {
1515 VStack {
1616 if let toolbarPosition = model. toolbarPosition {
@@ -28,7 +28,7 @@ struct OSIABWebView: View {
2828 )
2929 }
3030 Spacer ( )
31-
31+
3232 Button ( action: model. closeButtonPressed, label: {
3333 Text ( model. closeButtonText)
3434 . bold ( )
@@ -39,14 +39,14 @@ struct OSIABWebView: View {
3939 }
4040 if let error = model. error {
4141 OSIABErrorView (
42- error,
42+ error,
4343 reload: model. loadURL,
4444 reloadViewLayoutDirection: . fixed( value: . leftToRight)
4545 )
4646 } else {
4747 OSIABWebViewRepresentable ( model. webView)
4848 }
49-
49+
5050 if model. toolbarPosition == . bottom {
5151 OSIABNavigationView (
5252 showNavigationButtons: model. showNavigationButtons,
@@ -72,7 +72,7 @@ struct OSIABWebView: View {
7272private extension OSIABWebViewModel {
7373 convenience init (
7474 url: String ,
75- showURL: Bool ,
75+ showURL: Bool ,
7676 showToolbar: Bool ,
7777 toolbarPosition: OSIABToolbarPosition ,
7878 showNavigationButtons: Bool ,
@@ -112,7 +112,7 @@ private struct OSIABTestWebView: View {
112112 private let showNavigationButtons : Bool
113113 private let leftToRight : Bool
114114 private let isError : Bool
115-
115+
116116 init (
117117 closeButtonText: String = " Close " ,
118118 showURL: Bool = true ,
@@ -130,7 +130,7 @@ private struct OSIABTestWebView: View {
130130 self . leftToRight = leftToRight
131131 self . isError = isError
132132 }
133-
133+
134134 var body : some View {
135135 VStack {
136136 OSIABWebView (
@@ -150,142 +150,128 @@ private struct OSIABTestWebView: View {
150150 }
151151}
152152
153- // MARK: - Default Views
153+ struct OSIABWebView_Previews : PreviewProvider {
154+ static var previews : some View {
155+ // MARK: - Default Views
154156
155- #Preview( " Default - Light Mode " ) {
156- OSIABTestWebView ( )
157- }
157+ // Default - Light Mode
158+ OSIABTestWebView ( )
158159
159- #Preview( " Default - Dark Mode " ) {
160- OSIABTestWebView ( )
161- . preferredColorScheme ( . dark)
162- }
160+ // Default - Dark Mode
161+ OSIABTestWebView ( )
162+ . preferredColorScheme ( . dark)
163163
164- #Preview( " Error - Light Mode " ) {
165- OSIABTestWebView ( isError: true )
166- }
164+ // Error - Light Mode
165+ OSIABTestWebView (
166+ isError: true
167+ )
167168
168- // MARK: - Custom Close Button View
169+ // MARK: - Custom Close Button View
169170
170- #Preview( " Custom Close Button Text " ) {
171- OSIABTestWebView (
172- closeButtonText: " Done "
173- )
174- }
171+ // Custom Close Button Text
172+ OSIABTestWebView (
173+ closeButtonText: " Done "
174+ )
175175
176- // MARK: - No Toolbar View
176+ // MARK: - No Toolbar View
177177
178- #Preview( " No Toolbar " ) {
179- OSIABTestWebView (
180- showToolbar: false
181- )
182- }
178+ // No Toolbar
179+ OSIABTestWebView (
180+ showToolbar: false
181+ )
183182
184- // MARK: - Custom Views
183+ // MARK: - Custom Views
185184
186- #Preview( " No URL and No Navigation Buttons " ) {
187- OSIABTestWebView (
188- showURL: false ,
189- showNavigationButtons: false
190- )
191- }
185+ // No URL and No Navigation Buttons
186+ OSIABTestWebView (
187+ showURL: false ,
188+ showNavigationButtons: false
189+ )
192190
193- #Preview( " No URL, No Navigation Buttons and Left-to-Right " ) {
194- OSIABTestWebView (
195- showURL: false ,
196- showNavigationButtons: false ,
197- leftToRight: true
198- )
199- }
191+ // No URL, No Navigation Buttons and Left-to-Right
192+ OSIABTestWebView (
193+ showURL: false ,
194+ showNavigationButtons: false ,
195+ leftToRight: true
196+ )
200197
201- #Preview( " No URL " ) {
202- OSIABTestWebView (
203- showURL: false
204- )
205- }
198+ // No URL
199+ OSIABTestWebView (
200+ showURL: false
201+ )
206202
207- #Preview( " No URL and Left-To-Right " ) {
208- OSIABTestWebView (
209- showURL: false ,
210- leftToRight: true
211- )
212- }
203+ // No URL and Left-To-Right
204+ OSIABTestWebView (
205+ showURL: false ,
206+ leftToRight: true
207+ )
213208
214- #Preview( " No URL, Bottom Toolbar and No Navigation Buttons " ) {
215- OSIABTestWebView (
216- showURL: false ,
217- toolbarPosition: . bottom,
218- showNavigationButtons: false
219- )
220- }
209+ // No URL, Bottom Toolbar and No Navigation Buttons
210+ OSIABTestWebView (
211+ showURL: false ,
212+ toolbarPosition: . bottom,
213+ showNavigationButtons: false
214+ )
221215
222- #Preview( " No URL, Bottom Toolbar, No Navigation Buttons and Left-to-Right " ) {
223- OSIABTestWebView (
224- showURL: false ,
225- toolbarPosition: . bottom,
226- showNavigationButtons: false ,
227- leftToRight: true
228- )
229- }
216+ // No URL, Bottom Toolbar, No Navigation Buttons and Left-to-Right
217+ OSIABTestWebView (
218+ showURL: false ,
219+ toolbarPosition: . bottom,
220+ showNavigationButtons: false ,
221+ leftToRight: true
222+ )
230223
231- #Preview( " No URL and Bottom Toolbar " ) {
232- OSIABTestWebView (
233- showURL: false ,
234- toolbarPosition: . bottom
235- )
236- }
224+ // No URL and Bottom Toolbar
225+ OSIABTestWebView (
226+ showURL: false ,
227+ toolbarPosition: . bottom
228+ )
237229
238- #Preview( " No URL, Bottom Toolbar and Left-to-Right " ) {
239- OSIABTestWebView (
240- showURL: false ,
241- toolbarPosition: . bottom,
242- leftToRight: true
243- )
244- }
230+ // No URL, Bottom Toolbar and Left-to-Right
231+ OSIABTestWebView (
232+ showURL: false ,
233+ toolbarPosition: . bottom,
234+ leftToRight: true
235+ )
245236
246- #Preview( " No Navigation Buttons " ) {
247- OSIABTestWebView (
248- showNavigationButtons: false
249- )
250- }
237+ // No Navigation Buttons
238+ OSIABTestWebView (
239+ showNavigationButtons: false
240+ )
251241
252- #Preview( " No Navigation Buttons and Left-to-Right " ) {
253- OSIABTestWebView (
254- showNavigationButtons: false ,
255- leftToRight: true
256- )
257- }
242+ // No Navigation Buttons and Left-to-Right
243+ OSIABTestWebView (
244+ showNavigationButtons: false ,
245+ leftToRight: true
246+ )
258247
259- #Preview( " Left-to-Right " ) {
260- OSIABTestWebView (
261- leftToRight: true
262- )
263- }
248+ // Left-to-Right
249+ OSIABTestWebView (
250+ leftToRight: true
251+ )
264252
265- #Preview( " Bottom Toolbar and No Navigation Buttons " ) {
266- OSIABTestWebView (
267- toolbarPosition: . bottom,
268- showNavigationButtons: false
269- )
270- }
253+ // Bottom Toolbar and No Navigation Buttons
254+ OSIABTestWebView (
255+ toolbarPosition: . bottom,
256+ showNavigationButtons: false
257+ )
271258
272- #Preview( " Bottom Toolbar, No Navigation Buttons and Left-to-Right " ) {
273- OSIABTestWebView (
274- toolbarPosition: . bottom,
275- showNavigationButtons: false ,
276- leftToRight: true
277- )
278- }
259+ // Bottom Toolbar, No Navigation Buttons and Left-to-Right
260+ OSIABTestWebView (
261+ toolbarPosition: . bottom,
262+ showNavigationButtons: false ,
263+ leftToRight: true
264+ )
279265
280- #Preview( " Bottom Toolbar " ) {
281- OSIABTestWebView (
282- toolbarPosition: . bottom
283- )
284- }
266+ // Bottom Toolbar
267+ OSIABTestWebView (
268+ toolbarPosition: . bottom
269+ )
285270
286- #Preview( " Bottom Toolbar and Left-to-Right " ) {
287- OSIABTestWebView (
288- toolbarPosition: . bottom,
289- leftToRight: true
290- )
271+ // Bottom Toolbar and Left-to-Right
272+ OSIABTestWebView (
273+ toolbarPosition: . bottom,
274+ leftToRight: true
275+ )
276+ }
291277}
0 commit comments