Skip to content

Commit 66d694c

Browse files
committed
refactor(auth): improve iOS platform detection
Replace Capacitor.getPlatform() with Platform.is() getter methods in login/signup pages for better Ionic framework alignment and proper encapsulation. Add platform detection guidelines to documentation.
1 parent aaf221f commit 66d694c

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

.github/copilot-instructions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ npx cap open ios # Open in Xcode
104104
- Implement offline support with local database sync
105105
- Optimize performance with lazy loading and asset optimization
106106
- Follow mobile-first responsive design principles
107+
- **Platform Detection**: Use `Platform.is('ios')` from `@ionic/angular` instead of `Capacitor.getPlatform() === 'ios'` for better Ionic integration and consistency
107108

108109
## Configuration Files
109110

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,6 @@ npx cap open ios # Open project in Xcode
146146
- Use Visual Studio Code with Prettier extension
147147
- Run `npm run lint` before commits
148148
- Maintain comprehensive test coverage
149+
- **Platform Detection**: Use `Platform.is('ios')` from `@ionic/angular` instead of `Capacitor.getPlatform() === 'ios'` for better Ionic integration and consistency
149150

150151
This mobile application combines modern web technologies with native mobile capabilities to create a content authenticity and blockchain integration platform.

src/app/features/login/login.page.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import { Component } from '@angular/core';
33
import { UntypedFormGroup } from '@angular/forms';
44
import { MatSnackBar } from '@angular/material/snack-bar';
55
import { ActivatedRoute, Router } from '@angular/router';
6-
import { AlertController } from '@ionic/angular';
7-
import { Capacitor } from '@capacitor/core';
6+
import { AlertController, Platform } from '@ionic/angular';
87
import { TranslocoService } from '@ngneat/transloco';
98
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
109
import { FormlyFieldConfig } from '@ngx-formly/core';
@@ -38,7 +37,9 @@ export class LoginPage {
3837

3938
showResendEmailButton = false;
4039

41-
readonly isIOS = Capacitor.getPlatform() === 'ios';
40+
get isIOS(): boolean {
41+
return this.platform.is('ios');
42+
}
4243

4344
constructor(
4445
private readonly blockingActionService: BlockingActionService,
@@ -48,6 +49,7 @@ export class LoginPage {
4849
private readonly snackbar: MatSnackBar,
4950
private readonly onboardingService: OnboardingService,
5051
private readonly errorService: ErrorService,
52+
private readonly platform: Platform,
5153
private readonly route: ActivatedRoute,
5254
private readonly alertController: AlertController
5355
) {

src/app/features/signup/signup.page.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { HttpErrorResponse } from '@angular/common/http';
22
import { Component } from '@angular/core';
33
import { UntypedFormGroup } from '@angular/forms';
44
import { Router } from '@angular/router';
5-
import { Capacitor } from '@capacitor/core';
5+
import { Platform } from '@ionic/angular';
66
import { TranslocoService } from '@ngneat/transloco';
77
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
88
import { FormlyFieldConfig } from '@ngx-formly/core';
@@ -32,14 +32,17 @@ export class SignupPage {
3232

3333
fields: FormlyFieldConfig[] = [];
3434

35-
readonly isIOS = Capacitor.getPlatform() === 'ios';
35+
get isIOS(): boolean {
36+
return this.platform.is('ios');
37+
}
3638

3739
constructor(
3840
private readonly blockingActionService: BlockingActionService,
3941
private readonly diaBackendAuthService: DiaBackendAuthService,
4042
private readonly errorService: ErrorService,
4143
private readonly translocoService: TranslocoService,
42-
private readonly router: Router
44+
private readonly router: Router,
45+
private readonly platform: Platform
4346
) {
4447
combineLatest([
4548
this.translocoService.selectTranslate('email'),

0 commit comments

Comments
 (0)