Commit d6fb23c5 authored by achinta's avatar achinta

add: safe space for android and ios

parent 325a1ffa
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
"@capacitor/angular": "^2.0.3", "@capacitor/angular": "^2.0.3",
"@capacitor/app": "^7.0.1", "@capacitor/app": "^7.0.1",
"@capacitor/core": "latest", "@capacitor/core": "latest",
"capacitor-plugin-safe-area": "^4.0.0",
"rxjs": "~7.8.0", "rxjs": "~7.8.0",
"tslib": "^2.3.0", "tslib": "^2.3.0",
"zone.js": "~0.15.0" "zone.js": "~0.15.0"
...@@ -7132,6 +7133,15 @@ ...@@ -7132,6 +7133,15 @@
], ],
"license": "CC-BY-4.0" "license": "CC-BY-4.0"
}, },
"node_modules/capacitor-plugin-safe-area": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/capacitor-plugin-safe-area/-/capacitor-plugin-safe-area-4.0.0.tgz",
"integrity": "sha512-5VHT4wG2TlwHtyy3zKrAjKwgJQgC3KeMfRW1bc8abTETLYNLxb85zvfpA0QFE59BxbtYHD57GvXKJuUPgEHl3g==",
"license": "MIT",
"peerDependencies": {
"@capacitor/core": ">=7.0.0"
}
},
"node_modules/chalk": { "node_modules/chalk": {
"version": "4.1.2", "version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
......
...@@ -2,5 +2,6 @@ ...@@ -2,5 +2,6 @@
<br/> <br/>
<button [routerLink]="['portal']">dashboard</button> <button [routerLink]="['ad']">access denied</button> <button [routerLink]="['portal']">dashboard</button> <button [routerLink]="['ad']">access denied</button>
<button (click)="toggleTheme()">Toggle Theme</button> --> <button (click)="toggleTheme()">Toggle Theme</button> -->
<div class="content-container">
<router-outlet /> <router-outlet />
</div>
...@@ -6,6 +6,10 @@ import { isPlatformBrowser } from '@angular/common'; ...@@ -6,6 +6,10 @@ import { isPlatformBrowser } from '@angular/common';
import { filter } from 'rxjs'; import { filter } from 'rxjs';
import { App } from '@capacitor/app'; import { App } from '@capacitor/app';
// import { Platform } from '@ionic/angular';
import { SafeArea } from 'capacitor-plugin-safe-area';
import { Capacitor } from '@capacitor/core';
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
imports: [RouterOutlet, RouterModule], imports: [RouterOutlet, RouterModule],
...@@ -28,7 +32,7 @@ export class AppComponent implements OnInit { ...@@ -28,7 +32,7 @@ export class AppComponent implements OnInit {
public ngOnInit(): void { public ngOnInit(): void {
this.applySafeAreaInsets();
this.router.events.pipe( this.router.events.pipe(
filter(event => event instanceof NavigationEnd) filter(event => event instanceof NavigationEnd)
).subscribe((event: any) => { ).subscribe((event: any) => {
...@@ -49,4 +53,29 @@ export class AppComponent implements OnInit { ...@@ -49,4 +53,29 @@ export class AppComponent implements OnInit {
// Custom function to execute on route change // Custom function to execute on route change
this._themeService.updateSidebarState(false); this._themeService.updateSidebarState(false);
} }
async applySafeAreaInsets() {
const platform = Capacitor.getPlatform();
if (platform === 'ios' || platform === 'android') {
try {
const { insets } = await SafeArea.getSafeAreaInsets();
document.documentElement.style.setProperty('--safe-area-top', `${insets.top}px`);
document.documentElement.style.setProperty('--safe-area-bottom', `${insets.bottom}px`);
document.documentElement.style.setProperty('--safe-area-left', `${insets.left}px`);
document.documentElement.style.setProperty('--safe-area-right', `${insets.right}px`);
} catch (error) {
console.warn('SafeArea plugin failed on iOS:', error);
}
} else {
// Android or web fallback
document.documentElement.style.setProperty('--safe-area-top', '24px');
document.documentElement.style.setProperty('--safe-area-bottom', '16px');
document.documentElement.style.setProperty('--safe-area-left', '0px');
document.documentElement.style.setProperty('--safe-area-right', '0px');
}
}
} }
import { NgOptimizedImage } from '@angular/common'; // import { NgOptimizedImage } from '@angular/common';
import { Component, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
@Component({ @Component({
selector: 'app-colored-card', selector: 'app-colored-card',
imports: [ imports: [
NgOptimizedImage,
RouterModule RouterModule
], ],
templateUrl: './colored-card.component.html', templateUrl: './colored-card.component.html',
......
...@@ -63,11 +63,11 @@ body { ...@@ -63,11 +63,11 @@ body {
} }
.top_yellow_line { // .top_yellow_line {
width: 100%; // width: 100%;
height: 40px; // height: 40px;
background-color: #FFBF00; // background-color: #FFBF00;
} // }
.mat-mdc-form-field{ .mat-mdc-form-field{
...@@ -81,3 +81,10 @@ body { ...@@ -81,3 +81,10 @@ body {
color: var(--accent-color) !important; color: var(--accent-color) !important;
} }
} }
.content-container {
padding-top: var(--safe-area-top);
padding-bottom: var(--safe-area-bottom);
padding-left: var(--safe-area-left);
padding-right: var(--safe-area-right);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment