Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all 49299 articles
Browse latest View live

Ionic keyboard: Cannot scroll

$
0
0

I know there have been posts about this before, but the solutions either did not work for me, were not terribly clear, or did not apply to my project.

I am on Ionic 5. My app has a page with several text inputs, when I have selected an input, I cannot scroll. This is causing many issues down the line as users are accidentally selecting wrong answers in other fields as they are scrolling.

This app is only being used in it’s web form, not as a PWA. This problem occurs on phone browsers only and I am unable to replicate it on PC at all.

Any help is appreciated, thank you.

1 post - 1 participant

Read full topic


Ion Input Outline - Increase Label Size

$
0
0

Hi All,
Using Ionic Angular 8 but this would apply to the older versions too. In short I love the MD ion-input with outline and stacked label. However the stacked label is way too small for my users to read and are trying to increase the font size.

I have successfully increased the label size by changing the following property:

.label-floating.input-fill-outline.sc-ion-input-md-h
  .label-text-wrapper.sc-ion-input-md {
  transform: translateY(-55%) scale(1.05);
}

However the border outline is getting overlapped as the picture below.

I’m struggling to find the property to fix this. In the ionic libibrary there is a function called notched controller notch-controller.js. It talks about $form-control-label-stacked-scale being set to 0.75 and looks like this is hard-coded in the function. Is there a work around for this? (Without the needing to manually change this code?). I have provide an example stacklblitz as well. Many thanks in advance.

/**
         * If the element is visible then we can set the notch width.
         * The notch is only visible when the label is scaled,
         * which is why we multiply the width by 0.75 as this is
         * the same amount the label element is scaled by in the host CSS.
         * (See $form-control-label-stacked-scale in ionic.globals.scss).
         */
        notchSpacerEl.style.setProperty('width', `${width * 0.75}px`);

1 post - 1 participant

Read full topic

Fetching data works in browser but not in ios or android for certain pages

Capacitor - APP plugin on IOS

$
0
0

Hello, i use capacitor - app plugin on my android / ios application and i have issue with App.exitApp(); i know that this function only on android is there any solution that will do this on ios?

4 posts - 2 participants

Read full topic

"Webpage not available" on Android with Live Reload

$
0
0

I have recently set up a tabs Ionic 8 project to try out the new features. I have added Capacitor to the project and want to test out Live Reload with Android. While building and running the app on Android without Live Reload works, doing so with Live Reload enabled gives me either one of two results. This is with an Android emulator and hardware device. I get a “Webpage not available” WebView displayed with various errors like net::ERR_EMPTY_RESPONSE, net::ERR_CONNECTION_RESET, or net::ERR_SOCKET_NOT_CONNECTED:

I get a similar error page when I try to open the same private IP and port in a web browser on the same host machine:

I have tried clearing out my node_modules, www, and android folders and rebuilt multiple times. Here is the output of ionic info:

Ionic:

   Ionic CLI                     : 7.2.0 (/Users/user/.nvm/versions/node/v20.12.2/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 8.0.1
   @angular-devkit/build-angular : 17.3.6
   @angular-devkit/schematics    : 17.3.6
   @angular/cli                  : 17.3.6
   @ionic/angular-toolkit        : 11.0.1

Capacitor:

   Capacitor CLI      : 6.0.0
   @capacitor/android : 6.0.0
   @capacitor/core    : 6.0.0
   @capacitor/ios     : 6.0.0

Utility:

   cordova-res : 0.15.4
   native-run  : 2.0.1

System:

   NodeJS : v20.12.2 (/Users/user/.nvm/versions/node/v20.12.2/bin/node)
   npm    : 10.5.0
   OS     : macOS Unknown

capacitor.config.js:

import type { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  appId: 'com.app.name',
  appName: 'AppName',
  webDir: 'www/browser'
};

export default config;

angular.json:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "app": {
      "projectType": "application",
      "schematics": {
        "@ionic/angular-toolkit:page": {
          "styleext": "scss",
          "standalone": true
        }
      },
      "root": "",
      "sourceRoot": "src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:application",
          "options": {
            "outputPath": "www",
            "index": "src/index.html",
            "polyfills": ["src/polyfills.ts"],
            "tsConfig": "tsconfig.app.json",
            "inlineStyleLanguage": "scss",
            "assets": [
              {
                "glob": "**/*",
                "input": "src/assets",
                "output": "assets"
              }
            ],
            "styles": ["src/global.scss", "src/theme/variables.scss"],
            "scripts": [],
            "browser": "src/main.ts"
          },
          "configurations": {
            "production": {
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "2mb",
                  "maximumError": "5mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "2kb",
                  "maximumError": "4kb"
                }
              ],
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "outputHashing": "all"
            },
            "development": {
              "optimization": false,
              "extractLicenses": false,
              "sourceMap": true,
              "namedChunks": true
            },
            "ci": {
              "progress": false
            }
          },
          "defaultConfiguration": "production"
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "configurations": {
            "production": {
              "buildTarget": "app:build:production"
            },
            "development": {
              "buildTarget": "app:build:development"
            },
            "ci": {
              "progress": false
            }
          },
          "defaultConfiguration": "development"
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "buildTarget": "app:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.spec.json",
            "karmaConfig": "karma.conf.js",
            "inlineStyleLanguage": "scss",
            "assets": [
              {
                "glob": "**/*",
                "input": "src/assets",
                "output": "assets"
              }
            ],
            "styles": ["src/global.scss", "src/theme/variables.scss"],
            "scripts": []
          },
          "configurations": {
            "ci": {
              "progress": false,
              "watch": false
            }
          }
        },
        "lint": {
          "builder": "@angular-eslint/builder:lint",
          "options": {
            "lintFilePatterns": ["src/**/*.ts", "src/**/*.html"]
          }
        }
      }
    }
  },
  "cli": {
    "schematicCollections": ["@ionic/angular-toolkit"],
    "analytics": false
  },
  "schematics": {
    "@ionic/angular-toolkit:component": {
      "styleext": "scss"
    },
    "@ionic/angular-toolkit:page": {
      "styleext": "scss"
    },
    "@angular-eslint/schematics:application": {
      "setParserOptionsProject": true
    },
    "@angular-eslint/schematics:library": {
      "setParserOptionsProject": true
    }
  }
}

