tidev / titanium-sdk

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

feat(android): window titleAttributes parity #13954

Closed m1ga closed 11 months ago

m1ga commented 11 months ago

Parity for titleAttribues: {color}.

iOS allows you to quickly set the window title color with titleAttributes: { color: #fff}. It has more options but for now I only added color to Android.

Screenshot_20231217-122719

Test 1:

var win = Titanium.UI.createWindow({
    barColor: "pink",
    backgroundColor: "white",
    title: 'Autos',
    titleAttributes: {
        top: 0,
        color: "blue",
    },
});

win.addEventListener("click", function() {
    win.titleAttributes = {
        color: "yellow"
    }
})
win.open();

Test 2:

Same but with a navigation window setup:

var win = Titanium.UI.createWindow({
    barColor: "pink",
    backgroundColor: "white",
    title: 'Autos',
    titleAttributes: {
        top: 0,
        color: "blue",
    },
});

var navWin = Titanium.UI.createNavigationWindow({
    window: win,
});

win.addEventListener("click", function() {
    win.titleAttributes = {
        color: "yellow"
    }
})
navWin.open();

Workaround

Currently you have to either add a custom toolbar/actionbar or use a theme

   <style name="MyTheme" parent="Theme.Titanium.DayNight">
        <item name="toolbarStyle">@style/Widget.App.Toolbar</item>
    </style>

    <style name="Widget.App.Toolbar" parent="Widget.MaterialComponents.Toolbar.Primary">
        <item name="titleTextColor">#ffffff</item>
        <item name="android:background">#ff00ff</item>
    </style>