Skip to content

Commit

Permalink
[Progress] Fix dark background color of webview
Browse files Browse the repository at this point in the history
  • Loading branch information
markmur committed Jan 31, 2024
1 parent e7993f5 commit 3721e2a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
$0.colorScheme = .automatic

/// Enable preloading
$0.preloading.enabled = true
$0.preloading.enabled = false

$0.progressBarEnabled = true

/// Optional logger used for internal purposes
$0.logger = FileLogger("log.txt")
Expand Down
7 changes: 7 additions & 0 deletions Sources/ShopifyCheckoutSheetKit/CheckoutWebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ class CheckoutWebView: WKWebView {
injectionTime: WKUserScriptInjectionTime.atDocumentStart,
forMainFrameOnly: true
))

isOpaque = false
backgroundColor = ShopifyCheckoutSheetKit.configuration.backgroundColor

if #available(iOS 15.0, *) {
underPageBackgroundColor = ShopifyCheckoutSheetKit.configuration.backgroundColor
}
}

deinit {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class CheckoutWebViewController: UIViewController, UIAdaptivePresentationControl
navigationItem.rightBarButtonItem = closeBarButtonItem

checkoutView.viewDelegate = self

view.backgroundColor = ShopifyCheckoutSheetKit.configuration.backgroundColor
}

required init?(coder: NSCoder) {
Expand All @@ -86,11 +88,13 @@ class CheckoutWebViewController: UIViewController, UIAdaptivePresentationControl

// MARK: UIViewController Lifecycle

override public func viewWillAppear(_ animated: Bool) {
view.backgroundColor = ShopifyCheckoutSheetKit.configuration.backgroundColor
}

override public func viewDidLoad() {
super.viewDidLoad()

view.backgroundColor = ShopifyCheckoutSheetKit.configuration.backgroundColor

view.addSubview(checkoutView)
NSLayoutConstraint.activate([
checkoutView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ class IndeterminateProgressBarView: UIView {

NSLayoutConstraint.activate([
progressBar.topAnchor.constraint(equalTo: topAnchor),
progressBar.heightAnchor.constraint(equalToConstant: 4),
progressBar.heightAnchor.constraint(equalToConstant: 1),

Check failure on line 20 in Sources/ShopifyCheckoutSheetKit/IndeterminateProgressBarView.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Trailing Comma Violation: Collection literals should not have trailing commas (trailing_comma)
])

progressBar.tintColor = .systemGray5
progressBar.tintColor = ShopifyCheckoutSheetKit.configuration.spinnerColor
}

override func didMoveToSuperview() {
Expand All @@ -43,7 +43,6 @@ class IndeterminateProgressBarView: UIView {
}

func startAnimating() {
print("start animating")
alpha = 1
isHidden = false
}
Expand Down

0 comments on commit 3721e2a

Please sign in to comment.