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

[TIMOB-17821] Android: Add Support for Custom View to ActionBar #9425

Merged
merged 21 commits into from Feb 26, 2018

Conversation

ypbnv
Copy link
Contributor

@ypbnv ypbnv commented Sep 13, 2017

JIRA: https://jira.appcelerator.org/browse/TIMOB-17821

Description:
Expose setCustomView method for ActionBar.
We can add support in Alloy for that, but it would require some changes there as well.

Test cases:

With default action bar.

var window = Ti.UI.createWindow({title: 'Title', backgroundColor: 'gray'});
var customView = Ti.UI.createView({layout: 'horizontal'});
var button1 = Ti.UI.createButton({title: 'Button1'});
var button2 = Ti.UI.createButton({title: 'Button2'});
var picker = Ti.UI.createPicker({});
var slider = Ti.UI.createSlider({width: '30%', backgroundColor: 'teal'});
var data = [];

data[0]=Ti.UI.createPickerRow({title:'Row 1'});
data[1]=Ti.UI.createPickerRow({title:'Row 2'});
data[2]=Ti.UI.createPickerRow({title:'Row 3'});
picker.add(data);

customView.add(button1);
customView.add(slider);
customView.add(picker);

button2.addEventListener('click', function(){
    window.activity.actionBar.customView = customView;
});

window.add(button2);
window.open();

With Toolbar used as ActionBar.
Note that you need to use a theme with disabled ActionBar (eg. Theme.Titanium)

var window = Ti.UI.createWindow({title: 'Title', backgroundColor: 'gray'});
var customView = Ti.UI.createView({layout: 'horizontal'});
var button1 = Ti.UI.createButton({title: 'Button1'});
var button2 = Ti.UI.createButton({title: 'Button2'});
var picker = Ti.UI.createPicker({});
var slider = Ti.UI.createSlider({width: '30%', backgroundColor: 'teal'});
var toolbar = Ti.UI.createToolbar({top:0, barColor: '#222222', width: Ti.UI.FILL});
var data = [];

data[0]=Ti.UI.createPickerRow({title:'Row 1'});
data[1]=Ti.UI.createPickerRow({title:'Row 2'});
data[2]=Ti.UI.createPickerRow({title:'Row 3'});
picker.add(data);

customView.add(button1);
customView.add(slider);
customView.add(picker);

window.activity.supportToolbar = toolbar;

button2.addEventListener('click', function(){
    window.activity.actionBar.customView = customView;
});

window.add(toolbar);
window.add(button2);
window.open();

Preview:
example

@ypbnv ypbnv added this to the 7.0.0 milestone Sep 13, 2017
@sgtcoolguy sgtcoolguy modified the milestones: 7.0.0, 7.1.0 Nov 30, 2017
@build
Copy link
Contributor

build commented Feb 22, 2018

Messages
📖

💾 Here's the generated SDK zipfile.

Generated by 🚫 dangerJS

@lokeshchdhry
Copy link
Contributor

FR Passed.

customView for actionBar works as expected in both the cases.

Studio Ver: 5.0.0.201712081732
SDK Ver: 7.2.0 local build
OS Ver: 10.13.2
Xcode Ver: Xcode 9.2
Appc NPM: 4.2.12
Appc CLI: 7.0.2
Daemon Ver: 1.0.1
Ti CLI Ver: 5.0.14
Alloy Ver: 1.11.0
Node Ver: 8.9.1
NPM Ver: 5.5.1
Java Ver: 1.8.0_101
Devices: ⇨ google Nexus 5 --- Android 6.0.1
⇨ google Nexus 6P --- Android 8.0.0
Emulator: Android 4.2.2

@lokeshchdhry lokeshchdhry merged commit 7df6a0b into tidev:master Feb 26, 2018
@sgtcoolguy sgtcoolguy modified the milestones: 7.2.0, 7.3.0 May 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants