Skip to content

Commit

Permalink
Apk Buil Version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
deliciafernandes committed Dec 10, 2020
1 parent 322892c commit 637d58c
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 72 deletions.
84 changes: 28 additions & 56 deletions ResponseApp/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import 'dart:io';
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';

// import 'views/DetailedNewsPage.dart';
// import 'views/HomePage.dart';
// import 'views/MapsBody.dart';
// import 'views/NewsBody.dart';
// import 'views/OnboardingScreen.dart';
// import 'views/SOS.dart';
// import 'views/SOSselect.dart';
// import 'views/WhatToDoBody.dart';
// import 'package:response/views/Flood.dart';
import 'views/DetailedNewsPage.dart';
import 'views/HomePage.dart';
import 'views/MapsBody.dart';
import 'views/NewsBody.dart';
import 'views/OnboardingScreen.dart';
import 'views/SOS.dart';
import 'views/SOSselect.dart';
import 'views/WhatToDoBody.dart';
import 'package:response/views/Flood.dart';

void main() {
SystemChrome.setSystemUIOverlayStyle(
Expand All @@ -32,55 +30,29 @@ void main() {
runApp(ResponseApp());
}

class ResponseApp extends StatefulWidget {
@override
_ResponseAppState createState() => _ResponseAppState();
}

class _ResponseAppState extends State<ResponseApp> {
Completer<GoogleMapController> _controller = Completer();

static const LatLng _center = const LatLng(45.521563, -122.677433);

void _onMapCreated(GoogleMapController controller) {
_controller.complete(controller);
}

class ResponseApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
// initialRoute: HomePage.id,
// routes: {
// OnboardingScreen.id: (context) => OnboardingScreen(),
//
// //Home Screens
// HomePage.id: (context) => HomePage(),
// WhatToDoBody.id: (context) => WhatToDoBody(),
// NewsBody.id: (context) => NewsBody(),
// MapsBody.id: (context) => MapsBody(),
// Flood.id: (context) => Flood(),
//
// //SOS page
// SOS.id: (context) => SOS(),
// SOSselect.id: (context) => SOSselect(),
//
// //Detailed Screens
// DetailedNewsPage.id: (context) => DetailedNewsPage(),
// },
home: Scaffold(
appBar: AppBar(
title: Text('Maps Sample App'),
backgroundColor: Colors.green[700],
),
body: GoogleMap(
onMapCreated: _onMapCreated,
initialCameraPosition: CameraPosition(
target: _center,
zoom: 11.0,
),
),
),
initialRoute: HomePage.id,
routes: {
OnboardingScreen.id: (context) => OnboardingScreen(),

//Home Screens
HomePage.id: (context) => HomePage(),
WhatToDoBody.id: (context) => WhatToDoBody(),
NewsBody.id: (context) => NewsBody(),
MapsBody.id: (context) => MapsBody(),
Flood.id: (context) => Flood(),

//SOS page
SOS.id: (context) => SOS(),
SOSselect.id: (context) => SOSselect(),

//Detailed Screens
DetailedNewsPage.id: (context) => DetailedNewsPage(),
},
);
}
}
10 changes: 9 additions & 1 deletion ResponseApp/lib/utilities/LocationService.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import 'package:geolocator/geolocator.dart';
import 'package:geocoder/geocoder.dart';
import 'dart:async';

class LocationService {
String _userLocation = 'INDIA';
double latitude;
double longitude;

Future<String> getLocation() async {
GeolocationStatus geolocationStatus =
await Geolocator().checkGeolocationPermissionStatus();

try {
Position position = await Geolocator()
.getCurrentPosition(desiredAccuracy: LocationAccuracy.medium);
.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);

// Position position = await Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.medium);

final coordinates = Coordinates(position.latitude, position.longitude);
var addresses =
Expand Down Expand Up @@ -46,8 +52,10 @@ class LocationService {
Position position = await Geolocator()
.getCurrentPosition(desiredAccuracy: LocationAccuracy.low);

print("here ${position.latitude}");
return position.latitude;
} catch (e) {
print(e);
return 20.5937;
}
}
Expand Down
9 changes: 3 additions & 6 deletions ResponseApp/lib/views/MapsBody.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class _MapsBodyState extends State<MapsBody> {
markerId: MarkerId(_lastMapPosition.toString()),
position: _lastMapPosition,
infoWindow: InfoWindow(
title: 'Really cool place',
snippet: '5 Star Rating',
title: 'Your Current Location',
snippet: "Mumbai",
),
icon: BitmapDescriptor.defaultMarker,
));
Expand All @@ -73,11 +73,8 @@ class _MapsBodyState extends State<MapsBody> {

@override
void initState() {
// getLocationData();

getLocationData();
super.initState();

//map code
}

@override
Expand Down
15 changes: 6 additions & 9 deletions ResponseApp/lib/views/NewsBody.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class _NewsBodyState extends State<NewsBody> {
String _isClicked = 'national';

LocationService locationService = LocationService();
var userLocation;
var userLocation = "MUMBAI";

//New firestore instance
final _firestore = Firestore.instance;
Expand All @@ -31,13 +31,15 @@ class _NewsBodyState extends State<NewsBody> {

@override
void initState() {
super.initState();
getLocationData();
super.initState();
}

void getLocationData() async {
//Needs to be future!
Future getLocationData() async {
// Fetching _userLocation
userLocation = await locationService.getLocation();
setState(() {});
}

@override
Expand All @@ -49,8 +51,6 @@ class _NewsBodyState extends State<NewsBody> {
allowFontScaling: true,
);

print(userLocation);

return Column(
children: [
CustomAppBar(),
Expand Down Expand Up @@ -167,10 +167,7 @@ class _NewsBodyState extends State<NewsBody> {
: news.data['location']);

String newsLocation = location.toUpperCase();

//TODO: userLocation giving null
var temp = "MUMBAI";
if (temp.contains(newsLocation)) {
if (userLocation.contains(newsLocation)) {
//date conversion
DateTime myDateTime =
DateTime.parse(news.data['date'].toDate().toString());
Expand Down
1 change: 1 addition & 0 deletions ResponseApp/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dependencies:
intl:
geolocator: ^5.3.2+2
geocoder: ^0.2.1
# permission_handler: ^5.0.1+1

# Google Services:
provider: ^4.3.1
Expand Down

0 comments on commit 637d58c

Please sign in to comment.