refactor: wip app
This commit is contained in:
@@ -11,14 +11,18 @@ import { WebSqlite } from 'angular-web-sqlite';
|
|||||||
import { Sqlite } from './services/sqlite';
|
import { Sqlite } from './services/sqlite';
|
||||||
import { tables } from '../migrations/20260117';
|
import { tables } from '../migrations/20260117';
|
||||||
import { provideServiceWorker } from '@angular/service-worker';
|
import { provideServiceWorker } from '@angular/service-worker';
|
||||||
import {provideTranslateService } from "@ngx-translate/core";
|
import { provideTranslateService, TranslateService } from '@ngx-translate/core';
|
||||||
import {provideTranslateHttpLoader} from "@ngx-translate/http-loader";
|
import { provideTranslateHttpLoader } from '@ngx-translate/http-loader';
|
||||||
|
|
||||||
export const appConfig: ApplicationConfig = {
|
export const appConfig: ApplicationConfig = {
|
||||||
providers: [
|
providers: [
|
||||||
provideAppInitializer(async () => {
|
provideAppInitializer(async () => {
|
||||||
const sqlite = inject(Sqlite);
|
const sqlite = inject(Sqlite);
|
||||||
|
const translateService = inject(TranslateService);
|
||||||
|
translateService.addLangs(['en', 'es', 'pt']);
|
||||||
|
translateService.setFallbackLang('es');
|
||||||
await sqlite.initializeDatabase('gptdb');
|
await sqlite.initializeDatabase('gptdb');
|
||||||
|
await sqlite.dropAllTables();
|
||||||
await sqlite.batchSqlOperations(tables);
|
await sqlite.batchSqlOperations(tables);
|
||||||
await sqlite.executeQuery('PRAGMA foreign_keys = ON;');
|
await sqlite.executeQuery('PRAGMA foreign_keys = ON;');
|
||||||
document.dispatchEvent(new CustomEvent('ng-boot'));
|
document.dispatchEvent(new CustomEvent('ng-boot'));
|
||||||
@@ -33,10 +37,10 @@ export const appConfig: ApplicationConfig = {
|
|||||||
provideTranslateService({
|
provideTranslateService({
|
||||||
loader: provideTranslateHttpLoader({
|
loader: provideTranslateHttpLoader({
|
||||||
prefix: '/i18n/',
|
prefix: '/i18n/',
|
||||||
suffix: '.json'
|
suffix: '.json',
|
||||||
}),
|
}),
|
||||||
fallbackLang: 'en',
|
fallbackLang: 'en',
|
||||||
lang: 'en'
|
lang: 'en',
|
||||||
})
|
}),
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1 +1,4 @@
|
|||||||
<router-outlet></router-outlet>
|
<div class="content">
|
||||||
|
<router-outlet></router-outlet>
|
||||||
|
</div>
|
||||||
|
<app-bottom-navigation-bar [options]="menuOptions"/>
|
||||||
@@ -1,3 +1,30 @@
|
|||||||
import { Routes } from '@angular/router';
|
import { Routes } from '@angular/router';
|
||||||
|
import { Home } from './pages/home/home';
|
||||||
export const routes: Routes = [];
|
import { routes as settingsRoutes } from './pages/settings/settings.route'
|
||||||
|
export const routes: Routes = [
|
||||||
|
{
|
||||||
|
path: 'home',
|
||||||
|
component: Home,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'register',
|
||||||
|
component: Home,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'budget',
|
||||||
|
component: Home,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'settings',
|
||||||
|
children: settingsRoutes
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
pathMatch: 'full',
|
||||||
|
redirectTo: 'home',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '**',
|
||||||
|
redirectTo: 'home',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|||||||
19
src/app/app.scss
Normal file
19
src/app/app.scss
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
:host {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
height: 100%;
|
||||||
|
max-height: 100vh;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
height: calc(100% - 56px);
|
||||||
|
max-height: calc(100vh - 56px);
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
app-bottom-navigation-bar {
|
||||||
|
margin-top: auto;
|
||||||
|
width: 100%;
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
@@ -1,10 +1,13 @@
|
|||||||
import { TestBed } from '@angular/core/testing';
|
import { TestBed } from '@angular/core/testing';
|
||||||
import { App } from './app';
|
import { App } from './app';
|
||||||
|
|
||||||
|
import { provideTranslateService } from '@ngx-translate/core';
|
||||||
|
|
||||||
describe('App', () => {
|
describe('App', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
imports: [App],
|
imports: [App],
|
||||||
|
providers: [provideTranslateService({})],
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -13,5 +16,4 @@ describe('App', () => {
|
|||||||
const app = fixture.componentInstance;
|
const app = fixture.componentInstance;
|
||||||
expect(app).toBeTruthy();
|
expect(app).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,18 +1,33 @@
|
|||||||
import { Component, inject } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { RouterOutlet } from '@angular/router';
|
import { RouterOutlet } from '@angular/router';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { BottomNavigationBar } from './components/bottom-navigation-bar/bottom-navigation-bar';
|
||||||
|
import { BottomNavigationBarOption } from './components/bottom-navigation-bar/BottomNavigationBarOption';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
imports: [RouterOutlet],
|
imports: [RouterOutlet, BottomNavigationBar],
|
||||||
templateUrl: './app.html',
|
templateUrl: './app.html',
|
||||||
styles: [],
|
styleUrls: [
|
||||||
|
'./app.scss'
|
||||||
|
],
|
||||||
})
|
})
|
||||||
export class App {
|
export class App {
|
||||||
private readonly translate = inject(TranslateService);
|
|
||||||
constructor() {
|
protected menuOptions = [
|
||||||
this.translate.addLangs(['en', 'es', 'pt']);
|
new BottomNavigationBarOption('navbar.label.home', 'home', '/home'),
|
||||||
this.translate.setFallbackLang('en');
|
new BottomNavigationBarOption(
|
||||||
this.translate.use('en');
|
'navbar.label.register',
|
||||||
}
|
'barcode',
|
||||||
|
'/register',
|
||||||
|
'material-symbols-outlined',
|
||||||
|
),
|
||||||
|
new BottomNavigationBarOption(
|
||||||
|
'navbar.label.budget',
|
||||||
|
'barcode_reader',
|
||||||
|
'/budget',
|
||||||
|
'material-symbols-outlined',
|
||||||
|
),
|
||||||
|
new BottomNavigationBarOption('navbar.label.settings', 'settings', '/settings'),
|
||||||
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user