RadListView with tkGroupTemplate with inner content scroll horizontal - nativescript

Tell us about the problem
I am trying to horizontally set the content that is grouped with the function of but is not possible, because all content is horizontal.
Which platform(s) does your issue occur on?
Both
Please tell us how to recreate the issue in as much detail as possible.
<RadListView
[items]="dataItems"
#productsListView
[groupingFunction]="grouping"
>
<ng-template tkListItemTemplate let-item="item">
<StackLayout orientation="horizontal" width="100%">
<MDCardView width="100" height="100">
<Image stretch="aspectFill" [src]="item.image"></Image>
</MDCardView>
</StackLayout>
</ng-template>
<ng-template tkGroupTemplate let-category="category">
<GridLayout columns="*, auto" ios:height="50">
<Label
col="0"
style="font-weight: bold; font-size: 24"
[text]="category"
></Label>
<Label
col="1"
style="font-size: 12; color: gray;"
text="Ver más"
></Label>
</GridLayout>
</ng-template>
<ListViewGridLayout
tkListViewLayout
itemHeight="100"
scrollDirection="Horizontal"
></ListViewGridLayout>
</RadListView>

Try ScrollView within tkGroupTemplate
<ng-template tkGroupTemplate let-category="category">
<GridLayout>
<ScrollView orientation="horizontal" scrollBarIndicatorVisible="false">
<Label class="m-5 h2" [text]="category"></Label>
</ScrollView>
</GridLayout>
</ng-template>
Playground Sample

Related

Nativescript Ios Vertical align

Faced an unpleasant problem
help me please
When trying to align to the bottom of the page, the IOS unit does not completely go down
iosOverflowSafeArea did not help
<GridLayout columns="*,*" rows="*" row="1" col="0" class="project-type-content" width="100%" [iosOverflowSafeArea]="true">
<StackLayout width="100%" row="0" [col]="i" *ngFor="let item of projectTypes; let i=index" class="debug" verticalalignment="bottom" [iosOverflowSafeArea]="true">
<StackLayout width="75%" (tap)="onProjectTypeChoose(item.urlPrefix)" class="debug" [iosOverflowSafeArea]="true">
<GridLayout columns="*" rows="auto, auto" height="auto">
<StackLayout class="btn-type-choose" col="0" row="0">
<ns-rounded-button fontColor="#fff" borderColor="#fff" color="#fff" [text]="item.title" [bg]="item.bg"
width="100%"></ns-rounded-button>
</StackLayout>
<StackLayout width="100%" col="0" row="1" class="project-type-item">
<Label [text]="item.subTitle" width="100%" class="project-type-item-title monserrat regular"></Label>
<!--<Image [src]="item.image" stretch="aspectFill" class="project-type-item-image"></Image>-->
<HtmlView [html]="item.description" width="100%"></HtmlView>
<Image src="~/assets/images/firstScreenShadow.png" width="100%" horizontalAlignment="center"></Image>
<Label text="What`s New:" class="whats-new-title monserrat semi-bold"></Label>
<Label *ngIf="item.updateText && item.updateText[0]" [text]="item.updateText[0]" class="project-type-item-wats monserrat regular"></Label>
<Label *ngIf="item.updateText && item.updateText[1]" [text]="item.updateText[1]" class="project-type-item-wats monserrat regular"></Label>
<StackLayout width="100%" class="tap-to-choose" height="20">
<Button text="Tap to choose" class="tap-to-choose-btn" width="60%"></Button>
</StackLayout>
</StackLayout>
</GridLayout>
</StackLayout>
</StackLayout>
</GridLayout>
http://prntscr.com/mww4y3

In Nativescript how can I achieve a vertically aligned label text using StackLayout

