I've inherited an existing Angular application that uses Ionic Framework (in the past it was used for web and mobile, so that's why they choose to use Ionic Framework), btw now I need to extend the version that's used in the web version and using the popover what happens is that I'm unable to show it with a larger width than the space occupied from where it's opened.
You can see what happens in the this image
What I need to achieve is something like this mockup, as you can see it has a "div" that extends on the right, and what I need is to show the date picker side by side (If I'll be able to take space I need)
Here's the code, starting from the main page
<ion-grid>
<ion-row>
<ion-col size=2>
<button (click)="onDetailPageOpen();" class="scheduleButton">
Schedule<mat-icon>list</mat-icon></button>
</ion-col>
<ion-col size=2>
<button expand="full" (click)="presentPopover($event)" class="advancedSearchButton">
Advanced Search<mat-icon>tune</mat-icon>
</button >
</ion-col>
<ion-col size=4>
<input type="text" class="searchHere" placeholder="Search here" [(ngModel)]="SearchService.SearchText" />
</ion-col>
<ion-col size=1 style="padding-left: 135px;">
<button routerLink="#" class="searchButton">
<mat-icon>search</mat-icon>
</button>
</ion-col>
<ion-col size=>
</ion-col>
</ion-row>
</ion-grid>
Then the presentPopover method
async presentPopover(ev: any) {
const popover = await this.popoverController.create({
component: PopoverComponent,
componentProps: {},
event: ev,
// translucent: true
});
await popover.present();
}
and finally the PopOverControl with the buttons
<ion-grid class="ionGrid">
<ion-row>
<ion-col size="2">
<ion-button (click)="dateFilterPopover($event)">
<span class="material-icons icon">
<span class="material-icons-outlined">
date_range
</span>
</span>
</ion-button>
</ion-col>
<ion-col size="2"></ion-col>
<ion-col size="2">
<ion-button (click)="userSortPopover($event)">
<span class="material-icons icon">
person
</span>
</ion-button>
</ion-col>
<ion-col size="2"></ion-col>
<ion-col size="2">
<ion-button>
<span class="material-icons iconRef">
refresh
</span>
</ion-button>
</ion-col>
</ion-row>
</ion-grid>
Then the dateFilterPopOver
async dateFilterPopover(ev: any) {
const popover = await this.popoverController.create({
component: PopoverDateComponent,
componentProps: {},
event: ev,
translucent: true
});
await popover.present();
}
and the 2 datepicker at the end
<ion-item>
<ion-label>Date From</ion-label>
<ion-datetime
pickerFormat="MMM YYYY"
displayFormat="MMM YYYY"
[(ngModel)]="searchService.SearchDateFrom">
</ion-datetime>
</ion-item>
<ion-item>
<ion-label>Date To</ion-label>
<ion-datetime
pickerFormat="MMM YYYY"
displayFormat="MMM YYYY"
[(ngModel)]="searchService.SearchDateTo">
</ion-datetime>
</ion-item>
Any help please?
Thanks
Related
I'm doing a small UI with ionic, and I'm looking about the css utilities(https://ionicframework.com/docs/layout/css-utilities ).
I've this UI:
<ion-item>
<ion-grid >
<ion-row class="ion-align-items-center">
<ion-col size="4" class="ion-text-center">
<ion-avatar ><ion-img [src]="(loggedUser$ | async).avatarUrl"></ion-img></ion-avatar>
</ion-col>
<ion-col size="8" >
<ion-label >
<h2>{{ (loggedUser$ | async).userId }}</h2>
</ion-label>
</ion-col>
</ion-row>
</ion-grid>
</ion-item>
but currently, the ion-avatar is on the left of his ion-col.
Is there a way with those Ionic css utilities to center the ion-avatar in the middle of the column?
You need to add an extra div as shown.
From what I have seen the reason is how ionic framework creates the shadow dom. If you don't explicitly add the div to which to add the CSS util, ionic applies it in the wrong spot.
<ion-item>
<ion-grid >
<ion-row class="ion-align-items-center">
<ion-col size="4">
<div class="ion-text-center">
<ion-avatar ><ion-img [src]="(loggedUser$ | async).avatarUrl"></ion-img></ion-avatar>
</div>
</ion-col>
<ion-col size="8" >
<ion-label>
<h2>{{ (loggedUser$ | async).userId }}</h2>
</ion-label>
</ion-col>
</ion-row>
</ion-grid>
</ion-item>
I am trying to create a contact list on Ionic 5, using angular, but it is not possible to access this style. I'm a beginner at IONIC, can you help me?
How to leave a rendered image at the beginning of the card, with a icon and header and a icon with subheader, as in the image below?
my image:
my code:
<ion-content padding>
<ion-card>
<ion-grid>
<ion-row>
<ion-col>
<img src="https://material.angular.io/assets/img/examples/shiba1.jpg" style="border-radius: 50%; width: 80%; height: 85%">
</ion-col>
<ion-col>
<ion-item>
<h2>Marty McFly</h2>
</ion-item>
<ion-card-content>
<p>Wait a minute. Wait a minute, Doc. Uhhh</p>
</ion-card-content>
</ion-col>
</ion-row>
</ion-grid>
</ion-card>
</ion-content>
Thanks =)
You could just use a list of ion-items. They provide a round avatar to start the item, followed with a label which you can modify to sample your desired outcome.
<ion-content>
<ion-list>
<ion-item *ngFor="your loop here">
<ion-avatar slot="start">
<img src="...">
</ion-avatar>
<ion-label>
<ion-grid>
<ion-row>
<ion-col size="12">
<!-- name -->
</ion-col>
</ion-row>
<ion-row>
<ion-col size="2">
<!-- icon -->
</ion-col>
<ion-col size="10">
<!-- calender -->
</ion-col>
</ion-row>
<ion-row>
<ion-col size="2">
<!-- icon -->
</ion-col>
<ion-col size="10">
<!-- time -->
</ion-col>
</ion-row>
</ion-grid>
</ion-label>
</ion-item>
</ion-list>
</ion-content>
I have created a simple chat form in Ionic.
Problem: Buttons are going out of screen.
It looks like this this -
My chat.html
<ion-header>
<ion-navbar>
<ion-title>communicationgiven</ion-title>
<button ion-button (click)="close()" style="margin-left: 90%;margin-top: -3%">Close</button>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-list>
<div>
<p *ngFor="let list of list; let i = index;">
<ion-item>
<!-- <p style="color: #1bb0f4;font-size: 20px;">Tagto {{list.TAG_TO}}</p> -->
<p style="color: #1bb0f4;"> {{list.TAG_FROM}}</p>
<p style="color: #d2dce1;"> {{list.TAG}}</p>
</ion-item>
</p>
</div>
</ion-list>
</ion-content>
<ion-footer class="footer">
<form #com="ngForm" (submit)="onsubmit(com.value)">
<ion-input placeholder="TAG" type="text" name="TAG" ngModel ></ion-input>
<button ion-button type="submit" style="margin-left: 90%;margin-top: -5%;">Submit</button>
</form>
</ion-footer>
I want to know why my buttons are going out of the page; how can I make sure they stay inside the screen, irrespective of the screen size?
What is the best practice here? I am fairly new in CSS.
You have to use below code for left button
<ion-header>
<ion-navbar>
<button ion-button icon-only menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
<ion-title>
Page Title
</ion-title>
<ion-buttons end>
<button ion-button icon-only (click)="openModal()">
<ion-icon name="options"></ion-icon>
</button>
</ion-buttons>
</ion-navbar>
</ion-header>
For footer you can use ion-grid
<ion-footer class="footer">
<form #com="ngForm" (submit)="onsubmit(com.value)">
<ion-grid>
<ion-row>
<ion-col col-9>
<ion-input placeholder="TAG" type="text" name="TAG" ngModel ></ion-input>
</ion-col>
<ion-col col-3>
<button ion-button type="submit">Submit</button>
</ion-col>
</ion-row>
</ion-grid>
</form>
</ion-footer>
For more info please refer this
https://ionicframework.com/docs/api/components/toolbar/Navbar/
you had given style="margin-left: 90% that is margin from left side is 90% so obviously it will go out of screen, try to decrease the value.
It's hard to answer this one as I can't replicate the issue locally with what you've provided.
I'd start by reducing the margin-left: 90% on the button element, see how that goes.
In regard to best practices, an important one is to not use inline styles. That is putting styles in the style html attribute. Instead try using an external style sheet or at least an internal style sheet, see: https://www.w3schools.com/css/css_howto.asp
I have a form that gets visible when a button is clicked. I also have multiple input tags inside that form. When I type data on to the first input, it is visible but 2nd and 3rd input tags get hidden under the keyboard.
<div class="showmodal" *ngIf="formDisplay">
<div class="containdiv">
<ion-row class="milkColor">
<ion-label style="padding-left: 5%;">Add New Contact </ion-label>
<ion-icon class="iconPad" name="close" (click)="cancel()" > </ion-icon>
</ion-row>
<form #form="ngForm" (ngSubmit)="logForm(form)" novalidate>
<ion-row>
<ion-col>
<ion-label text-right> <b>Name :</b> </ion-label>
</ion-col>
<ion-col>
<ion-input [value]="name" name="name" [(ngModel)]="name" type="text" placeholder="Contact Name" required></ion-input>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-label text-right> <b>Occupation :</b> </ion-label>
</ion-col>
<ion-col>
<ion-input [value]="service" name="service" [(ngModel)]="service" type="text" placeholder="Occupation" required></ion-input>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<ion-label text-right > <b>Contact No. :</b> </ion-label>
</ion-col>
<ion-col>
<ion-input [value]="number" name="number" [(ngModel)]="number" type="number" placeholder="Number" required></ion-input>
</ion-col>
</ion-row>
<ion-row >
<ion-col text-center>
<button [disabled]=!form.valid class="textLower" ion-button type="submit" value="Submit" >Submit</button>
</ion-col>
</ion-row>
</form>
</div>
</div>
and in my css
.showmodal {
position: fixed;
top: 0;
height: 100%;
width: 100%;
background: rgba(23, 22, 22, 0.2);
z-index: 10;
left: 0px;
}
.showmodal .containdiv {
background: white;
margin-top:52%;
min-height:30%;
overflow:auto;
margin: 150px 20px 0 17px;
}
I need all 3 inputs to be visible when that form arrives, and if I have more than 3 input tags, I should able to scroll the list of inputs
Can someone help me??
On the button (click) event where you set formDisplay to true to show the form, add scroll so the form content will go up a little and the inputs will show up higher on the screen and not hidden by the keyboard.
Something as the following:
HTML
<button ....(click)="displayForm()"...>Display Form</form>
Typescript
displayForm(){
...
this.displayForm=true;
window.scroll(0, 100); // or an other number of pixels enough to display
...
}
I'm using Ionic 3 flexbox grid system as shown below.This is a Modal `controller.
.html
<ion-content class="content">
<ion-grid no-padding>
<ion-row class="header">
</ion-row>
<ion-row padding class="details">
<ion-col>
<form [formGroup]="forgotPasswordForm" (submit)="goToNext()" novalidate>
<ion-item>
<ion-label>
<ion-icon name="person"></ion-icon>
</ion-label>
<ion-input type="text" placeholder="Distributor ID" formControlName="distributorId"></ion-input>
</ion-item>
<button ion-button block class="button-radius-25" type="submit"><span>Next <ion-icon name="arrow-round-forward"></ion-icon></span></button>
<ion-item no-lines>
<ion-label class="font-size-14" text-center>Not a member? Sign up now!</ion-label>
</ion-item>
</form>
</ion-col>
</ion-row>
</ion-grid>
</ion-content>
.scss
.content {
ion-grid {
height: 100%;
}
.header {
flex: 1;
}
.details {
flex: 3;
}
}
Mobile device - No issues
But on the desktop, it shows as below.
Q: It seems very bad on a larger device.How can I keep the same kind of ratio (I mean small sizes on components for Button and textbox) and centered the content on the larger device too? Hope you'll give the suggestions for this.
You can use col-sm-, col-md-... to change item size in different screen size:
<ion-row padding class="details">
<ion-col col-lg-6 col-md-6 col-12>
<form [formGroup]="forgotPasswordForm" (submit)="goToNext()" novalidate>
<ion-item>
<ion-label>
<ion-icon name="person"></ion-icon>
</ion-label>
<ion-input type="text" placeholder="Distributor ID" formControlName="distributorId"></ion-input>
</ion-item>
<button ion-button block class="button-radius-25" type="submit"><span>Next <ion-icon name="arrow-round-forward"></ion-icon></span></button>
<ion-item no-lines>
<ion-label class="font-size-14" text-center>Not a member? Sign up now!</ion-label>
</ion-item>
</form>
</ion-col>
</ion-row>
and to center item:
.details{
justify-content: center;
}
See more about ionic grid