Skip to content

Commit 888c943

Browse files
committed
CreateTripPlannerScreen- minor modifications
1 parent 4561fcd commit 888c943

File tree

10 files changed

+93
-22
lines changed

10 files changed

+93
-22
lines changed

src/app/app.component.html

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
<div class="page">
22
<app-toolbar title="UltiCar"></app-toolbar>
33
<div class="main">
4-
<div class="navLinks">
5-
<a [routerLink]="['']">Register</a>
6-
<a [routerLink]="['/login']">Sign In</a>
7-
<a [routerLink]="['/dashboard']">Plan a Trip</a>
8-
</div>
9-
<div id="routing">
10-
<div class="container">
11-
<router-outlet></router-outlet>
12-
</div>
13-
</div>
14-
</div>
4+
<app-header></app-header>
155

src/app/common/common.module.ts

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,55 @@
11
import { NgModule } from '@angular/core';
22
import { CommonModule } from '@angular/common';
3+
import { AgmCoreModule } from '@agm/core'
34
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
5+
import { Routes, RouterModule } from '@angular/router';
46
import { TextBoxComponent } from './components/presentation/text-box/text-box.component';
57
import { LoginComponent } from './components/smart/login/login.component';
68
import { CheckBoxComponent } from './components/presentation/check-box/check-box.component';
79
import { ToolbarComponent } from './components/presentation/toolbar/toolbar.component';
810
import { RaisedButtonComponent } from './components/presentation/raised-button/raised-button.component';
911
import { BasicButtonComponent } from './components/presentation/basic-button/basic-button.component';
1012
import { IconButtonComponent } from './components/presentation/icon-button/icon-button.component';
11-
import { GMapsDirectionsDirective } from './states/gmaps.directive';
13+
import { GMapsDirectionsService} from './states/gmaps.service';
1214
import { MatToolbarModule, MatCheckboxModule, MatButtonModule, MatFormFieldModule, MatFormFieldControl, MatInputModule, MatIconModule, MatCardModule, MatAutocompleteModule } from '@angular/material';
15+
import { HeaderComponent } from './components/presentation/header/header.component';
1316

1417
@NgModule({
1518
imports: [
16-
CommonModule, MatToolbarModule, MatCheckboxModule, MatButtonModule, MatFormFieldModule, MatInputModule, MatIconModule, MatCardModule, FormsModule, ReactiveFormsModule, MatAutocompleteModule
19+
CommonModule,
20+
MatToolbarModule,
21+
MatCheckboxModule,
22+
MatButtonModule,
23+
MatFormFieldModule,
24+
MatInputModule,
25+
MatIconModule,
26+
MatCardModule,
27+
FormsModule,
28+
ReactiveFormsModule,
29+
MatAutocompleteModule,
30+
AgmCoreModule,
31+
RouterModule
32+
],
33+
declarations: [
34+
TextBoxComponent,
35+
LoginComponent,
36+
CheckBoxComponent,
37+
ToolbarComponent,
38+
RaisedButtonComponent,
39+
BasicButtonComponent,
40+
IconButtonComponent,
41+
GMapsDirectionsService,
42+
HeaderComponent
43+
],
44+
exports: [
45+
ToolbarComponent,
46+
MatCardModule,
47+
RaisedButtonComponent,
48+
ReactiveFormsModule,
49+
MatAutocompleteModule,
50+
GMapsDirectionsService,
51+
HeaderComponent
1752
],
18-
declarations: [TextBoxComponent, LoginComponent, CheckBoxComponent, ToolbarComponent, RaisedButtonComponent, BasicButtonComponent, IconButtonComponent, GMapsDirectionsDirective],
19-
exports: [ToolbarComponent, MatCardModule, RaisedButtonComponent, ReactiveFormsModule, MatAutocompleteModule, GMapsDirectionsDirective],
20-
2153
})
2254

2355
export class FeCommonModule { }
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<div class="navLinks">
2+
<a [routerLink]="['']">Register</a>
3+
<a [routerLink]="['/login']">Sign In</a>
4+
<a [routerLink]="['/dashboard']">Plan a Trip</a>
5+
</div>
6+
<div id="routing">
7+
<div class="container">
8+
<router-outlet></router-outlet>
9+
</div>
10+
</div>

src/app/common/components/presentation/header/header.component.scss

Whitespace-only changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Component, OnInit } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-header',
5+
templateUrl: './header.component.html',
6+
styleUrls: ['./header.component.scss']
7+
})
8+
export class HeaderComponent implements OnInit {
9+
10+
constructor() { }
11+
12+
ngOnInit() {
13+
}
14+
15+
}

src/app/common/states/gmaps.directive.ts renamed to src/app/common/states/gmaps.service.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ declare var google: any;
77
selector: 'directions-service'
88
})
99

