Skip to content

Instantly share code, notes, and snippets.

View synga's full-sized avatar
🏠
Working from home

Gabriel Barreto synga

🏠
Working from home
View GitHub Profile
@synga
synga / products.service.ts
Created January 25, 2020 21:27
Firebase Offline Exemplo
import { Injectable } from '@angular/core';
import { Product } from '../interfaces/product';
// aqui você substitui pelo angularFire que ta utilizando
import * as firebase from 'firebase';
// import do localStorage do angular, tem que instalar essa lib https://www.npmjs.com/package/@ngx-pwa/local-storage
import { StorageMap } from '@ngx-pwa/local-storage';
@Injectable({
providedIn: 'root'
})
@synga
synga / firebase_pic.ts
Created September 22, 2018 14:11
Transformando um metodo para retornar promise.
//função de cadastro de cliente
adicionarCliente() {
// NÃO FAÇO A MINIMA IDEIA DO QUE FAZ ESSE METODO ABAIXO, MAS SE ALGO APÓS ELE RETORNA UM VALOR NECESSÁRIO PARA CUMPRIR...
// ...ESSE METODO DE ADICIONAR CLIENTE, O CERTO SERIA TRANSFORMAR EM PROMISE TAMBÉM.
this.cliente.clienteFinalizado = true;
this.clienteProvider.adicionarCliente(this.cliente);
//faz o upload da foto
this.uploadPhoto().then(response => {
// após upload concluído, a variável foto recebe a URL da foto no storage
import { Component, State, Listen, Watch } from "@stencil/core";
@Component({
tag: "todo-list",
styleUrl: "todo-list.css"
})
export class TodoList {
@State() concluidas: number = 0;
@State() tarefas: Array<{ feito: boolean; descricao: string }> = [];
@State() input: string = "";
import { Component, Prop } from '@stencil/core';
@Component({
tag: 'my-component',
styleUrl: 'my-component.css'
})
export class MyComponent {
@Prop() first: string;
import { Component, Prop, Event, EventEmitter, State } from '@stencil/core';
@Component({
tag: 'todo-item',
styleUrl: "todo-item.css"
})
export class TodoItem {
@Prop() posicao: number;
@Prop() descricao: string;
@synga
synga / suaPagina.ts
Created July 19, 2018 15:19
Implementação de m navguard para garantir que o usuário não deixe a view caso comece a preencher um formulário
// Todos os imports da sua página e @component
// para esse exemplo assumo que você esteja usando formbuilder/formgroup
export class suaPagina {
// propriedade que vai dizer se o usuário poderá ou não deixar a página
podeSair: boolean = false;
// CASO O USUARIO QUEIRA SAIR MAS TENHA PREENCHIDO ALGO.
ionViewCanLeave() {
// se a variavel para sair for falsa e seu formulário está em estado de 'dirty' (algo já foi preenchido) entra na condição
if (this.canLeave == false && this.seuForm.dirty) {
@synga
synga / YourPage.ts
Last active May 10, 2018 15:28
Ionic Normalize strings for filter.
// Faça dessa forma na sua pagina do searchbar
import { Normalize } from '/path/to/normalize';
export class YourPage {
constructor(public norm: Normalize){}
filter(ev: any) {
// Reset items back to all of the items
this.inicializaSeuFiltro();
@synga
synga / routes.js
Created February 16, 2018 13:07
Example of how to lazy load pages in VueJS, this'll result in a page per chunk.
// Lazy Loading a component
const HomePage = resolve => {
require.ensure(['./components/Home/HomePage.vue'], () => {
resolve(require('./components/Home/HomePage.vue'));
});
};
// Exported routes to be used in main.js
export const routes = [
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
@synga
synga / push_fcm.ts
Created July 4, 2017 00:03
Push notification com ionic e Google Cloud Messaging
/*
COM O FCM, PRIMEIRO INSTALA O PLUGIN QUE TA NO IONIC NATIVE MESMO https://ionicframework.com/docs/native/fcm/
FAZ COMO TODO PLUGIN, INSTALA O PLUGIN, INSTALA O WRAPPER.
DEPOIS COLOCA O PLUGIN NO SEU APP.MODULE:
*/
import { FCM } from '@ionic-native/fcm';
@NgModule({
declarations: [