Warning message in output of ionic build:

Output location: /Users/user/AppName/www

Application bundle generation complete. [7.563 seconds]

▲ [WARNING] The glob pattern import("./**/*.entry.js*") did not match any files [empty-glob]

    node_modules/@stencil/core/internal/client/index.js:2749:2:
      2749 │   `./${bundleId}.entry.js${BUILD24.hotModuleReplacement && hmrVe...
           ╵   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


▲ [WARNING] 20 rules skipped due to selector errors:
  :host-context([dir=rtl]) .ion-float-start -> Unknown pseudo-class :host-context([object Object])
  .ion-float-start:dir(rtl) -> Unknown pseudo-class :dir
  :host-context([dir=rtl]) .ion-float-end -> Unknown pseudo-class :host-context([object Object])
  .ion-float-end:dir(rtl) -> Unknown pseudo-class :dir
  :host-context([dir=rtl]) .ion-float-sm-start -> Unknown pseudo-class :host-context([object Object])
  .ion-float-sm-start:dir(rtl) -> Unknown pseudo-class :dir
  :host-context([dir=rtl]) .ion-float-sm-end -> Unknown pseudo-class :host-context([object Object])
  .ion-float-sm-end:dir(rtl) -> Unknown pseudo-class :dir
  :host-context([dir=rtl]) .ion-float-md-start -> Unknown pseudo-class :host-context([object Object])
  .ion-float-md-start:dir(rtl) -> Unknown pseudo-class :dir
  :host-context([dir=rtl]) .ion-float-md-end -> Unknown pseudo-class :host-context([object Object])
  .ion-float-md-end:dir(rtl) -> Unknown pseudo-class :dir
  :host-context([dir=rtl]) .ion-float-lg-start -> Unknown pseudo-class :host-context([object Object])
  .ion-float-lg-start:dir(rtl) -> Unknown pseudo-class :dir
  :host-context([dir=rtl]) .ion-float-lg-end -> Unknown pseudo-class :host-context([object Object])
  .ion-float-lg-end:dir(rtl) -> Unknown pseudo-class :dir
  :host-context([dir=rtl]) .ion-float-xl-start -> Unknown pseudo-class :host-context([object Object])
  .ion-float-xl-start:dir(rtl) -> Unknown pseudo-class :dir
  :host-context([dir=rtl]) .ion-float-xl-end -> Unknown pseudo-class :host-context([object Object])
  .ion-float-xl-end:dir(rtl) -> Unknown pseudo-class :dir

A bit more info is that I have switched to ESBuild for Angular as recommended by the Ionic VSCode extension. I believe ESBuild changes the webapp build directory from www to www/browser, so I wonder if that’s related. Maybe the Live Reload feature is not properly finding the index.html in the new location. If there is any more info I can provide, please let me know.

1 post - 1 participant

Read full topic

How to fix the "Data path "" must NOT have additional properties(standalone)" error

$
0
0

I just cloned the conference repo and i am trying to generate my first component using the command

ng generate component contact/form

I keep getting this error
"

Schematic input does not validate against the Schema: {“project”:“app”,“name”:“contact/form”,“displayBlock”:false,“inlineStyle”:false,“inlineTemplate”:false,“standalone”:false,“changeDetection”:“Default”,“style”:“css”,“type”:“Component”,“skipTests”:true,“flat”:false,“skipImport”:false,“skipSelector”:false,“export”:false}
Errors:

Data path “” must NOT have additional properties(standalone).
[ERROR] Could not generate component.

"
i tried to change the command to be “ionic generate component test” , same issue.
I dnt know what i am doing wrong , this is my ionic info

Ionic:

Ionic CLI : 7.2.0 (C:\Program Files\nvm\v20.12.2\node_modules@ionic\cli)
Ionic Framework : @ionic/angular 8.0.0
@angular-devkit/build-angular : 16.0.0
@angular-devkit/schematics : 16.0.0
@angular/cli : 16.0.0
@ionic/angular-toolkit : 6.1.0

Capacitor:

Capacitor CLI : 4.6.3
@capacitor/android : 4.6.3
@capacitor/core : 4.6.3
@capacitor/ios : 4.6.3

Utility:

cordova-res : 0.15.4
native-run : 1.7.1

System:

NodeJS : v20.12.2 (C:\Program Files\nodejs\node.exe)
npm : 10.5.0
OS : Windows 10

1 post - 1 participant

Read full topic

Temporarily changing the colour variable value in Ionic 8 with the theming update

$
0
0

In an Angular app with Ionic Framework, I have a component, where on a specific action, I need to make the default colour variable --ion-background-color transparent, and revert back to the defined colour when the specific action is finished. In Ionic 7, It was recommended to define all the colour variables inside a theme/variables.scss file. Changing the colour variable could be done by importing the theme/variables.scss inside the needed component and changing the --ion-background-color there whenever I wanted to make it transparent.

component.scss

@import "{path}/theme/variables.scss";

.transparent-active {
  --background: transparent !important;
  --ion-background-color: transparent !important;
}

component.ts

enableTransparency = false;

onAction(): void {
   this.enableTransparency = true;
}

onActionFinished(): void {
   this.enableTransparency = false;
}

component.html

<ion-content [class.transparent-active]="enableTransparency">
</ion-content>

This used to work without any issues.


However, in Ionic 8 they updated the default colour palette and recommended removing all the colour variables unless you needed to define your own colour palette. The new colour variables for light and dark themes are automatically imported when you import the core.scss and the relevant dark theme SCSS file (dark.class.css). If there are any variables defined in the theme/variables.scss file, they will overwrite the default palette.

I need to migrate to the new colour palette so I have removed all the variables from the theme/variables.scss file. The issue is that since global variables are removed, there’s no defined --ion-background-color variable for me to make transparent inside the component. The solution I have used in Ionic 7 doesn’t work. I have tried importing the core.scss and the relevant dark theme SCSS (dark.class.css) to the component’s SCSS file to see if it would import the needed colour variable, but it still doesn’t seem to work. I also need to make sure that the --ion-background-color variable returns to its original colour when the transparency is turned off as well.

1 post - 1 participant

Read full topic

How to build an Ionic App with an integrated Map

$
0
0

Hi everyone,

This is my first post here, so it’s a pleasure to meet you all!

I’m interested in creating a Web App with an integrated map where users can add markers, save them, and make them visible to anyone who downloads the app.

I’ve already done some research and started developing something simple, but I’m open to suggestions on the direction or starting point.

I’m open to using any framework; ideally, I’d prefer the easiest one, but if React (for example) is better suited for this type of project than Angular, I’m eager to learn it.

Also, some people suggest Leaflet over google Maps because on the long run, if the app will become popular (I know I’m dreaming but you never know…), Google Maps will be more expensive.

Thank you,
Raff

1 post - 1 participant

Read full topic


Cannot manage multiple menus

$
0
0

Hello !

I would like to manage multiple menus in my app, but I could not figure out how to do it.

As I understood from the doc page of Ionic (ion-menu: API Framework Docs for Types of Menu Components), I have to create a class where I define the action to be made when the button is clicked on.

When I create this class directly in the page where the menu is to be used, it works. But, as I want this menus to appear on multiple pages, I would like to define the class at one single location and be able to call it wherever I want.

When doing this, he always tells me that the property does not exist. Do you know what am I doing wrong?

Thanks A LOT for your help !

Here are the details :

--------------My “services.ts” file where I define my class ----------------

import { Injectable } from ‘@angular/core’;
import { MenuController } from ‘@ionic/angular’;

@Injectable({
providedIn: ‘root’
})
export class MenuService {

constructor(private menuCtrl: MenuController) {}

openFirstMenu() {
this.menuCtrl.open(‘first-menu’);
}

openSecondMenu() {
this.menuCtrl.open(‘second-menu’);
}

openEndMenu() {
this.menuCtrl.open(‘end’);
}

------------- My app module file ----------------------------

import { NgModule } from ‘@angular/core’;
import { BrowserModule } from ‘@angular/platform-browser’;
import { RouteReuseStrategy } from ‘@angular/router’;

import { IonicModule, IonicRouteStrategy } from ‘@ionic/angular’;

import { AppComponent } from ‘./app.component’;
import { AppRoutingModule } from ‘./app-routing.module’;
import { MenuService } from ‘…/Services/services’;

@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule,],
providers: [{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }, MenuService],
bootstrap: [AppComponent],
})
export class AppModule {
}

------------ My app components file -------------------

import { Component } from ‘@angular/core’;
import { MenuService } from ‘…/Services/services’;

@Component({
selector: ‘app-root’,
templateUrl: ‘app.component.html’,
styleUrls: [‘app.component.scss’],
})

export class AppComponent {

constructor(private menuService: MenuService) {}

public appPages = [
{ title: ‘Dashboard’, url: ‘/dashboard’, icon: ‘bar-chart’},
{ title: ‘Maintenance’, url: ‘/maintenance’, icon: ‘construct’ },
{ title: ‘Favorites’, url: ‘/folder/favorites’, icon: ‘heart’ },
{ title: ‘Archived’, url: ‘/folder/archived’, icon: ‘archive’ },
{ title: ‘Trash’, url: ‘/folder/trash’, icon: ‘trash’ },
{ title: ‘Spam’, url: ‘/folder/spam’, icon: ‘warning’ },
];
public labels = [‘Family’, ‘Friends’, ‘Notes’, ‘Work’, ‘Travel’, ‘Reminders’];

public enginePropertyList = [
{ id: ‘0’, sn:‘my serial number’, model: ‘my engine model’},
];

ngOnInit() {
this.menuService.openFirstMenu();
this.menuService.openSecondMenu();
this.menuService.openEndMenu();
}

}

-------------- My maintenance.page.ts where I try to import the elements of my class ---------------

import { Component, OnInit } from ‘@angular/core’;
import { MenuService } from ‘…/…/Services/services’;

@Component({
selector: ‘app-maintenance’,
templateUrl: ‘./maintenance.page.html’,
styleUrls: [‘./maintenance.page.scss’],
})
export class MaintenancePage implements OnInit {

constructor(private menuService: MenuService) {}

ngOnInit() {
this.menuService.openFirstMenu();
this.menuService.openSecondMenu();
this.menuService.openEndMenu();
}

}

-------------- My html code where I have my buttons to access my menus ----------------

Menu

Tap a button below to open a specific menu.

  <ion-button expand="block" (click)="openFirstMenu()">Open First Menu</ion-button>
  <ion-button expand="block" (click)="openSecondMenu()">Open Second Menu</ion-button>
  <ion-button expand="block" (click)="openEndMenu()">Open End Menu</ion-button>
</ion-content>

-------------- The displayed errors ---------------------------

[ng] Error: src/app/maintenance/maintenance.page.html:37:43 - error TS2339: Property ‘openFirstMenu’ does not exist on type ‘MaintenancePage’.
[ng]
[ng] 37 <ion-button expand=“block” (click)=“openFirstMenu()”>Open First Menu
[ng] ~~~~~~~~~~~~~
[ng]
[ng] src/app/maintenance/maintenance.page.ts:6:16
[ng] 6 templateUrl: ‘./maintenance.page.html’,
[ng] ~~~~~~~~~~~~~~~~~~~~~~~~~
[ng] Error occurs in the template of component MaintenancePage.
[ng]
[ng]
[ng] Error: src/app/maintenance/maintenance.page.html:38:43 - error TS2339: Property ‘openSecondMenu’ does not exist on type ‘MaintenancePage’.
[ng]
[ng] 38 <ion-button expand=“block” (click)=“openSecondMenu()”>Open Second Menu
[ng] ~~~~~~~~~~~~~~
[ng]
[ng] src/app/maintenance/maintenance.page.ts:6:16
[ng] 6 templateUrl: ‘./maintenance.page.html’,
[ng] ~~~~~~~~~~~~~~~~~~~~~~~~~
[ng] Error occurs in the template of component MaintenancePage.
[ng]
[ng]
[ng] Error: src/app/maintenance/maintenance.page.html:39:43 - error TS2339: Property ‘openEndMenu’ does not exist on type ‘MaintenancePage’.
[ng]
[ng] 39 <ion-button expand=“block” (click)=“openEndMenu()”>Open End Menu
[ng] ~~~~~~~~~~~
[ng]
[ng] src/app/maintenance/maintenance.page.ts:6:16
[ng] 6 templateUrl: ‘./maintenance.page.html’,
[ng] ~~~~~~~~~~~~~~~~~~~~~~~~~
[ng] Error occurs in the template of component MaintenancePage.
[ng]
[ng]
[ng]
[ng] × Failed to compile.

1 post - 1 participant

Read full topic

Printing image via bluetooth

$
0
0

We tried printing an image to a bluetooth thermal printer using @capacitor-community/bluetooth-le but it was really really slow. We switched to other plugins which had a really nice result( fast connection and fast printing) but the main issue is that there’s is no ios support and only supports android.
Do you know any plugin that allow printing on ios with a good speed. Thanks in advance.

1 post - 1 participant

Read full topic

Ld: Assertion failed: (aliasSectionNum == sectionNum &&"alias and its target must be located in the same section")

$
0
0

I upgraded XCode to last version (15.3) in order to solve this warning:

ITMS-90725: SDK version issue - This app was built with the iOS 16.4 SDK. Starting April 29, 2024, all iOS and iPadOS apps must be built with the iOS 17 SDK or later, included in Xcode 15 or later, in order to be uploaded to App Store Connect or submitted for distribution.

Run on simulator works but If I try to build for production/app store I receive build error:

ld: Assertion failed: (aliasSectionNum == sectionNum && "alias and its target must be located in the same section"), function assignAliasAtomOffsetInSection, file Layout.cpp, line 3358.

I tried to add “-ld64” flag to “Other Linker Flags” as read on several posts but I can’t solve.

Could you please help me to solve the issue?

Thanks

1 post - 1 participant

Read full topic

iOS SDK needs to be upgraded

$
0
0

I have this issue when submitting to the App store:

SDK version issue. This app was built with the iOS 16.1SDK. Starting April 29, 2024 (today), all iOS and iPadOS apps must be built with the iOS 17 SDK or later, included in Xcode 15 or later, in order to be uploaded to App Store Connect or submitted for distribution

I saw this thread: How to build an app with iOS 12.1 SDK or later? - #3 by skydive

But was a little weary of it because I thought we all use capacitor now. What is the current way of dealing with this issue?

1 post - 1 participant

Read full topic

IPhone 8 cannot open attachments

$
0
0

When I try to open any attachment, I temporarily write it to cache.

However I get an error “Unable to save” on this iphone 8. Is there a way around it or does capacitor just not work on older iphones?

public async viewFile(filename: string, fileData: ArrayBuffer, mimeType: string): Promise<void> {
        let fileUrl: string = await this.writeFileToCache(filename, UtilClass.getFileDataAsBase64(mimeType, fileData));
        if ((fileUrl || "").length > 0) {
            await FileOpener.openFile({path: fileUrl, mimeType: mimeType}).catch(async (e) => {
                if (e.message.startsWith("File cannot be opened.")) {
                    let alert: HTMLIonAlertElement = await this.alertController.create({
                        cssClass: "fp-alert",```