10-
export class GMapsDirectionsDirective {
10+
export class GMapsDirectionsService {
1111

1212
@Input() origin: any;
1313
@Input() destination: any;
@@ -22,6 +22,7 @@ export class GMapsDirectionsDirective {
2222

2323
updateDirections() {
2424
this.gmapsApi.getNativeMap().then(map => {
25+
//Prepare Map and Display Settings
2526
if (!this.originPlaceId || !this.destinationPlaceId) {
2627
return;
2728
}
@@ -40,13 +41,19 @@ export class GMapsDirectionsDirective {
4041
}
4142
});
4243

44+
//Update Display
4345
this.directionsDisplay.setDirections({ routes: [] });
46+
47+
//Determine Directions
48+
//Request
4449
directionsService.route({
4550
origin: { placeId: this.originPlaceId },
4651
destination: { placeId: this.destinationPlaceId },
4752
avoidHighways: true,
4853
travelMode: google.maps.DirectionsTravelMode.DRIVING
49-
}, function (response: any, status: any) {
54+
},
55+
//Response
56+
function (response: any, status: any) {
5057
if (status === 'OK') {
5158
service.directionsDisplay.setDirections(response);
5259
map.setZoom(30);
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
<mat-card>
22
<h1>{{ title }}</h1>
33
<div class="container">
4-
<agm-map [latitude]="latitude" [longitude]="longitude" [zoom]="zoom" [styles]="mapCustomStyles">
5-
<directions-service [origin]="origin" [destination]="destination"></directions-service>
4+
<agm-map [latitude]="latitude" [longitude]="longitude" [zoom]="zoom">
5+
<directions-service></directions-service>
66
</agm-map>
77
</div>
8-
<br/><br/>
98
<div class="trip-inputs">
109
<input placeholder="Enter your pickup location." autocorrect="off" autocapitalize="off" spellcheck="off" type="text" class="form-control"
1110
#pickupInput [formControl]="destinationInput" size="55">
1211
<input placeholder="Enter your destination." autocorrect="off" autocapitalize="off" spellcheck="off" type="text" class="form-control"
1312
#pickupOutput [formControl]="destinationOutput" size="55">
1413
</div>
15-
<app-raised-button label="Find Your Ride" color="primary" (click)="onFindRideClick($event)"></app-raised-button>
14+
<app-raised-button label="Find Your Ride" color="primary"></app-raised-button>
1615
</mat-card>

src/app/passengers/components/smart/trip-planner/trip-planner.component.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ agm-map {
55
}
66

77
.trip-inputs {
8+
padding-top: 30px;
89
padding-bottom: 30px;
910
}
1011

src/app/passengers/components/smart/trip-planner/trip-planner.component.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Component, OnInit, Input, ElementRef, NgZone, ViewChild } from '@angular/core';
22
import { FormControl, ReactiveFormsModule } from '@angular/forms';
33
import { GMapsDirectionsDirective } from 'app/common/states/gmaps.directive';
4+
import { GMapsDirectionsService } from 'app/common/states/gmaps.service';
45
import { } from '@types/googlemaps';
56
import { GoogleMapsAPIWrapper, MapsAPILoader } from '@agm/core';
67

@@ -30,13 +31,16 @@ export class TripPlannerComponent implements OnInit {
3031
public pickupOutputElementRef: ElementRef;
3132

3233
@ViewChild(GMapsDirectionsDirective) directive: GMapsDirectionsDirective;
34+
@ViewChild(GMapsDirectionsService) service: GMapsDirectionsService;
3335

3436
constructor(
3537
private ngZone: NgZone,
3638
private mapsAPILoader: MapsAPILoader,
3739
private gmapsApi: GoogleMapsAPIWrapper,
3840
private _elementRef: ElementRef) {
3941
}
42+
private gmapsApi: GoogleMapsAPIWrapper,
43+
) { }
4044

4145
ngOnInit() {
4246
//Default Map View
@@ -83,16 +87,23 @@ export class TripPlannerComponent implements OnInit {
8387
if (inputType === 'pickup') {
8488
this.directive.origin = { longitude: place.geometry.location.lng(), latitude: place.geometry.location.lat() };
8589
this.directive.originPlaceId = place.place_id;
90+
this.service.origin = { longitude: place.geometry.location.lng(), latitude: place.geometry.location.lat() };
91+
this.service.originPlaceId = place.place_id;
8692
} else {
8793
this.directive.destination = { longitude: place.geometry.location.lng(), latitude: place.geometry.location.lat() };
8894
this.directive.destinationPlaceId = place.place_id;
95+
this.service.destination = { longitude: place.geometry.location.lng(), latitude: place.geometry.location.lat() };
96+
this.service.destinationPlaceId = place.place_id;
8997
}
9098
if (this.directive.directionsDisplay === undefined) {
99+
if (this.service.directionsDisplay === undefined) {
91100
this.mapsAPILoader.load().then(() => {
92101
this.directive.directionsDisplay = new google.maps.DirectionsRenderer;
102+
this.service.directionsDisplay = new google.maps.DirectionsRenderer;
93103
});
94104
}
95105
this.directive.updateDirections();
106+
this.service.updateDirections();
96107
this.zoom = 12;
97108
});
98109
});
@@ -101,6 +112,8 @@ export class TripPlannerComponent implements OnInit {
101112
getDistanceAndDuration() {
102113
this.estimatedTime = this.directive.estimatedTime;
103114
this.estimatedDistance = this.directive.estimatedDistance;
115+
this.estimatedTime = this.service.estimatedTime;
116+
this.estimatedDistance = this.service.estimatedDistance;
104117
}
105118

106119
onFindRideClick(event) {

src/styles.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
@include mat-core();
44

5+
body {
6+
margin: 0px;
7+
}
8+
59
$my-theme-primary: mat-palette($mat-cyan);
610
$my-theme-accent: mat-palette($mat-teal);
711
$my-theme-warn: mat-palette($mat-red);

0 commit comments

Comments
 (0)