diff --git a/src/app/perfil/perfil.page.scss b/src/app/pages/perfil/perfil.page.scss
similarity index 100%
rename from src/app/perfil/perfil.page.scss
rename to src/app/pages/perfil/perfil.page.scss
diff --git a/src/app/perfil/perfil.page.spec.ts b/src/app/pages/perfil/perfil.page.spec.ts
similarity index 100%
rename from src/app/perfil/perfil.page.spec.ts
rename to src/app/pages/perfil/perfil.page.spec.ts
diff --git a/src/app/pages/perfil/perfil.page.ts b/src/app/pages/perfil/perfil.page.ts
new file mode 100644
index 0000000..a625fde
--- /dev/null
+++ b/src/app/pages/perfil/perfil.page.ts
@@ -0,0 +1,61 @@
+import { Component, OnInit } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { FormsModule } from '@angular/forms';
+import {
+ IonContent,
+ IonHeader,
+ IonTitle,
+ IonToolbar,
+ IonItem,
+ IonList,
+ IonButtons,
+ IonMenuButton,
+ IonImg,
+ IonAccordionGroup,
+ IonAccordion,
+ IonLabel,
+ IonCard,
+ IonCardHeader,
+ IonCardTitle,
+ IonCardSubtitle,
+ IonCardContent,
+} from '@ionic/angular/standalone';
+import { AuthService } from 'src/app/services/auth.service';
+import { HeaderComponent } from 'src/app/components/header/header.component';
+
+@Component({
+ selector: 'app-perfil',
+ templateUrl: './perfil.page.html',
+ styleUrls: ['./perfil.page.scss', '../../app.component.scss'],
+ standalone: true,
+ imports: [
+ HeaderComponent,
+ IonList,
+ IonItem,
+ IonContent,
+ IonHeader,
+ IonTitle,
+ IonToolbar,
+ CommonModule,
+ FormsModule,
+ IonButtons,
+ IonMenuButton,
+ IonImg,
+ IonAccordionGroup,
+ IonAccordion,
+ IonLabel,
+ IonCard,
+ IonCardHeader,
+ IonCardTitle,
+ IonCardSubtitle,
+ IonCardContent,
+ ],
+})
+export class PerfilPage implements OnInit {
+ pageTittle: string = 'Perfil';
+ constructor(
+ public auth: AuthService,
+ ) {}
+
+ ngOnInit() {}
+}
diff --git a/src/app/perfil/perfil-routing.module.ts b/src/app/perfil/perfil-routing.module.ts
deleted file mode 100644
index e6ccf9f..0000000
--- a/src/app/perfil/perfil-routing.module.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { NgModule } from '@angular/core';
-import { Routes, RouterModule } from '@angular/router';
-
-import { PerfilPage } from './perfil.page';
-
-const routes: Routes = [
- {
- path: '',
- component: PerfilPage
- }
-];
-
-@NgModule({
- imports: [RouterModule.forChild(routes)],
- exports: [RouterModule],
-})
-export class PerfilPageRoutingModule {}
diff --git a/src/app/perfil/perfil.module.ts b/src/app/perfil/perfil.module.ts
deleted file mode 100644
index 78692f2..0000000
--- a/src/app/perfil/perfil.module.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { NgModule } from '@angular/core';
-import { CommonModule } from '@angular/common';
-import { FormsModule } from '@angular/forms';
-
-import { IonicModule } from '@ionic/angular';
-
-import { PerfilPageRoutingModule } from './perfil-routing.module';
-
-import { PerfilPage } from './perfil.page';
-
-@NgModule({
- imports: [
- CommonModule,
- FormsModule,
- IonicModule,
- PerfilPageRoutingModule
- ],
- declarations: [PerfilPage]
-})
-export class PerfilPageModule {}
diff --git a/src/app/perfil/perfil.page.ts b/src/app/perfil/perfil.page.ts
deleted file mode 100644
index 87afa2e..0000000
--- a/src/app/perfil/perfil.page.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { Component, OnInit } from '@angular/core';
-
-@Component({
- selector: 'app-perfil',
- templateUrl: './perfil.page.html',
- styleUrls: ['./perfil.page.scss', '../app.component.scss'],
-})
-export class PerfilPage {
-
- constructor() { }
-
-}
diff --git a/src/app/services/auth-guard.service.ts b/src/app/services/auth-guard.service.ts
index cafd160..94ca916 100644
--- a/src/app/services/auth-guard.service.ts
+++ b/src/app/services/auth-guard.service.ts
@@ -3,22 +3,17 @@ import { CanActivate, Router } from '@angular/router';
import { AuthService } from './auth.service';
@Injectable({
- providedIn: 'root',
+ providedIn: 'root'
})
-export class AuthGuard implements CanActivate {
+export class AuthGuardService implements CanActivate {
- constructor(private auth: AuthService, private router: Router) {}
+ constructor(private auth: AuthService, private router: Router) { }
async canActivate() {
try {
- const result = await this.auth.isLogged();
- if (!result) {
- this.router.navigate(['/login']);
- return false;
- }
-
- return true;
- } catch (error) {
+ await this.auth.isLogged();
+ return true
+ } catch {
this.router.navigate(['/login']);
return false;
}
diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts
index 7fee13e..58693ad 100644
--- a/src/app/services/auth.service.ts
+++ b/src/app/services/auth.service.ts
@@ -1,9 +1,9 @@
import { Injectable } from '@angular/core';
import { AngularFireAuth } from '@angular/fire/compat/auth';
import firebase from 'firebase/compat/app';
-import { firebaseError } from '../utils/firebase/errorFirebase';
import { Router } from '@angular/router';
import { Preferences } from '@capacitor/preferences';
+import { firebaseError } from '../utils/errorFirebase';
@Injectable({
providedIn: 'root',
@@ -13,10 +13,7 @@ export class AuthService {
async createUser(email: string, password: string) {
try {
- await this.auth.createUserWithEmailAndPassword(
- email,
- password
- );
+ await this.auth.createUserWithEmailAndPassword(email, password);
return;
} catch (error) {
@@ -81,23 +78,33 @@ export class AuthService {
}
}
- async isLogged(): Promise
{
+ async isLogged() {
return new Promise((resolve, reject) => {
- this.auth.authState.subscribe(
+ return this.auth.authState.subscribe(
(user) => {
if (user) {
- resolve(user);
+ this.refreshToken(user);
+ resolve(true);
} else {
- reject('Usuário não logado');
+ reject(false);
}
},
- (error) => {
- reject(error);
+ () => {
+ reject(false);
}
);
});
}
+ async refreshToken(user: any) {
+ try {
+ await user?.getIdTokenResult(true);
+ return true;
+ } catch (error) {
+ return null;
+ }
+ }
+
async getUser() {
try {
const user = await this.auth.currentUser;
@@ -107,21 +114,21 @@ export class AuthService {
}
}
- async getToken(key: string) {
+ async getStorage(key: string) {
try {
- const token = await Preferences.get({ key });
- return token.value;
+ const result = await Preferences.get({ key });
+ return result.value;
} catch (error) {
- return 'Erro interno do servidor'
+ return 'Erro interno do servidor';
}
}
- async setToken(key: string, value: any) {
+ async setStorage(key: string, value: any) {
try {
await Preferences.set({ key, value });
return;
} catch (error) {
- return 'Erro interno do servidor'
+ return 'Erro interno do servidor';
}
}
}
diff --git a/src/app/services/news.service.ts b/src/app/services/news.service.ts
index 2e1e1c5..d2d6d44 100644
--- a/src/app/services/news.service.ts
+++ b/src/app/services/news.service.ts
@@ -7,7 +7,7 @@ import { Injectable } from '@angular/core';
export class NewsService {
constructor(private http: HttpClient) {}
- public getNews(qtd: number = 10, page: number = 1) {
+ getNews(qtd: number = 10, page: number = 1) {
return this.http.get(
`https://servicodados.ibge.gov.br/api/v3/noticias/?qtd=${qtd}&page=${page}`
);
diff --git a/src/app/services/utils.service.spec.ts b/src/app/services/utils.service.spec.ts
deleted file mode 100644
index d70aee3..0000000
--- a/src/app/services/utils.service.spec.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { TestBed } from '@angular/core/testing';
-
-import { UtilsService } from './utils.service';
-
-describe('UtilsService', () => {
- let service: UtilsService;
-
- beforeEach(() => {
- TestBed.configureTestingModule({});
- service = TestBed.inject(UtilsService);
- });
-
- it('should be created', () => {
- expect(service).toBeTruthy();
- });
-});
diff --git a/src/app/services/utils.service.ts b/src/app/services/utils.service.ts
deleted file mode 100644
index 5b4b5a0..0000000
--- a/src/app/services/utils.service.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { Injectable } from '@angular/core';
-import { ToastController } from '@ionic/angular';
-
-@Injectable({
- providedIn: 'root',
-})
-export class UtilsService {
- constructor(private toast: ToastController) {}
-
- public async toastMesage(header: string, message: string) {
- const toastMessage = await this.toast.create({
- header,
- message,
- duration: 3500,
- });
-
- toastMessage.present();
- }
-
- public teste(){
- return import.meta.env['NG_APP_API_KEY']
- }
-}
diff --git a/src/app/utils/firebase/errorFirebase.ts b/src/app/utils/errorFirebase.ts
similarity index 100%
rename from src/app/utils/firebase/errorFirebase.ts
rename to src/app/utils/errorFirebase.ts
diff --git a/src/app/utils/firebase/errorObjMessage.ts b/src/app/utils/errorObjMessage.ts
similarity index 100%
rename from src/app/utils/firebase/errorObjMessage.ts
rename to src/app/utils/errorObjMessage.ts
diff --git a/src/env.d.ts b/src/env.d.ts
index f27c3a9..2fdf0a8 100644
--- a/src/env.d.ts
+++ b/src/env.d.ts
@@ -1,27 +1,12 @@
-// Define the type of the environment variables.
declare interface Env {
readonly NODE_ENV: string;
- // Replace the following with your own environment variables.
- // Example: NGX_VERSION: string;
[key: string]: any;
}
-// Choose how to access the environment variables.
-// Remove the unused options.
-
-// 1. Use import.meta.env.YOUR_ENV_VAR in your code. (conventional)
declare interface ImportMeta {
readonly env: Env;
}
-
-// 2. Use _NGX_ENV_.YOUR_ENV_VAR in your code. (customizable)
-// You can modify the name of the variable in angular.json.
-// ngxEnv: {
-// define: '_NGX_ENV_',
-// }
declare const _NGX_ENV_: Env;
-
-// 3. Use process.env.YOUR_ENV_VAR in your code. (deprecated)
declare namespace NodeJS {
export interface ProcessEnv extends Env {}
}
diff --git a/src/index.html b/src/index.html
index a4a7ff8..3b0aae1 100644
--- a/src/index.html
+++ b/src/index.html
@@ -3,7 +3,7 @@
- Agência de Notícias - IBGE
+ Ionic App
diff --git a/src/main.ts b/src/main.ts
index 91ec6da..78f588d 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -1,12 +1,31 @@
-import { enableProdMode } from '@angular/core';
-import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
+import { enableProdMode, importProvidersFrom } from '@angular/core';
+import { bootstrapApplication } from '@angular/platform-browser';
+import { RouteReuseStrategy, provideRouter } from '@angular/router';
+import {
+ IonicRouteStrategy,
+ provideIonicAngular,
+} from '@ionic/angular/standalone';
-import { AppModule } from './app/app.module';
+import { routes } from './app/app.routes';
+import { AppComponent } from './app/app.component';
import { environment } from './environments/environment';
+import { provideHttpClient } from '@angular/common/http';
+
+import { firebaseConfig } from './app/credentials';
+import { AngularFireModule } from '@angular/fire/compat';
if (environment.production) {
enableProdMode();
}
-platformBrowserDynamic().bootstrapModule(AppModule)
- .catch(err => console.log(err));
+bootstrapApplication(AppComponent, {
+ providers: [
+ { provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
+ provideIonicAngular(),
+ provideRouter(routes),
+ provideHttpClient(),
+ importProvidersFrom(
+ AngularFireModule.initializeApp(firebaseConfig),
+ ),
+ ],
+});
diff --git a/src/polyfills.ts b/src/polyfills.ts
index 394705a..e2cc080 100644
--- a/src/polyfills.ts
+++ b/src/polyfills.ts
@@ -41,7 +41,7 @@
* (window as any).__Zone_enable_cross_context_check = true;
*
*/
-
+
import './zone-flags';
/***************************************************************************************************
diff --git a/src/theme/variables.scss b/src/theme/variables.scss
index 83ba539..da4132f 100644
--- a/src/theme/variables.scss
+++ b/src/theme/variables.scss
@@ -86,65 +86,65 @@
body {
--ion-color-primary: #428cff;
- --ion-color-primary-rgb: 66, 140, 255;
+ --ion-color-primary-rgb: 66,140,255;
--ion-color-primary-contrast: #ffffff;
- --ion-color-primary-contrast-rgb: 255, 255, 255;
+ --ion-color-primary-contrast-rgb: 255,255,255;
--ion-color-primary-shade: #3a7be0;
--ion-color-primary-tint: #5598ff;
--ion-color-secondary: #50c8ff;
- --ion-color-secondary-rgb: 80, 200, 255;
+ --ion-color-secondary-rgb: 80,200,255;
--ion-color-secondary-contrast: #ffffff;
- --ion-color-secondary-contrast-rgb: 255, 255, 255;
+ --ion-color-secondary-contrast-rgb: 255,255,255;
--ion-color-secondary-shade: #46b0e0;
--ion-color-secondary-tint: #62ceff;
--ion-color-tertiary: #6a64ff;
- --ion-color-tertiary-rgb: 106, 100, 255;
+ --ion-color-tertiary-rgb: 106,100,255;
--ion-color-tertiary-contrast: #ffffff;
- --ion-color-tertiary-contrast-rgb: 255, 255, 255;
+ --ion-color-tertiary-contrast-rgb: 255,255,255;
--ion-color-tertiary-shade: #5d58e0;
--ion-color-tertiary-tint: #7974ff;
--ion-color-success: #2fdf75;
- --ion-color-success-rgb: 47, 223, 117;
+ --ion-color-success-rgb: 47,223,117;
--ion-color-success-contrast: #000000;
- --ion-color-success-contrast-rgb: 0, 0, 0;
+ --ion-color-success-contrast-rgb: 0,0,0;
--ion-color-success-shade: #29c467;
--ion-color-success-tint: #44e283;
--ion-color-warning: #ffd534;
- --ion-color-warning-rgb: 255, 213, 52;
+ --ion-color-warning-rgb: 255,213,52;
--ion-color-warning-contrast: #000000;
- --ion-color-warning-contrast-rgb: 0, 0, 0;
+ --ion-color-warning-contrast-rgb: 0,0,0;
--ion-color-warning-shade: #e0bb2e;
--ion-color-warning-tint: #ffd948;
--ion-color-danger: #ff4961;
- --ion-color-danger-rgb: 255, 73, 97;
+ --ion-color-danger-rgb: 255,73,97;
--ion-color-danger-contrast: #ffffff;
- --ion-color-danger-contrast-rgb: 255, 255, 255;
+ --ion-color-danger-contrast-rgb: 255,255,255;
--ion-color-danger-shade: #e04055;
--ion-color-danger-tint: #ff5b71;
--ion-color-dark: #f4f5f8;
- --ion-color-dark-rgb: 244, 245, 248;
+ --ion-color-dark-rgb: 244,245,248;
--ion-color-dark-contrast: #000000;
- --ion-color-dark-contrast-rgb: 0, 0, 0;
+ --ion-color-dark-contrast-rgb: 0,0,0;
--ion-color-dark-shade: #d7d8da;
--ion-color-dark-tint: #f5f6f9;
--ion-color-medium: #989aa2;
- --ion-color-medium-rgb: 152, 154, 162;
+ --ion-color-medium-rgb: 152,154,162;
--ion-color-medium-contrast: #000000;
- --ion-color-medium-contrast-rgb: 0, 0, 0;
+ --ion-color-medium-contrast-rgb: 0,0,0;
--ion-color-medium-shade: #86888f;
--ion-color-medium-tint: #a2a4ab;
--ion-color-light: #222428;
- --ion-color-light-rgb: 34, 36, 40;
+ --ion-color-light-rgb: 34,36,40;
--ion-color-light-contrast: #ffffff;
- --ion-color-light-contrast-rgb: 255, 255, 255;
+ --ion-color-light-contrast-rgb: 255,255,255;
--ion-color-light-shade: #1e2023;
--ion-color-light-tint: #383a3e;
@@ -158,10 +158,10 @@
.ios body {
--ion-background-color: #000000;
- --ion-background-color-rgb: 0, 0, 0;
+ --ion-background-color-rgb: 0,0,0;
--ion-text-color: #ffffff;
- --ion-text-color-rgb: 255, 255, 255;
+ --ion-text-color-rgb: 255,255,255;
--ion-color-step-50: #0d0d0d;
--ion-color-step-100: #1a1a1a;
@@ -194,6 +194,7 @@
--ion-toolbar-border-color: var(--ion-color-step-250);
}
+
/*
* Material Design Dark Theme
* -------------------------------------------
@@ -201,10 +202,10 @@
.md body {
--ion-background-color: #121212;
- --ion-background-color-rgb: 18, 18, 18;
+ --ion-background-color-rgb: 18,18,18;
--ion-text-color: #ffffff;
- --ion-text-color-rgb: 255, 255, 255;
+ --ion-text-color-rgb: 255,255,255;
--ion-border-color: #222222;
@@ -244,4 +245,4 @@ html {
* https://ionicframework.com/docs/layout/dynamic-font-scaling
*/
--ion-dynamic-font: var(--ion-default-dynamic-font);
-}
+}
\ No newline at end of file
diff --git a/tsconfig.json b/tsconfig.json
index e426762..6d869b4 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -18,10 +18,7 @@
"importHelpers": true,
"target": "es2022",
"module": "es2020",
- "lib": [
- "es2018",
- "dom"
- ],
+ "lib": ["es2018", "dom"],
"useDefineForClassFields": false
},
"angularCompilerOptions": {