Skip to content

Commit

Permalink
Fix webview background color
Browse files Browse the repository at this point in the history
  • Loading branch information
Bunn committed Dec 11, 2024
1 parent 3d3e45c commit 2811c4d
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 4 deletions.
10 changes: 7 additions & 3 deletions LocalPackages/AIChat/Package.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// swift-tools-version: 6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
Expand All @@ -11,10 +10,15 @@ let package = Package(
products: [
.library(
name: "AIChat",
targets: ["AIChat"]),
targets: ["AIChat"]
),
],
targets: [
.target(
name: "AIChat"),
name: "AIChat",
resources: [
.process("Resources/Assets.xcassets")
]
),
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class AIChatWebViewController: UIViewController {
private lazy var webView: WKWebView = {
let webView = WKWebView(frame: .zero, configuration: chatModel.webViewConfiguration)
webView.isOpaque = false /// Required to make the background color visible
webView.backgroundColor = .systemBackground
webView.backgroundColor = .webViewBackgroundColor
webView.navigationDelegate = self
webView.translatesAutoresizingMaskIntoConstraints = false
return webView
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "1.000",
"green" : "1.000",
"red" : "1.000"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.086",
"green" : "0.086",
"red" : "0.086"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
26 changes: 26 additions & 0 deletions LocalPackages/AIChat/Sources/AIChat/UIColor+Extension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// UIColor+Extension.swift
// DuckDuckGo
//
// Copyright © 2024 DuckDuckGo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import UIKit

extension UIColor {
static var webViewBackgroundColor: UIColor {
return UIColor(named: "webViewBackgroundColor", in: Bundle.module, compatibleWith: nil) ?? UIColor.red
}
}

0 comments on commit 2811c4d

Please sign in to comment.