Skip to content

SwiftUI-usable WKWebView and UIScrollView with advanced scroll

Notifications You must be signed in to change notification settings

Ant-tree/Ant-SwiftUIScrollView

Repository files navigation

Ant-SwiftUIScrollView

SwiftUI-usable WKWebView and UIScrollView with advanced scroll

Makes you able to enables / disables the scroll, tracks the current scroll position.

Plus, you can check for the loading state of the webview.

Previews

WebView loading Scroll position tracking Nested scroll control
1 2 3

Usage

Simply call the AntWebView or AntObservableScrollView and it will be there.

Function AntWebView AntObservableScrollView AntControllableScrollView
Enables / disables the scroll O O X (Use introspect)
Scroll position tracking O O O
Scrolls to specific point X O O
Loading completion listening O X X

Currently, the AntControllableScrollView is unstable due to its UIKit feature.

Thus, use the AntObservableScrollView instead and use SwiftUI-Introspect to enable or disable the scroll event.

AntWebView(
 urlString,
 isScrollable: $scrollEnabled
) { loading, error in
 print("loading status : \(loading)")
 showProgressCircle = loading
} onScroll: { point, isScrollingUp in
 print("Where am I : \(point)")
 print("Am I going up ? : \(isScrollingUp)")
 scrollPosition = point
}.frame(
 minWidth: 0,
 maxWidth: .infinity,
 minHeight: 0,
 maxHeight: .infinity,
 alignment: .center
)

For the AntObservableScrollView,

AntObservableScrollView(content: { proxy in
 //Contents to be scrolled
 VStack {
 }
}, onScrollChanged: { point in
 print("Where am I : \(point)")
}, isScrollable: $scrollEnabled)

screen

About

SwiftUI-usable WKWebView and UIScrollView with advanced scroll

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages