-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use components for home page
1 parent
23e777a
commit bbd3f30
Showing
13 changed files
with
163 additions
and
162 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<capacitor-google-map #mapRef></capacitor-google-map> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
capacitor-google-map { | ||
display: inline-block; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
ion-content { | ||
--background: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; | ||
import { IonicModule } from '@ionic/angular'; | ||
|
||
import { MapComponent } from './map.component'; | ||
|
||
describe('MapComponent', () => { | ||
let component: MapComponent; | ||
let fixture: ComponentFixture<MapComponent>; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [MapComponent], | ||
imports: [IonicModule.forRoot()], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(MapComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
})); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { | ||
AfterViewInit, | ||
Component, | ||
ElementRef, | ||
OnDestroy, | ||
OnInit, | ||
ViewChild, | ||
} from '@angular/core'; | ||
import { destroyMap, loadMap } from '../../state/map/map.actions'; | ||
import { AppState } from '../../state/app.state'; | ||
import { Store } from '@ngrx/store'; | ||
import { MapConfiguration } from './map-configuration'; | ||
|
||
@Component({ | ||
selector: 'app-map', | ||
templateUrl: './map.component.html', | ||
styleUrls: ['./map.component.scss'], | ||
}) | ||
export class MapComponent implements OnInit, AfterViewInit, OnDestroy { | ||
@ViewChild('mapRef', { static: false }) mapRef?: ElementRef; | ||
|
||
constructor(private store: Store<AppState>) {} | ||
|
||
ngOnInit() {} | ||
|
||
ngAfterViewInit() { | ||
if (this.mapRef) { | ||
this.store.dispatch( | ||
loadMap({ map: this.mapRef, config: MapConfiguration }), | ||
); | ||
} else { | ||
console.log('TODO: MapRef is undefined'); | ||
} | ||
} | ||
|
||
ngOnDestroy() { | ||
this.store.dispatch(destroyMap()); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
app/src/app/components/refuge-modal/refuge-modal.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<ng-container *ngIf="modalState$ | async as state"> | ||
<ion-modal | ||
#modal | ||
[isOpen]="state.isOpen" | ||
[breakpoints]="[0, 0.3, 1]" | ||
[initialBreakpoint]="0.3" | ||
(ionModalDidDismiss)="dismissedModal()" | ||
class="ion-modal" | ||
> | ||
<ng-template class="example-modal"> | ||
<app-refuge | ||
class="example-modal" | ||
[refuge]="state.refuge" | ||
(clickedBar)="changeCurrentModalSize(modal)" | ||
></app-refuge> | ||
</ng-template> | ||
</ion-modal> | ||
</ng-container> |
3 changes: 3 additions & 0 deletions
3
app/src/app/components/refuge-modal/refuge-modal.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.ion-modal { | ||
--width: 100%; | ||
} |
24 changes: 24 additions & 0 deletions
24
app/src/app/components/refuge-modal/refuge-modal.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; | ||
import { IonicModule } from '@ionic/angular'; | ||
|
||
import { RefugeModalComponent } from './refuge-modal.component'; | ||
|
||
describe('RefugeModalComponent', () => { | ||
let component: RefugeModalComponent; | ||
let fixture: ComponentFixture<RefugeModalComponent>; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [RefugeModalComponent], | ||
imports: [IonicModule.forRoot()], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(RefugeModalComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
})); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
30 changes: 30 additions & 0 deletions
30
app/src/app/components/refuge-modal/refuge-modal.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { IonModal } from '@ionic/angular'; | ||
import { closeModal } from '../../state/components/modal/modal.actions'; | ||
import { selectModalState } from '../../state/components/modal/modal.selectors'; | ||
import { AppState } from '../../state/app.state'; | ||
import { Store } from '@ngrx/store'; | ||
|
||
@Component({ | ||
selector: 'app-refuge-modal', | ||
templateUrl: './refuge-modal.component.html', | ||
styleUrls: ['./refuge-modal.component.scss'], | ||
}) | ||
export class RefugeModalComponent implements OnInit { | ||
modalState$ = this.store.select(selectModalState); | ||
|
||
constructor(private store: Store<AppState>) {} | ||
|
||
ngOnInit() {} | ||
|
||
dismissedModal() { | ||
this.store.dispatch(closeModal()); | ||
} | ||
|
||
changeCurrentModalSize(modal: IonModal) { | ||
modal.getCurrentBreakpoint().then((breakpoint) => { | ||
if (breakpoint == 1) modal.setCurrentBreakpoint(0.3).then(); | ||
if (breakpoint == 0.3) modal.setCurrentBreakpoint(1).then(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,5 @@ | ||
<app-searchbar-location></app-searchbar-location> | ||
<ion-content [fullscreen]="true"> | ||
<ng-container *ngIf="modalState$ | async as state"> | ||
<ion-modal | ||
#modal | ||
[isOpen]="state.isOpen" | ||
[breakpoints]="[0, 0.3, 1]" | ||
[initialBreakpoint]="0.3" | ||
(ionModalDidDismiss)="dismissedModal()" | ||
class="ion-modal" | ||
> | ||
<ng-template class="example-modal"> | ||
<app-refuge | ||
class="example-modal" | ||
[refuge]="state.refuge" | ||
(clickedBar)="changeCurrentModalSize(modal)" | ||
></app-refuge> | ||
</ng-template> | ||
</ion-modal> | ||
</ng-container> | ||
<capacitor-google-map #mapRef></capacitor-google-map> | ||
<app-refuge-modal></app-refuge-modal> | ||
<app-map></app-map> | ||
</ion-content> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +0,0 @@ | ||
#container { | ||
text-align: center; | ||
|
||
position: absolute; | ||
left: 0; | ||
right: 0; | ||
top: 50%; | ||
transform: translateY(-50%); | ||
} | ||
|
||
#container strong { | ||
font-size: 20px; | ||
line-height: 26px; | ||
} | ||
|
||
#container p { | ||
font-size: 16px; | ||
line-height: 22px; | ||
|
||
color: #8c8c8c; | ||
|
||
margin: 0; | ||
} | ||
|
||
#container a { | ||
text-decoration: none; | ||
} | ||
|
||
capacitor-google-map { | ||
display: inline-block; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
ion-content { | ||
--background: none; | ||
} | ||
|
||
#container { | ||
text-align: center; | ||
position: absolute; | ||
left: 0; | ||
right: 0; | ||
top: 50%; | ||
transform: translateY(-50%); | ||
} | ||
|
||
#container strong { | ||
font-size: 20px; | ||
line-height: 26px; | ||
} | ||
|
||
#container p { | ||
font-size: 16px; | ||
line-height: 22px; | ||
color: #8c8c8c; | ||
margin: 0; | ||
} | ||
|
||
#container a { | ||
text-decoration: none; | ||
} | ||
|
||
ion-list { | ||
padding-top: 0; | ||
padding-bottom: 0; | ||
} | ||
|
||
.ion-modal { | ||
--width: 100%; | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters