How to change an action bar title text when moving from one tab to another tabs in nativescript - angular2-routing

When loading this mainactivity page for the first time, it is loading
the third tab page action bar text.
I need to load the action bar text based on clicking the tab.
For Eg: When I click the second tab means second tab action bar have
to get trigger.
main.activity.html:
<ActionBar title="MainActivity" class="action-bar">
</ActionBar>
<TabView selectedIndex="0" (selectedIndexChange)="onIndexChanged($event)" iosIconRenderingMode="alwaysTemplate" selectedTabTextColor="blue" sdkExampleTitle sdkToggleNavButton>
<TabView iosIconRenderingMode="alwaysOriginal"></TabView>
<StackLayout *tabItem="{title: 'First Tab',iconSource:'res://store'}" >
<first-page></first-page>
</StackLayout>
<StackLayout *tabItem="{title: 'Second Tab',iconSource:'res://myapps'}" >
<second-page></second-page>
</StackLayout>
<StackLayout *tabItem="{title: 'Third Tab',iconSource:'res://home'}" >
<third-page></third-page>
</StackLayout>
</TabView>
main.activity.ts:
public onIndexChanged(args) {
let tabView = <TabView>args.object;
console.log("Selected index changed! New inxed: " + tabView.selectedIndex);
}

For every tab position, we need to add the tabindex and add the title for appropriate page.
<ActionBar *ngIf="tabIndex == 1" title="My Apps" color="black"> </ActionBar>

Related

What to use when i need a box with a border and some different text with different fonts and sizee

Hi i have spend some days searching for the answer how to solve this
This is what i want, just made a image how it should look like
What is the best solution to use to solve this?
I tryed to do this with a Frame but it just allowed be to use 1 content .
Can i use more then one content in some way
( Content can just have one setup of fontcolor and fontsize and so on. )
I just get to this part
Here i try to put a label with margin with - so it go above.
But this is really bad to to. because i need to have the implementation under the frams. like this.
_stack.Children.Add(frame);
_stack.Children.Add(bordertext);
and when i fill the frame with content the lable apear in another position because how it relate to the margin when the Frame get higher.
But if i put the lable implementation above the Frame then it appear in the background of the frame
_stack.Children.Add(bordertext);
_stack.Children.Add(frame);
And the label get weard with the shadow that i cant figure out how to get rid of.
C#
Frame frame = new Frame
{
BorderColor = Color.Brown,
CornerRadius = 10,
HasShadow = false,
Margin = 10,
BackgroundColor = Color.White,
};
Label bordertext = new Label( );
bordertext.Text = "BorderText";
bordertext.Margin = new Thickness(40, -65,0 , 0);
bordertext.BackgroundColor = Color.White;
_stack.Children.Add(frame);
_stack.Children.Add(bordertext);
PART OF THE SOLUTION
#Jason 's solution to put
the Content in a Stacklayout and then put it in a Frame Solves the problem with having more then one text with different font,sizes and stuff.
But i put a text outside the Stacklayout so i can have the Text on the border. But because i put the Bordertext first and then the Frame. Then the Border text gets in the background.
If i put it after the Frame then i gets in the front. But then i have a big problem with dynamic text that the BorderText will appear very strange depending on how much text.
How i cant put the BorderText in front even if i implement in before so i cant move it down a little bit.
_stack.Children.Add(new Label { Text = "Bordertext", Margin = new Thickness(0, 0, 0, -25) });
_stack.Children.Add(_frame);
To compose a layout, first determine what boxes (rectangles) you need inside other boxes. Each "box" is some container (layout) type.
I see one box "A", the size of the parent-container, containing the border lines "B", overlaid by a box "C" that blocks part of one line, and contains a text "D".
I see a second box "E", inset slightly from the parent-container, which contains additional content "F".
To overlay multiple items, use a one-cell Grid, with children at (row,column) of 0,0 - which can be omitted because is default:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="FormsApp1.MainPage">
<Grid BackgroundColor="Violet">
<!-- Border lines formed by one box visually "inside" another, via margins.
Instead use "Rectangle" if need rounded corners. -->
<BoxView BackgroundColor="Red" Margin="10"/>
<BoxView BackgroundColor="LightCoral" Margin="16"/>
<!-- Text "box" given size by putting inside a StackLayout. -->
<!-- Some of these dimensions may not be needed. -->
<StackLayout WidthRequest="300" HeightRequest="30">
<Label Text="Header Text" TextColor="Black" BackgroundColor="White" FontSize="18"
HorizontalOptions="Start"
WidthRequest="150" HeightRequest="30" Margin="20,0" Padding="20,0,0,0"/>
</StackLayout>
<!-- this contains your contents. -->
<StackLayout BackgroundColor="#2196F3" Padding="10" Margin="40">
<Label Text="Content line 1" HorizontalTextAlignment="Center" TextColor="White"/>
<Label Text="Content line 2" HorizontalTextAlignment="Center" TextColor="White"/>
</StackLayout>
</Grid>
</ContentPage>
"Positioning" is done via "Margin" and "Padding" properties.
I've used various colors, so you can see the parts of this layout. "ContentPage" wrapper might not be needed; use whatever your app expects as topmost container.
layout of group' frame' with header text:

Sub menu items appearing on bottom bar and not within the flyout

I am trying to add a sub menu under my flyout but its placing it on the bottom bar instead for some reason.
addonsflayout.Items.Add(new ShellContent {
Title = "Airliners",
Icon = "tab_about",
Content = new AboutPage()
});
addonsflayout.Items.Add(new ShellContent {
Title = "Piston Planes",
Icon = "tab_about",
Content = new AboutPage()
});
addonsflayout.Items.Add(new ShellContent {
Title = "Turbo Props",
Icon = "tab_about",
Content = new AboutPage()
});
My Main shell flyouts are describe as such
<FlyoutItem Title="Addons" x:Name="addonsflayout" Icon="icon_about.png">
<ShellContent Route="AddonsPage" ContentTemplate="{DataTemplate local:AddonsPage}" />
</FlyoutItem>
<!-- When the Flyout is visible this will be a menu item you can tie a click behavior to -->
<MenuItem Text="Logout" StyleClass="MenuItemLayoutStyle" Clicked="OnMenuItemClicked">
</MenuItem>
But its placing them in the bottom bar so it is.
When I want them here
How does one tell it to show for the side menu and not the bottom bar I am using xamrain forms
Edit 2
While adding FlyoutDisplayOptions="AsMultipleItems" does get it to appear its also adding it to the bottom bar and without indentition in the side menu
<FlyoutItem Title="Addons" FlyoutDisplayOptions="AsMultipleItems" x:Name="addonsflayout" Icon="icon_about.png">
<ShellContent Route="AddonsPage" ContentTemplate="{DataTemplate local:AddonsPage}" />
</FlyoutItem>
Piston planes should be further in. Also doing this has removed my main menu item addons.

GroupShortNameBinding adds a bullet point - how to remove

I have enabled Grouping on a list in iOS and added an Alphabet index to each entry
However, even though it displays the letters correctly, it's showing me a bullet point delimeter between each one?
I want to get rid of these, can anyone advise how please?
<ListView ItemsSource="{Binding allGames}" IsGroupingEnabled="True" GroupShortNameBinding="{Binding LETTER}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Label TextColor="Black" Text="{Binding GAME_NAME}"/>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Code for adding the index key (alphabet) to the list
if (allGames == null)
{
allGames = new ObservableCollection<GAME_TBL>();
}
var services = new DataModels();
GAME_SELECTION _select = new GAME_SELECTION();
allGames = await services.Games(1, _select);
foreach (GAME_TBL _indexTable in allGames)
{
_indexTable.LETTER = _indexTable.GAME_NAME.Substring(0, 1);
}
You can't remote the so-called "bullet points" - that is by design. The official term for that part is called Jump list.
What is happening behind the scenes is that you have too many grouped items. In this case, sometimes the phone's height can't fit all of them, so it is hiding some of the items behind the dots.
You can customize the list - change its color, etc, but the bullets can't be removed. However, what you can do is to reduce the count of your items, because I see some that are repeating - you have 3xS & 2xT, etc. If that is by design, then leave it like so. If not, try to better group the items.

Issues changing the background colour of the currently selected item in a ListView - Nativescript/Angular2

I am busy with a Nativescript/Angular2 app where I display a list of active stock takes in a ListView. I am trying to change the background color lf the current selected stock take item in the ListView to show the currently selected StockTake. I add the css class to the StackLayout inside the ng-template but for some reason the css isn't applied when I tap on a item. Any idea what could be going wrong here/how I can fix this? I don't get any errors so i'm completely lost as to what the issue might be here...
my ListView xml code:
<ListView [items]="activeStockTakes" class="list-group">
<ng-template let-activeStockTake="item" let-i="index">
<StackLayout [class.highlight]="item.isSelected" (tap)="selectActiveStockTake(item, index)">
<Label class="list-group-item" [text]="activeStockTake.UserCode + ' - ' + activeStockTake.Comment"></Label>
</StackLayout>
</ng-template>
</ListView>
my css code:
.highlight {
background-color: red !important;
border-radius: 3;
}
my selectActiveStockTake event:
selectActiveStockTake(item, index) {
//console.log(args.index);
this.selectedActiveStockTake = this.activeStockTakes[index];
this.selectedActiveStockTake.isSelected = true;
console.log(this.selectedActiveStockTake.UserCode);
}
Try
<ListView [items]="activeStockTakes" class="list-group">
<ng-template let-activeStockTake="item" let-i="index">
<StackLayout [class.highlight]="item.isSelected" (tap)="selectActiveStockTake(item, i)">
<Label class="list-group-item" [text]="activeStockTake.UserCode + ' - ' + activeStockTake.Comment"></Label>
</StackLayout>
</ng-template>
</ListView>
and then:
selectActiveStockTake(item, i) {
item.isSelected = !item.isSelected;
}
This is a much cleaner solution and should work perfectly.

How to display button over a map / MapLayer in windows phone 8?

I'm new in Windows phone 8 development and I have problem to add button on MapLayer.
I'd like to display a button over a map so I just draw it on the map widget like this:
<Grid x:Name="MyMapGrid" Margin="10,-15,15,0" VerticalAlignment="Top" Height="296" >
<maps:Map x:Name="MyMapi" Center="31.765537,35.106812" ZoomLevel="7" Margin="0,0,0,0" VerticalAlignment="Top" Height="296" Width="442" />
<Button x:Name="myCustomButton" Visibility="Visible" Content="" HorizontalAlignment="Left" Margin="347,0,0,0" VerticalAlignment="Top" Width="84" Height="84" BorderThickness="0">
<Button.Background>
<ImageBrush ImageSource="/myZoom.png"/>
</Button.Background>
</Button>
</Grid>
After this action I need to put some icons on the map so I used MapOverlay and MapLayer like this:
Map MyMap = new Map();
MapOverlay overlay = new MapOverlay
{
GeoCoordinate = MyMap.Center,
Content = new Image()
{
Source = new BitmapImage(new Uri("customIcon.png", UriKind.Relative)),
}
};
MapLayer layer = new MapLayer();
layer.Add(overlay);
MyMap.Layers.Add(layer);
MyMapGrid.Children.Add(MyMap);
I also need my button (myCustomButton) will stay visible - but it disappear.
how can I still have some button over the map and also view some icons on it?
Thank you all!
For button Change the path to definite like ImageSource="/Assets/Icon/location.png" with the folder name and make sure that BuildAction is set to content for that image
For icon also try the same.

Resources