I am trying to display a background image on my login page, it is not showing.
I have tried adding the class to the page and my layout. Neither is working.
Is there something in my code that is preventing this for some reason?
<Page loaded="pageLoaded" class="page bgImage" actionBarHidden="true" xmlns="http://www.nativescript.org/tns.xsd">
<FlexboxLayout class="page">
<GridLayout rows="auto, auto, auto">
<StackLayout class="form ">
<Image class="logo" src="~/images/johnevolve.png" />
<Label class="header" text="Health Conscious" />
<StackLayout class="input-field">
<Label text="Username" />
<TextField class="input" text="{{ email }}" hint="Email"
keyboardType="email" autocorrect="false"
autocapitalizationType="none" returnKeyType="next" />
<Label class="hr-light" />
</StackLayout>
<StackLayout class="input-field">
<Label text="Password" />
<TextField id="password" class="input" text="{{ password }}"
hint="Password" secure="true" returnKeyType="{{ isLoggingIn ? 'done' : 'next' }}" />
<Label class="hr-light" />
</StackLayout>
<StackLayout class="input-field" visibility="{{ !isLoggingIn ? 'visible' : 'collapse' }}">
<TextField id="confirmPassword" class="input" text="{{ confirmPassword }}"
hint="Confirm password" secure="true" returnKeyType="done" />
<Label class="hr-light" />
</StackLayout>
<Button text="{{ isLoggingIn ? 'Log In' : 'Sign Up' }}" tap="{{ submit }}"
class="btn btn-primary m-t-20" />
<Label visibility="{{ isLoggingIn ? 'visible' : 'collapse' }}"
text="Forgot your password?" class="login-label" tap="{{ forgotPassword }}" />
</StackLayout>
</GridLayout>
<Label class="login-label sign-up-label" tap="{{ toggleForm }}">
<FormattedString>
<Span text="{{ isLoggingIn ? 'Don’t have an account? ' : 'Back to Login' }}" />
<Span text="{{ isLoggingIn ? 'Sign up' : '' }}" class="bold" />
</FormattedString>
</Label>
</FlexboxLayout>
</Page>
and my css:
.bgImage {
background-image: url("~/images/1-login.png");
}
Edit: Here is the page css rule in case you need that:
.page {
align-items: center;
flex-direction: column;
}
Does anyone know what's going wrong here?
Thank you.
Image In Question:
If this is NativeScript 5.x and you are using HMR/Webpack; the issue is most likely WebPack caused. I have a blog article about this on how to disable HMR mode and re-use Legacy mode.
In a nutshell you need to re-enable Legacy mode.
http://fluentreports.com/blog/?p=935
Please note; this is only relevent to NativeScript 5.x; NativeScript 6 (coming out shortly) will probably not let you re-enable legacy mode.
If you find legacy mode does actually fix your issue; please report this issue to the https://github.com/nativescript/NativeScript-Dev-Webpack repo so it can be looked at.
There was the problem with your FlexboxLayout . It was taking the 100% height and overlapping the background image with it's content.
You can also try with giving background Image to your FlexboxLayout.
<FlexboxLayout class="page bgImage">
and in app.css
.bgImage{
/* background-color: green; */
background-image: url("~/images/1-login.png");
background-repeat: no-repeat;
background-size: cover
}
I have created a playground for you here.
Related
I'm new to NativeScript and just can't figure out how to load a plugin right.
As mentioned here, I added the plugin and from here, followed the steps for Core JS, but nothing seems to work.
I've tried with the RadListView and PullToRefresh so far but I keep hitting the same/similar roadblock. For the PullToRefresh plugin, the error I receive is as you see below.
JS: HMR: Hot Module Replacement Enabled. Waiting for signal.
JS: Error: Building UI from XML. #screens/home/home-page.xml:32:11
JS: > Building UI from XML. #screens/orders/orders-items-page.xml:9:5
JS: > Module '#nstudio/nativescript-pulltorefresh' not found for element '#nstudio/nativescript-pulltorefresh:PullToRefresh'.
JS: > _nativescript_core__WEBPACK_IMPORTED_MODULE_0__.Property is not a constructor
I'm running a NativeScript Core JS sample project with minor cosmetic modifications. I'm not entirely sure what code to post up here for reference, but here goes
home-page.xml
<Page xmlns="http://schemas.nativescript.org/tns.xsd">
<BottomNavigation>
<TabStrip>
<TabStripItem class="navigation__item">
<Label text="Orders"/>
<Image src="font://" class="fas t-36"/>
</TabStripItem>
<TabStripItem class="navigation__item">
<Label text="Inventory"/>
<Image src="font://" class="fas t-36"/>
</TabStripItem>
<TabStripItem class="navigation__item">
<Label text="Promotions"/>
<Image src="font://" class="fas t-36"/>
</TabStripItem>
<!-- <TabStripItem class="navigation__item"> <Label text="Analytics"/> <Image src="font://" class="fas t-36"/> </TabStripItem> -->
</TabStrip>
<TabContentItem>
<Tabs>
<TabStrip id="top-nav">
<TabStripItem>
<Label text="Current Orders"></Label>
</TabStripItem>
<TabStripItem>
<Label text="Past Orders"></Label>
</TabStripItem>
</TabStrip>
<TabContentItem>
<Frame defaultPage="screens/orders/orders-items-page"/>
</TabContentItem>
<TabContentItem>
<Frame defaultPage="screens/inventory/inventory-page"/>
</TabContentItem>
</Tabs>
</TabContentItem>
<TabContentItem>
<Frame defaultPage="screens/inventory/inventory-page"/>
</TabContentItem>
<TabContentItem>
<Frame defaultPage="screens/promotions/promotions-page"/>
</TabContentItem>
<!-- <TabContentItem> <Frame defaultPage="screens/analytics/analytics-page"/> </TabContentItem> -->
</BottomNavigation>
</Page>
orders-item-page.xml
<Page navigatingTo="onNavigatingTo" loaded="loaded" xmlns="http://schemas.nativescript.org/tns.xsd" xmlns:PullRefresh="#nstudio/nativescript-pulltorefresh">
<GridLayout rows="auto, *">
<FlexboxLayout flexDirection="row" justifyContent="space-around">
<Button class="" col="0" text="New Orders" tap="filter"></Button>
<Button class="" col="1" text="Preparing" tap="filter"></Button>
<Button class="" col="2" text="Ready for Pickup" tap="filter"></Button>
</FlexboxLayout>
<PullRefresh:PullToRefresh refresh="refreshList" indicatorFillColor="#fff000" indicatorColor="#3489db">
<ListView items="{{ orders }}" row="1">
<ListView.itemTemplate>
<GridLayout class="p-10 order-list-item" rows="auto, auto, auto, auto" columns="*, auto" androidElevation="5" margin="5" backgroundColor="white" borderRadius="10">
<FlexboxLayout flexDirection="row" row="0" colSpan="2" justifyContent="space-between">
<Label class="{{ 'status ' + status }}" text="{{ statusText }}" textTransform="uppercase"/>
<Label class="font-weight-bold" text="{{ 'Order to be Ready in ' + totalTime }}" fontSize="12"/>
</FlexboxLayout>
<FlexboxLayout class="m-t-10" flexDirection="row" row="1" colSpan="2" justifyContent="space-between">
<Label class="font-weight-bold" text="{{ '#' + number }}" fontSize="15"/>
<Label class="font-weight-bold" text="{{ '₹' + value }}" fontSize="15"/>
</FlexboxLayout>
<Label class="" text="{{ dateTime + ' | ' + itemsBrief }}" row="2" col="0" color="gray" fontSize="12"/>
<FlexboxLayout flexDirection="row" row="3" colSpan="2">
<Button flexGrow="1" class="text-center font-weight-bold" text="Mark Ready" tap="filter"></Button>
<Button flexGrow="1" class="text-center font-weight-bold" text="Mark Ready" tap="filter"></Button>
</FlexboxLayout>
</GridLayout>
</ListView.itemTemplate>
</ListView>
</PullRefresh:PullToRefresh>
<!-- <ActivityIndicator busy="{{ isLoading }}" row="1" horizontalAlignment="center" verticalAlignment="center"/> -->
</GridLayout>
</Page>
I have an AbsoluteLayout that is supposed to open and go over a mdCardview, but it seems that it is trying to squeeze everything inside the cardview. I tried messing with the CSS position tag, but it doesn't change one bit.
In the picture below you can see the save button which is also an absolutelayout, this one does go over every other component.
This is my TimeCard component which has a button and a absolute layout that would be used as a popup
<template>
<GridLayout class="dialog" rows="*, *" columns="*" :class="{ dialogOpen: dialogOpen }">
<MDButton :text="label" #tap="showDialog()" class="fill" />
<AbsoluteLayout class="dialog-wrapper">
<StackLayout top="100" left="20" class="dialog">
<TimePicker v-bind="$attrs" v-on="$listeners" />
<MDButton text="Confirm" class="cancel" />
<Button class="btn btn-outline" text="Cancel" #tap="closeDialog"></Button>
</StackLayout>
</AbsoluteLayout>
</GridLayout>
</template>
data: () => ({
dialogOpen: false
}),
methods: {
showDialog() {
this.dialogOpen = true
},
closeDialog() {
this.dialogOpen = false
}
}
This is my availabilityCard which contains a slot with the timecard component
<StackLayout >
<MDCardView elevation="5px" ripple="true" width="100%" margin="30px" class="cardview">
<GridLayout rows="*, *" columns="*, *, *" class="card" width="auto">
<StackLayout col="0" row="0">
<Label class="title" :text="getNameAndDayOfMonth(day)" />
</StackLayout>
<MDButton col="2" row="0" text="fill" class="fill" #tap="showActions()" v-if="!show && Object.keys(value).length === 0" />
<GridLayout row="1" colSpan="3" columns="auto, auto, *" rows="*, *" width="auto" v-else>
<GridLayout row="0" columns="auto, auto" rows="*" colSpan="2" width="auto">
<slot />
</GridLayout>
<MDButton text="clear" col="2" row="0" class="cancel" #tap="cancelTime()" />
<template v-if="Object.keys(value).length !== 0">
<Label :text="format(value.start)" col="0" row="1" />
<Label :text="format(value.end)" col="1" row="1" />
</template>
</GridLayout>
</GridLayout>
</MDCardView>
</StackLayout>
This is the parent component availability that defines the timecard component
<StackLayout>
<AvailabilityCard v-for="(day, i) in days" :key="i" v-model="day.element" :day="day.date">
<TimeCard col="0" label="begin" v-model="day.element.start"></TimeCard>
<TimeCard col="1" label="eind" v-model="day.element.end"></TimeCard>
</AvailabilityCard>
</StackLayout>
Availability component screen:
I am using nativescript-camera-plus for custom Layout. I tried default icons first which was working fine, but when i put custom gridlayout inside cam then it was not visible.
I have made all icon visible to false when i was checking, but now i just put a general code to show where i'm facing problem.
<Cam:CameraPlus id="camPlus" loaded="camLoaded" height="{{ cameraHeight }}" galleryPickerMode="multiple" enableVideo="true" confirmVideo="false" saveToGallery="true" showCaptureIcon="false" showGalleryIcon="false" showToggleIcon="false" showFlashIcon="false" confirmPhotos="true" flashOffIcon="icon" autoSquareCrop="true" insetButtons="true" insetButtonsPercent="0.02" imagesSelectedEvent="{{ imagesSelectedBinding }}" debug="true">
<GridLayout rows="auto, *, auto" columns="auto, *, auto"><Button row="0" col="0" text="Flash" class="btn-transparent" tap="{{ toggleFlash }}" /><Button row="0" col="2" text="Camera" class="btn-transparent" tap="{{ toggleCamera }}" /><Image row="1" col="1" horizontalAlignment="center" verticalAlignment="center" src="https://img.clipartfest.com/4ec5e2315cea92482da5546e1e7fca89_-pinterest-cute-clipart-snowman-clipart-transparent-background_300-300.png" stretch="none" /><Button row="2" col="0" text="Gallery" class="btn-transparent" tap="{{ openGallery }}" /><Button row="2" col="2" text="Take" class="btn-transparent" tap="{{ takePic }}" /></GridLayout>
</Cam:CameraPlus>
I guess it's a bug with the plugin itself. Here is a workaround,
XML
<Cam:CameraPlus id="camPlus" loaded="camLoaded" height="{{ cameraHeight }}">
<GridLayout id="overlay" rows="auto, *, auto" columns="auto, *, auto">
<Button row="0" col="0" text="Flash" class="btn-transparent" tap="{{ toggleFlash }}" />
<Button row="0" col="2" text="Camera" class="btn-transparent" tap="{{ toggleCamera }}" />
<Image row="1" col="1" horizontalAlignment="center" verticalAlignment="center" src="https://img.clipartfest.com/4ec5e2315cea92482da5546e1e7fca89_-pinterest-cute-clipart-snowman-clipart-transparent-background_300-300.png" stretch="none" />
<Button row="2" col="0" text="Gallery" class="btn-transparent" tap="{{ openGallery }}" />
<Button row="2" col="2" text="Take" class="btn-transparent" tap="{{ takePic }}" />
</GridLayout>
</Cam:CameraPlus>
JS
function camLoaded(args) {
const parentView = args.object.nativeView;
const overlayView = args.object.page.getViewById("overlay");
parentView.removeView(overlayView.nativeView);
overlayView.nativeView.setLayoutParams(new android.widget.RelativeLayout.LayoutParams(android.widget.RelativeLayout.LayoutParams.FILL_PARENT, android.widget.RelativeLayout.LayoutParams.FILL_PARENT));
parentView.addView(overlayView.nativeView);
}
In my NativeScript project, I'm trying to make a bottom bar with an icon and then the word that resembles it underneath it. Like this
Here's the html of what I tried to do:
<GridLayout rows="*,60">
<ScrollView row="0">
<WrapLayout orientation="horizontal">
<Label text="There are no leagues currently." style="color: black; text-align: center; font-weight: bold"></Label>
<Label text="Contact your commissioner" style="color: black; text-align: center; font-weight: bold"></Label>
<Label text="to create one." style="color: black; text-align: center; font-weight: bold"></Label>
</WrapLayout>
</ScrollView>
<StackLayout row="1" orientation="horizontal">
<Button textWrap="true" width="25%">
<FormattedString>
<Span text="\n" class="fa"></Span>
<Span text="Home"></Span>
</FormattedString>
</Button>
<Button textWrap="true" width="25%">
<FormattedString>
<Span text="\n" class="fa"></Span>
<Span text="All Cocktails"></Span>
</FormattedString>
</Button>
<Button textWrap="true" width="25%">
<FormattedString>
<Span text="\n" class="fa"></Span>
<Span text="Favorite"></Span>
</FormattedString>
</Button>
<Button textWrap="true" width="25%">
<FormattedString>
<Span text="\n" class="fa"></Span>
<Span text="Profile"></Span>
</FormattedString>
</Button>
</StackLayout>
</GridLayout>
and here's my css:
.fa {
font-family: 'Font Awesome 5 Free';
}
However, whenever I try to do this, it comes out like this
I'm not quite sure where to go so any help would be great. Thanks!
Here's a working example of my code: https://play.nativescript.org/?template=play-ng&id=r8Jodt&v=19
Use the GridLayout for BottomBar, you can look for the playground sample here
<GridLayout columns="*,*,*,*" rows="*,*" width="100%" row="1" backgroundColor="lightgray">
<Label text="" row="0" col="0" class="fa" width="100%" textAlignment="center"></Label>
<Label text="Home" row="1" col="0" width="100%" textAlignment="center"></Label>
<Label text="" row="0" col="1" class="fa" width="100%" textAlignment="center"></Label>
<Label text="All Cocktails" row="1" col="1" width="100%" textAlignment="center"></Label>
<Label text="" row="0" col="2" class="fa" width="100%" textAlignment="center"></Label>
<Label text="Favorite" row="1" col="2" width="100%" textAlignment="center"></Label>
<Label text="" row="0" col="3" class="fa" width="100%" textAlignment="center"></Label>
<Label text="Profile" row="1" col="3" width="100%" textAlignment="center"></Label>
</GridLayout>
The actual problem here is that \n works only with JavaScript, while using it in HTML (XML) file you should use the encode version of the character that is
, that should give you a new line.
Are you trying to have a custom TabBar for your TabView? If Yes, you may try the nativescript-vector-icons which allows you to use font icons on TabBar.
Make their position as display:absolute and within the class it should be inline-block. With some margins it should be easy to adjust
I would contain all the buttons in a div, and then each button and label group in it's own div.
<div id='button-row'>
<div class='bottom-button>
<button></button>
<p class='label>Label</p>
</div>
<div class='bottom-button>
<button></button>
<p class='label>Label</p>
</div>
// repeat for your buttons
</div>
Your css:
.button-row {
display: flex;
flex-direction: row;
justify-content: space-between;
}
.bottom-button {
display: flex;
flex-direction: column;
justify-content: center;
// the font awesome icons are considered text I believe, so
text-align: center;
// would also work
}
This will make all your buttons in the row evenly spaced, and place your button on top of the label. I like using flexbox because its quick and easy, and mobile responsive. I'm not a CSS pro by any means but it works for me.
Edit: just saw your markup. Try giving formatted string the css of .bottom-button and see if that works.
For \n just worked for android.
using hex code
also not worked for both ios and android.
the final solution I find is as below:
(for nativescript-vue)
<Label textWrap="true" col="0" row="0">
<FormattedString>
<Span class="number" :text="days" />
<Span class="format" :text="'\n' + 'Gün'" />
</FormattedString>
</Label>
I'm developing some app made on nativescript. Recently, i see that my app is more like website not an app, beacuse of how navigation works.
I'm having bottom nav (atached - this grey with 5 icons) that is used to load proper views.
But when i click on home or any other icon, new view is loaded, but also nav is 'reloaded'. So it will not stay in place but load with new view. My question is - is possible oto have static botom bar ? I've tried 2 plugins found on marketplace, but without success. Thanks for and help.
<Page class="page" loaded="loaded" xmlns:header="components/header" xmlns:footer="components/footer">
<GridLayout rows="120,*,60">
<StackLayout row="0">
<!-- Common header -->
<header:header/>
</StackLayout>
<ScrollView row="1" verticalAlignment="top" class="scrollview" tap="{{ loadPage }}">
<StackLayout class="redeem">
<Label text="Enter your code below to redeem your reward" class="info" textWrap="true"></Label>
<Label text="Code" class="info code" textWrap="true"></Label>
<TextField />
<Button text="Redeem" class="button blue"></Button>
</StackLayout>
</ScrollView>
<StackLayout row="2">
<!-- Common footer -->
<footer:footer/>
</StackLayout>
</GridLayout>
</Page>
:
<AbsoluteLayout class="footer" loaded="menu" horizontalAlignment="center" xmlns:sd="nativescript-ui-sidedrawer">
<GridLayout rows="auto" columns="*,*,*,*,*" horizontalAlignment="center">
<Label row="0" col="0" class="fa" text="" tap="{{ mainPage }}"></Label>
<Label row="0" col="1" class="fa" text="" tap="{{ creditPage }}"></Label>
<Label row="0" col="2" class="fa" text="" tap="{{ seatPage }}"></Label>
<Label row="0" col="3" class="fa" text="" tap="{{ refs }}"></Label>
<Label id="openMenu" row="0" col="4" class="fa" text="" tap="toggleDrawer"></Label>
<!--<Label id="openMenu" row="0" col="4" class="fa" text="" tap="{{ loadPage }}"></Label>-->
</GridLayout>
</AbsoluteLayout>
You could use DockLayout and dock the content to the bottom (Angular example here)
Also in the upcoming release 4.0.0 of NativeScript (expected April-2018) will provide support for different root views (apart from Page) meaning you could create bottom static layout like GridLayout or even better a bottom TabView (also coming for Android in 4.0.0) and create Frame in the upper layout for your dynamic content. (Look here)