Increase Navigation bar height for ipad - titanium

Trying to increase navigation bar for iPad
navgroup.height = 80;
Can any on suggest me for increasing the navigation bar for iPad.

Well, the Apple's iOS Human Interface Guidelines states "Don’t specify the height of a navigation bar programmatically,".
So you can't, this is hardcoded to be 44dip on the iPad.
However, you could just make your own navbar view, with your own custom gradient, just float it to the top of your window, this is a start, with a background gradient and custom height of 50px:
var win = Ti.UI.createWindow({
navBarHidden : true
});
var navBar = Ti.UI.createView({
top : 0,
width : Ti.UI.FILL,
height : 50, // Your custom navbar height
backgroundGradient : { // Nice linear gradient, put your own custom colors here
type : 'linear',
startPoint : {
x : 0,
y : 0
},
endPoint : {
x : 0,
y : '100%'
},
colors : [{
color : '#75060a',
offset : 0.0
}, {
color : '#cc0000',
offset : 1.0
}]
}
});
// I usually add a bottom border view, just looks better IMO
navbar.add(Ti.UI.createView({
width : Ti.UI.FILL,
height : 1,
bottom : 0,
backgroundColor : '#000000'
}))
win.add(navBar);
You may want to add custom buttons and titles to this to make it more functional but this should get you started. The nice part about this approach is you have the most control, and its completely cross platform (works on android quite nicely).

Related

Capture the area within a square box using camera in react native

I want to show a square box on my camera screen and I want to capture the area within that square box how I can achieve that?
It will not scan any bar code or QR code it will simply capture the area within a square box and skip all the rest.
this is the image of the view
You can not achieve directly. Follow the step as :
Snap : this.camera.takePictureAsync({ fixOrientation: true, mirrorImage: true })
Crop with ImageEditor by setting cropData as
const { uri, width, height } = capturedImg;
{
offset: { x: 0, y: 0 },
size: { imagewidth, height }, displaySize: { width: cameraSize.width, height: cameraSize.height }
}
Now crop your camera size photo with box origin and size

Only use slicebox cuboid option

Does anyone know how I can ensure only the cuboid animation is used on my slider? I don't particularly love the slicing action but do like the rotating cube options both left to right and top to bottom. I have checked the docs but can only see how to change orientation of the slicing animation or set to random.
The JS settings referred to in the docs are here:
JS
$.Slicebox.defaults = {
// (v)ertical, (h)orizontal or (r)andom
orientation : 'h',
// perspective value
perspective : 1200,
// number of slices / cuboids
// needs to be an odd number 15 => number > 0 (if you want the limit higher, change the _validate function).
cuboidsCount : 5,
// if true then the number of slices / cuboids is going to be random (cuboidsCount is overwitten)
cuboidsRandom : false,
// the range of possible number of cuboids if cuboidsRandom is true
// it is strongly recommended that you do not set a very large number :)
maxCuboidsCount : 5,
// each cuboid will move x pixels left / top (depending on orientation). The middle cuboid doesn't move. the middle cuboid's neighbors will move disperseFactor pixels
disperseFactor : 0,
// color of the hidden sides
colorHiddenSides : '#222',
// the animation will start from left to right. The left most cuboid will be the first one to rotate
// this is the interval between each rotation in ms
sequentialFactor : 150,
// animation speed
// this is the speed that takes "1" cuboid to rotate
speed : 600,
// transition easing
easing : 'ease',
// if true the slicebox will start the animation automatically
autoplay : true,
// time (ms) between each rotation, if autoplay is true
interval: 3000,
// the fallback will just fade out / fade in the items
// this is the time fr the fade effect
fallbackFadeSpeed : 300,
// callbacks
onBeforeChange : function( position ) { return false; },
onAfterChange : function( position ) { return false; },
onReady : function() { return false; }
};
I haven't copied all the js code as there's lots!
You just need to change number of slices to 1
cuboidsCount : 1

Center buttons in a view horizontally