I need something like this:
But this is what I have at the moment:
.rotate {
transform: rotate(-90deg);
font-size: 16px;
color: #FFFFFF;
}
This is my code:
<StackLayout backgroundColor="#3C414B" width="12%" height="100%" horizontalAlignment="center" verticalAlignment="center" (tap)="openDrawer('Right')">
<StackLayout class="rotate" orientation="horizontal">
<Label class="fa" style="margin-right: 10px" text=""></Label>
<Label width="100%" class="" text="New Category" textwrap="false"></Label>
</StackLayout>
</StackLayout>
You will have to set the height explicitly to the width of the element, transform doesn't take care of that by default.
Or you may even consider using an image, here is a related thread from Forums.
It looks like you rotate inner <StackLayout class="rotate" ...>, but it still get width limit of outer <StackLayout width="12%" ...>
Try so:
<StackLayout class="rotate" backgroundColor="#3C414B" width="100%" height="12%" horizontalAlignment="center" verticalAlignment="center">
<StackLayout orientation="horizontal">
<Label class="fa" style="margin-right: 10px" text=""></Label>
<Label text="New Category" textwrap="false" backgroundColor="yellow"></Label>
</StackLayout>
</StackLayout>
Or try to find solution with other layout type. For example, AbsoluteLayout

Nativescript inner StackLayout

Hello everyone I'm trying to make inner StackLayouts but the second one comes to top of first one so that I can't see the second StackLayout should I handle with css if it is how or is there an other way
Here is my code
<StackLayout orientation="horizontal">
<StackLayout width="500">
<GridLayout columns="50, *" rows="*" width="500" height="50"
verticalAlignment="top">
<Label text="Name" row="0" col="0" backgroundColor="red">
</Label>
<Label text="Fol" row="0" col="1" class="alignRight"
backgroundColor="blue"></Label>
</GridLayout>
</StackLayout>
<StackLayout orientation="horizontal" width="500" height="180">
<Image src="http://lorempixel.com/400/200" width="500" left="10"
top="30">
</Image>
</StackLayout>
</StackLayout>
Thank you
At first I would delete the widths to see how the page is displayed. 500 is a very big value. Only large tablets can support that.
As an example at first I would try this :
<GridLayout columns="auto, auto">
<GridLayout col="0" columns="50, *" rows="*" verticalAlignment="top">
<Label text="Name" row="0" col="0" backgroundColor="red">
</Label>
<Label text="Fol" row="0" col="1" class="alignRight"
backgroundColor="blue"></Label>
</GridLayout>
<Image col="1" src="http://lorempixel.com/400/200" left="10" op="30">
</Image>
</GridLayout>
After you see the two parts align horizontally you can start tweaking the widths

How can I make a StackLayout with ngFor loop into scrollable list?

<StackLayout width="100%" *ngFor="let item of (videos$ | async)">
<CardView class="studentCard" margin="2" elevation="10" radius="1">
<GridLayout rows="auto, auto, auto" columns="auto, auto, *">
<Image [src]="item.snippet.thumbnails.high.url" stretch="aspectFill" colSpan="3" row="0"></Image>
<Label [text]="item.snippet.channelTitle" textWrap="true" row="2" colSpan="1" ></Label>
<Label [text]="item.snippet.title" textWrap="true" row="2" col="1" colSpan="2" >></Label>
</GridLayout>
</CardView>
</StackLayout>
I tried to wrap it in ScrollView, didn't work.
I couldn't make (items$ | async) work with ListView either, seems ngFor can't work with ListView, we need ng-template for ListView.
I tried the following but only the first item is rendering
<ScrollView>
<ListView [items]="videos$ | async" class="list-group">
<ng-template let-item="item">
<GridLayout class="list-group-item">
<Image [src]="item.snippet.thumbnails.high.url"></Image>
<Label [text]="item.snippet.channelTitle" ></Label>
<Label [text]="item.snippet.title">></Label>
</GridLayout>
</ng-template>
</ListView>
</ScrollView>
Wraping the entire code first with StackLayout then with ScrollView worked
<ScrollView>
<StackLayout>
<StackLayout width="100%" *ngFor="let item of (videos$ | async)">
<CardView class="studentCard" margin="2" elevation="10" radius="1">
<GridLayout rows="auto, auto, auto" columns="auto, auto, *">
<Image [src]="item.snippet.thumbnails.high.url" stretch="aspectFill" colSpan="3" row="0"></Image>
<Label [text]="item.snippet.channelTitle" textWrap="true" row="2" colSpan="1" ></Label>
<Label [text]="item.snippet.title" textWrap="true" row="2" col="1" colSpan="2" >></Label>
</GridLayout>
</CardView>
</StackLayout>
</StackLayout>
</ScrollView>

