From 0c93fa77aa911e92d3dfbae312e2884706414753 Mon Sep 17 00:00:00 2001 From: Michael Gangolf Date: Tue, 21 May 2024 20:04:15 +0200 Subject: [PATCH] feat(ios): add overrideUserInterfaceStyle to Picker (#14041) --- apidoc/Titanium/UI/Picker.yml | 15 +++++++++++++++ iphone/Classes/TiUIPicker.m | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/apidoc/Titanium/UI/Picker.yml b/apidoc/Titanium/UI/Picker.yml index f32ace414ae..84235b4a4eb 100644 --- a/apidoc/Titanium/UI/Picker.yml +++ b/apidoc/Titanium/UI/Picker.yml @@ -282,6 +282,21 @@ properties: since: "5.2.0" default: "black" + - name: overrideUserInterfaceStyle + summary: Forces the picker to used assigned theme instead of the system theme. + description: | + When set to [USER_INTERFACE_STYLE_DARK](Titanium.UI.USER_INTERFACE_STYLE_DARK) or + [USER_INTERFACE_STYLE_LIGHT](Titanium.UI.USER_INTERFACE_STYLE_LIGHT), the picker will ignore + the system's current theme and use the theme assigned to this property instead. + + When set to [USER_INTERFACE_STYLE_UNSPECIFIED](Titanium.UI.USER_INTERFACE_STYLE_UNSPECIFIED), + the picker will use the system's current theme. + type: Number + default: Titanium.UI.USER_INTERFACE_STYLE_UNSPECIFIED + constants: Titanium.UI.USER_INTERFACE_STYLE_* + osver: {ios: {min: "13.0"}} + since: "12.4.0" + - name: format24 summary: | Determines whether the Time pickers display in 24-hour or 12-hour clock format. diff --git a/iphone/Classes/TiUIPicker.m b/iphone/Classes/TiUIPicker.m index 37c4daaa87e..1f06ad8cdd5 100644 --- a/iphone/Classes/TiUIPicker.m +++ b/iphone/Classes/TiUIPicker.m @@ -225,6 +225,15 @@ - (void)setBackgroundColor_:(id)value } } +- (void)setOverrideUserInterfaceStyle_:(id)args +{ + ENSURE_SINGLE_ARG(args, NSNumber); + if (picker != nil) { + int style = [TiUtils intValue:args def:UIUserInterfaceStyleUnspecified]; + ((UIDatePicker *)[self picker]).overrideUserInterfaceStyle = style; + } +} + - (void)setDateTimeColor_:(id)value { // Guard date picker and iOS 14+ date picker style