Code Monkey home page Code Monkey logo

viewpager's Introduction

Google Play View Pager And Tabs Module

##Copyright This module is base on the android module from Astuetz with some changes
Thanks astuetz for greate solution.

Description

Note: Unfortunately I have no time to support this plugin. Please fork me and help to the others if you can. Thank you.

This module is like Google Play tabs and ViewPager whit:

  • Support RTL ( Right To Left )
  • Customizing color of ( Indicator, Underline, Text, Tabs Background, Separator )
  • Add or Remove tabs in runtime
  • Changed all color in runtime
  • Using custom font and style ( Appcelerator font object )
  • Set current tab ( only creation time yet )
  • show tabs in two style ( Scrolling, Adjust with screen width )
  • set padding
  • 4 events supported ( Touch, Page Scrolled, Page Selected, Page Scroll State Changed )
  • Supported all UI element that it extends of View object except Ti.UI.Window ( ex. TextField, Button, View, Scroll View, etc. )
  • Set Tab height
  • supported android theme resource like Holo theme for all colors

###if you like the module please donate. ###
BitCoint Address:
1NLwq7hGahzHHnsAAD6P7kZ9RSKk4ReBCH

Accessing the tabs Module

To access this module from JavaScript, you would do the following:

var module = require("com.navid.tabs");
var tabs = module.createPagerTabs();

The module variable is a reference to the Module object. The tabs variable is a instance of viewpager.

Alloy

For Alloy there's a widget to wrap this module.

Reference

This module use https://github.com/astuetz/PagerSlidingTabStrip with some changes

Fork repository is here: https://github.com/dreamlearn/PagerSlidingTabStrip

module.createPagerTabs

var win = Ti.UI.createWindow();
win.open();
var module = require('com.navid.tabs');
var tabs = module.createPagerTabs();
win.add(tabs);

module.property

  • tab ( Object)
    • color ( Text color )
    • colorResource ( Android resource string, ex. "holo_blue_dark" )
    • indicatorColor
    • indicatorResource
    • underlineColor
    • underlineResource
    • dividerColor
    • dividerResource
    • backgroundColor
    • backgroundResource
    • indicatorHeight
    • underlineHeight
    • dividerPadding
    • upperCase ( if set true all tabs title will show capital case, default is false )
    • shouldExpand ( if set true the width tabs adjusted with screen width, if set false the tab enabled scrolling. default is false )
    • padding ( only right padding and left padding )
    • alignment ( module.ALIGNMENT_RIGHT or module.ALIGNMENT_LEFT, default is module.ALIGNMENT_LEFT )
    • font ( same as Appcelerator font object )
  • views
    • array
      • [0]
        • title ( Title of tab )
        • view ( Object of Appcelerator view ( Button, Label, View, ImageView and etc... except Window )
  • current ( set current tab in first time, if alignment set with ALIGNMENT_RIGHT detects itself and select tab from right to left, ex. the 1 index is first tab in right )

The priority of color and color resource is with Color, if color not set use its resource if it set ex.

{
   color: "red",
  colorResource: "holo_blue_light"
}

text will be red and colorResource will be ignored }

Usage

var win = Ti.UI.createWindow();
win.open();

var tabs = require('com.navid.tabs');

var text = Ti.UI.createTableView({
	title: "NAVID",
    backgroundColor: "white",
	data: [
    	{title: "1"},
        {title: "2"},
	    {title: "3"},
    	{title: "4"},
        {title: "5"}
	]
});

var text2 = Ti.UI.createTableView({
	title: "NAVID",
    backgroundColor: "white",
    data: [
	    {title: "1"},
    	{title: "2"},
        {title: "3"},
	    {title: "4"},
    	{title: "5"},
        {title: "6"}
	]
});

var text3 = Ti.UI.createTableView({
    title: "NAVID",
    backgroundColor: "white",
    data: [
        {title: "1"},
        {title: "2"}
    ]
});

var tabs = tabs.createPagerTabs({
    current: 4,
    tab: {
        indicatorResource: "holo_blue_light",
        colorResource: "holo_blue_light",
        backgroundColor: "white",
        alignment: tabs.ALIGNMENT_RIGHT
    },
    views: [
        {
            title: "Test1",
            view: text
        },
        {
            title: "Test2",
            view: text2
        },
        {
            title: "Test3",
            view: text3
        }
    ]
});

tabs.add("Dynamic Tab", Ti.UI.createLabel({text:"Label 1"}));
tabs.add("Dynamic Tab 2", Ti.UI.createLabel({text:"Position 2"}));

tabs.addEventListener('pageScrolled', function (evt) {
    console.log('Page Scrolled');
});

