tidev / titanium-sdk

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

Android: new control Ti.UI.BottomNavigation #14126

Open m1ga opened 1 month ago

m1ga commented 1 month ago

Work in progress

var win1 = Ti.UI.createWindow({backgroundColor:"red"});
var win2 = Ti.UI.createWindow({backgroundColor:"red"});
var tab1 = Ti.UI.createTab({ window: win1, title: 'Blue', icon: '/images/icon.png'});
var tab2 = Ti.UI.createTab({window: win2,   title: 'Red',   icon: '/images/starmask.png'});

var lbl1 = Ti.UI.createLabel({text:"Text 1", color: "#fff", bottom: 0});
var lbl2 = Ti.UI.createLabel({text:"Text 2", color: "#fff", bottom: 0});
win1.add(lbl1);
win2.add(lbl2);
win1.addEventListener("click", function(){
    tab1.badge = 20;
});

var bottomNav = Ti.UI.createTabGroup({
    tabs: [tab1, tab2],
    theme: "Theme.Titanium.Material3.DayNight",
    newLayout:true,
    style: Ti.UI.Android.TABS_STYLE_BOTTOM_NAVIGATION
});
bottomNav.open();

Just a test for now.

Currently working:

Bildschirmaufnahme_20241002_231752.webm

Current issues:

hansemannn commented 1 month ago

Can't you replace the old tab group API with the newer API internally? I do not see iOS implementing the same API as it already has, as it's the same. Ideally, this change would only swap the internal UI behind Ti.UI.TabGroup while retaining the API structure. Legacy things like the style property can be dropped and edge cases like changing themes at runtime as well.

m1ga commented 1 month ago

Pushed my current WIP where I use the old structure and you can use newLayout:true:

var bottomNav = Ti.UI.createTabGroup({
    tabs: [tab1, tab2],
    newLayout:true, // <- new
    style: Ti.UI.Android.TABS_STYLE_BOTTOM_NAVIGATION
});

to use the new XML layout.

I'm working on it at the moment :smile:

m1ga commented 1 month ago

Test a different app today and added more parts: Screenshot_20241005-174416 icon setter, shiftMode

m1ga commented 1 month ago

icon can now use Ti.App.Android.drawable.something and that can load animated icons too:

https://github.com/user-attachments/assets/478c9fdc-5a9c-4a6d-a721-6d37694ab830

(demo icon from https://shapeshifter.design/ )

m1ga commented 1 month ago

Floating version is back: Screenshot_20241017-131630

m1ga commented 1 month ago

New property iconFont so you can use icons from a font right away:

'#tabHome': {
    icon: "\ueac1",
    iconFamily: "tabler-icons"
}

Screenshot_20241019-234001

and with tintColor/activteTintColor support

Screenshot_20241019-235342

m1ga commented 1 month ago

Some updates:

simple test: Screenshot_20241020-220819 phone is in dark mode, all colors are set in the TSS file