I am relatively new to Xamarin and I am trying to achieve a screen something like this:
For the vertical listed items what I did, is I created individual StackLayouts for each item (so that in future if I need to add something to a specific item I can do it), that in themselves have Grids that further have the Icons and the Label.
Something like this (I cant use XAML and have to code it in):
ysiStackLayout layoutPropertyDashboardIem = new ysiStackLayout()
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.Center,
};
layoutDashboardItems.Children.Add(layoutPropertyDashboardIem);
Grid gridProperty = new Grid()
{
HorizontalOptions = LayoutOptions.Center,
RowDefinitions = {
new RowDefinition { Height = GridLength.Auto }
},
ColumnDefinitions =
{
new ColumnDefinition {Width = GridLength.Auto}
},
ColumnSpacing = 1
};
layoutPropertyDashboardIem.Children.Add(gridProperty);
ysiIcon iconProperty = new ysiIcon()
{
Icon = IconSet.fa_AngleDoubleLeft,
IconSize = 30
};
gridProperty.Children.Add(iconProperty, 0, 0);
ysiLabel labelProperty = new ysiLabel()
{
Text = "Property"
};
gridProperty.Children.Add(labelProperty, 1, 0);
`
This is giving me the necessary items correctly;
But I am unable to give the spacing between the two items, annoyingly so. I have tried properties like Spacing and Padding but I haven't been able to find the exact way.
Can someone please me direct an approach I can opt for?
It'd really be a lot of help!
First, I would suggest adding child items before adding the parents to the root layout if that makes sense.
So create your grid, add item to that grid, then add the grid to the parent StackLayout.
To add the spacing, I would try Spacing and/or Margin:
ysiStackLayout layoutPropertyDashboardIem = new ysiStackLayout() {
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.Center,
Spacing = 5 // Adding Spacing
};
Grid gridProperty = new Grid() {
HorizontalOptions = LayoutOptions.Center,
RowDefinitions = { new RowDefinition { Height = GridLength.Auto } },
ColumnDefinitions = { new ColumnDefinition {Width = GridLength.Auto} },
ColumnSpacing = 1,
Margin = new Thickness(5) // Adding Margin
};
ysiIcon iconProperty = new ysiIcon() {
Icon = IconSet.fa_AngleDoubleLeft,
IconSize = 30
};
gridProperty.Children.Add(iconProperty, 0, 0);
ysiLabel labelProperty = new ysiLabel { Text = "Property" };
gridProperty.Children.Add(labelProperty, 1, 0);
layoutPropertyDashboardIem.Children.Add(gridProperty); // Add children in reverse order up the layout tree
layoutDashboardItems.Children.Add(layoutPropertyDashboardIem); // Add children in reverse order up the layout tree
Related
I'm trying to place a sketch on a building on the map with Leaflet. I succeeded in this as well, I can place and scale an image in svg format on the map. But when I add a new sketch to the map, I want the old sketch to be deleted from the map.
map.removeLayer(sketchLayer)
sketchLayer.removeFrom(map)
map.removeLayer(L.sketchLayer)
i tried these
My codes,
splitCoordinate (value) {
const topLeftCoordinates = value.top_left.split(',')
const topRightCoordinates = value.top_right.split(',')
const bottomLeftCoordinates = value.bottom_left.split(',')
this.initMap(topLeftCoordinates, topRightCoordinates, bottomLeftCoordinates)
},
initMap (topLeftCoordinates, topRightCoordinates, bottomLeftCoordinates) {
let map = this.$refs.map.mapObject
map.flyTo(new L.LatLng(topLeftCoordinates[0], topLeftCoordinates[1]), 20, { animation: true })
const vm = this
var topleft = L.latLng(topLeftCoordinates[0], topLeftCoordinates[1])
var topright = L.latLng(topRightCoordinates[0], topRightCoordinates[1])
var bottomleft = L.latLng(bottomLeftCoordinates[0], bottomLeftCoordinates[1])
var sketchLayer = L.imageOverlay.rotated(vm.imgUrl, topleft, topright, bottomleft, {
opacity: 1,
interactive: true
})
map.addLayer(sketchLayer)
}
Fix:
The error was related to the javascript scope. I defined the sketchLayer in the data and my problem solved.
var stage, output;
function init() {
stage = new createjs.Stage("testCanvas");
// this lets our drag continue to track the mouse even when it leaves the canvas:
// play with commenting this out to see the difference.
stage.mouseMoveOutside = true;
var circle = new createjs.Shape();
circle.graphics.beginFill("red").drawRoundRect(0, 0, 100,20,10);
//console.log(circle.graphics.command.radius);
var label = new createjs.Text("drag me", "bold 14px Arial", "#FFFFFF");
label.textAlign = "center";
label.y = -7;
var dragger = new createjs.Container();
dragger.x = 50;
dragger.y = 10;
dragger.addChild(circle, label);
stage.addChild(dragger);
dragger.on("pressmove",function(evt) {
// currentTarget will be the container that the event listener was added to:
//evt.currentTarget.x = evt.stageX;
//evt.currentTarget.y = evt.stageY;
// make sure to redraw the stage to show the change:
//console.log(evt.currentTarget.children[0].graphics.command);
var newWidth= evt.stageX - evt.currentTarget.x;
console.log(evt.currentTarget.children[0].graphics);
if(newWidth<0)
newWidth = 0;
evt.currentTarget.children[0].graphics.command.w= newWidth;
evt.currentTarget.children[1].x= newWidth/2;
stage.update();
});
stage.update();
}
this code is working fine under http://www.createjs.com/demos
(i can reach this evt.currentTarget.children[0].graphics.command.w, because evt.currentTarget.children[0] returns shape)
but not on your own html. it is there any js i need to add in the heading?
Did you checked if "pressmove" trigger?
Maybe you should use this stage.enableMouseOver(20); to enable mouse events.
I have a page setup that requires multiple instances of Google Maps via the API to be initialized. All works fine when one map is initialized the first time. When you re click on the button to do so, the map does not fully show.
var locations = [
['test1', 45.440188, -75.676309, 1, 'transportation.png'],
['test2', 45.439463, -75.675751, 1, 'medical.png'],
['test3', 45.439792, -75.683544, 1, 'schools.png'],
['test4', 45.439652, -75.676929, 1, 'shopping.png']
];
function initialize_1() {
var mapOptions = {
center: new google.maps.LatLng(45.438612, -75.677561),
zoom: 16,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas_1"), mapOptions);
marker = new google.maps.Marker({
position: new google.maps.LatLng(45.438612, -75.677561),
map: map
});
var marker, i;
var iconBase = 'http://www.elkproperty.com/new/images/icons/';
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map
,icon: iconBase + locations[i][4]
});
}
}
I think the issue is that you are initialising map to a hidden layer. Try to move call to initialize_1() after show():
onclick="$('#units_1').hide(); $('#unitArrow_1').hide(); $('#amenity_1').show(); $('#amenityArrow_1').show(); initialize_1();"
Other option is to force resize event after divs are visible. For this to work you would probably have to make map variable global.
google.maps.event.trigger(map, 'resize');
Maybe unrelated to your question but do you have to initialise the map layer each time you show div with map? Maybe you could test whether it is initialised or not, for example:
var isInit_1 = false;
function initialize_1() {
if (isInit_1) { return; }
isInit_1 = true;
var mapOptions = {
...
I am able to implement auto suggest drop down in jquery .Now I am implementing a same functionality in titanium but when i googled I don't found much in autosuggestion
drop down in titanium .
can you suggest a way of autogestion.
Mean I have a array (element).When I click on textfield it show related element.
Try the following code and modify as per your need. Here I Used array(searchArray) as data storage(You can replace it with database field or source whatever as per your requirement).
//Table view showing your autocomplete values
var tblvAutoComplete = Ti.UI.createTableView({
width : '100%',
backgroundColor : '#EFEFEF',
height : 0,
maxRowHeight : 35,
minRowHeight : 35,
allowSelection : true
});
//Starts auto complete
txtAutoComplete.addEventListener('change', function(e){
var pattern = e.source.value;
var tempArray = PatternMatch(searchArray, pattern);
CreateAutoCompleteList(tempArray);
});
//You got the required value and you clicks the word
tblvAutoComplete.addEventListener('click', function(e){
txtAutoComplete.value = e.rowData.result;
});
//Returns the array which contains a match with the pattern
function PatternMatch(arrayToSearch, pattern){
var searchLen = pattern.length;
arrayToSearch.sort();
var tempArray = [];
for(var index = 0, len = arrayToSearch.length; index< len; index++){
if(arrayToSearch[index].substring(0,searchLen).toUpperCase() === pattern.toUpperCase()){
tempArray.push(arrayToSearch[index]);
}
}
return tempArray;
}
//setting the tableview values
function CreateAutoCompleteList(searchResults){
var tableData = [];
for(var index=0, len = searchResults.length; index < len; index++){
var lblSearchResult = Ti.UI.createLabel({
top : 2,
width : '40%',
height : 34,
left : '5%',
font : { fontSize : 14 },
color : '#000000',
text : searchResults[index]
});
//Creating the table view row
var row = Ti.UI.createTableViewRow({
backgroundColor : 'transparent',
focusable : true,
height : 50,
result : searchResults[index]
});
row.add(lblSearchResult);
tableData.push(row);
}
tblvAutoComplete.setData(tableData);
tblvAutoComplete.height = tableData.length * 35;
}
This code worked for me in both ios and android. Hope your problems get resolved:D
I have a view that is set to show when a button is clicked.
This works but only if the button has been clicked once already.
So it works but not as it should eg. the first time the button is clicked.
I add the view to tableView as soon as it is created later in the code BTW.
here is some code to look at...
var vLabel = Ti.UI.createView({
backgroundColor : 'white',
width : '100%',
height : 46,
bottom : 25
});
var topBorderView = Ti.UI.createView({
backgroundColor : '#d8d8d8',
width : '100%',
height : 1,
top : 0
});
var aLabel = Ti.UI.createLabel({
backgroundColor : 'white',
objName : 'aLabel',
text : "All Points - Takes a few moments to load.",
font : {
fontSize : 12
},
color : '#df0101',
backgroundPaddingTop : 5,
backgroundPaddingBottom : 3,
left : '5%',
width : '90%',
height : 42,
top : 2,
zIndex : 6000,
textAlign : Ti.UI.TEXT_ALIGNMENT_CENTER
});
vLabel.add(topBorderView);
vLabel.add(aLabel);
sortButton.addEventListener('click', function(e) {
vLabel.visible = 1;
vLabel.show();
var loaders = getLoader();
tableView.add(loaders);
loaders.start();
var tempRows = [];
if (content.uid == 998) {
if (e.index == 0) {
tempRows = sortAllPoints(content, e.index);
loaders.stop();
vLabel.visible = false;
tableView.remove(loaders);
tableView.setData(tempRows, {
animationStyle : Titanium.UI.iPhone.RowAnimationStyle.NONE
});
rowMainData = tableView.data;
SearchBar.value = '';
} else {
tempRows = sortAllPoints(content, e.index);
loaders.stop();
vLabel.visible = false;
tableView.remove(loaders);
tableView.setData(tempRows, {
animationStyle : Titanium.UI.iPhone.RowAnimationStyle.NONE
});
rowMainData = tableView.data;
SearchBar.value = '';
}
}
});
Anyone have any clue as to why the view is showing on the 2nd button click but not the first??
Everything else works as it should eg. the loader animation
Thanks a lot,
George.
Lateral Thinking! That's what you need. I had set the position of the view to be relative the bottom of the tableView. This worked while there was nothing in the table eg. it was loading or sorting the content. The answer was to make it's position relative to the top therefore no matter whether the content was being loaded or being sorted it is always visible. Sleep is good for this sort of thing!
use setVisible method:
someView.setVisible = true