Skip to content

Commit

Permalink
Merge pull request #30 from JMTheo/ultimos-lancamentos-v3
Browse files Browse the repository at this point in the history
Ultimos lancamentos v3
  • Loading branch information
JMTheo authored Jun 6, 2021
2 parents e9fb47d + ee7fc81 commit 2fe293d
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,22 @@
<ion-input type="date" [formControl]="diaCompra" ngDefaultControl name="diaCompra"></ion-input>
</ion-item>
<ion-item>
<ion-label position="fixed">Tipo</ion-label>
<ion-select [formControl]="tipoTransacao" ngDefaultControl name = "tipoOperacao">
<ion-label position="fixed">Operação</ion-label>
<ion-select [formControl]="tipoOperacao" ngDefaultControl name = "tipoOperacao">
<ion-select-option value="entrada" >Entrada</ion-select-option>
<ion-select-option value="saida" >Saída</ion-select-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label position="fixed">Transação</ion-label>
<ion-select [formControl]="tipoTransacao" ngDefaultControl name = "tipoTransacao">
<ion-select-option value="salario" >Salário</ion-select-option>
<ion-select-option value="imovel" >Imóvel</ion-select-option>
<ion-select-option value="investimentos" >Investimentos</ion-select-option>
<ion-select-option value="boleto" >Boleto</ion-select-option>
<ion-select-option value="alimentacao"> Alimentação</ion-select-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label position="fixed">Valor</ion-label>
<ion-input [formControl]="valor" name ="valor" ngDefaultControl type= number ></ion-input>
Expand All @@ -40,4 +50,4 @@
</ion-row>


</ion-content>
</ion-content>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { LocalStorageService } from '../../service/local-storage-service.service
export class LancamentosModalComponent implements OnInit {
titulo = new FormControl('', Validators.required);
diaCompra = new FormControl('', Validators.required);
tipoOperacao = new FormControl('', Validators.required);
tipoTransacao = new FormControl('', Validators.required);
valor = new FormControl('', Validators.required);

Expand All @@ -30,6 +31,7 @@ export class LancamentosModalComponent implements OnInit {
id: this.titulo.value + this.diaCompra.value,
titulo: this.titulo.value,
diaCompra: this.diaCompra.value,
tipoOperacao: this.tipoOperacao.value,
tipoTransacao: this.tipoTransacao.value,
valor: this.valor.value,
};
Expand All @@ -43,4 +45,4 @@ export class LancamentosModalComponent implements OnInit {
}

ngOnInit() {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<ion-col>
<ion-avatar>
<img
[src]="srcImg"
[src]="iconeLancamento(tipoTransacao)"
/> <!-- -->
</ion-avatar>
</ion-col>
Expand All @@ -15,4 +15,4 @@
<ion-col [ngStyle]="corTexto()"> {{ valor }} </ion-col>
</ion-row>
</ion-grid>
</ion-card>
</ion-card>
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,61 @@ import { Component, OnInit, Input } from '@angular/core';
styleUrls: ['./ultimos-lancamentos.component.scss'],
})
export class UltimosLancamentosComponent implements OnInit {

constructor() {

}
@Input() srcImg: string
constructor() {}
@Input() srcImg: string;
@Input() diaCompra: string;
@Input() titulo: string;
@Input() valor: string;
@Input() tipoTransacao: string;
@Input() tipoOperacao: string;

ngOnInit() {}


ngOnInit() {
}

corTexto() {
let style = {
'color': ''
}
if(this.tipoTransacao == 'saida') {
style.color = 'red'
color: '',
};
if (this.tipoOperacao == 'saida') {
style.color = 'red';
} else {
style.color = 'green'
style.color = 'green';
}
return style;
}

}
iconeLancamento(tipoTransacao:string) {
this.tipoTransacao = tipoTransacao;
switch (this.tipoTransacao) {
case 'salario': {
this.srcImg = "https://image.freepik.com/free-vector/money-bags-coins-flat-design-vector-illustration_16734-107.jpg";
break;
}
case 'boleto': {
this.srcImg = "https://www.sicoobsc.com.br/cruzalta/wp-content/uploads/sites/46/2014/05/icon_pagamento.png"
break;
}
case 'imovel': {
this.srcImg = 'https://e7.pngegg.com/pngimages/98/702/png-clipart-font-awesome-computer-icons-house-icon-design-house-angle-logo.png';
break;
}

case 'investimentos': {
this.srcImg = "https://static.vecteezy.com/ti/vetor-gratis/p1/2519573-investimento-grafico-icone-design-ilustracao-vetor.jpg"
break;
}
case 'alimentacao': {
this.srcImg = "https://i.pinimg.com/originals/83/04/31/830431f04b70f189d95cd42e4bf1d502.jpg";
break;
}
default: {
this.srcImg = '';
this.tipoTransacao = ""
break;
}
}
return this.srcImg;
}
}
1 change: 1 addition & 0 deletions src/app/interface/lancamento.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export interface Lancamento {
titulo: string;
valor: number;
tipoTransacao: string;
tipoOperacao: string;
}
2 changes: 1 addition & 1 deletion src/app/pages/home/home.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ <h1 class="vlr-home">R$ {{ valorDinamico }}</h1>
</ion-col>
</ion-grid>
</div>
</ion-content>
</ion-content>
4 changes: 2 additions & 2 deletions src/app/pages/lancamentos/lancamentos.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { LancamentosPageRoutingModule } from './lancamentos-routing.module';

import { LancamentosPage } from './lancamentos.page';

import { LancamentosModalComponent } from 'src/app/components/lancamentos-modal/lancamentos-modal.component';
import { LancamentosModalComponent } from '../../components/lancamentos-modal/lancamentos-modal.component';
import { UltimosLancamentosModule } from '../../components/ultimos-lancamentos/ultimos-lancamentos.module';

@NgModule({
Expand All @@ -23,4 +23,4 @@ import { UltimosLancamentosModule } from '../../components/ultimos-lancamentos/u
declarations: [LancamentosPage, LancamentosModalComponent],
entryComponents: [LancamentosModalComponent]
})
export class LancamentosPageModule {}
export class LancamentosPageModule {}
5 changes: 2 additions & 3 deletions src/app/pages/lancamentos/lancamentos.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
></ion-button>
</ion-col>
</ion-row>

<app-ultimos-lancamentos *ngFor="let i of lancamentosList"
srcImg="https://i.pinimg.com/originals/83/04/31/830431f04b70f189d95cd42e4bf1d502.jpg"
diaCompra = {{i.diaCompra}}
titulo= {{i.titulo}}
valor= {{i.valor}}
tipoOperacao={{i.tipoOperacao}}
tipoTransacao={{i.tipoTransacao}}
></app-ultimos-lancamentos>

Expand All @@ -34,4 +33,4 @@
</ion-fab>
</div>

</ion-content>
</ion-content>
2 changes: 1 addition & 1 deletion src/app/pages/lancamentos/lancamentos.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ export class LancamentosPage implements OnInit {
async retornaTodosLancamentos() {
this.lancamentosList = await this.storage.retornaTodosLancamentos();
}
}
}

0 comments on commit 2fe293d

Please sign in to comment.