@sumaris-net/ngx-components 18.22.28 → 18.22.29-alpha1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -145,9 +145,10 @@ import * as i4$1 from 'ionic-cache';
145
145
  import { CacheModule } from 'ionic-cache';
146
146
  import * as i13$1 from '@awesome-cordova-plugins/downloader/ngx';
147
147
  import { NotificationVisibility } from '@awesome-cordova-plugins/downloader/ngx';
148
- import { StatusBar, Style } from '@capacitor/status-bar';
148
+ import { Style, StatusBar } from '@capacitor/status-bar';
149
149
  import { Browser } from '@capacitor/browser';
150
150
  import { Clipboard } from '@capacitor/clipboard';
151
+ import { EdgeToEdge } from '@capawesome/capacitor-android-edge-to-edge-support';
151
152
  import * as i2$6 from '@angular/cdk/platform';
152
153
  import * as i3$5 from '@angular/cdk/clipboard';
153
154
  import { select } from '@rx-angular/state/selections';
@@ -6760,6 +6761,7 @@ class CapacitorPlugins {
6760
6761
  static Camera = 'Camera';
6761
6762
  static StatusBar = 'StatusBar';
6762
6763
  static Keyboard = 'Keyboard';
6764
+ static EdgeToEdge = 'EdgeToEdge';
6763
6765
  //static readonly BarcodeScanner = 'BarcodeScanner';
6764
6766
  static isAvailable = Capacitor.isPluginAvailable;
6765
6767
  }
@@ -25461,21 +25463,99 @@ class PlatformService extends StartableService {
25461
25463
  console.error('[platform] Unable to copy to clipboard: ' + data);
25462
25464
  }
25463
25465
  }
25466
+ async updateTheme(options) {
25467
+ if (!options)
25468
+ return;
25469
+ const style = document.documentElement.style;
25470
+ // options.colors = {
25471
+ // ...options.colors,
25472
+ // primary: '#124541',
25473
+ // };
25474
+ // Set colors
25475
+ if (options.colors) {
25476
+ console.info('[platform] Changing theme colors ', options.colors);
25477
+ // Add 100 & 900 color for primary and secondary color
25478
+ ['primary', 'secondary'].forEach((colorName) => {
25479
+ const color = options.colors[colorName];
25480
+ options.colors[colorName + '100'] = (color && mixHex('#ffffff', color, 10)) || undefined;
25481
+ options.colors[colorName + '900'] = (color && mixHex('#000000', color, 12)) || undefined;
25482
+ });
25483
+ Object.getOwnPropertyNames(options.colors).forEach((colorName) => {
25484
+ // Remove existing value
25485
+ style.removeProperty(`--ion-color-${colorName}`);
25486
+ style.removeProperty(`--ion-color-${colorName}-rgb`);
25487
+ style.removeProperty(`--ion-color-${colorName}-contrast`);
25488
+ style.removeProperty(`--ion-color-${colorName}-contrast-rgb`);
25489
+ style.removeProperty(`--ion-color-${colorName}-shade`);
25490
+ style.removeProperty(`--ion-color-${colorName}-tint`);
25491
+ // Set new value, if any
25492
+ const color = options.colors[colorName];
25493
+ if (isNotNilOrBlank(color)) {
25494
+ // Base color
25495
+ style.setProperty(`--ion-color-${colorName}`, color);
25496
+ style.setProperty(`--ion-color-${colorName}-rgb`, hexToRgbArray(color).join(', '));
25497
+ // Contrast color
25498
+ const contrastColor = getColorContrast(color, true);
25499
+ style.setProperty(`--ion-color-${colorName}-contrast`, contrastColor);
25500
+ style.setProperty(`--ion-color-${colorName}-contrast-rgb`, hexToRgbArray(contrastColor).join(', '));
25501
+ // Shade color
25502
+ style.setProperty(`--ion-color-${colorName}-shade`, getColorShade(color));
25503
+ // Tint color
25504
+ style.setProperty(`--ion-color-${colorName}-tint`, getColorTint(color));
25505
+ }
25506
+ });
25507
+ }
25508
+ // Set CSS vars
25509
+ if (options.vars) {
25510
+ console.info('[platform] Changing theme vars ', options.vars);
25511
+ Object.getOwnPropertyNames(options.vars).forEach((varName) => {
25512
+ // Set new value, if any
25513
+ const value = options.vars[varName];
25514
+ if (isNotNilOrBlank(value)) {
25515
+ style.setProperty(varName, value);
25516
+ }
25517
+ else {
25518
+ style.removeProperty(varName);
25519
+ }
25520
+ });
25521
+ }
25522
+ // Set dark mode
25523
+ if (isNotNil(options.darkMode)) {
25524
+ await this.toggleDarkTheme(options.darkMode);
25525
+ }
25526
+ }
25464
25527
  async toggleDarkTheme(enable) {
25528
+ const classList = document.documentElement.classList;
25465
25529
  // Toggle the class
25466
- const wasEnabled = document.documentElement.classList.contains('dark');
25530
+ const wasEnabled = classList.contains('dark');
25467
25531
  if (enable !== wasEnabled) {
25468
25532
  console.debug(`[platform] ${enable ? 'Enable' : 'Disable'} dark mode...`);
25469
- document.documentElement.classList.toggle('dark', enable);
25533
+ classList.toggle('dark', enable);
25470
25534
  }
25471
- // Configure status basr style (Android)
25472
- if (this.isApp() && this.isAndroid()) {
25535
+ // If mobile (Android or iOS)
25536
+ if (this.isApp() && (this.isIOS() || this.isAndroid())) {
25537
+ // Read the primary color, if any
25538
+ const style = getComputedStyle(document.documentElement);
25539
+ const primaryColor = style.getPropertyValue('--ion-color-primary')?.trim();
25540
+ // Configure status bar style
25541
+ const statusBarStyle = enable ? Style.Light : Style.Dark;
25542
+ console.debug(`[platform] StatusBar style: ${statusBarStyle} ...`);
25473
25543
  try {
25474
- await StatusBar.setStyle({ style: enable ? Style.Light : Style.Dark });
25544
+ await StatusBar.setStyle({ style: statusBarStyle });
25475
25545
  }
25476
25546
  catch (err) {
25477
25547
  console.error('[platform] Error while setting StatusBar style', err);
25478
25548
  }
25549
+ // Configure status bar background color (always use black on dark mode)
25550
+ const backgroundColor = !primaryColor || enable ? '#000000' : primaryColor;
25551
+ console.debug(`[platform] StatusBar background color: ${backgroundColor}`);
25552
+ try {
25553
+ await EdgeToEdge.setBackgroundColor({ color: backgroundColor });
25554
+ await StatusBar.setBackgroundColor({ color: backgroundColor });
25555
+ }
25556
+ catch (err) {
25557
+ console.error('[platform] Error while setting StatusBar background color', err);
25558
+ }
25479
25559
  }
25480
25560
  }
25481
25561
  toggleHighContrast(enable) {
@@ -25506,7 +25586,9 @@ class PlatformService extends StartableService {
25506
25586
  });
25507
25587
  this.registerSubscription(combineLatest([isScreen$, this.settings.darkMode$]).subscribe(([isScreen, enable]) => this.toggleDarkTheme(isScreen && enable)));
25508
25588
  }
