Skip to content

Commit e12403a

Browse files
committed
UIKitBackend: Implement openURL action, kind of support colorScheme(_:)
Only supports colorScheme(_:) for text at the moment, and doesn't dynamically react when the system color scheme changes.
1 parent 5240b06 commit e12403a

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import SwiftCrossUI
2+
import UIKit
3+
4+
extension ColorScheme {
5+
var userInterfaceStyle: UIUserInterfaceStyle {
6+
switch self {
7+
case .light:
8+
return .light
9+
case .dark:
10+
return .dark
11+
}
12+
}
13+
}

Sources/UIKitBackend/UIKitBackend+Passive.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@ extension UIKitBackend {
4141
environment: EnvironmentValues
4242
) {
4343
let wrapper = textView as! WrapperWidget<UILabel>
44+
wrapper.child.overrideUserInterfaceStyle = environment.colorScheme.userInterfaceStyle
4445
wrapper.child.attributedText = UIKitBackend.attributedString(
45-
text: content, environment: environment)
46+
text: content,
47+
environment: environment
48+
)
4649
}
4750

4851
public func size(

Sources/UIKitBackend/UIKitBackend.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ public final class UIKitBackend: AppBackend {
111111

112112
public func show(widget: Widget) {
113113
}
114+
115+
public func openExternalURL(_ url: URL) throws {
116+
UIApplication.shared.open(url)
117+
}
114118
}
115119

116120
extension App {

0 commit comments

Comments
 (0)