Image button Nativescript and Angular

I need to create an Image button which includes a custom image and a label in {N} + Angular.
Something like this:
Here's my code. I'm using the stack layout inside the grid layout. I can't see the label below the image.
<GridLayout columns="*,*" rows="*,*,*,*,*,*" width="400" height="400">
<StackLayout class=" btn-sq-lg " col="0" row="0" (tap)="gotoSRTPage()">
<Image col="0" row ="1" src="res://ic_briefcase" > </Image>
<Label class= "label" textWrap="true" col="0" row="2" text="SRT" horizontalAlignment="center" verticalAlignment="center"></Label>
</StackLayout>
<StackLayout class=" btn-sq-lg " col="1" row="0" (tap)="">
<Image col="1" row ="1" src="res://ic_blog" > </Image>
<Label class= "label" col="1" row="2" text="SRT" horizontalAlignment="center" verticalAlignment="center"</Label>
</StackLayout>
<StackLayout class=" btn-sq-lg " col="0" row="3" (tap)="">
<Image col="0" row ="4" src="res://ic_reminder" > </Image>
<Label class= "label" textWrap="true" col="0" row="5" text="SRT" horizontalAlignment="center" verticalAlignment="center"></Label>
</StackLayout>
<StackLayout class=" btn-sq-lg " col="1" row="3" (tap)="">
<Image col="1" row ="4" src="res://ic_announcement" > </Image>
<Label class="label" textWrap="true" col="1" row="5" text="SRT" horizontalAlignment="center" verticalAlignment="center"></Label>
</StackLayout>
</GridLayout>
css file:
.btn-sq-lg {
background-color: white;
}
.label {
text-align: center;
color:#00caab;
}
So far i haven't found a straight-forward way to do it but i have a work around
You can try the following
some.component.html
<StackLayout class="btn-img" orientation="horizontal" padding="5" (tap)="onTappedFun()" >
<Image src="res://facebook" width="10%" height="100%" marginRight="10"></Image>
<Label text="Login via Facebook" verticalAlignment="center"></Label>
</StackLayout>
some.component.css
.btn-img{
border-radius: 5;
border-width: 1;
color: white;
margin: 10;
font-size: 22;
border-color: #2b3c6a;
background-color: #3B5997;
}
some.component.ts
onTappedFun(){
console.log("Hey i was tapped");
}
Result
Using only CSS you can reach the desired style:
.my-button {
color: #395469;
background-color: #FFFFFF;
background-image: url("https://play.nativescript.org/dist/assets/img/NativeScript_logo.png");
background-repeat: no-repeat;
background-position: 35 28;
background-size: 60 60;
border-width: 2;
border-color: #395469;
border-radius: 28;
height: 56;
font-size: 16;
}
In the XML apply the style class:
<Button text="I like NativeScript" class="my-button"></Button>
You can try this :
<GridLayout columns="*,*" rows="*,*" width="400" height="400">
<StackLayout row="0" col="0" orientation="vertical">
<Image src="~/images/star-empty.png" height="80%"></Image>
<Label class="label" textWrap="true" text="Button Name1" height="20%"></Label>
</StackLayout>
<StackLayout row="0" col="1" orientation="vertical">
<Image src="~/images/star-empty.png" height="80%"></Image>
<Label class="label" textWrap="true" text="Button Name2" height="20%"></Label>
</StackLayout>
<StackLayout row="1" col="0" orientation="vertical">
<Image src="~/images/star-empty.png" height="80%"></Image>
<Label class="label" textWrap="true" text="Button Name3" height="20%"></Label>
</StackLayout>
<StackLayout row="1" col="1" orientation="vertical">
<Image src="~/images/star-empty.png" height="80%"></Image>
<Label class="label" textWrap="true" text="Button Name4" height="20%"></Label>
</StackLayout>
</GridLayout>
<Button>
<Image res="<path>"></Image>
<Label text="{{text}}"></Label>
</Button>
--EDIT--
Why have I been downvoted for this? It answers the question that was asked?

Resources