25509
- const style = getComputedStyle(win.document.documentElement);
25589
+ else {
25590
+ await this.toggleDarkTheme(false);
25591
+ }
25510
25592
  // Workaround, for MS Windows touch screen (detected as mobile, but forced as desktop)
25511
25593
  if (!mobile &&
25512
25594
  (win.document.documentElement?.classList.contains('plt-mobile') || win.document.documentElement.classList?.contains('plt-mobileweb'))) {
@@ -25514,19 +25596,6 @@ class PlatformService extends StartableService {
25514
25596
  win.document.documentElement.classList.remove('plt-mobile', 'plt-mobileweb');
25515
25597
  win.document.documentElement.classList.add('plt-desktop');
25516
25598
  }
25517
- // Configure status bar background color
25518
- if (this.isApp() && this.isAndroid()) {
25519
- const primaryColor = style.getPropertyValue('--ion-color-primary')?.trim();
25520
- if (primaryColor) {
25521
- console.debug(`[platform] StatusBar background color: ${primaryColor}`);
25522
- try {
25523
- await StatusBar.setBackgroundColor({ color: primaryColor });
25524
- }
25525
- catch (err) {
25526
- console.error('[platform] Error while setting StatusBar background color', err);
25527
- }
25528
- }
25529
- }
25530
25599
  }
25531
25600
  async configureCapacitorPlugins() {
25532
25601
  if (!this._capacitor)
@@ -25534,8 +25603,14 @@ class PlatformService extends StartableService {
25534
25603
  console.info('[platform] Configuring Capacitor plugins...');
25535
25604
  let pluginName;
25536
25605
  try {
25606
+ pluginName = CapacitorPlugins.EdgeToEdge;
25607
+ if (this.isApp()) {
25608
+ // TODO tests enable
25609
+ await EdgeToEdge.disable();
25610
+ }
25537
25611
  pluginName = CapacitorPlugins.StatusBar;
25538
- if (this.isApp() && this.isAndroid()) {
25612
+ if (this.isApp()) {
25613
+ // Avoid overlays (Android 15 or iOS)
25539
25614
  await StatusBar.setOverlaysWebView({ overlay: false });
25540
25615
  }
25541
25616
  // Hide accessory bar (iOS only)