tabs doesnt get fixed in ionic inside ion-content - tabs

I have been trying making ion-tabs fixed inside ion-content but it hardly seems posssible. So is there any way of making tabs fixed inside a scollable content in ionic?
$( "ion-content" ).scroll(function() {
var scrollWidth = $(".main-content").height()-$(".header-bar").height();
if (parseInt($(this).scrollTop()) > scrollWidth ) {
$("#fixedAboutTabs").addClass("fixed");
});
}
else {
$("#fixedAboutTabs").removeClass("fixed");
});
.fixed{
left: 0;
top:44px;
position: fixed;
z-index:100;
width: 100%;
}
<ion-view>
<div class="header-bar">
<button class="button button-clear arrow-btn" ng-click="goBack()"> <img src="img/arrow.png" class="arrow-img"> </button>
<h1 class="title">{{product.productName}}</h1>
</div>
<ion-content on-scroll="onScroll()" overflow-scroll="true" has-bouncing="false">
<div class="main-content">
<img src="img/video.png" class="video-img">
<div class="product-info">
//some content here
</div> <!--product info closes -->
</div> <!--main content closes-->
<div id="staticAboutTabs" class="demo-tabs">
<ul>
//customized tabs (want to make this tabs fixed bewlow header-bar)
</ul>
</div>
</ion-content>
</ion-view>
Instead of ion-tabs i have used my own customized tabs. let me know if the ion-tabs or any custom made tabs can be fixed inside scrollable ion-content

Try this by placing the to-be-fixed content inside <div slot="fixed"> </div>
<ion-content>
<div slot="fixed">
<ion-tabs #tabs tabsPlacement="top">
<ion-tab-bar slot="top" tabsHighlight="true">
<ion-tab-button tab="tab1">
<ion-label>Tab1</ion-label>
</ion-tab-button>
<ion-tab-button tab="tab2">
<ion-label>Tab2</ion-label>
</ion-tab-button>
</ion-tab-bar>
</ion-tabs>
</div>
</ion-content>

Related

Hide div when add items - ionic framework

Im trying to hide specific div (empty state) when i add some item from add button, any ideas how can i do that easily?
Best Regards, Will.
page.html
<ion-content>
<!-- DIV ABOVE -->
<div class="center-div">
<img src="assets/imgs/noItem.svg" />
<div class="center">
<h1>Empty List</h1>
</div>
</div>
<ion-refresher (ionRefresh)="doRefresh($event)">
<ion-refresher-content pullingIcon="arrow-dropdown" pullingText="Pull to refresh" refreshingSpinner="circles" refreshingText="Refreshing...">
</ion-refresher-content>
</ion-refresher>
<ion-list>
<button *ngFor="let item of items" ion-item (click)="goToItemDetail(crop)">
...
</ion-list>
<ion-fab right bottom>
<button ion-fab class="button-fab" (click)="addItem()">
<ion-icon name="add"></ion-icon>
</button>
</ion-fab>
</ion-content>
Yes, you can hide div with the help of *ngIf="condition"
<div class="center" *ngIf="items">
<h1>Empty List</h1>
</div>
or you can also check boolean varible on button like
// isVisible: boolean
addItem() {
this.isVisible = false;
}
<div class="center" *ngIf="!isVisible">
<h1>Empty List</h1>
</div>

Ionic: position button from bottom

In ionic how can i put a button at some percentage from the bottom ion-content?
I've tried
<ion-view>
<ion-content>
<div class="button-bottom">
<button class="button button-block button-energized">Button</button>
</div>
</ion-content>
</ion-view>
css:
.button-bottom{
position: absolute;
bottom: 30%;
}
but the button now not take the full width.
Try giving your container an explicit width:
.button-bottom{
position: absolute;
bottom: 30%;
width: 100%;
}
Add "full" variable in your button
Ex:- button class="button button-block button-energized" full >Button</button>
For more reference see Ionic Documentation on UI Components in the link below.
Ionic Full Button
Just move the button to outside of the ion-content.
Example:
Ionic 3:
<ion-view>
<ion-content>
</ion-content>
<div class="button-bottom">
<button class="button button-block button-energized">Button</button>
</div>
</ion-view>
Ionic 4:
<ion-header>
<ion-toolbar>
<ion-title>Example</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<p> your content </p>
</ion-content>
<ion-row>
<ion-col>
<ion-button>
Button Bottom (Not fixed on scroll)
</ion-button>
</ion-col>
</ion-row>

How to make an Image grid with two images in each row in ionic framework without flex-wrap:wrap;

I want to make a grid in which i want to two images in each row. I am using flex-wrap: wrap; it is working fine on android 4.4+ but not working with less than android 4.4. I want to achieve this with out using flex-wrap
Here is my view:
<ion-view class="feeds-categories-view">
<ion-nav-buttons side="left">
<button menu-toggle="left" class="button button-icon icon ion-navicon"> </button>
</ion-nav-buttons>
<ion-nav-title>
<span>Feeds Categories</span>
</ion-nav-title>
<ion-content scroll="true" class="has-header has-subheader">
<div class="row-cat row">
<div class="col col-50" ng-repeat="items in ProductList">
<img ng-src="{{items.image}}" width="100%" />
</div>
</div>
</ion-content>
</ion-view>
Controller:
.controller('Home-FeedsCtrl', function($scope) {
$scope.ProductList = [
{"id":"1","text":"product","image":"http://g03.a.alicdn.com/kf/HTB1KjhsLXXXXXXgXpXXq6xXFXXXp/HOT-Hybrid-Silicone-Smooth-Hard-Rubber-Phone-Case-For-font-b- iPhone-b-font-5-5G.jpg"},
{"id":"2","text":"product","image":"http://g03.a.alicdn.com/kf/HTB1KjhsLXXXXXXgXpXXq6xXFXXXp/HOT-Hybrid-Silicone-Smooth-Hard-Rubber-Phone-Case-For-font-b- iPhone-b-font-5-5G.jpg"},
{"id":"3","text":"product","image":"http://g03.a.alicdn.com/kf/HTB1KjhsLXXXXXXgXpXXq6xXFXXXp/HOT-Hybrid-Silicone-Smooth-Hard-Rubber-Phone-Case-For-font-b- iPhone-b-font-5-5G.jpg"},
{"id":"4","text":"product","image":"http://g03.a.alicdn.com/kf/HTB1KjhsLXXXXXXgXpXXq6xXFXXXp/HOT-Hybrid-Silicone-Smooth-Hard-Rubber-Phone-Case-For-font-b- iPhone-b-font-5-5G.jpg"},
{"id":"5","text":"product","image":"http://g03.a.alicdn.com/kf/HTB1KjhsLXXXXXXgXpXXq6xXFXXXp/HOT-Hybrid-Silicone-Smooth-Hard-Rubber-Phone-Case-For-font-b- iPhone-b-font-5-5G.jpg"},
{"id":"6","text":"product","image":"http://g03.a.alicdn.com/kf/HTB1KjhsLXXXXXXgXpXXq6xXFXXXp/HOT-Hybrid-Silicone-Smooth-Hard-Rubber-Phone-Case-For-font-b- iPhone-b-font-5-5G.jpg"},
{"id":"7","text":"product","image":"http://g03.a.alicdn.com/kf/HTB1KjhsLXXXXXXgXpXXq6xXFXXXp/HOT-Hybrid-Silicone-Smooth-Hard-Rubber-Phone-Case-For-font-b- iPhone-b-font-5-5G.jpg"},
{"id":"8","text":"product","image":"http://g03.a.alicdn.com/kf/HTB1KjhsLXXXXXXgXpXXq6xXFXXXp/HOT-Hybrid-Silicone-Smooth-Hard-Rubber-Phone-Case-For-font-b- iPhone-b-font-5-5G.jpg"},
{"id":"9","text":"product","image":"http://g03.a.alicdn.com/kf/HTB1KjhsLXXXXXXgXpXXq6xXFXXXp/HOT-Hybrid-Silicone-Smooth-Hard-Rubber-Phone-Case-For-font-b- iPhone-b-font-5-5G.jpg"},
]
})
Stylesheet:
.cat-img-box{
width: 50%
}
.row-cat{
margin-top: 15px !important;
flex-wrap: wrap !important;
}
.col-cat{
padding: 20px !important;
}
<div ng-repeat="(key, image) in images">
<div class="row" ng-show="$even">
<div class="col"><img src="images[$index]"></div>
<div class="col"><img src="images[$index+1]"></div>
</div>
</div>
Shis could work.
reference:
Create Row every after 2 item in Angular ng-repeat - Ionic Grid
Put this css into your css file.
.row .col:nth-child(2n+1){float:none;}
This will make the float none after 2nd element of the loop.

