Sliding cards in Ionic 3 - html

I have a div with some <ion-row> and ion-col. The thing I would like to do is make the <ion-card> item like an <ion-item-sliding> list https://ionicframework.com/docs/v3/components/#sliding-list
I do not know if it is possible without changing all the structure I have now.
<ion-row>
<h2>{{day.date}}</h2>
</ion-row>
<div *ngFor="let item of day.dayArray; let i=index">
<ion-row>
<ion-col col-10 class="no-padding">
<ion-card (click)="openDetails(j, i)">
<ion-row>
<ion-col col-3>
<span class="departure-time">{{ item.hour }}</span>
<span class="departure-time-desc">{{ item.date | date: "a" }}</span>
</ion-col>
<ion-col col-3>
<ion-avatar item-start>
<img *ngIf="segment != 'driver'" [src]="item.driver.profile_image">
<img *ngIf="segment === 'driver'" [src]="imageUrl">
</ion-avatar>
</ion-col>
<ion-col col-6>
<span *ngIf="segment === 'driver'" class="destination">{{item.destination.direction}}</span>
<span *ngIf="segment === 'driver' && item.passengers.length === 1" class="driver-age">{{item.passengers.length}} pasajero</span>
<span *ngIf="segment === 'driver' && item.passengers.length != 1" class="driver-age">{{item.passengers.length}} pasajeros</span>
<span *ngIf="segment != 'driver'" class="driver-name">{{item.driver.first_name}} {{item.driver.last_name}}</span>
<span *ngIf="segment != 'driver'" class="driver-age">{{item.destination.direction}}</span>
</ion-col>
</ion-row>
</ion-card>
</ion-col>
<ion-col col-2 class="chat-col" (click)="openChat(j, i)">
<ion-icon name="chatbubbles" color="danger" [ngClass]="{'notification': item.notificationInJourney}"></ion-icon>
</ion-col>
</ion-row>
</div>
</div>```

Related

Change color background slide white gradient IONIC 3

I would like to change the orange background to green, but with some animation, for example, when it is orange it will turn green.
If you can check out the two gifs I've assembled, you'll understand what I mean.
HOW IT IS CURRENTLY -> GIF
HOW I WANT THEM TO BE -> GIF
HOME.HTML
<ion-content >
<div style="background-color: #f87f0e; padding: 10px;">
<ion-slides pager>
<ion-slide >
<ion-card style="border-radius: 15px;margin-bottom: 35px">
<ion-card-content style="font-family: sans-serif;">
<ion-row>
<ion-col col-12>
<P style="color: #9e9e9e;float: left;font-size: 15px">BALANCE PERSONAL</P>
</ion-col>
<ion-col col-12>
<H2 style="float: left;font-size: 20px">4.235632 <small>MIC</small></H2>
</ion-col>
</ion-row>
</ion-card-content>
</ion-card>
</ion-slide>
<ion-slide>
<ion-card style="border-radius: 15px">
<ion-card-content style="font-family: sans-serif;">
<ion-row>
<ion-col col-12>
<P style="color: #9e9e9e;float: left;font-size: 15px">BALANCE BUSINESS</P>
</ion-col>
<ion-col col-12>
<H2 style="float: left;font-size: 20px">4.235632 <small>MIC</small></H2>
</ion-col>
</ion-row>
</ion-card-content>
</ion-card>
</ion-slide>
</ion-slides>
</div>
</ion-content>
You need to change backgroud-color for each ion-card.
<ion-content >
<div style="background-color: #f87f0e; padding: 10px;">
<ion-slides pager>
<ion-slide >
<ion-card style="background-color: red; border-radius: 15px;margin-bottom: 35px">
<ion-card-content style="font-family: sans-serif;">
<ion-row>
<ion-col col-12>
<P style="color: #9e9e9e;float: left;font-size: 15px">BALANCE PERSONAL</P>
</ion-col>
<ion-col col-12>
<H2 style="float: left;font-size: 20px">4.235632 <small>MIC</small></H2>
</ion-col>
</ion-row>
</ion-card-content>
</ion-card>
</ion-slide>
<ion-slide>
<ion-card style="background-color: green; border-radius: 15px">
<ion-card-content style="font-family: sans-serif;">
<ion-row>
<ion-col col-12>
<P style="color: #9e9e9e;float: left;font-size: 15px">BALANCE BUSINESS</P>
</ion-col>
<ion-col col-12>
<H2 style="float: left;font-size: 20px">4.235632 <small>MIC</small></H2>
</ion-col>
</ion-row>
</ion-card-content>
</ion-card>
</ion-slide>
</ion-slides>
</div>
</ion-content>

unable to set header and content in the same alignment using ionic 2

I ma displaying the dynamic data into the it is displaying in the below format
here if us see the alignment between the header and content we can clearly see the mis match and in the body also i got any data with large content it is displaying in the below format
below is my html code
<ion-grid class="g-table">
<ion-row wrap>
<ion-col>
Names
</ion-col>
<ion-col>
Qty
</ion-col>
<ion-col>
Amount
</ion-col>
<ion-col text-center>
Status
</ion-col>
<ion-col>
Reason
</ion-col>
<ion-col>
Name
</ion-col>
</ion-row>
<div class="tbody">
<ion-row *ngFor="let value of Data" wrap >
<ion-col>
{{value.Name}}
</ion-col>
<ion-col>
{{value.Qty}}
</ion-col>
<ion-col>
{{value.Amount | number:'.2'}}
</ion-col>
<ion-col text-center>
{{value.Status}}
</ion-col>
<ion-col>
{{value.Reason}}
</ion-col>
<ion-col>
{{value.Name}}
</ion-col>
</ion-row>
<ion-row >
<ion-col>
Total
</ion-col>
<ion-col>
</ion-col>
<ion-col>
{{Total|number:'.2'}}
</ion-col>
<ion-col>
</ion-col>
<ion-col>
</ion-col>
<ion-col>
</ion-col>
</ion-row>

Using ng-show in ionic template

I need to show a corresponding button to my string value in JSON.
I tried to use ng-show but I see every button on my site.
<ion-col ng-show="channels.fields.status == 'on'" col-sm-1 class="verse">
<button ion-button color="secondary" class="big_on"> On </button>
</ion-col>
<ion-col ng-show="channels.fields.status == 'off'" col-sm-1 class="verse">
<button ion-button color="light" class="big_off"> Off </button>
</ion-col>
<ion-col ng-show="channels.fields.status == 'error'" col-sm-1 class="verse">
<button ion-button color="danger" class="big_error"> Error </button>
</ion-col>
Change ng-show to ng-if
Try Following code,
<ion-col ng-if="channels.fields.status == 'on'" col-sm-1 class="verse"><button ion-button color="secondary" class="big_on">On</button></ion-col>
<ion-col ng-if="channels.fields.status == 'off'" col-sm-1 class="verse"> <button ion-button color="light" class="big_off">Off</button> </ion-col>
<ion-col ng-if="channels.fields.status == 'error'" col-sm-1 class="verse"> <button ion-button color="danger" class="big_error">Error</button> </ion-col>
I haven't used ionic 2 but as far as I know, "ion-col" is part of ionic 2 which uses Angular2.
Try using *ngIf instead of ng-show. For example:
<ion-col *ngIf="channels.fields.status == 'on'" col-sm-1 class="verse <button ion-button color="secondary" class="big_on">On</button></ion-col>

How do you implement Ionic2 Virtual Scroll when you have an array of objects that have an array of objects?

Using Ionic2/Angular2 I want to use Virtual scroll to make manageable a long list of contacts in contact invite. I've tried replacing both of my *ngFor with [virtualScroll].
The array to map:
var groupedContacts = [contactObject...];
var contactObject = {letter: "a", contacts: [singleContactObject...]};
//scores or even hundreds of contacts per letter
var singleContactObject = {name: "someName", number: "somePhone"};
Original HTML
<ion-content>
<ion-item-group class="invite-sheet" *ngFor="let group of groupedContacts">
<ion-item-divider class="header-letter">{{group.letter}}</ion-item-divider>
<ion-item *ngFor="let contact of group.contacts">
<ion-row align-items-center>
<ion-col width-40>
<h4 text-wrap class="name-invite">{{contact.name}}</h4>
</ion-col>
<ion-col width-35>
<p>{{contact.number}}</p>
</ion-col>
<ion-col width-25>
<button class="inner-invite" (click)="invite(contact)">Invite</button>
</ion-col>
</ion-row>
</ion-item>
</ion-item-group>
</ion-content>
HTML attempt 1:
<ion-content>
<ion-item-group [virtualScroll] = "groupedContacts">
<ion-item-divider *virtualHeader="let group">
{{group.letter}}
</ion-item-divider>
<ion-item *ngFor="let contact of group.contacts">
<ion-row align-items-center>
<ion-col width-40>
<h4 text-wrap class="name-invite">{{contact.name}}</h4>
</ion-col>
<ion-col width-35>
<p>{{contact.number}}</p>
</ion-col>
<ion-col width-25>
<button class="inner-invite" (click)="invite(contact)">Invite</button>
</ion-col>
</ion-row>
</ion-item>
</ion-item-group>
</ion-content>
HTML attempt 2:
<ion-content>
<ion-item-group [virtualScroll] = "groupedContacts">
<ion-item-divider *virtualHeader="let group">
{{group.letter}}
</ion-item-divider>
<ion-item-group [virtualScroll]="contacts">
<ion-row align-items-center>
<ion-col width-40 *virtualItem="let contact">
<h4 text-wrap class="name-invite">{{contact.name}}</h4>
</ion-col>
<ion-col width-35 *virtualItem="let contact">
<p>{{contact.number}}</p>
</ion-col>
<ion-col width-25 *virtualItem="let contact">
<button class="inner-invite" (click)="invite(contact)">Invite</button>
</ion-col>
</ion-row>
</ion-item>
</ion-item-group>
</ion-content>
HTML attempt 3:
<ion-content>
<ion-item-group class="invite-sheet" *ngFor="let group of groupedContacts">
<ion-item-divider class="header-letter">{{group.letter}}</ion-item-divider>
<ion-item-group [virtualScroll]="group.contacts">
<ion-row align-items-center>
<ion-col width-40 *virtualItem="let contact">
<h4 text-wrap class="name-invite">{{contact.name}}</h4>
</ion-col>
<ion-col width-35 *virtualItem="let contact">
<p>{{contact.number}}</p>
</ion-col>
<ion-col width-25 *virtualItem="let contact">
<button class="inner-invite" (click)="invite(contact)">Invite</button>
</ion-col>
</ion-row>
</ion-item>
</ion-item-group>
</ion-content>
No of the attempts produced results so I must fundamentally misunderstand something.
UPDATE:
Here is what I came up with after seeing #wannadream recommendation. I get a blank screen:
<ion-content>
<ion-list [virtualScroll]="groupedContacts" approxItemHeight="50px">
<ion-item *virtualItem="#group">
<ion-item-divider class="header-letter">{{group.letter}}</ion-item-divider>
<ion-list [virtualScroll]="group.contacts" approxItemHeight="50px">
<ion-item *virtualItem="#contact">
<ion-col width-40>
<h4 text-wrap class="name-invite">{{contact.name}}</h4>
</ion-col>
<ion-col width-35>
<p>{{contact.number}}</p>
</ion-col>
<ion-col width-25>
<button class="inner-invite" (click)="invite(contact)">Invite</button>
</ion-col>
</ion-item>
</ion-list>
</ion-item>
</ion-list>
</ion-content>

`item-right` is not working inside button element of `ion-col`

I want to display name="ios-navigate" (which is showing as a navigation icon in bellow image) right side in the column partition. I have given item-right attribute to the button element inside 'ion-col' but its not working.
Its currently displaying bellow,
<ion-item>
<ion-row>
<ion-col width-33>
<button style="padding: 0px 0px;" [disabled]="!item.Website" ion-button icon-left clear item-right (click)="RedirectWebsite(item.Website)">
<ion-icon name="md-globe" item-left large></ion-icon>
WWW
</button>
</ion-col>
<ion-col width-33>
<button ion-button icon-left clear item-right [disabled]="!item.Phone" (click)="dialNumber(item.Phone)">
<ion-icon name="md-call" color="primary" item-left large></ion-icon>
Phone
</button>
</ion-col>
<ion-col width-33>
<button ion-button item-right icon-left clear (click)="GetRoute(item.geometry.location.lat,item.geometry.location.lng)">
<ion-icon icon-right name="ios-navigate" color="primary" large></ion-icon>
</button>
</ion-col>
</ion-row>
</ion-item>
Check out the latest ion-grid API based on flexbox. width-* is deprecated for col-*. Also item-left and item-right attributes work for ion-item elements.
You need to use row attributes.Try justify-content-end to align horizontally right.
<ion-row justify-content-end>
<ion-col col-4>
<button style="padding: 0px 0px;" [disabled]="!item.Website" ion-button icon-left clear (click)="RedirectWebsite(item.Website)">
<ion-icon name="md-globe" item-left large></ion-icon>
WWW
</button>
</ion-col>
<ion-col col-4>
<button ion-button icon-left clear [disabled]="!item.Phone" (click)="dialNumber(item.Phone)">
<ion-icon name="md-call" color="primary" item-left large></ion-icon>
Phone
</button>
</ion-col>
<ion-col col-4>
<button ion-button icon-left clear (click)="GetRoute(item.geometry.location.lat,item.geometry.location.lng)">
<ion-icon icon-right name="ios-navigate" color="primary" large></ion-icon>
</button>
</ion-col>
</ion-row>