Skip to content

Commit

Permalink
feat margin cards
Browse files Browse the repository at this point in the history
  • Loading branch information
sansan88 committed Dec 8, 2023
1 parent 46f1c30 commit c4ccdaf
Show file tree
Hide file tree
Showing 16 changed files with 773 additions and 468 deletions.
80 changes: 40 additions & 40 deletions src/app/models/game.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
import { Timestamp } from 'firebase/firestore';
import { Timestamp } from "firebase/firestore";

export interface Game {
id: string
externalId: string
date: string
time: string
dateTime: Timestamp
location: string
city: string
longitude: string
latitude: string
liga: string

name: string
description: string

teamName: string
teamId: string

teamHomeId: string
teamHome: string
teamHomeLogo: string
teamHomeLogoText: string

teamAwayId: string
teamAway: string
teamAwayLogo: string
teamAwayLogoText: string

referee1: string
referee2: string
spectators: string

resut: string
type: string
updated: Date
clubRef: any
teamRef: any
id: string;
externalId: string;
date: string;
time: string;
dateTime: Timestamp;
location: string;
city: string;
longitude: string;
latitude: string;
liga: string;

name: string;
description: string;

teamName: string;
teamId: string;

teamHomeId: string;
teamHome: string;
teamHomeLogo: string;
teamHomeLogoText: string;

teamAwayId: string;
teamAway: string;
teamAwayLogo: string;
teamAwayLogoText: string;

referee1: string;
referee2: string;
spectators: string;

result: string;
type: string;
updated: Date;
clubRef: any;
teamRef: any;

// Business Logic Fields
status: boolean
countAttendees: number
attendees: any
status: boolean;
countAttendees: number;
attendees: any;
}
export interface SwissUnihockeyGame extends Game {}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
<ng-container *ngIf="game$ | async as game">
<ion-header [translucent]="true">
<!--<ion-header [translucent]="true">
<ion-toolbar>
<ion-title></ion-title>
<ion-buttons slot="primary">
<ion-button (click)="close()">{{"common.close" | translate}}</ion-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
</ion-header>-->

<!-- class="ion-padding" -->
<ion-content>
<ion-fab vertical="top" horizontal="end">
<ion-fab-button size="small" (click)="close()">
<ion-icon name="close" size="small"></ion-icon>
</ion-fab-button>
</ion-fab>
<capacitor-google-map #map></capacitor-google-map>
<ion-list [inset]="true">
<ion-list-header> {{"common.details" | translate}} </ion-list-header>
Expand Down Expand Up @@ -48,6 +53,12 @@ <h2>{{game.date}} {{game.time}} Uhr</h2>
<ion-label class="ion-text-wrap">
<h2>{{game.location}} {{game.city}}</h2>
</ion-label>
<ion-icon
color="primary"
(click)="openMaps(game)"
slot="end"
name="map-outline"
></ion-icon>
</ion-item>

<ion-item>
Expand All @@ -56,6 +67,27 @@ <h2>{{game.location}} {{game.city}}</h2>
<h2>{{game.liga}} {{game.teamName}}</h2>
</ion-label>
</ion-item>

<ion-item *ngIf="game.result">
<ion-icon slot="start" name="podium-outline"></ion-icon>
<ion-label class="ion-text-wrap">
<h2>{{game.result}}</h2>
</ion-label>
</ion-item>

<ion-item *ngIf="game.referee1">
<ion-icon slot="start" name="person-circle-outline"></ion-icon>
<ion-label class="ion-text-wrap">
<h2>{{game.referee1}} {{game.referee2}}</h2>
</ion-label>
</ion-item>

<ion-item *ngIf="game.spectators && game.spectators != '0' ">
<ion-icon slot="start" name="people-outline"></ion-icon>
<ion-label class="ion-text-wrap">
<h2>{{game.spectators}}</h2>
</ion-label>
</ion-item>
</ion-list>

<ion-list [inset]="true" lines="none" *ngIf="isFuture">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ import {
} from "@ionic/angular";
import { Game } from "src/app/models/game";
import { GoogleMap } from "@capacitor/google-maps";
import { Geolocation, PermissionStatus } from "@capacitor/geolocation";
import { Browser } from "@capacitor/browser";
import {
Geolocation,
PermissionStatus,
Position,
} from "@capacitor/geolocation";
import { ChampionshipService } from "src/app/services/firebase/championship.service";
import { forkJoin, lastValueFrom, Observable, of } from "rxjs";
import { AuthService } from "src/app/services/auth.service";
Expand Down Expand Up @@ -45,9 +50,7 @@ export class ChampionshipDetailPage implements OnInit {
user$: Observable<User>;
user: User;

attendeeListTrue: any[] = [];
attendeeListFalse: any[] = [];
attendeeListUndefined: any[] = [];
coordinates: Position;

constructor(
private readonly modalCtrl: ModalController,
Expand All @@ -72,28 +75,24 @@ export class ChampionshipDetailPage implements OnInit {
console.log(params);
this.game = JSON.parse(params.data);
*/
this.game$ = of(this.game);

this.attendeeListTrue = [];
this.attendeeListFalse = [];
this.attendeeListUndefined = [];
this.game$ = of(this.game);

this.game$ = this.getGame(this.game.teamId, this.game.id);
this.game$.subscribe({
next: (data) => {
console.log("GAMES Data received");
this.game = {
...this.game,
...data,
};
this.cdr.detectChanges();
this.game$ = this.getGame(this.game.teamId, this.game.id);
this.game$.subscribe({
next: (data) => {
console.log("GAMES Data received");
this.game = {
...this.game,
...data,
};
this.cdr.detectChanges();

this.setMap();
},
error: (err) => console.error("GAMES Error in subscription:", err),
complete: () => console.log("GAMES Observable completed"),
});
// });
this.setMap();
},
error: (err) => console.error("GAMES Error in subscription:", err),
complete: () => console.log("GAMES Observable completed"),
});
// });

// let this.mapRef = @ViewChild('map') abc;
}
Expand Down Expand Up @@ -262,13 +261,16 @@ export class ChampionshipDetailPage implements OnInit {
console.log("No Permission Request possible");
}
try {
const coordinates = await Geolocation.getCurrentPosition();
if (coordinates.coords.latitude && coordinates.coords.longitude) {
this.coordinates = await Geolocation.getCurrentPosition();
if (
this.coordinates.coords.latitude &&
this.coordinates.coords.longitude
) {
this.newMap.addMarker({
title: "Meine Position",
coordinate: {
lat: coordinates.coords.latitude,
lng: coordinates.coords.longitude,
lat: this.coordinates.coords.latitude,
lng: this.coordinates.coords.longitude,
},
isFlat: true,
snippet: "Meine Position",
Expand All @@ -278,4 +280,28 @@ export class ChampionshipDetailPage implements OnInit {
console.log("no coordinates on map");
}
}

openMaps(game: Game) {
if (this.coordinates.coords.longitude && this.coordinates.coords.latitude) {
Browser.open({
url:
"https://www.google.com/maps/dir/?api=1&destination=" +
game.latitude +
"," +
game.longitude +
"&origin=" +
this.coordinates.coords.latitude +
"," +
this.coordinates.coords.longitude,
});
} else {
Browser.open({
url:
"https://www.google.com/maps/dir/?api=1&destination=" +
game.latitude +
"," +
game.longitude,
});
}
}
}
Loading

0 comments on commit c4ccdaf

Please sign in to comment.