diff --git a/mobile/ios/Runner/NativeMessageActionSurface.swift b/mobile/ios/Runner/NativeMessageActionSurface.swift index fb070b7da..0e4668693 100644 --- a/mobile/ios/Runner/NativeMessageActionSurface.swift +++ b/mobile/ios/Runner/NativeMessageActionSurface.swift @@ -73,6 +73,17 @@ enum NativeMessageActionSurfaceLayout { @available(iOS 16.0, *) enum NativeMessageActionSurfaceAppearance { + static func interfaceStyle(from value: Any?) -> UIUserInterfaceStyle { + switch value as? String { + case "dark": + return .dark + case "light": + return .light + default: + return .unspecified + } + } + static func backdropEffect(reduceTransparency: Bool) -> UIVisualEffect? { guard !reduceTransparency else { return nil } @@ -246,6 +257,9 @@ final class NativeMessageActionSurfacePlatformView: NSObject, from: arguments?["errorColor"], fallback: .systemRed ) + let interfaceStyle = NativeMessageActionSurfaceAppearance.interfaceStyle( + from: arguments?["interfaceStyle"] + ) let actionArguments = arguments?["actions"] as? [[String: Any]] let actions = actionArguments?.compactMap( @@ -267,8 +281,10 @@ final class NativeMessageActionSurfacePlatformView: NSObject, surfaceView.backgroundColor = .clear surfaceView.clipsToBounds = false surfaceView.accessibilityViewIsModal = true + surfaceView.overrideUserInterfaceStyle = interfaceStyle backdropView.translatesAutoresizingMaskIntoConstraints = false + backdropView.overrideUserInterfaceStyle = interfaceStyle backdropView.layer.cornerRadius = NativeMessageActionSurfaceLayout.cornerRadius backdropView.layer.cornerCurve = .continuous backdropView.layer.masksToBounds = true diff --git a/mobile/ios/RunnerTests/RunnerTests.swift b/mobile/ios/RunnerTests/RunnerTests.swift index d9c8efa66..4fc4fe3bf 100644 --- a/mobile/ios/RunnerTests/RunnerTests.swift +++ b/mobile/ios/RunnerTests/RunnerTests.swift @@ -482,6 +482,21 @@ class RunnerTests: XCTestCase { ) } + func testNativeMessageActionSurfaceMatchesFlutterInterfaceStyle() { + XCTAssertEqual( + NativeMessageActionSurfaceAppearance.interfaceStyle(from: "dark"), + .dark + ) + XCTAssertEqual( + NativeMessageActionSurfaceAppearance.interfaceStyle(from: "light"), + .light + ) + XCTAssertEqual( + NativeMessageActionSurfaceAppearance.interfaceStyle(from: "system"), + .unspecified + ) + } + private func displayP3Image(red: CGFloat, green: CGFloat, blue: CGFloat) throws -> UIImage { let colorSpace = try XCTUnwrap(CGColorSpace(name: CGColorSpace.displayP3)) let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.premultipliedLast.rawValue) diff --git a/mobile/lib/features/channels/message_actions/message_action_popover.dart b/mobile/lib/features/channels/message_actions/message_action_popover.dart index c045aebef..062781e75 100644 --- a/mobile/lib/features/channels/message_actions/message_action_popover.dart +++ b/mobile/lib/features/channels/message_actions/message_action_popover.dart @@ -461,6 +461,7 @@ class _IosNativeMessageActionSurface extends HookWidget { 'foregroundColor': context.colors.onSurface.toARGB32(), 'separatorColor': context.colors.outlineVariant.toARGB32(), 'errorColor': context.colors.error.toARGB32(), + 'interfaceStyle': context.colors.brightness.name, }, creationParamsCodec: const StandardMessageCodec(), onPlatformViewCreated: (id) => viewId.value = id,