tabs.addEventListener('pageSelected', function (evt) {
    console.log('Page Selected');
});

tabs.addEventListener('pageScrollStateChanged', function (evt) {
    console.log('Page Scroll Changed');
});

tabs.addEventListener('click', function (evt) {
    console.log('Click');
});
tabs.addEventListener('longClick', function (evt) {
    console.log('Long click');
});
tabs.addEventListener('touch', function (evt) {
    console.log('Touch');
});
tabs.addEventListener('focusChange', function (evt) {
    console.log('Focus Change');
});

win.add(tabs);

Author

Full Name: Navid Ghahremani

Email: [email protected]

Please fill free to contact and share your idea with me ( Add new feature, fixing bug, get some help and etc... )

License

It's open source and it's under Apache licenses

viewpager's People

Contributors

fokkezb avatar ghahramani avatar manumaticx avatar ricardoalcocer avatar timanrebel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

viewpager's Issues

Crash on 2.3.7

[ERROR] : �� �AndroidRuntime: Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1
[ERROR] : �� �AndroidRuntime:   at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463)
[ERROR] : �� �AndroidRuntime:   at com.astuetz.viewpager.extensions.PagerSlidingTabStrip.<init>(PagerSlidingTabStrip.java:162)
[ERROR] : �� �AndroidRuntime:   at com.astuetz.viewpager.extensions.PagerSlidingTabStrip.<init>(PagerSlidingTabStrip.java:115)
[ERROR] : �� �AndroidRuntime:   at com.astuetz.viewpager.extensions.PagerSlidingTabStrip.<init>(PagerSlidingTabStrip.java:111)
[ERROR] : �� �AndroidRuntime:   at com.navid.tabs.PagerTabsView.<init>(PagerTabsView.java:55)
[ERROR] : �� �AndroidRuntime:   at com.navid.tabs.PagerTabsView.<init>(PagerTabsView.java:86)
[ERROR] : �� �AndroidRuntime:   at com.navid.tabs.PagerTabsProxy.createView(PagerTabsProxy.java:40)

Test app from you version of PagerSlidingTabStrip work fine but not ti module.

Can't install using gittio

Hi,
When I try to install the module with gittio i get this error:
$ gittio install com.navid.tabs
[INFO] com.navid.tabs searching...
[ERROR] com.navid.tabs:android no distributable available
[ERROR] com.navid.tabs:mobileweb no distributable available

any idea?
Thanks.

dividerPadding and textAllCaps

I'm getting a packaging error when trying to compile an app using Titanium 3.3.0.RC.

[ERROR] Failed to package application:
[ERROR]
[ERROR] /Users/ralcocer/Dropbox/Work/Manning/2014/code/ch4/TiConference/build/android/res/values/attrs.xml:9: error: Attribute "dividerPadding" has already been defined
[ERROR] /Users/ralcocer/Dropbox/Work/Manning/2014/code/ch4/TiConference/build/android/res/values/attrs.xml:14: error: Attribute "textAllCaps" has already been defined

Any ideas?

No resource found that matches the given name 'android:Theme.Holo.Light'.

I imported github code to Ti studio and build the module, when run the app with this module, I am getting below error

[DEBUG] /Users/admin/Documents/android-sdk-macosx/platform-tools/aapt package -m -J /Users/admin/Documents/Test_workspace/testApp/build/android/gen -M /Users/admin/Documents/Test_workspace/testApp/build/android
/AndroidManifest.xml -S /Users/admin/Documents/Test_workspace/testApp/build
/android/res -I /Users/admin/Documents/android-sdk-macosx/platforms/android-10/android.jar
[ERROR] Error generating R.java from manifest
[ERROR] /Users/admin/Documents/Test_workspace/testApp/build/android/res/values-v11/styles.xml:2: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light'.
[ERROR] /Users/admin/Documents/Test_workspace/testApp/build/android/res/values-v14/styles.xml:2: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light.DarkActionBar'.
[ERROR] : �� �Build process exited with code 1
[ERROR] : �� �Project failed to build after 3s 248ms

tabStrip not ajusting its size correctly

If the ViewPager module is added to a tabgroup in a page that is not the first, when you go to the tab page containing the viewPager, the tabStrip has all the pages pushed to the left. It seems like at the time the module was adjusting its children, the screen dimensions where not available, maybe line 52 of PagerTabsView.java. I've tried using the pageScrolled event, which fires as soon as you arrive to the viewPager to reassign the shouldExpand property, but it seems like those properties can only be added in the constructor and not at runtime. Changing orientation seems to trigger some sort of repaint event that properly sets the tabStrip the way it should.

Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.