Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(iOS): new architecture props #983

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions ios/NewArch/FabricViewImplementationProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ import Foundation
@objc public protocol FabricViewImplementationProtocol {
var actions: [NSDictionary]? { get set }
var title: NSString? { get set }
var themeVariant: NSString? { get set }
var shouldOpenOnLongPress: Bool { get set }
@objc optional var hitSlop: UIEdgeInsets { get set }
var onPressAction: ((String) -> Void)? { get set }
}
20 changes: 20 additions & 0 deletions ios/NewArch/MenuView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,26 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &
_view.title = [NSString stringWithUTF8String:newViewProps.title.c_str()];
}

if (oldViewProps.themeVariant != newViewProps.themeVariant) {
_view.themeVariant = [NSString stringWithUTF8String:newViewProps.themeVariant.c_str()];
}

if (oldViewProps.shouldOpenOnLongPress != newViewProps.shouldOpenOnLongPress) {
_view.shouldOpenOnLongPress = newViewProps.shouldOpenOnLongPress;
}

if (oldViewProps.hitSlop.top != newViewProps.hitSlop.top ||
oldViewProps.hitSlop.bottom != newViewProps.hitSlop.bottom ||
oldViewProps.hitSlop.left != newViewProps.hitSlop.left ||
oldViewProps.hitSlop.right != newViewProps.hitSlop.right) {
_view.hitSlop = UIEdgeInsetsMake(
newViewProps.hitSlop.top,
newViewProps.hitSlop.left,
newViewProps.hitSlop.bottom,
newViewProps.hitSlop.right
);
}

[super updateProps:props oldProps:oldProps];
}

Expand Down
4 changes: 2 additions & 2 deletions ios/Shared/ActionSheetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ public class ActionSheetView: UIView {
}
}

@objc var shouldOpenOnLongPress: Bool = false
@objc public var shouldOpenOnLongPress: Bool = false

private var _themeVariant: String?
@objc var themeVariant: NSString? {
@objc public var themeVariant: NSString? {
didSet { self._themeVariant = themeVariant as? String }
}

Expand Down
6 changes: 3 additions & 3 deletions ios/Shared/MenuViewImplementation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ public class MenuViewImplementation: UIButton {
}
}

@objc var shouldOpenOnLongPress: Bool = false {
@objc public var shouldOpenOnLongPress: Bool = false {
didSet {
self.setup()
}
}

private var _themeVariant: String?
@objc var themeVariant: NSString? {
@objc public var themeVariant: NSString? {
didSet {
self._themeVariant = themeVariant as? String
self.setup()
}
}

@objc var hitSlop: UIEdgeInsets = .zero
@objc public var hitSlop: UIEdgeInsets = .zero

override init(frame: CGRect) {
super.init(frame: frame)
Expand Down
8 changes: 8 additions & 0 deletions src/NativeModuleSpecs/UIMenuNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ export interface NativeProps extends ViewProps {
actions: Array<MenuAction>;
actionsHash: string; // just a workaround to make sure we don't have to manually compare MenuActions manually in C++ (since it's a struct and that's a pain)
title?: string;
themeVariant?: string;
shouldOpenOnLongPress?: boolean;
hitSlop: {
top: Int32;
bottom: Int32;
left: Int32;
right: Int32;
}
}

export default codegenNativeComponent<NativeProps>(
Expand Down
Loading