I am creating NativeScript - Angular app. I had a problem with routing inside my app with not working back button (back button in my smartphone, it is supposed to go back to previous page but it is turning off my app).
I was using in my app.component.html file so I changed it to and back buttons started to works like it supposed to but layout of my home page is completly destroyed - all objects in in overlap on themselfs and "Preview" ActionBar appears in one of .
<!-- app.component.html -->
<GridLayout class="page">
<ScrollView>
<GridLayout rows="80 *" columns="*">
<FlexboxLayout class="menu">
<Image class="menu" src="~/app/images/burger.png" width="10%"></Image>
</FlexboxLayout>
<ScrollView></ScrollView>
<GridLayout class="bialy" row="1" rows="*" columns="*">
<FlexboxLayout>
<GridLayout class="space"></GridLayout>
<page-router-outlet></page-router-outlet>
</FlexboxLayout>
</GridLayout>
</GridLayout>
</ScrollView>
</GridLayout>
<!-- app.css -->
GridLayout.page {
background: linear-gradient(-85deg, #08BD73, #02A373);
flex-direction: column;
}
GridLayout.bialy {
background: white;
flex-direction: column;
border-radius: 40 40 0 0;
justify-content: center;
}
<!-- home.component.html -->
<Button text="Add" [nsRouterLink]="['/new']"></Button>
<Button text="Watering" [nsRouterLink]="['/watering']"></Button>
<Button text="catalog" [nsRouterLink]="['/catalog']" ></Button>
What shall I do to make my app with the same as app version with
This is how version with looks like (screen 1):
And this is how version with looks like (and I want my app to look like this) (screen 2)
Set actionBarVisibility to never on page-router-outlet to hide the action bar.
Your home component doesn't seem to have any layout which may be the reason you are seeing only the last button, wrap them with a StackLayout.
Related
I am having issues with GridLayout losing their column sizing inside a TabView whenever I go to another tab below the current index
An example is below where I am navigating from the 'Freaks' tab to the 'Legends' tab before it and the items inside the GridLayout lose their column position. All of them seem to revert back to column 0'. Both of the tabs uses the same component with only the data being passed as props being different.
Original GridLayout column position in 'Freaks' tab
GridLayout in 'Legends' tab losing column specifications
Gridlayout code would be
<GridLayout columns="40, *, auto" class="w-100 py-7 border-bottom-light" #longPress="optionsOpened">
<TImage :col="0" :src="image" class="w-40 h-40 round" />
<StackLayout :col="1" class="px-20" verticalAlignment="center">
<Label class="text-13" :text="`${data.attributes.first_name} ${data.attributes.last_name}`" textWrap="true" />
<Label v-if="role" class="text-11 text-grey text-capitalize" :text="data.attributes.jersey_number ? `#${data.attributes.jersey_number} ${role}` : role" />
</StackLayout>
<template v-if="!hide_action">
<StackLayout class="action-container" :col="2" orientation="horizontal">
<ActionTile class="at" :text="0xf00c" :is_icon="true" v-if="data.attributes.available == true" #tap.native="markAvailability(!data.attributes.available)" />
<ActionTile class="at" color="red" :text="0xf00d" :is_icon="true" v-if="data.attributes.available == false" #tap.native="markAvailability(!data.attributes.available)" />
</StackLayout>
</template>
</GridLayout>
Has anyone encountered a similar issue? If so, what was your fix? Any help would be much appreciated.
Why does this following code produce this result: https://imgur.com/a/lQhLs8o ?
However, if I move the BottomNavigatorBar component to top position before CountryListComponent, it produces the desired result that looks like this: https://imgur.com/a/23z7bb2 ?
<template>
<Page actionBarHidden="true">
<DockLayout height="100%">
// first
<CountryListComponent dock="top">
// second
<BottomNavigationBar dock="bottom" activeColor="pink"
inactiveColor="yellow"
backgroundColor="black"
verticalAlignment="bottom"
#tabSelected="this.changeTab"
row="1">
<BottomNavigationTab title="Fiaarst" icon="icon-29.png" />
<BottomNavigationTab title="Second" icon="icon-29.png" />
<BottomNavigationTab title="Third" icon="icon-29.png" />
</BottomNavigationBar>
</DockLayout>
</Page>
</template>
CountryListComponent
<template>
<StackLayout backgroundColor="blue">
</StackLayout>
</template>
Refer the DockLayout documentation, by default stretchLastChild will be true which means BottomNavigationBar will take entire space if it's last child and vice versa.
I'm unable get showModal to pass context through a frame to the default page. Also, showingModally does not seem to fire when modal is loaded (I guess args from showingModally should pass context?).
I've tried the example provided on https://docs.nativescript.org/ui/modal-view under Custom Actionbar, because I need the modal to load within a frame. The modal opens and closes fine, but showingModally in the modal XML does not seem to run.
home/home-page.js
const modalView = "home/modal-root";
function openModal(args) {
console.log('Opens modal');
const mainpage = args.object.page;
const context = "some context";
mainpage.showModal(modalView, context, () => {
console.log('Modal closed');
}, true);
}
exports.openModal = openModal;
home/home-page.xml
<Page xmlns="http://www.nativescript.org/tns.xsd">
<Page.actionBar>
<ActionBar title="Modal view Navigation" />
</Page.actionBar>
<GridLayout rows="auto, *">
<Button text="Open modal" tap="openModal" textWrap="true" />
</GridLayout>
</Page>
home/modal-root.xml
<Frame defaultPage="home/modal-view-page" />
home/modal-view-page.js
function onShowingModally(args) {
console.log("onShowingModally");
}
exports.onShowingModally = onShowingModally;
function onCloseModal(args) {
args.object.closeModal();
}
exports.onCloseModal = onCloseModal;
home/modal-view-page.xml
<Page backgroundColor="green" showingModally="onShowingModally">
<Page.actionBar>
<ActionBar backgroundColor="red" title="Modal view" icon="">
</ActionBar>
</Page.actionBar>
<StackLayout backgroundColor="lightGreen">
<Label text="Modal view with ActionBar" style="text-align:center;" textWrap="true" />
<Button text="Close Modal" tap="onCloseModal" />
</StackLayout>
</Page>
I've added the example to https://play.nativescript.org/?template=play-js&id=lFxTi4&v=9
with console logging.
Console show "Opens modal" on open and "Modal closed" on close as expected (from home/home-page.js), but "onShowingModally" (home/modal-view-page.js) nevers shows in console.
I think the docs need to be fixed. When you have the Frame being shown modally, the event will be called on the Frame not on the page within. If you are showing a simple view instead of Frame, then the event should be called on the view, basically whatever is the root view for your modal and in your example it's the Frame.
Updated Playground
Is there a way to change/set the height of a GridLayout row after it has already been drawn?
For example, I have a GridLayout setup like this:
<GridLayout class="template_body" rows="40,*,60">
<StackLayout row="0" [visibility]="isTablet ? 'visible' : 'collapsed'">
<Label text="Drag statements to the proper category."></Label>
<FlexboxLayout flexDirection="row" row="1" [visibility]="isSubmitted ? 'visible' : 'collapsed'">
<AbsoluteLayout height="10" width="10" class="correct-legend"></AbsoluteLayout><Label class="legend-label" text="Correct"></Label>
<AbsoluteLayout height="10" width="10" class="incorrect-legend"></AbsoluteLayout><Label class="legend-label" text="Incorrect"></Label>
</FlexboxLayout>
</StackLayout>
I want to change the height of the first row based on a condition. to rows="100,*,60"
I've tried getting the rows by using getRows() on the gridlayout, but seem to not be able to do anything with what is returned. It appears it is returning an Observable rather than an array of rows as the api says it should return.
If you want more control than rows="auto, *,auto" will give, you can give the gridlayout an id such as id="someId" and then try in js/ts...
page.getViewById("someId").rows="100, *,60";
page.getViewById("someId").requestLayout();
This must be a simple problem, but I can't get my head around it. I have a resizable title window. Inside I just want a VGroup to hold the contents of the form and an HGroup to have a few buttons at the bottom. Very standard stuff.
<!-- Content -->
<s:VGroup id="content" height="340" width="100%">
...more stuff in here...
</s:VGroup>
<!-- Buttons -->
<s:HGroup id="buttonGroup" width="100%">
...buttons in here...
</s:HGroup>
Horizonal resizing works fine. However, I want it to behave such that when the TitleWindow is resized vertically that the buttons stay in the same place relative to the TitleWindow and the content VGroup is resized vertically. But I don't know what to set the height of the VGroup to?
Ideally it would be like this:
height="{this.parent.height - buttonGroup.height - top*
or something like that....
You can also try the following trick:
<s:VGroup id="layoutContainer" width="100%" height="100%">
<s:SkinnableContainer id="content" height="100%">
....content here....
</s:SkinnableContainer>
<!-- Buttons -->
<s:HGroup id="buttonGroup">
... buttons here...
</s:HGroup>
</s:VGroup>
The intent is to make the content-container take as mush as possible vertical space within the VGroup.
Let me know if that worked for you!
Use constraint properties.
You could try for AS:
content.top = 0;
content.bottom = buttonGroup.height;
buttonGroup.bottom = 0;
But better put it to MXML definition of the components
<s:VGroup id="content" top="0" bottom="{buttonGroup.height}" width="100%">
...more stuff in here...
</s:VGroup>
<s:HGroup id="buttonGroup" bottom="0" width="100%">
...buttons in here...
</s:HGroup>
Add some paddings and margins if you like