Ionic subheader bar overlapping content

In a view with header and subheader, subheader content overlaps the contents of the view.
Header in slide menu
<ion-nav-buttons side="left">
<button class="button button-icon button-clear ion-navicon" menu-toggle="left" ng-hide="$exposeAside.active"></button>
</ion-nav-buttons>
</ion-nav-bar>
<ion-nav-view name="menuContent" animation="slide-left-right"></ion-nav-view>
Subheader in a view
<ion-header-bar align-title="center" class="bar bar-subheader custom bar-energized" ng-if="datos.subTitulo">
<div class="buttons">
<a class="ion-chevron-left" href="#/app/ranking/ubicacion/{{datos.divAnt}}" ng-if="datos.divAnt"></a>
</div>
<h2 class="subtitle">{{datos.subTitulo}}</h2>
<div class="buttons">
<a class="ion-chevron-right" href="#/app/ranking/ubicacion/{{datos.divSig}}" ng-if="datos.divSig"></a>
</div>
</ion-header-bar>
Div buttons in subheader overlapping content, h2 show 100%.
Something is missing in this code? Thanks
[EDIT]
Rewrote the code to suit my needs: subheader smaller than the header with two links in the corners and a title.
<ion-header-bar align-title="center" class="bar-subheader subheader_custom bar-energized">
<div class="button button-clear">
<a class="icon ion-ios-arrow-back blanco" href="#/app/ranking/ubicacion/{{datos.divAnt}}" ng-if="datos.divAnt"></a>
</div>
<div class="h2 title title_custom">{{datos.subTitulo}}</div>
<div class="button button-clear">
<a class="icon ion-ios-arrow-forward blanco" href="#/app/ranking/ubicacion/{{datos.divSig}}" ng-if="datos.divSig"></a>
</div>
</ion-header-bar>
Add this css:
.has-subheader {
top: 70px;
}
.bar-subheader.subheader_custom {
display: block;
height: 26px;
top: 44px;
}
.title.title_custom {
font-size: 16px;
font-weight: 300;
height: 20px;
left: 0;
line-height: 20px;
margin: 2px 10px 2px 10px;
min-width: 24px;
overflow: hidden;
position: absolute;
right: 0;
text-align: center;
text-overflow: ellipsis;
top: 0;
white-space: nowrap;
z-index: 0;
}
Even buttons are not in line with the subheader title. Any ideas?
New status:
Make sure that the content view knows it needs to leave space for the subheaders by adding the CSS class has-subheader:
<ion-content class="has-header has-subheader">
</ion-content>
See http://ionicframework.com/docs/components/#subheader
If you face this issue in Android, then use the following
.platform-android .bar-subheader {
top: 93px;
}
https://forum.ionicframework.com/t/sub-header-not-showing-on-android-with-tabs/15341/18
You can easily change the height of the subheader, footer, and subfooter if you are using SASS with Ionic. If you want a 70px tall subheader simply add $bar-subheader-height: 70px; to your ionic.app.scss file. Your scss file should look something similar to:
// The path for our ionicons font files, relative to the built CSS in www/css
$ionicons-font-path: "../lib/ionic/fonts" !default;
$bar-subheader-height: 70px;
// Include all of Ionic
#import "www/lib/ionic/scss/ionic";
Check out the www/lib/ionic/scss/_variables.scss file for some of the other things you can change easily.
Here are instructions for setting up sass with ionic and here is a quick tutorial.
You can add has-header or has-subheader class to your main content in ion-content directive.
Here's my code:
<ion-view view-title="View Title">
<ion-content>
<div class="bar bar-header">
<h2 class="title">Sub Header</h2>
</div>
<div class="list has-header">
<a class="item item-icon-left" href="#">
<i class="icon ion-email"></i>
Check mail
</a>
<a class="item item-icon-left item-icon-right" href="#">
<i class="icon ion-chatbubble-working"></i>
Call Ma
<i class="icon ion-ios-telephone-outline"></i>
</a>
</div>
</ion-content>
</ion-view>
<div class="list has-header"> I add the has-header class to my list to avoid subheader overlapping

