Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import UIKit
import XCTest

@testable import webview_flutter_wkwebview

class ColorProxyAPITests: XCTestCase {
func testPigeonDefaultConstructor() {
let registrar = TestProxyApiRegistrar()
let api = registrar.apiDelegate.pigeonApiUIColor(registrar)

let instance = try? api.pigeonDelegate.pigeonDefaultConstructor(pigeonApi: api, red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)
XCTAssertNotNil(instance)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ class UIViewProxyAPITests: XCTestCase {
let api = registrar.apiDelegate.pigeonApiUIView(registrar)

let instance = UIView(frame: .zero)
let value = 0xFFF4_4336
let red = 0.5
let green = 0.5
let blue = 0.5
let alpha = 0.5
try? api.pigeonDelegate.setBackgroundColor(
pigeonApi: api, pigeonInstance: instance, value: Int64(value))

let red = CGFloat(Double((value >> 16 & 0xff)) / 255.0)
let green = CGFloat(Double(value >> 8 & 0xff) / 255.0)
let blue = CGFloat(Double(value & 0xff) / 255.0)
let alpha = CGFloat(Double(value >> 24 & 0xff) / 255.0)
pigeonApi: api, pigeonInstance: instance, value: UIColor(red: red, green: green, blue: blue, alpha: alpha))

XCTAssertEqual(
instance.backgroundColor, UIColor(red: red, green: green, blue: blue, alpha: alpha))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import Foundation
import UIKit

/// ProxyApi implementation for `UIColor`.
///
/// This class may handle instantiating native object instances that are attached to a Dart instance
/// or handle method calls on the associated native class or an instance of that class.
class ColorProxyAPIDelegate : PigeonApiDelegateUIColor {
func pigeonDefaultConstructor(pigeonApi: PigeonApiUIColor, red: Double, green: Double, blue: Double, alpha: Double) throws -> UIColor {
return UIColor(red: red, green: green, blue: blue, alpha: alpha)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,8 @@ class ProxyAPIDelegate: WebKitLibraryPigeonProxyApiDelegate {
return PigeonApiSecCertificate(
pigeonRegistrar: registrar, delegate: SecCertificateProxyAPIDelegate())
}

func pigeonApiUIColor(_ registrar: WebKitLibraryPigeonProxyApiRegistrar) -> PigeonApiUIColor {
return PigeonApiUIColor(pigeonRegistrar: registrar, delegate: ColorProxyAPIDelegate())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,10 @@
/// or handle method calls on the associated native class or an instance of that class.
class UIViewProxyAPIDelegate: PigeonApiDelegateUIView {
#if os(iOS)
func setBackgroundColor(pigeonApi: PigeonApiUIView, pigeonInstance: UIView, value: Int64?)
func setBackgroundColor(pigeonApi: PigeonApiUIView, pigeonInstance: UIView, value: UIColor?)
throws
{
if value == nil {
pigeonInstance.backgroundColor = nil
} else {
let red = CGFloat(Double((value! >> 16 & 0xff)) / 255.0)
let green = CGFloat(Double(value! >> 8 & 0xff) / 255.0)
let blue = CGFloat(Double(value! & 0xff) / 255.0)
let alpha = CGFloat(Double(value! >> 24 & 0xff) / 255.0)

pigeonInstance.backgroundColor = UIColor(red: red, green: green, blue: blue, alpha: alpha)
}
pigeonInstance.backgroundColor = value
}

func setOpaque(pigeonApi: PigeonApiUIView, pigeonInstance: UIView, opaque: Bool) throws {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ class PlatformWebView {
}

/// The view’s background color.
Future<void> setBackgroundColor(int? value) {
Future<void> setBackgroundColor(UIColor? value) {
final WKWebView webView = nativeWebView;
switch (webView) {
case UIViewWKWebView():
Expand Down
Loading