public async writeFileToCache(fileName: string, fileData: string): Promise<string> {
    const savedFile: WriteFileResult = await Filesystem.writeFile({
        path: `${fileName}`,
        data: fileData,
        directory: Directory.Cache
    });
    return savedFile.uri
}

1 post - 1 participant

Read full topic

Ion-fab-button : How to change the displayed fab-buttons format and position?

$
0
0

Hello Everyone !

I would like to display some names when the main fab-button is clicked on.

So far, I could just put some text in it. I also could change de width of the buttons, but is also change the size of the main button which I would like to remain square.

Also, I could like each fab button to adapt themselves to the size of the text in it.

Could you help me on this?
Here below a picture of what I currently have and what I would like to do. Also, find my code below the picture.

--------------- Global CSS ------------------

ion-fab-button::part(native) {
background-color: #b7f399;
border-radius: 15px;
box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.3), 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
color: black;
}

ion-fab-button::part(native):hover::after {
background-color: #a3e681;
}

ion-fab-button::part(native):active::after {
background-color: #87d361;
}

ion-fab-list::part(native) {
position: fixed;
bottom: 100px;
right: 100px;
}

---------------- HTML -----------------------

<ion-fab-button>
  <ion-icon name="chevron-up-circle"></ion-icon>
</ion-fab-button>
<ion-fab-list side="top">
  <ion-fab-button position="fixed" right="100px">
    <ion-icon name="globe"></ion-icon>
  </ion-fab-button>
  <ion-fab-button label="Coucou">
    Hello world ! 
  </ion-fab-button>
  <ion-fab-button>
    <ion-icon name="globe"></ion-icon>
  </ion-fab-button>
</ion-fab-list>

1 post - 1 participant

Read full topic

IonDateTime - two components showing same value

$
0
0

I want to use IonDateTime to update the expirationDate and executionDate of a transaction. I create one code to be reused. But when using it on one page, the 2nd call of the component is displaying the same value as the 1st call of the component though the value of the field value of the 2nd component is different. I added several console logs to confirm the values and sure enough, the values in the props are correct but the 2nd call still displays the first value through they have different keys too.

For example, when formData.executionDate = 2024-04-25 and formData.expirationDate = 2024-04-26, both IonDateTime show 2025-04-25. Thinking it was a timezone issue, I changed the formData.executionDate to a completely different date (i.e. 2024-04-24) and both show 2024-04-24.

Is it a bug or am I missing something? See the code below… specifically DatePicker.

          <IonItem>
            <DatePicker
              key={`executionDate-${transaction.id}`}
              label="Execution Date"
              value={formData.executionDate}
              onDateChange={handleDateChange}
              fieldName="executionDate"
            />
          </IonItem>
          <IonItem>
            <DatePicker
              key={`expirationDate-${transaction.id}`}
              label="Expiration Date"
              value={formData.expirationDate}
              onDateChange={handleDateChange}
              fieldName="expirationDate"
            />
          </IonItem>
import React, { useEffect, useState } from "react";
import {
  IonDatetimeButton,
  IonModal,
  IonDatetime,
} from "@ionic/react";
import { DatePickerProps } from "../../types/types-DatePicker";
import { isWeekday } from "@shared/utils/date";
import "./DatePicker.css";

export const DatePicker: React.FC<DatePickerProps> = ({
  label,
  value,
  onDateChange,
  fieldName,
}) => {
  const [isFocused, setIsFocused] = useState(false);
  const [uniqueKey, setUniqueKey] = useState(0);

  useEffect(() => {
    setUniqueKey(Math.random());
  }, []);

  return (
    <>
      <label
        htmlFor="date"
        className={`custom-datetime-label ${
          isFocused || value ? "floating" : ""
        }`}
      >
        {label}
      </label>

      <IonDatetimeButton
        key={`${fieldName}-button-${value}-${uniqueKey}`}
        datetime="date"
        className="custom-datetime-button"
        onFocus={() => setIsFocused(true)}
        onBlur={() => setIsFocused(false)}
      />
      <IonModal keepContentsMounted={true}>
        <IonDatetime
          key={`${fieldName}-datetime-${value}-${uniqueKey}`}
          id="date"
          className="custom-ion-datetime"
          slot="content"
          presentation="date"
          name="date"
          value={value}
          showDefaultTitle={true}
          showDefaultButtons={true}
          isDateEnabled={isWeekday}
          doneText="Save"
          cancelText="Cancel"
          onIonChange={(e) => onDateChange(e, fieldName)}
        >
          <span slot="title">Select {label}</span>
        </IonDatetime>
      </IonModal>
    </>
  );
};

1 post - 1 participant

Read full topic


Ionic react datetime showing incorrect time when editing

$
0
0

I am new to Ionic React. I am trying to make a calendar app in which I can add/edit/delete Tasks. I can do all of that, but heres the issue.

When I edit the startDate or endDate the time seems to be 2 hours in the past. So when I create a startDate: 7-4-2024 13:00 and endDate 9-4-2024 23:59 and click edit, the new values inside the edit-mode change to: startDate 7-4-2024 11:00 and for endDate 9-4-2024 21:59. Here comes the weird part of it. When I click save (or check the console.log(newTask) the time seems to be saved correct. For example when I edit a Task en change the time to eg. 17:00, the time spinner automaticly jumps to 15:00. But when I save the task the time is saved at 17:00.

TLDR, the datetime only shows incorrect when I try to edit a Task, but after saving they do show the correct time.

Anyone have any idea on how to fix this? If anyone knows a better approach to doing this, ANY help is welcome :)!

EventComponentList.tsx:

export interface TaskComponentProps {
    task: Task;
    index: number;
    onDelete: () => void;
    onEdit: (newTask: Task) => void;
}

const TaskComponent: React.FC<TaskComponentProps> = ({task, onDelete, onEdit}) => {

    const {
        handleInputChange,
        handleDateChange,
        newTask,
        expandedText,
        setExpandedText,
        editing,
        setEditing,
        setNewTask,
        handleToggleChange,
    } = useTaskForm();

    // useEffect hook to reset newTask when editing mode is turned off
    useEffect(() => {
        if (!editing) {
            setNewTask({...task}); // Reset newTask when editing mode is turned off
        }
    }, [editing, task]);

    const handleEditClick = () => {
        const start = new Date(newTask.startDate)
        const end = new Date(newTask.endDate)

        let x = (new Date()).getTimezoneOffset() * 60000;
        let localISOTimeStart = (new Date(start.getTime() - x)).toISOString();
        let localISOTimeEnd = (new Date(end.getTime() - x)).toISOString();

        console.log('start', start);
        console.log('end', end);
        setNewTask({ // Aanpassen naar directe instelling van het nieuwe Task object
            ...newTask,
            startDate: localISOTimeStart,
            endDate: localISOTimeEnd
        });

        setEditing(true);
    };

    const handleSaveClick = () => {
        onEdit(newTask); // Zorg ervoor dat de bewerkte taak correct wordt doorgegeven
        setEditing(false); // Turn off editing mode
    };

    const handleCancelClick = () => {
        setEditing(false); // Turn off editing mode
    };

    const toggleExpand = (textType: string) => {
        setExpandedText(expandedText === textType ? null : textType); // Toggle expanded text
    };

     return (
        <IonCard>
           
                <IonList className={'edit-task-form'}>
                    <IonItem>
                      <IonTextarea
                            label={"Name"}
                            labelPlacement={"floating"}
                            autoGrow={true}
                            name="name"
                            value={newTask.title}
                            onIonChange={(e) => setNewTask({...newTask, title: e.detail.value!})}
                        />
                    </IonItem>

                    {/* rest of the inputs */}

                    <IonItem>
                        <IonLabel>Startdatum</IonLabel>
                        <IonDatetimeButton datetime="startDate"></IonDatetimeButton>
                        <IonModal keepContentsMounted={true}>
                            <IonDatetime
                                id="startDate"
                                onIonChange={handleDateChange('startDate')}
                                value={newTask.startDate}
                            />
                        </IonModal>
                    </IonItem>
                    <IonItem>
                        <IonLabel>Einddatum</IonLabel>
                        <IonDatetimeButton datetime={"endDate"}></IonDatetimeButton>
                        <IonModal keepContentsMounted={true}>
                            <IonDatetime
                                id="endDate"
                                onIonChange={handleDateChange('endDate')}
                                value={newTask.endDate}
                            />
                        </IonModal>
                    </IonItem>

TaskHelper.tsx:

export function useTaskForm() {

    const handleDateChange = (name: string) => (e: CustomEvent<any>) => {
        const value = new Date(e.detail.value);
        console.log('Nieuwe tijd:', value); // Controleren of de nieuwe tijd correct is
        setNewTask(prevState => ({
            ...prevState,
            [name]: value
        }));
    };

    const handleEditTask = async (index: number, editedTask: Task) => {
        const updatedTasks = [...tasks];
        updatedTasks[index] = editedTask;
        setTasks(updatedTasks);
        await (await initializeStorage).set('tasks', updatedTasks);
        setNewTask(emptyTask);
        setSelectedTaskIndex(null);
    };

    const handleSaveTask = async () => {
        const updatedTask: Task = {
            ...newTask,
        };
        const updatedTasks = [...tasks, updatedTask];
        setTasks(updatedTasks);
        await (await initializeStorage).set('tasks', updatedTasks);
        setNewTask(emptyTask);
        const now = new Date();
        const twoHoursLater = new Date(now.getTime() + 2 * 60 * 60 * 1000); // +2 uur
        document.getElementById('startDate')?.setAttribute('value', twoHoursLater.toISOString());
        document.getElementById('endDate')?.setAttribute('value', twoHoursLater.toISOString());
        dismiss(); 
    };

Task.tsx:


interface Task {
  title: string;
  description: string;
  startDate: Date;
  endDate: Date;
  openTimeSlot: boolean;
  remindMe: boolean;
  priority: number;
  category: number;
  url: string;
  note: string;
}

export default Task; 

things I’ve tried:

value={newTask.startDate ? newTask.startDate.toISOString() : undefined} display-timezone="UTC"

value={newTask.startDate ? newTask.startDate.toISOString() : undefined} // Convert Date to string onIonChange={(e) => setNewTask({...newTask, startDate: new Date(e.detail.value!)})}

value={newTask.startDate.getTime() + 2 * 60 * 60 * 1000).toISOString()}

none of the above seem to work when editing a Task :`(

3 posts - 2 participants

Read full topic

Tab Bar UI Problem

$
0
0

Whenever i click on the Tab Bar on pressing last tab my UI get messed up
case1
this is what my tabbar looks like ^
case2
whenever i click on the Summary Tab my UI get messy as shown in the last ss ^^

my code:

<template>
  <ion-page>
    <ion-tabs> 
   
      <ion-router-outlet></ion-router-outlet>
     
      <ion-tab-bar slot="bottom">
        <ion-tab-button tab="tab1" href="/tabs/tab1" @click="setCurrentTab('tab1')">
          <!-- <ion-img class="h-6 w-6" :src="currentTab === 'tab1' ? '/fluentmic24filledGreen.svg' : '/fluentmic24filled.svg'" key="tab1"></ion-img>
         -->
       
         
         <ion-icon :icon="languageOutline"></ion-icon>
          <ion-label class="mt-1">Text</ion-label>
        </ion-tab-button>

        <ion-tab-button tab="tab2" href="/tabs/tab2" @click="setCurrentTab('tab2')">
          <ion-icon aria-hidden="true" :icon="micSharp" />
          <ion-label>Audio</ion-label>
        </ion-tab-button>

        <ion-tab-button tab="tab3" href="/tabs/tab3" @click="setCurrentTab('tab3')">
          <ion-icon :icon="documentTextOutline"></ion-icon>
          <ion-label>Document</ion-label>
        </ion-tab-button>

        <ion-tab-button tab="tab4" href="/tabs/tab4" @click="setCurrentTab('tab4')">
          <ion-icon :icon="cameraOutline"></ion-icon>
          <ion-label>Camera </ion-label>
        </ion-tab-button>

       
      

        <!-- <ion-tab-button tab="tab6" href="/tabs/tab6" @click="setCurrentTab('tab6')">
          <ion-icon :icon="refresh"></ion-icon>
          <ion-label>History </ion-label>
        </ion-tab-button> -->


         <ion-tab-button tab="tab5" href="/tabs/tab5" >
          <ion-icon :icon="bookOutline"></ion-icon>
          <ion-label>Summary </ion-label>
        </ion-tab-button>

      </ion-tab-bar>
    </ion-tabs>
 
  </ion-page>
</template>
<style scoped>
ion-tab-button[aria-selected="true"] ion-label,
ion-tab-button[aria-selected="true"] ion-icon {
  color: red; 
  background: red;
  background-color: red;
}


ion-tab-bar {
  --color-selected: darkorange; 
  --color:black;
  background-color: #e0b8d6;
  box-shadow: rgba(16, 11, 15, 0.2) 0px 8px 24px;
  display:flex;
  justify-content: space-around;

  
}

ion-tab-button[aria-selected="true"] ion-img {
  filter: brightness(0) saturate(100%) invert(29%) sepia(95%) saturate(3433%) hue-rotate(204deg) brightness(97%) contrast(100%);


}
ion-tab-button{
  background: #FFFBFE;
  --padding-start:0px;
  --padding-end:0px;
  /* flex: 0 0 16%; */
 
  flex-grow: 1;
}
</style>

2 posts - 2 participants

Read full topic

Why can't style default inputs anymore? T_T

$
0
0

Guys, why!? Why did you do this? Now, since upgrading to Ionic 8, if I want the correctly rounded corners back on my inputs I have to go through my ENTIRE application and put a custom CSS class on EVERY SINGLE INPUT? That is so uncool. Why can’t we overwrite the default anymore? Why take away the ability to have easy custsom styles that can be applied with just a single css file to any Ionic app? Worst decision ever…

RE: ion-input: Custom Input With Styling and CSS Properties

2 posts - 2 participants

Read full topic

Why does an Ionic app download JS files from the project again?

$
0
0

Hello guys, I have component rendering issues.

When working on an Ionic project or any kind of simple web project in a local environment, I have all the necessary files within the project folder. So Images, all other js files are loaded really fast because they are already installed.
Likewise, when I download an app developed using the Ionic framework to a mobile device, I expect the components to load quickly since the @Ionic/core packages are already installed in the application.

However, in reality, the components are not displayed until the Ionic-related JS files are downloaded on the webview browser, causing a slight delay before rendering.

My development environment uses Angular 17, and all routes are lazy-loaded. I discovered this issue in the livereload debugging environment.

I am unsure whether this issue arises from:

  • My misunderstanding of default browser behavior
  • The browser functioning as I expected, but Angular’s lazy loading mechanism causing the problem
  • A problem specific to Ionic’s live reload environment

I would be grateful if anyone could provide an explanation about this issue.

I hope to gain a deeper understanding of this problem and find a solution to eliminate the delay in component rendering.

Thanks.

1 post - 1 participant

Read full topic

IonItemOptions stays open after ionIonSwipe is excecuted

$
0
0

Describe the Bug

So when I use the IonItemSliding with the IonItemOption expandable, the Option stays open even after the onIonSwipe action is excecuted. So I have one which I use to delete an Item.
<IonItemOptions side="end" onIonSwipe={onDelete}> <IonItemOption color="danger" onClick={onDelete} expandable>
After one Item is deleted the option Delete stays visible.

Expected Behavior

What I expected to happen was the slider dissapearing after the function is excecuted. So after the Item is deleted the Delete option should be hidden again until swiping an Item again.

Steps to Reproduce

Using the IonItemSliding with IonItemOptions & IonItemOption with a function attached to it.

Screenshots

Additional Information

I am trying my application in the web, so first I thought it was due to my browse (safari, chrome, firefox, etc.) so I installed the app on my phone. I got the exact same behaviour.

2 posts - 2 participants

Read full topic

Viewing all 49299 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>