discofy inicial
This commit is contained in:
18
src/app/tab1/tab1-routing.module.ts
Normal file
18
src/app/tab1/tab1-routing.module.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { Tab1Page } from './tab1.page';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: Tab1Page,
|
||||
},
|
||||
|
||||
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule]
|
||||
})
|
||||
export class Tab1PageRoutingModule {}
|
||||
20
src/app/tab1/tab1.module.ts
Normal file
20
src/app/tab1/tab1.module.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { Tab1Page } from './tab1.page';
|
||||
import { ExploreContainerComponentModule } from '../explore-container/explore-container.module';
|
||||
|
||||
import { Tab1PageRoutingModule } from './tab1-routing.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
IonicModule,
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
ExploreContainerComponentModule,
|
||||
Tab1PageRoutingModule
|
||||
],
|
||||
declarations: [Tab1Page]
|
||||
})
|
||||
export class Tab1PageModule {}
|
||||
92
src/app/tab1/tab1.page.html
Normal file
92
src/app/tab1/tab1.page.html
Normal file
@@ -0,0 +1,92 @@
|
||||
<ion-header [translucent]="true">
|
||||
<ion-toolbar>
|
||||
<ion-title>
|
||||
Mi Perfil
|
||||
</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content [fullscreen]="true">
|
||||
<ion-header collapse="condense">
|
||||
<ion-toolbar>
|
||||
<ion-title class="titulo" size="large">Mi Perfil</ion-title>
|
||||
</ion-toolbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-grid>
|
||||
<div class='fotoPerfil'>
|
||||
<ion-row>
|
||||
<ion-col>
|
||||
|
||||
<ion-img class="fotoPerfil" width="100%" height="100%" [src]='fotoSrc' alt='barraquinha'></ion-img>
|
||||
<div class="textoPie">{{nombre}}</div>
|
||||
|
||||
<div class="addFoto">
|
||||
<ion-button [disabled]='editDisabled'>
|
||||
<ion-icon name="image" slot="icon-only"></ion-icon>
|
||||
<input type="file" (change)="loadImageFromDevice($event);cargarImagen()" id="file-input-perfil" accept="image/png, image/jpeg">
|
||||
</ion-button>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<ion-button (click)="enableEdit()" label="editar" [disabled]='editEnabled'>
|
||||
<ion-icon name="create"></ion-icon>
|
||||
</ion-button>
|
||||
<div id="botonesHidden1" class="botonesHidden">
|
||||
<ion-button (click)="saveEdit()" label="guardar" [disabled]='editDisabled'>
|
||||
<ion-icon name="save"></ion-icon>
|
||||
</ion-button>
|
||||
<ion-button (click)="cancelEdit()" [disabled]='editDisabled'>
|
||||
Cancelar
|
||||
</ion-button></div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
|
||||
|
||||
<ion-row>
|
||||
<ion-col>
|
||||
<div id="cajaDatos" class='datosDisplay'>
|
||||
<div class="datosLabel">Teléfono: </div>
|
||||
<div [contentEditable]='editEnabled'>{{telefono}}</div>
|
||||
<div class="datosLabel">Localización: </div>
|
||||
<div [contentEditable]='editEnabled'>{{localizacion}}</div>
|
||||
</div>
|
||||
</ion-col>
|
||||
<ion-col>
|
||||
<div class="galeria">
|
||||
<input type="file" (change)="loadImageFromDevice($event)" id="file-input-galeria" accept="image/png, image/jpeg">
|
||||
<ion-slides (ionDrag)="onSlideChanged()">
|
||||
<ion-slide *ngFor="let foto of galeriaFotos">
|
||||
<div class="fotoGaleria"><img src="{{foto}}">
|
||||
<ion-button (click)="borrarDeGaleria()">
|
||||
<ion-icon name="trash-outline"></ion-icon>
|
||||
</ion-button>
|
||||
</div>
|
||||
</ion-slide>
|
||||
</ion-slides>
|
||||
</div>
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
|
||||
|
||||
<ion-row>
|
||||
<ion-button (click)="addEvento()">
|
||||
<ion-icon name="add-circle-outline">
|
||||
</ion-icon>
|
||||
Añadir evento
|
||||
</ion-button>
|
||||
</ion-row>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</ion-grid>
|
||||
|
||||
</ion-content>
|
||||
65
src/app/tab1/tab1.page.scss
Normal file
65
src/app/tab1/tab1.page.scss
Normal file
@@ -0,0 +1,65 @@
|
||||
:root {--ion-background-color: #494949;
|
||||
--ion-background-color-rgb: 73,73,73;
|
||||
|
||||
--ion-text-color: #eeeeee;
|
||||
--ion-text-color-rgb: 238,238,238;}
|
||||
|
||||
*{
|
||||
padding: 5px;
|
||||
letter-spacing: 2px;
|
||||
}
|
||||
.titulo{
|
||||
font: "arial";
|
||||
|
||||
}
|
||||
.fotoPerfil{
|
||||
display: block;
|
||||
text-align: end;
|
||||
max-width: 800px;
|
||||
max-height: auto;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.textoPie{
|
||||
position: relative;
|
||||
bottom: 40px;
|
||||
right: 20px;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.addFoto{
|
||||
position: relative;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.datosDisplay{
|
||||
|
||||
float: left;
|
||||
position: relative;
|
||||
margin: auto;
|
||||
|
||||
}
|
||||
|
||||
.datosLabel{
|
||||
color: grey;
|
||||
}
|
||||
|
||||
.galeria{
|
||||
|
||||
display: block;
|
||||
max-width: 300px;
|
||||
max-height: auto;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.botonesHidden{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.botonesVisible{
|
||||
display: none;
|
||||
}
|
||||
|
||||
ion-slides {
|
||||
height: 100%;
|
||||
}
|
||||
25
src/app/tab1/tab1.page.spec.ts
Normal file
25
src/app/tab1/tab1.page.spec.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
import { ExploreContainerComponentModule } from '../explore-container/explore-container.module';
|
||||
|
||||
import { Tab1Page } from './tab1.page';
|
||||
|
||||
describe('Tab1Page', () => {
|
||||
let component: Tab1Page;
|
||||
let fixture: ComponentFixture<Tab1Page>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [Tab1Page],
|
||||
imports: [IonicModule.forRoot(), ExploreContainerComponentModule]
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(Tab1Page);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
169
src/app/tab1/tab1.page.ts
Normal file
169
src/app/tab1/tab1.page.ts
Normal file
@@ -0,0 +1,169 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { NodeCompatibleEventEmitter } from 'rxjs/internal/observable/fromEvent';
|
||||
import { Tab1Service } from './tab1.service'
|
||||
import { Discoteca } from '../discoteca'
|
||||
import { IonSlides} from '@ionic/angular';
|
||||
import { AlertController } from '@ionic/angular';
|
||||
import { ViewChild } from '@angular/core';
|
||||
import { Evento } from '../evento';
|
||||
import { Router } from '@angular/router';
|
||||
import { PerfilDiscotecaPageModule } from '../perfil-discoteca/perfil-discoteca.module';
|
||||
|
||||
@Component({
|
||||
selector: 'app-tab1',
|
||||
templateUrl: 'tab1.page.html',
|
||||
styleUrls: ['tab1.page.scss']
|
||||
})
|
||||
|
||||
|
||||
export class Tab1Page implements OnInit {
|
||||
@ViewChild('IonSlides') slides: IonSlides;
|
||||
nombre: string;
|
||||
telefono: number;
|
||||
localizacion: string;
|
||||
fotoSrc: string;
|
||||
fotoLoaded: string;
|
||||
someURL: string;
|
||||
editDisabled: string;
|
||||
editEnabled: string;
|
||||
galeriaFotos: string[];
|
||||
galeriaFake: string[];
|
||||
currentIndex: number;
|
||||
eventos: Evento[];
|
||||
alertCtrl: AlertController;
|
||||
|
||||
constructor(private tab1Service: Tab1Service, private router: Router) {
|
||||
|
||||
}
|
||||
|
||||
ngOnInit(){
|
||||
this.initValues();
|
||||
}
|
||||
|
||||
initValues(): void{
|
||||
this.getNombre();
|
||||
this.getTelefono();
|
||||
this.getLocalizacion();
|
||||
this.getEventos();
|
||||
this.editDisabled="true";
|
||||
this.editEnabled="false";
|
||||
this.fotoSrc = '../assets/barraca.jpg';
|
||||
this.fotoLoaded = this.fotoSrc;
|
||||
this.galeriaFotos = [];
|
||||
|
||||
}
|
||||
|
||||
|
||||
getNombre(): void{
|
||||
this.nombre = this.tab1Service.getNombre();
|
||||
}
|
||||
|
||||
getTelefono(): void{
|
||||
this.telefono = this.tab1Service.getTelefono();
|
||||
}
|
||||
|
||||
getLocalizacion(): void{
|
||||
this.localizacion = this.tab1Service.getLocalizacion();
|
||||
}
|
||||
|
||||
getEventos(): void{
|
||||
this.eventos = this.tab1Service.getEventos();
|
||||
}
|
||||
|
||||
cargarImagen(){
|
||||
this.fotoSrc = this.someURL;
|
||||
}
|
||||
|
||||
addGaleria(){
|
||||
this.galeriaFotos.push(this.someURL);
|
||||
this.slides.update();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
loadImageFromDevice(event): void{
|
||||
|
||||
const file = event.target.files[0];
|
||||
|
||||
let blobURL: string;
|
||||
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.readAsDataURL(file);
|
||||
|
||||
reader.onload = () => {
|
||||
|
||||
let blob: Blob = new Blob([new Uint8Array((reader.result as ArrayBuffer))]);
|
||||
let blobURL = URL.createObjectURL(blob);
|
||||
this.someURL = reader.result as string;
|
||||
if (event.target.id=="file-input-perfil")
|
||||
this.cargarImagen();
|
||||
else if (event.target.id=="file-input-galeria")
|
||||
this.addGaleria();
|
||||
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
enableEdit(){
|
||||
this.editDisabled="false";
|
||||
this.editEnabled="true";
|
||||
let cajaDatos = document.getElementById("cajaDatos");
|
||||
cajaDatos.style.background="white";
|
||||
cajaDatos.style.color="black";
|
||||
let botones = document.getElementById("botonesHidden1");
|
||||
botones.style.display = "block";
|
||||
botones = document.getElementById("botonesHidden2");
|
||||
botones.style.display = "block";
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
disableEdit(){
|
||||
this.editDisabled="true";
|
||||
this.editEnabled="false";
|
||||
let cajaDatos = document.getElementById("cajaDatos");
|
||||
cajaDatos.style.background="inherit";
|
||||
cajaDatos.style.color="inherit";
|
||||
let botones = document.getElementById("botonesHidden1");
|
||||
botones.style.display = "none";
|
||||
botones = document.getElementById("botonesHidden2");
|
||||
botones.style.display = "none";
|
||||
|
||||
|
||||
}
|
||||
|
||||
saveEdit(){
|
||||
this.fotoLoaded = this.fotoSrc;
|
||||
this.disableEdit();
|
||||
|
||||
}
|
||||
|
||||
cancelEdit(){
|
||||
if(this.fotoLoaded)
|
||||
this.fotoSrc = this.fotoLoaded;
|
||||
this.disableEdit();}
|
||||
|
||||
borrarDeGaleria(){
|
||||
this.galeriaFotos.splice(this.currentIndex, 1);
|
||||
|
||||
}
|
||||
|
||||
onSlideChanged() {
|
||||
this.slides.getActiveIndex().then(index =>{
|
||||
this.currentIndex = index;}
|
||||
);
|
||||
|
||||
this.slides.update();
|
||||
}
|
||||
|
||||
addEvento() {
|
||||
this.router.navigate(['prompt-evento']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
16
src/app/tab1/tab1.service.spec.ts
Normal file
16
src/app/tab1/tab1.service.spec.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { Tab1Service } from './tab1.service';
|
||||
|
||||
describe('Tab1Service', () => {
|
||||
let service: Tab1Service;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(Tab1Service);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
54
src/app/tab1/tab1.service.ts
Normal file
54
src/app/tab1/tab1.service.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { Injectable, OnInit } from '@angular/core';
|
||||
import { stringify } from 'querystring';
|
||||
import { Tab1Page } from './tab1.page'
|
||||
import { Discoteca } from '../discoteca'
|
||||
import { Galeria } from '../galeria';
|
||||
import { Evento } from '../evento';
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class Tab1Service implements OnInit{
|
||||
|
||||
discoteca: Discoteca;
|
||||
galeria: Galeria;
|
||||
eventos: Evento[];
|
||||
|
||||
constructor() {
|
||||
|
||||
}
|
||||
|
||||
ngOnInit(){
|
||||
this.initValues();
|
||||
}
|
||||
|
||||
initValues(): void{
|
||||
this.discoteca = new Discoteca();
|
||||
this.discoteca.setNombre('Barraca');
|
||||
this.discoteca.setTelefono(666666666);
|
||||
this.discoteca.setLocalizacion('Calle del Barquillo');
|
||||
this.galeria = new Galeria();
|
||||
this.galeria.setDiscoteca(this.discoteca.getNombre());
|
||||
}
|
||||
|
||||
getNombre(): string{
|
||||
this.initValues();
|
||||
return this.discoteca.getNombre();
|
||||
}
|
||||
|
||||
getTelefono(): number{
|
||||
this.initValues();
|
||||
return this.discoteca.getTelefono();
|
||||
}
|
||||
|
||||
getLocalizacion(): string{
|
||||
this.initValues();
|
||||
return this.discoteca.getLocalizacion();
|
||||
}
|
||||
|
||||
getEventos(): Evento[]{
|
||||
return this.discoteca.getEventos();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user