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

feat(ios): add overrideUserInterfaceStyle to Picker #14041

Merged
merged 1 commit into from
May 21, 2024
Merged

Conversation

m1ga
Copy link
Contributor

@m1ga m1ga commented May 18, 2024

The compact UI picker doesn't allow the user to set a text color. If you use your phone in light mode but have a dark background it will look like this:

Simulator Screenshot - iPhone 15 Pro Max - 2024-05-18 at 15 52 51

This PR will allow you to switch the overrideUserInterfaceStyle for the Picker. I took most of the code/docs from the app overrideUserInterfaceStyle and modified it to use the picker instead of the whole app.

That way you can at least set the text color to white!

Test

var win = Ti.UI.createWindow({backgroundColor:"black"});

var picker = Ti.UI.createPicker({
  type:Ti.UI.DATE_PICKER_STYLE_COMPACT,
  minDate:new Date(2009,0,1),
  maxDate:new Date(2014,11,31),
  value:new Date(2014,3,12),
  backgroundColor:"transparent"
});
var btn = Ti.UI.createButton({
  title:"toggle", bottom: 40
});
var isLight = true;
btn.addEventListener("click", function(e){
  picker.overrideUserInterfaceStyle = isLight ? Titanium.UI.USER_INTERFACE_STYLE_DARK:Titanium.UI.USER_INTERFACE_STYLE_LIGHT;
  isLight = !isLight;
})
win.add([picker,btn]);
win.open();
  • Run app in light mode
  • click the toggle button to switch between the styles.

Simulator Screenshot - iPhone 15 Pro Max - 2024-05-18 at 15 56 22

@hansemannn hansemannn merged commit 0c93fa7 into master May 21, 2024
7 checks passed
@m1ga m1ga deleted the iosPickerUIMode branch May 21, 2024 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants