tidev / titanium-sdk

🚀 Native iOS and Android Apps with JavaScript
https://titaniumsdk.com/
Other
2.76k stars 1.21k forks source link

feat(android): statusBarColor for Window #14089

Closed m1ga closed 2 months ago

m1ga commented 3 months ago

Android: Add statusBarColor property to change the statusBar color using code

var win = Ti.UI.createWindow({
    statusBarColor:"#0f0"
});
setTimeout(function(){
    win.statusBarColor = "#f00";
},2000)

win.open();

Test: run the code: status bar is green and after one second it's red

Current workaround either use a normal Android theme and set it there or Hyperloop

import Activity from 'android.app.Activity';
import Color from 'android.graphics.Color';

var win = Ti.UI.createWindow();
win.addEventListener("open", function(){
    const activity = new Activity(win.activity);
    setInterval(function(){
        activity.getWindow().setStatusBarColor(Color.argb(Math.floor(Math.random()*255), Math.floor(Math.random()*255), Math.floor(Math.random()*255), 0));
    }, 500)
})
win.open();