I am trying to design a calculator for various formulas which may have inputs in different units. Specifically, I need to have this alignment (from left to right):
Essentially, I need to have a "3 column" layout of repeating items.
Below I am providing my form code with my actual results compared to what I am trying to achieve (can't post images yet so I have added links). Thanks in advance for your help!
I have tried using multiple columns in a grid system but this has not worked. I have also tried playing with the "slot".
<form #form="ngForm" (ionChange)="sendUserData(form)">
<ion-grid>
<ion-row>
<ion-col
no-margin
no-padding
size-sm="6"
offset-sm="3"
size-md="4"
offset-md="4"
>
<ion-card color="primary" style="display:block">
<ion-card-header>
<ion-card-title text-center>{{ output }}</ion-card-title>
</ion-card-header>
</ion-card>
</ion-col>
</ion-row>
<ion-row color="primary" justify-content-center>
<ion-col align-self-center size-sm="6" size-md="4">
<ion-item lines="full">
<ion-label (click)="presentAlert()" slot="start" fixed
>Dialysis:</ion-label
>
<ion-label
color="secondary"
(click)="presentAlert()"
slot="start"
fixed
>More Info</ion-label
>
<ion-segment
slot="end"
mode="ios"
no-padding
no-margin
(ionChange)="sendUserData()"
[(ngModel)]="userData.dialysis"
name="dialysis"
>
<ion-segment-button mode="ios" value="true">
<ion-label>Yes</ion-label>
</ion-segment-button>
<ion-segment-button mode="ios" value="false">
<ion-label>No</ion-label>
</ion-segment-button>
</ion-segment>
</ion-item>
<ion-item lines="full">
<ion-label slot="start" fixed>Creatinine:</ion-label>
<ion-input
slot="start"
placeholder="0"
(ionChange)="sendUserData()"
[(ngModel)]="userData.creatinine"
name="creatinine"
type="number"
no-margin
no-padding
></ion-input>
<ion-segment
slot="end"
mode="ios"
no-padding
no-margin
(ionChange)="sendUserData()"
[(ngModel)]="userData.creatinineUnits"
name="creatinineUnits"
>
<ion-segment-button mode="ios" value="umol">
<ion-label>µmol/L</ion-label>
</ion-segment-button>
<ion-segment-button mode="ios" value="mgdl">
<ion-label>mg/dL</ion-label>
</ion-segment-button>
</ion-segment>
</ion-item>
<ion-item lines="full">
<ion-label slot="start" fixed>Bilirubin:</ion-label>
<ion-input
slot="start"
placeholder="0"
(ionChange)="sendUserData()"
[(ngModel)]="userData.bilirubin"
name="bilirubin"
type="number"
no-margin
no-padding
></ion-input>
<ion-segment
slot="end"
mode="ios"
no-padding
no-margin
(ionChange)="sendUserData()"
[(ngModel)]="userData.bilirubinUnits"
name="bilirubinUnits"
>
<ion-segment-button mode="ios" value="umol">
<ion-label>µmol/L</ion-label>
</ion-segment-button>
<ion-segment-button mode="ios" value="mgdl">
<ion-label>mg/dL</ion-label>
</ion-segment-button>
</ion-segment>
</ion-item>
<ion-item lines="full">
<ion-label slot="start" fixed>INR:</ion-label>
<ion-input
slot="start"
placeholder="0"
(ionChange)="sendUserData()"
[(ngModel)]="userData.inr"
name="inr"
type="number"
no-margin
no-padding
></ion-input>
</ion-item>
<ion-item lines="full">
<ion-label slot="start" fixed>Sodium:</ion-label>
<ion-input
slot="start"
placeholder="0"
(ionChange)="sendUserData()"
[(ngModel)]="userData.sodium"
name="sodium"
type="number"
no-margin
no-padding
></ion-input>
<ion-segment
slot="end"
mode="ios"
no-padding
no-margin
(ionChange)="sendUserData()"
[(ngModel)]="userData.sodiumUnits"
name="sodiumUnits"
>
<ion-segment-button mode="ios" value="mmol">
<ion-label>mmol/L</ion-label>
</ion-segment-button>
<ion-segment-button mode="ios" value="meq">
<ion-label>mEq/L</ion-label>
</ion-segment-button>
</ion-segment>
</ion-item>
<ion-button
(click)="clear()"
id="clear"
color="danger"
fill="outline"
expand="block"
margin
padding
>Clear</ion-button
>
</ion-col>
</ion-row>
</ion-grid>
</form>
This is what I get with the above code:
https://i.imgur.com/la0IFXE.jpg
Trying to get something like this:
https://i.imgur.com/3PYWf9I.jpg
Figured it out, for anyone who is curious:
<ion-grid>
<ion-item>
<ion-row>
<ion-col align-self-center size="4">
<ion-label>Creatinine:</ion-label>
</ion-col>
<ion-col align-self-center size="3">
<ion-input (ionChange)="sendUserData()" [(ngModel)]="userData.creatinine" placeholder="0" type="number"></ion-input>
</ion-col>
<ion-col align-self-center size="5">
<ion-segment (ionChange)="sendUserData()" [(ngModel)]="userData.creatinineUnits">
<ion-segment-button value="umol">
<ion-label>µmol/L</ion-label>
</ion-segment-button>
<ion-segment-button value="mgdl">
<ion-label>mg/dL</ion-label>
</ion-segment-button>
</ion-segment>
</ion-col>
</ion-row>
</ion-item>
<ion-item>
</ion-grid>
Related
i am using ionic 4 and when the input has focus the keyboard shows and pushes the screen up and i am not able to scroll the html design smash and will not look good
hers the code i am using
<ion-header no-border>
<ion-toolbar>
<ion-row id="progressbar" class="top-bar">
<app-progress [progress]="loadProgress"></app-progress>
</ion-row>
<ion-buttons slot="start">
<ion-back-button class="back-button" *ngIf="back" mode="ios" icon="ios-
arrow-back" color="dark"
(click)="backSlide()"></ion-back-button>
</ion-buttons>
<ion-buttons slot="end" mode="md">
<ion-button class="page-numbering" mode="md">
<span class="first-page-number textBlack">{{pageNumber}}</span><span
class="second-page-number normal">/5</span>
</ion-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<ion-content [ngClass]="{'no-padding-div': isIonContent, 'padding-div': !isIonContent}"
force-overscroll="false" fixed="true">
<ion-slides [options]="slideOpts" #slides>
<ion-slide>
<ion-grid id="profileGrid">
<ion-row id="containerRow">
<ion-col no-padding>
<form [formGroup]="profileForm" class="formStyle">
<ion-row id="title-message" class="info-box-profile">
<ion-row class="welcome-title medium" justify-content-center><ion-label></ion-label></ion-row>
<ion-row class="welcome-sbtitle normal" justify-content-center><ion-label></ion-label></ion-row>
</ion-row>
<ion-row id="fname">
<p class="box-titles normal">What’s your first name?</p>
<ion-item mode="md">
<ion-input class="normal" formControlName="First_Name" placeholder="First name" id="name" mode="md"></ion-input>
</ion-item>
</ion-row>
<ion-row id="bday" align-items-start>
<p class="box-titles normal">When is your birthday?</p>
<ion-item mode="md">
<ion-datetime #picker class="normal timePicker" formControlName="Date_Of_Birth" displayFormat="MM/DD/YYYY"
Placeholder="Date of birth" pickerFormat="MM/DD/YYYY" [(ngModel)]="date"
(ionChange)="picktime($event)" mode="md"></ion-datetime>
<ion-icon class="arrow-down-icon" name="ios-arrow-down" slot="end"></ion-icon>
</ion-item>
</ion-row>
<ion-row align-items-start id="gender-title">
<p class="box-titles normal">Which one are you?</p>
</ion-row>
<ion-row id="gender-row" justify-content-center>
<ion-col align-self-center size="6">
<div (click)="female()" class="female" [ngClass]="{'female-image': gender == '', 'female-image1': gender == 'female', 'female-image2': gender == 'male'}">
</div>
</ion-col>
<ion-col align-self-center size="6">
<div (click)="male()" class="male" [ngClass]="{'male-image': gender == '', 'male-image1': gender == 'male', 'male-image2': gender == 'female'}">
</div>
</ion-col>
</ion-row>
<ion-row id="next-button" justify-content-center>
<ion-button class="cta" shape="round" color="secondary" expand="full"
[disabled]="(profileForm.valid) ? false : true" (click)="onClick()">
Next
</ion-button>
<!-- <ion-button class="cta" shape="round" color="secondary" expand="full"
[disabled]="(profileForm.valid && gender != '') ? false : true" (click)="onClick()">
Next
</ion-button> -->
</ion-row>
</form>
</ion-col>
</ion-row>
</ion-grid>
</ion-slide>
<ion-slide>
....
</ion-slides>
</ion-content>
when i click on the first name input the keyboard pushes the screen up and the content smashes, i tried many solution but none of them worked for me
and i also added this in my app.module.ts
IonicModule.forRoot({
mode: 'ios',
scrollAssist: false,
scrollPadding: false,
}),
I'm getting a problem using ion-slides on Ionic 3.
It's using all my screen size, but when i scroll down there is all my stuft and it is ok, but i need those slides be smaller
This is my code:
<ion-header>
<ion-navbar>
<ion-title>
Productos
</ion-title>
<ion-buttons end>
<button (click)="reloadProducts()" style="background:none" ion-button round full large text-center icon-right> <!--(click)="imeiViewer()"-->
<ion-icon name="cart"></ion-icon>
<ion-badge *ngIf="itemInfoHeader.length > 0" id="cart-badge">{{itemInfoHeader.length}}</ion-badge>
</button>
</ion-buttons>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-slides pager>
<ion-slide style="width:100%; height: 50%; " *ngFor="let slide of slide_items" >
<div>
<img src="assets/img/{{slide}}.png">
</div>
</ion-slide >
</ion-slides>
<ion-grid>
<ion-row>
<ion-col col-6>
<button ion-button block icon-start>Filtrar
<ion-icon name="options"></ion-icon>
</button>
</ion-col>
<ion-col col-6>
<button ion-button block icon-end>Ordenar
<ion-icon name="reorder"></ion-icon>
</button>
</ion-col>
</ion-row>
</ion-grid>
<ion-col col-6 col-md-4 col-xl-3 *ngFor="let producto of itemInfo">
<ion-item class="item-thumbnail-left" >
<ion-grid>
<ion-row>
<ion-col col-6>
<img src="http://186.176.206.154:8088/images/Products/{{producto.ItemId}}_l_.PNG" >
</ion-col>
<ion-col col-6>
<h3>{{producto.ItemId}}</h3>
<ion-item class="item item-text-wrap">{{producto.ItemName}}</ion-item>
<p style="position:absolute;right:10px;">
<button ion-button (click)="addToCart(producto)" icon-end >
<ion-icon name="cart"></ion-icon>
</button>
</p>
</ion-col>
</ion-row>
</ion-grid>
</ion-item>
</ion-col>
</ion-content>
if anyone knows how to make my slides "circles" goes up. I tried reducing Height but it doesn't work.
I am using this as guide -> https://ionicframework.com/docs/components/#slides
Fixed! I had to add style="height: 300px;" on ion-slides.
I have referred this example from ionic framework documentation and created a segment of my own.
<div padding>
<ion-segment [(ngModel)]="pet">
<ion-segment-button value="kittens">
Kittens
</ion-segment-button>
<ion-segment-button value="puppies">
Puppies
</ion-segment-button>
</ion-segment>
</div>
<div [ngSwitch]="pet">
<ion-list *ngSwitchCase="'puppies'">
<ion-item>
<ion-thumbnail item-start>
<img src="img/thumbnail-puppy-1.jpg">
</ion-thumbnail>
<h2>Ruby</h2>
</ion-item>
...
</ion-list>
<ion-list *ngSwitchCase="'kittens'">
<ion-item>
<ion-thumbnail item-start>
<img src="img/thumbnail-kitten-1.jpg">
</ion-thumbnail>
<h2>Luna</h2>
</ion-item>
...
</ion-list>
</div>
Here, they are displaying different ion-list on different button clicks.
But I am a different element type to be displayed on two different button clicks.
Here is my code-
<div>
<ion-segment [(ngModel)]="pet">
<ion-segment-button value="audios">
Audios
</ion-segment-button>
<ion-segment-button value="images">
Images
</ion-segment-button>
</ion-segment>
</div>
<div [ngSwitch]="pet">
//this is coming
<ion-list *ngSwitchCase="'audios'">
<p align="left">
Resources
</p>
<ion-item-divider>
Category Name
</ion-item-divider>
<ion-item class="custom-font-size">
<i class="material-icons rotate theme-color" item-start> format_align_center</i>
Lemon Exercise<span item-end>08:12</span>
</ion-item>
<ion-item class="custom-font-size">
<ion-icon name="md-play" class="play-icon-color" item-start></ion-icon>
Sample Goal Audio<span item-end>04:11</span>
</ion-item>
<ion-item class="custom-font-size">
<ion-icon name="md-play" class="play-icon-color" item-start></ion-icon>
Mindfulness<span item-end> 07:12</span>
</ion-item>
<ion-item-divider>
Category Name
</ion-item-divider>
<ion-item class="custom-font-size">
<ion-icon name="md-play" class="play-icon-color" item-start></ion-icon>
Audio File Name<span item-end>11:00</span>
</ion-item>
<ion-item class="custom-font-size">
<ion-icon name="md-play" class="play-icon-color" item-start></ion-icon>
Sample Goal Audio<span item-end>10:12</span>
</ion-item>
<ion-item class="custom-font-size">
<ion-icon name="md-play" class="play-icon-color" item-start></ion-icon>
Mindfulness<span item-end>10:12</span>
</ion-item>
</ion-list>
//this is not coming
<ion-grid *ngSwitchCase="'images'">
<div *ngFor="let images of image; let i = index;">
<ion-row *ngIf="i % 3 === 0">
<ion-col col-4 *ngIf="i < images.length">
<img [src]="images[i].url" />
</ion-col>
<ion-col col-4 *ngIf="i+1 < images.length">
<img [src]="images[i+1].url" />
</ion-col>
<ion-col col-4 *ngIf="i+2 < images.length">
<img [src]="images[i+2].url" />
</ion-col>
</ion-row>
</div>
</ion-grid>
</div>
in .ts file i have stored images as
this.image = [
{ url: 'assets/imgs/placeholder.png'},
{ url: 'assets/imgs/placeholder.png' },
{ url: 'assets/imgs/placeholder.png' }
];
As you can see i want to display a ion-list on first segment button click and display a image grid on second segment button click. As of now nothing comes up when i click on the second button
I think you're for loop is not correct, You are using the loop and inside it, you are trying to use an index on each item which is not an array. Below code should be working
<div>
<ion-segment [(ngModel)]="pet">
<ion-segment-button value="audios">
Audios
</ion-segment-button>
<ion-segment-button value="images">
Images
</ion-segment-button>
</ion-segment>
</div>
<div [ngSwitch]="pet">
<ion-list *ngSwitchCase="'audios'">
<p align="left">
Resources
</p>
<ion-item-divider>
Category Name
</ion-item-divider>
<ion-item class="custom-font-size">
<i class="material-icons rotate theme-color" item-start> format_align_center</i>
Lemon Exercise<span item-end>08:12</span>
</ion-item>
<ion-item class="custom-font-size">
<ion-icon name="md-play" class="play-icon-color" item-start></ion-icon>
Sample Goal Audio<span item-end>04:11</span>
</ion-item>
<ion-item class="custom-font-size">
<ion-icon name="md-play" class="play-icon-color" item-start></ion-icon>
Mindfulness<span item-end> 07:12</span>
</ion-item>
<ion-item-divider>
Category Name
</ion-item-divider>
<ion-item class="custom-font-size">
<ion-icon name="md-play" class="play-icon-color" item-start></ion-icon>
Audio File Name<span item-end>11:00</span>
</ion-item>
<ion-item class="custom-font-size">
<ion-icon name="md-play" class="play-icon-color" item-start></ion-icon>
Sample Goal Audio<span item-end>10:12</span>
</ion-item>
<ion-item class="custom-font-size">
<ion-icon name="md-play" class="play-icon-color" item-start></ion-icon>
Mindfulness<span item-end>10:12</span>
</ion-item>
</ion-list>
<ion-grid *ngSwitchCase="'images'">
<div *ngFor="let image of images; let i = index;">
<ion-row>
<ion-col col-4>
<img [src]="image.url" />
</ion-col>
<ion-col col-4>
<img [src]="image.url" />
</ion-col>
<ion-col col-4>
<img [src]="image.url" />
</ion-col>
</ion-row>
</div>
</ion-grid>
</div>
I want to make bottom sheet with some buttons in ionic2, all resources I found are examples in ionic1: this is an example:
this is the link I want to do like it:
enter link description here
is is my html:
<ion-content no-padding no-margin>
<ion-list no-lines no-padding no-margin>
<ion-list-header>
Share Options
</ion-list-header>
<ion-item>
<ion-grid>
<ion-row>
<ion-col col-3 text-center>
<button ion-button clear icon-only>
<ion-icon name="md-copy" id="copyIcon"></ion-icon>
</button><br/>
<span class="optionName">Copy Link</span>
</ion-col>
<ion-col col-3 text-center>
<button ion-button icon-only class="SMBtn" id="FBBtn">
<ion-icon name="logo-facebook" color="light" id="FBIcon"></ion-icon>
</button><br/>
<span class="optionName">Facebook</span>
</ion-col>
<ion-col col-3 text-center>
<button ion-button icon-only class="SMBtn" id="twitterBtn">
<ion-icon name="logo-twitter"></ion-icon>
</button><br/>
<span class="optionName">Twitter</span>
</ion-col>
<ion-col col-3 text-center>
<button ion-button icon-only class="SMBtn" id="googleBtn">
<ion-icon name="logo-googleplus"></ion-icon>
</button><br/>
<span class="optionName">Google Plus</span>
</ion-col>
</ion-row>
<ion-row>
<ion-col col-3 text-center>
<button ion-button icon-only class="SMBtn" id="whatsBtn">
<ion-icon name="logo-whatsapp" id="copyIcon"></ion-icon>
</button><br/>
<span class="optionName">Wahts Up</span>
</ion-col>
<ion-col col-3 text-center>
<button ion-button icon-only class="SMBtn" id="tumblrBtn">
<ion-icon name="logo-tumblr"></ion-icon>
</button><br/>
<span class="optionName">Tumblr</span>
</ion-col>
<ion-col col-3 text-center>
<button ion-button icon-only class="SMBtn" id="linkedBtn">
<ion-icon name="logo-linkedin"></ion-icon>
</button><br/>
<span class="optionName">Linked-in</span>
</ion-col>
<ion-col col-3 text-center>
<button ion-button icon-only class="SMBtn" id="moreBtn">
<ion-icon name="ios-more"></ion-icon>
</button><br/>
<span class="optionName">More</span>
</ion-col>
</ion-row>
</ion-grid>
</ion-item>
</ion-list>
</ion-content>
I make it appear like a popover but I don't want that I want it to be like action sheet appear from bottom, anyone can help me in this issue?
I am using Ionic2 and I want to make design like that:
I made the cart but I can't make the position as image
this is card code:
<ion-grid>
<ion-row wrap>
<ion-col width-50>
<ion-card>
<ion-item>
<ion-icon name="start" item-start></ion-icon>
<ion-icon name="ios-heart-outline" item-end></ion-icon>
</ion-item>
<ion-card-content text-center>
<ion-item text-center>
<img src="http://safe-pay.co/safepay/public/uploadedimg/user/avatar.png" style="width:40px;height:40px" />
</ion-item>
<ion-item>
<span>Canon Power <br/>shot SX60 HS</span>
</ion-item>
<ion-item>
<span id="oldPrice">119.900KD</span>
</ion-item>
<ion-item>
<span id="newPrice">100.900KD</span>
</ion-item>
<ion-item>
<ion-rating [numStars]="5" [readOnly]="false" [value]="3" (clicked)="starClicked($event)">
</ion-rating>
</ion-item>
</ion-card-content>
</ion-card>
</ion-col>
</ion-row>
</ion-grid>
this is the output
can any one tell me the how to position them
try putting style to make it aligned as you want ..
<div style="width:100%;float:left;">
<ion-card style="width:33.33%;float:left;">
<ion-card-content text-center>
SAMLE1
</ion-card-content>
</ion-card>
<ion-card style="width:33.33%;float:left;">
<ion-card-content text-center>
SAMLE2
</ion-card-content>
</ion-card>
<ion-card style="width:33.33%;float:left;">
<ion-card-content text-center>
SAMLE3
</ion-card-content>
</ion-card>
</div>