I have buttons I want to center horizontally in a view. There are three, and all I can seem to get is:
[button1-button2-button3------------------------------]
What I really want is
[--------button1--------button2--------button3--------]
These buttons are dynamic widths too. The amount of buttons will change, some views have 1, others have 2 or 3. Depending on an action, the number of buttons can change. I need this support both iOS and android.
Try splitting the screen into n different columns using percentage layout. Then add your buttons to their respective invisible container.
var n = // Your number of buttons horizontal
var container = Ti.UI.createView({width : "100%", layout: "horizontal" });
for(var i=0;i<n;i++) {
var column = Ti.UI.createView({
width : (100/n)+"%",
});
// Create your button here
// .....
// .....
// Now add it to the column
column.add(yourNthButton);
// Now add the column to the container
container.add(column);
}
How about wrapping your buttons in a view with layout set to 'horizontal'?
var wrapperView = Ti.UI.createView({
layout : 'horizontal',
...
});
// In a view with horizontal layout,
// the positioning is relative to the preceding element
var buttonOne = Ti.UI.createButton({
right : 10,
...
});
wrapperView.add(buttonOne);
Untested, but give it a try!
UPDATE
Ok, the above code alone won't do what you wanted. I wrote a more complete example here.
Seems a bit clumsy, so if someone has a better solution, please let us know!
// Create our window
var win = Ti.UI.createWindow();
// Our wrapper view
var wrapperView = Ti.UI.createView({
width : Ti.UI.FILL,
height : 40,
top : 0,
layout : 'horizontal',
});
// Add some test buttons to our wrapper
for(var i=0; i<3; i++) {
wrapperView.add(Ti.UI.createButton({
title : 'Test ' + i,
height : 30,
}));
}
// Add wrapperView to our window and open it
win.add(wrapperView);
win.open();
// Wait until "size" becomes available
win.addEventListener('postlayout', distributeButtons);
// Distribute buttons evenly
function distributeButtons() {
if(wrapperView.children) {
// Get the width of the wrapper view
var wrapperWidth = wrapperView.size.width;
var buttonWidths = 0;
var buttonSpacer;
var childrenLength = wrapperView.children.length;
// Get the button sizes
for(var i=0; i<childrenLength; i++) {
buttonWidths += wrapperView.children[i].size.width;
};
// Calculate the spaces between the buttons
buttonSpacer = (wrapperWidth - buttonWidths) / (childrenLength + 2);
// Set the buttons left value
for(var i=0; i<childrenLength; i++) {
wrapperView.children[i].left = buttonSpacer;
};
}
}
If you can put a toolbar, you can use the "flexspace" button, which will create a space necessary to fill the gap between other buttons. Here's the syntax from simple toolbar example in titanium docs:
var send = Titanium.UI.createButton({
title: 'Send',
style: Titanium.UI.iPhone.SystemButtonStyle.DONE,
});
var camera = Titanium.UI.createButton({
systemButton: Titanium.UI.iPhone.SystemButton.CAMERA,
});
var cancel = Titanium.UI.createButton({
systemButton: Titanium.UI.iPhone.SystemButton.CANCEL
});
flexSpace = Titanium.UI.createButton({
systemButton:Titanium.UI.iPhone.SystemButton.FLEXIBLE_SPACE
});
var toolbar = Titanium.UI.iOS.createToolbar({
items:[send, flexSpace, camera, flexSpace, cancel],
bottom:0,
borderTop:true,
borderBottom:false
});
win.add(toolbar)
try this
var yourView = Ti.UI.createView({ layout:"horizontal"});
var buttonsHolder = Ti.UI.createView({ width:"100%" });
// this view will hold the buttons
var button1 = Ti.UI.createButton({title:"button1 , left:0"}); // the left button
var button2 = Ti.UI.createButton({title:"button2"}); // the middle button
var button3 = Ti.UI.createButton({title:"button3",right:0}); // the right button
buttonsHolder(button1);
buttonsHolder(button2);
buttonsHolder(button3);
yourView.add(buttonsHolder);
Hieyy bro
If you are want achieve this using titanium alloy in xml. in that case you can use %.
Container ------------width 100%-----layout horizontal---------
first child--------left 10%------- width 20%
second child--------left 10%------- width 20%
third child--------left 10%------- width 20%-----right 10%
if you don't get your answer please let me know
Spartacus Thanks:)
If using Alloy, then I recommend using percentages to control width and position. Here's an example that centers three small images below a larger image, also centered:
<TableViewRow selectionStyle="Ti.UI.iPhone.TableViewCellSelectionStyle.NONE" backgroundColor="white" layout="vertical">
<ImageView id="detailsFeaturedImage" top="10"/>
<View height="60">
<View layout="horizontal">
<View left="25%" width="10%"><ImageView image="images/thumb-up-7#2x.png" onClick="thumb_up" /></View>
<View left="10%" width="10%"><ImageView image="images/thumb-down-7#2x.png" onClick="thumb_down"/></View>
<View left="10%" width="10%"><ImageView image="images/flag-7#2x.png" onClick="flag_for_review"/></View>
</View>
</View>
</TableViewRow>

Paging toolbar blinks with PDF viwer in sencha touch 2.2

I want to create a view for viewing a pdf from the server.I got this st2_pdf_panel after several minutes in google.I followed the demo and copy the pdf.js and PDF.js into my project.
1 But when the app runs,the paging toolbar will show first before loading the pdf file in the middle of the view and then it will dock to the bottom.
2 The pdf view does not scroll and the scale looks bad in the iphone screen,i can hardly see the words in the page.
3 How to zoom in or zoom out ?
4 Is there any substitue for this solution ?
Below is the code of the view :
Ext.define('Myapp.view.PDF',{
extend : 'Ext.Container',
requires : ['Ext.ux.panel.PDF'],
config : {
items : [
{
xtype : 'titlebar',
docked : 'top',
title : 'PDF',
items : [
{
text : 'back',
ui : 'back',
align : 'left',
listeners : {
tap : function(){
console.log('goback');
}
}
}
]
},//title bar
{
xtype : 'pdfpanel',
height : '100%',
src : 'http://cdn.mozilla.net/pdfjs/tracemonkey.pdf',
style : {
backgroundColor : '#333'
},
pageScale : 0.5,
pageText: 'page {0} of {1}',
}
]
}//config
});

Sencha Touch toolbar height

I dynamically create a bottom toolbar but it has its default height no matter the value I give to the height property. I tried the purcentage, pixels, simple numbers but nothing works.
myComponent.add({
xtype:'toolbar',
autoDestroy:true,
docked:'bottom',
bottom:0,
width:'100%',
height:'5px',
margin:'0 0 0 0',
padding:'0 0 0 0',
layout:{
pack:'middle',
align:'middle'
}
});
You must change the minHeight property.
A working Example from my Code:
Ext.define('MyApp.view.FailureBar', {
extend : 'Ext.Toolbar',
alias : 'widget.failureBar',
config : {
docked : 'bottom',
minHeight : '30px',
zIndex : 1,
cls : 'failureBar'
}
});