Embed content of a html file to another html page using the Ionic framework?

I”m currently creating a website using the Ionic framework that has a sidebar on the left side. Users can click on an item to go to another page of the website.
Now I have to copy the code of the sidebar to every page and that's useless and not the way to go.
So my question is if it is possible to "embed" a html page in a specific section of another page.
For example I could have my sidebar be "static" and load in a login.html file in a specific div.
And having one html file with all the pages would be very hard to maintain and organise.
Is that possible in some kind of way?
EDIT: As requesting, I'm adding the most relevant code I already have
<ion-side-menus>
<!-- Main page-->
<ion-side-menu-content>
<ion-header-bar class="bar-dark">
<!-- Knop toggleSidebar -->
<button class="button button-icon" ng-click="triggerSidebar()">
<i class="icon ion-navicon"></i>
</button>
<h1 class="title">Proof of concept</h1>
</ion-header-bar>
<ion-content>
<div class="row">
<div class="col" col-50>5 + 8 = </div>
<div class="col" col-25><input type="number" placeholder="13"></div>
<div class="col" col-25><button class="button button-small">Controleer</button></div>
</div>
</ion-content>
</ion-side-menu-content>
<!-- End Main page -->
<!-- Sidebar -->
<ion-side-menu side="left">
<ion-header-bar class="bar-dark">
<h1 class="title">Sidebar</h1>
</ion-header-bar>
<ion-content>
<div class="item item-divider">Settings</div>
<a class="item" href="profiles.html"><i class="icon ion-person"></i> Profiles<span class="item-note">Freddy</span></a>
<a class="item" href="#"><i class="icon ion-information-circled"></i> About</a>
<a class="item" href="#"><i class="icon ion-android-mail"></i> Contact</a>
</div>
</ion-content>
</ion-side-menu>
<!-- End sidebar -->
What I'm trying to reach is, when someone clicks on the "profiles" option, the content of the main page gets switched with content taken from another html file
You can solve it using angular UI-routing:
$stateProvider
.state("menu", {
url: "/menu",
abstract: true,
templateUrl: "views/menu.html"
})
.state('menu.combinedPage1', {
url: '/combinedPage1',
views: {
"EmbeddedContent": {
templateUrl: "views/embedded1.html",
controller: "EmbeddedController1"
}
}
})
.state('menu.combinedPage2', {
url: '/combinedPage2',
views: {
"EmbeddedContent": {
templateUrl: "views/embedded2.html",
controller: "EmbeddedController2"
}
}
})
Here "menu" is abstract state and contains embedded views that controlled by router.
<ion-side-menus>
<ion-side-menu-content>
<ion-nav-view name="EmbeddedContent"></ion-nav-view>
</ion-side-menu-content>
</ion-side-menus>
You can do it by using frames :) with only html the following code will help
<html>
<head>
<title>Multiple Pages</title>
</head>
<FRAMESET cols="20%, 80%">
<FRAME SRC="sidebar.html">
<FRAME SRC="content.html">
</FRAMESET>
</html>
also you can do it with php like this
#side_bar{
background-color: red;
width: 200px;
height: 100%;
float: left;
}
<div id="side_bar">
<?php
include_once('sidebar.html');
?>
</div>
You can make a link so when they click on the "profiles" it goes to another page and then you can put the code for your sidebar in a php document and use a php include tag to show it in the new page. See the example below:
sidebarCode.php:
<ion-side-menu side="left">
<ion-header-bar class="bar-dark">
<h1 class="title">Sidebar</h1>
</ion-header-bar>
<ion-content>
<div class="item item-divider">Settings</div>
<a class="item" href="profiles.html"><i class="icon ion-person"></i> Profiles<span class="item-note">Freddy</span></a>
<a class="item" href="#"><i class="icon ion-information-circled"></i> About</a>
<a class="item" href="#"><i class="icon ion-android-mail"></i> Contact</a>
</div>
</ion-content>
The new page:
<!--Specific Did You Want-->
<div>
<?php include 'sidebarCode.php';?>
</div>
Inside <ion-side-menu-content> you can load scripts via the ui router.
So what you can do is when a user clicks on a menu item, you store the page HTML as template using $templatecache and then just reload your view inside <ion-side-menu-content> that will do your job !