clean up, and a few tests #57
|
@ -11,10 +11,11 @@ class ListViewPage extends StatefulWidget {
|
||||||
const ListViewPage({Key? key}) : super(key: key);
|
const ListViewPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ListViewPage> createState() => _ListViewPageState();
|
State<ListViewPage> createState() => ListViewPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ListViewPageState extends State<ListViewPage> {
|
@visibleForTesting
|
||||||
|
class ListViewPageState extends State<ListViewPage> {
|
||||||
final List<Venue> allVenues = globals.VENUES;
|
final List<Venue> allVenues = globals.VENUES;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
375
lib/Map.dart
375
lib/Map.dart
|
@ -1,22 +1,12 @@
|
||||||
import 'dart:convert';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_applicationdemo/BottomNavPage.dart';
|
import 'package:flutter_applicationdemo/BottomNavPage.dart';
|
||||||
import 'package:flutter_applicationdemo/ListViewPage.dart';
|
|
||||||
import 'package:flutter_applicationdemo/WeatherData.dart';
|
|
||||||
import 'package:flutter_applicationdemo/WebScraper.dart';
|
import 'package:flutter_applicationdemo/WebScraper.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:flutter_applicationdemo/HomePage.dart';
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'login/User.dart';
|
import 'login/User.dart';
|
||||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||||
import 'package:flutter_google_places/flutter_google_places.dart';
|
import 'package:flutter_google_places/flutter_google_places.dart';
|
||||||
import 'package:http/http.dart' as http;
|
|
||||||
import 'package:http/retry.dart';
|
|
||||||
import 'package:intl/number_symbols.dart';
|
|
||||||
import 'package:location/location.dart';
|
import 'package:location/location.dart';
|
||||||
import 'package:geolocator/geolocator.dart';
|
|
||||||
import 'package:intl/intl.dart';
|
|
||||||
import 'package:flutter_applicationdemo/login/User.dart';
|
import 'package:flutter_applicationdemo/login/User.dart';
|
||||||
import 'SettingsPage.dart';
|
import 'SettingsPage.dart';
|
||||||
import 'venuePage.dart';
|
import 'venuePage.dart';
|
||||||
|
@ -25,7 +15,6 @@ import 'globals.dart' as globals;
|
||||||
|
|
||||||
import 'package:syncfusion_flutter_sliders/sliders.dart';
|
import 'package:syncfusion_flutter_sliders/sliders.dart';
|
||||||
|
|
||||||
import 'HomePage.dart';
|
|
||||||
import 'FeedbackPage.dart';
|
import 'FeedbackPage.dart';
|
||||||
import 'login/CreateAccountPage.dart';
|
import 'login/CreateAccountPage.dart';
|
||||||
import 'login/signInPage.dart';
|
import 'login/signInPage.dart';
|
||||||
|
@ -37,7 +26,7 @@ class Map extends StatefulWidget {
|
||||||
|
|
||||||
const kGoogleApiKey = "AIzaSyAUmhd6Xxud8SwgDxJ4LlYlcntm01FGoSk";
|
const kGoogleApiKey = "AIzaSyAUmhd6Xxud8SwgDxJ4LlYlcntm01FGoSk";
|
||||||
|
|
||||||
final homeSacffoldKey = GlobalKey<ScaffoldState>();
|
final homeScaffoldKey = GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
late CameraPosition _currentCameraPosition;
|
late CameraPosition _currentCameraPosition;
|
||||||
|
|
||||||
|
@ -77,8 +66,7 @@ class MapState extends State<Map> {
|
||||||
void createBottomSheet(String venueName) async {
|
void createBottomSheet(String venueName) async {
|
||||||
var webScraper = WebScraper();
|
var webScraper = WebScraper();
|
||||||
await webScraper.getWebsiteData(venueName);
|
await webScraper.getWebsiteData(venueName);
|
||||||
Scaffold.of(context).showBottomSheet<void>(
|
Scaffold.of(context).showBottomSheet<void>(((context) {
|
||||||
((context) {
|
|
||||||
return Container(
|
return Container(
|
||||||
height: 420,
|
height: 420,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
|
@ -87,13 +75,7 @@ class MapState extends State<Map> {
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
/*const Text('BottomSheet'),
|
Text(webScraper.openingHoursThisWeek.length.toString()),
|
||||||
ElevatedButton(
|
|
||||||
child: const Text('Close BottomSheet'),
|
|
||||||
onPressed: () {Navigator.pop(context);})*/
|
|
||||||
Container(
|
|
||||||
child: Text(webScraper.openingHoursThisWeek.length.toString()),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
|
@ -139,6 +121,7 @@ class MapState extends State<Map> {
|
||||||
final Mode _mode = Mode.fullscreen;
|
final Mode _mode = Mode.fullscreen;
|
||||||
|
|
||||||
int currentIndex = 0;
|
int currentIndex = 0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
_currentCameraPosition = _stockholmCity;
|
_currentCameraPosition = _stockholmCity;
|
||||||
|
@ -146,27 +129,29 @@ class MapState extends State<Map> {
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
title: const Text("Sun chasers"),
|
title: const Text("Sun chasers"),
|
||||||
key: homeSacffoldKey,
|
key: homeScaffoldKey,
|
||||||
actions: <Widget>[createFilterMenuButton()],
|
actions: <Widget>[createFilterMenuButton()],
|
||||||
backgroundColor: const Color.fromARGB(255, 190, 146, 160),
|
backgroundColor: const Color.fromARGB(255, 190, 146, 160),
|
||||||
),
|
),
|
||||||
drawer : Drawer(
|
drawer: Drawer(
|
||||||
child: Container(
|
child: Container(
|
||||||
child: globals.LOGGED_IN_USER.userID == 0 ? buildDrawerSignedOut(context) : buildDrawerSignedIn(context),
|
child: globals.LOGGED_IN_USER.userID == 0
|
||||||
|
? buildDrawerSignedOut(context)
|
||||||
|
: buildDrawerSignedIn(context),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
body: Stack(
|
||||||
body: Stack (
|
|
||||||
children: [
|
children: [
|
||||||
GoogleMap(
|
GoogleMap(
|
||||||
cameraTargetBounds: CameraTargetBounds(LatLngBounds(
|
cameraTargetBounds: CameraTargetBounds(LatLngBounds(
|
||||||
northeast: const LatLng(59.3474696569038, 18.1001602476002147),
|
northeast: const LatLng(59.3474696569038, 18.1001602476002147),
|
||||||
southwest: const LatLng(59.297332547922636, 17.999522500277884))),
|
southwest:
|
||||||
|
const LatLng(59.297332547922636, 17.999522500277884))),
|
||||||
minMaxZoomPreference: MinMaxZoomPreference(12.5, 18.5),
|
minMaxZoomPreference: MinMaxZoomPreference(12.5, 18.5),
|
||||||
onCameraMove: (CameraPosition camera){
|
onCameraMove: (CameraPosition camera) {
|
||||||
_currentCameraPosition = camera;
|
_currentCameraPosition = camera;
|
||||||
},
|
},
|
||||||
onCameraIdle: (){
|
onCameraIdle: () {
|
||||||
(context as Element).reassemble();
|
(context as Element).reassemble();
|
||||||
removeMarkersOutOfRange();
|
removeMarkersOutOfRange();
|
||||||
addMarkersInRange();
|
addMarkersInRange();
|
||||||
|
@ -185,8 +170,8 @@ class MapState extends State<Map> {
|
||||||
closeBottomSheetIfOpen();
|
closeBottomSheetIfOpen();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
// ElevatedButton(onPressed: () {} //_handelPressButton
|
// ElevatedButton(onPressed: () {} //_handelPressButton
|
||||||
// ,child: const Text("Search Placses"))
|
// ,child: const Text("Search Placses"))
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
floatingActionButton: Padding(
|
floatingActionButton: Padding(
|
||||||
|
@ -298,8 +283,8 @@ class MapState extends State<Map> {
|
||||||
));
|
));
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
PopupMenuItem<dynamic> createPriceSlider() {
|
PopupMenuItem<dynamic> createPriceSlider() {
|
||||||
|
@ -339,43 +324,6 @@ class MapState extends State<Map> {
|
||||||
CameraPosition(target: LatLng(lat, lng), zoom: 14.5)));
|
CameraPosition(target: LatLng(lat, lng), zoom: 14.5)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _boxes(double lat, double lng, String restaurantName) {
|
|
||||||
return GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
_gotoLocation(lat, lng);
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
child: FittedBox(
|
|
||||||
child: Material(
|
|
||||||
color: Colors.white,
|
|
||||||
elevation: 14.0,
|
|
||||||
borderRadius: BorderRadius.circular(24.0),
|
|
||||||
shadowColor: Color(0x802196F3),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: <Widget>[
|
|
||||||
Container(
|
|
||||||
width: 250,
|
|
||||||
height: 200,
|
|
||||||
child: ClipRRect(
|
|
||||||
borderRadius: new BorderRadius.circular(24.0),
|
|
||||||
child:
|
|
||||||
const Image(image: AssetImage('assets/images/bild.png')),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Text(restaurantName),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _goToCurrentPosition(LatLng latlng) async {
|
Future<void> _goToCurrentPosition(LatLng latlng) async {
|
||||||
final GoogleMapController controller = await _controller.future;
|
final GoogleMapController controller = await _controller.future;
|
||||||
controller.animateCamera(CameraUpdate.newCameraPosition(CameraPosition(
|
controller.animateCamera(CameraUpdate.newCameraPosition(CameraPosition(
|
||||||
|
@ -386,26 +334,36 @@ class MapState extends State<Map> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeMarkersOutOfRange() {
|
void removeMarkersOutOfRange() {
|
||||||
for(int i = 0; i<closeByMarkersList.length; i++){
|
for (int i = 0; i < closeByMarkersList.length; i++) {
|
||||||
Marker marker = closeByMarkersList[i];
|
Marker marker = closeByMarkersList[i];
|
||||||
globals.venueAlreadyAdded(globals.getVenueByID(int.parse(marker.markerId.value))!.venueName);
|
globals.venueAlreadyAdded(
|
||||||
if(marker.position.longitude - _currentCameraPosition.target.longitude > 0.02 || marker.position.latitude - _currentCameraPosition.target.latitude > 0.02){
|
globals.getVenueByID(int.parse(marker.markerId.value))!.venueName);
|
||||||
|
if (marker.position.longitude - _currentCameraPosition.target.longitude >
|
||||||
|
0.02 ||
|
||||||
|
marker.position.latitude - _currentCameraPosition.target.latitude >
|
||||||
|
0.02) {
|
||||||
closeByMarkersList.remove(marker);
|
closeByMarkersList.remove(marker);
|
||||||
globals.getVenueByID(int.parse(marker.markerId.value))?.isShownOnMap = false;
|
globals.getVenueByID(int.parse(marker.markerId.value))?.isShownOnMap =
|
||||||
|
false;
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addMarkersInRange() {
|
void addMarkersInRange() {
|
||||||
for(int i = 0; i< globals.VENUES.length; i++){
|
for (int i = 0; i < globals.VENUES.length; i++) {
|
||||||
if(!globals.VENUES[i].isShownOnMap && (globals.VENUES[i].position.longitude - _currentCameraPosition.target.longitude < 0.02 && globals.VENUES[i].position.latitude - _currentCameraPosition.target.latitude < 0.02)){
|
if (!globals.VENUES[i].isShownOnMap &&
|
||||||
|
(globals.VENUES[i].position.longitude -
|
||||||
|
_currentCameraPosition.target.longitude <
|
||||||
|
0.02 &&
|
||||||
|
globals.VENUES[i].position.latitude -
|
||||||
|
_currentCameraPosition.target.latitude <
|
||||||
|
0.02)) {
|
||||||
Marker marker = Marker(
|
Marker marker = Marker(
|
||||||
markerId: MarkerId(globals.VENUES[i].venueID.toString()),
|
markerId: MarkerId(globals.VENUES[i].venueID.toString()),
|
||||||
position: globals.VENUES[i].position,
|
position: globals.VENUES[i].position,
|
||||||
onTap: () => createBottomDrawer(globals.VENUES[i]),
|
onTap: () => createBottomDrawer(globals.VENUES[i]),
|
||||||
icon: globals.VENUES[i].drawIconColor()
|
icon: globals.VENUES[i].drawIconColor());
|
||||||
);
|
|
||||||
globals.VENUES[i].isShownOnMap = true;
|
globals.VENUES[i].isShownOnMap = true;
|
||||||
closeByMarkersList.add(marker);
|
closeByMarkersList.add(marker);
|
||||||
}
|
}
|
||||||
|
@ -415,27 +373,29 @@ class MapState extends State<Map> {
|
||||||
createBottomDrawer(Venue venue) async {
|
createBottomDrawer(Venue venue) async {
|
||||||
_bottomSheetIsOpen = true;
|
_bottomSheetIsOpen = true;
|
||||||
// Scaffold.of(context).showBottomSheet<void>(((context) {
|
// Scaffold.of(context).showBottomSheet<void>(((context) {
|
||||||
showModalBottomSheet(context: context, builder: (BuildContext context) {
|
showModalBottomSheet(
|
||||||
return InkWell(
|
context: context,
|
||||||
onTap: () {
|
builder: (BuildContext context) {
|
||||||
Navigator.push(
|
return InkWell(
|
||||||
context,
|
onTap: () {
|
||||||
MaterialPageRoute(builder: (context) => VenuePage(venue)),
|
Navigator.push(
|
||||||
);
|
context,
|
||||||
},
|
MaterialPageRoute(builder: (context) => VenuePage(venue)),
|
||||||
child: Container(
|
);
|
||||||
height: 175,
|
},
|
||||||
color: const Color(0xFFF5F5F5),
|
child: Container(
|
||||||
child: Center(
|
height: 175,
|
||||||
child: Column(
|
color: const Color(0xFFF5F5F5),
|
||||||
children: [
|
child: Center(
|
||||||
bottomSheetWidgetContainer(venue, context),
|
child: Column(
|
||||||
],
|
children: [
|
||||||
|
bottomSheetWidgetContainer(venue, context),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
),
|
});
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Container bottomSheetWidgetContainer(Venue venue, BuildContext context) {
|
Container bottomSheetWidgetContainer(Venue venue, BuildContext context) {
|
||||||
|
@ -454,7 +414,6 @@ class MapState extends State<Map> {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
// columnCoveringRating(),
|
// columnCoveringRating(),
|
||||||
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
|
@ -465,8 +424,8 @@ class MapState extends State<Map> {
|
||||||
children: [
|
children: [
|
||||||
Column(
|
Column(
|
||||||
children: const [
|
children: const [
|
||||||
weatherIconRow(),
|
WeatherIconRow(),
|
||||||
weatherStatusRow(),
|
WeatherStatusRow(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
columnHandlingReadMoreButton(context, venue),
|
columnHandlingReadMoreButton(context, venue),
|
||||||
|
@ -544,45 +503,14 @@ class MapState extends State<Map> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAllMarkersAsInvisible() {
|
void setAllMarkersAsInvisible() {
|
||||||
for(Venue venue in hiddenVenues){
|
for (Venue venue in hiddenVenues) {
|
||||||
venue.isShownOnMap = false;
|
venue.isShownOnMap = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
Future<void> _handelPressButton() async {
|
|
||||||
Prediction? p = await PlacesAutocomplete.show(
|
|
||||||
context: context,
|
|
||||||
apiKey: kGoogleApiKey,
|
|
||||||
mode: _mode, // Mode.fullscreen
|
|
||||||
language: "en",
|
|
||||||
strictbounds: false,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
hintText:'serach',
|
|
||||||
focusedBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(20), borderSide: BorderSide(color: Colors.white))
|
|
||||||
),
|
|
||||||
types: [""],
|
|
||||||
components: [Component(Component.country, "se")]);
|
|
||||||
if (p != null) {
|
|
||||||
displayPrediction(p,homeSacffoldKey.currentState);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Future<void> displayPrediction(Prediction p, ScaffoldState? currentState) async {
|
|
||||||
GoogleMapsPlaces places = GoogleMapsPlaces(
|
|
||||||
apiKey: kGoogleApiKey,
|
|
||||||
apiHeaders: await const GoogleApiHeaders().getHeaders()
|
|
||||||
);
|
|
||||||
PlacesDetailsResponse detail = await places.getDetailsByPlaceId(p.placeId!);
|
|
||||||
final lat = detail.result.geometry!.location.lat;
|
|
||||||
final lng = detail.result.geometry!.location.lng;
|
|
||||||
markersList.clear();
|
|
||||||
markersList.add(Marker(markerId: const MarkerId("0"), position: LatLng(lat, lng), infoWindow: InfoWindow(title: detail.result.name)));
|
|
||||||
setState(() {});
|
|
||||||
googleMapController.animateCamera(CameraUpdate.newLatLngZoom(LatLng(lat,lng), 14.0));
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class weatherIconRow extends StatelessWidget {
|
class WeatherIconRow extends StatelessWidget {
|
||||||
const weatherIconRow({
|
const WeatherIconRow({
|
||||||
Key? key,
|
Key? key,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@ -600,8 +528,8 @@ class weatherIconRow extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class weatherStatusRow extends StatelessWidget {
|
class WeatherStatusRow extends StatelessWidget {
|
||||||
const weatherStatusRow({
|
const WeatherStatusRow({
|
||||||
Key? key,
|
Key? key,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@ -645,36 +573,16 @@ Widget buildDrawerSignedIn(BuildContext context) {
|
||||||
title: Text('Sign out'),
|
title: Text('Sign out'),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
globals.LOGGED_IN_USER = User(0, "", "");
|
globals.LOGGED_IN_USER = User(0, "", "");
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => BottomNavPage()), //Replace Container() with call to Map-page.
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: Icon(Icons.thumb_up_alt),
|
|
||||||
title: Text('Give feedback'),
|
|
||||||
onTap: () {
|
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => FormForFeedback(),
|
builder: (context) =>
|
||||||
),
|
BottomNavPage()), //Replace Container() with call to Map-page.
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: Icon(Icons.settings),
|
|
||||||
title: Text('Settings'),
|
|
||||||
onTap: () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => SettingsPage(),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
giveFeedbackTile(context),
|
||||||
|
settingsTile(context),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -685,76 +593,87 @@ Widget buildDrawerSignedOut(BuildContext context) {
|
||||||
child: ListView(
|
child: ListView(
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
children: [
|
children: [
|
||||||
DrawerHeader(
|
drawerHeader(),
|
||||||
decoration:
|
createAccountTile(context),
|
||||||
const BoxDecoration(color: Color.fromARGB(255, 190, 146, 160)),
|
logInTile(context),
|
||||||
child: Column(
|
giveFeedbackTile(context),
|
||||||
children: const <Widget>[
|
settingsTile(context),
|
||||||
Text(
|
|
||||||
'Sun Chaser',
|
|
||||||
style: TextStyle(fontSize: 32),
|
|
||||||
),
|
|
||||||
SizedBox(height: 30),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: Icon(Icons.account_box_rounded),
|
|
||||||
title: Text('Create account'),
|
|
||||||
onTap: () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => CreateAccountPage(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: Icon(Icons.login),
|
|
||||||
title: Text('Sign in'),
|
|
||||||
onTap: () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => SignInPage(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: Icon(Icons.thumb_up_alt),
|
|
||||||
title: Text('Give feedback'),
|
|
||||||
onTap: () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => FormForFeedback(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
leading: Icon(Icons.settings),
|
|
||||||
title: Text('Settings'),
|
|
||||||
onTap: () {
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => SettingsPage(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class _Marker {
|
DrawerHeader drawerHeader() {
|
||||||
var Plats_1;
|
return DrawerHeader(
|
||||||
var Gatunr_1;
|
decoration: const BoxDecoration(color: Color.fromARGB(255, 190, 146, 160)),
|
||||||
var coordinates;
|
child: Column(
|
||||||
|
children: const <Widget>[
|
||||||
_Marker(this.Plats_1, this.Gatunr_1, this.coordinates);
|
Text(
|
||||||
|
'Sun Chaser',
|
||||||
|
style: TextStyle(fontSize: 32),
|
||||||
|
),
|
||||||
|
SizedBox(height: 30),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
ListTile settingsTile(BuildContext context) {
|
||||||
|
return ListTile(
|
||||||
|
leading: Icon(Icons.settings),
|
||||||
|
title: Text('Settings'),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => SettingsPage(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
ListTile giveFeedbackTile(BuildContext context) {
|
||||||
|
return ListTile(
|
||||||
|
leading: Icon(Icons.thumb_up_alt),
|
||||||
|
title: Text('Give feedback'),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => FormForFeedback(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
ListTile logInTile(BuildContext context) {
|
||||||
|
return ListTile(
|
||||||
|
leading: Icon(Icons.login),
|
||||||
|
title: Text('Sign in'),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => SignInPage(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
ListTile createAccountTile(BuildContext context) {
|
||||||
|
return ListTile(
|
||||||
|
leading: Icon(Icons.account_box_rounded),
|
||||||
|
title: Text('Create account'),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => CreateAccountPage(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,13 +24,20 @@ import 'globals.dart' as globals;
|
||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
await Firebase.initializeApp();
|
await Firebase.initializeApp();
|
||||||
await loadAllVenues();
|
// await loadAllVenues();
|
||||||
await fetchWeather();
|
// await fetchWeather();
|
||||||
|
await weatherInstance();
|
||||||
await loadAllVenuesSQL();
|
await loadAllVenuesSQL();
|
||||||
|
|
||||||
runApp(MyApp());
|
runApp(MyApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future weatherInstance() async{
|
||||||
|
WeatherData weather = WeatherData(3, 12);
|
||||||
|
globals.forecast = weather;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Future fetchWeather() async {
|
Future fetchWeather() async {
|
||||||
WeatherData tempWeather = WeatherData(0, 0);
|
WeatherData tempWeather = WeatherData(0, 0);
|
||||||
Uri weatherDataURI = Uri.parse(
|
Uri weatherDataURI = Uri.parse(
|
||||||
|
|
|
@ -19,24 +19,18 @@ class VenuePage extends StatefulWidget {
|
||||||
final Venue venue;
|
final Venue venue;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<VenuePage> createState() => _VenuePageState(venue);
|
State<VenuePage> createState() => VenuePageState(venue);
|
||||||
}
|
}
|
||||||
|
|
||||||
class _VenuePageState extends State<VenuePage> {
|
@visibleForTesting
|
||||||
|
class VenuePageState extends State<VenuePage> {
|
||||||
late WeatherData currentWeather;
|
late WeatherData currentWeather;
|
||||||
final String imageLink = '';
|
final String imageLink = '';
|
||||||
late final Venue venue;
|
late final Venue venue;
|
||||||
late VenueInfo venueInfo;
|
late VenueInfo venueInfo;
|
||||||
|
|
||||||
_VenuePageState(this.venue);
|
VenuePageState(this.venue);
|
||||||
|
|
||||||
validateAndGetImageLink() {
|
|
||||||
if (imageLink == '') {
|
|
||||||
return 'https://live.staticflickr.com/6205/6081773215_19444220b6_b.jpg';
|
|
||||||
} else {
|
|
||||||
return imageLink;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
@ -64,7 +58,7 @@ class _VenuePageState extends State<VenuePage> {
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
globals.forecast = tempWeather;
|
globals.forecast = tempWeather;
|
||||||
currentWeather = tempWeather; //Could be a widget instead??
|
currentWeather = tempWeather;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
throw const HttpException("Problem fetching the weather data");
|
throw const HttpException("Problem fetching the weather data");
|
||||||
|
|
19
test/ListViewPageTest.dart
Normal file
19
test/ListViewPageTest.dart
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
|
import 'package:flutter_applicationdemo/ListViewPage.dart';
|
||||||
|
import 'package:flutter_applicationdemo/Venue.dart';
|
||||||
|
import 'package:flutter_applicationdemo/globals.dart' as globals;
|
||||||
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||||
|
|
||||||
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
test('Test ListViewPage can access venues', () {
|
||||||
|
// ListViewPage listViewPage = const ListViewPage();
|
||||||
|
ListViewPageState listViewPage = ListViewPageState();
|
||||||
|
globals.VENUES.add(Venue(00, 'Aira', 'Biskopsudden', '9', const LatLng(59.354823, 19.29485)));
|
||||||
|
|
||||||
|
expect(globals.VENUES.first, listViewPage.allVenues.first);
|
||||||
|
});
|
||||||
|
}
|
19
test/VenuePageTest.dart
Normal file
19
test/VenuePageTest.dart
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import 'package:flutter_applicationdemo/Venue.dart';
|
||||||
|
import 'package:flutter_applicationdemo/WeatherData.dart';
|
||||||
|
import 'package:flutter_applicationdemo/venuePage.dart';
|
||||||
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||||
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
test('Venue Page Has Access to Venue Instance', () {
|
||||||
|
Venue venue = Venue(00, 'Aira', 'Biskopsudden', '9', const LatLng(59.354823, 19.29485));
|
||||||
|
VenuePage venuePage = VenuePage(venue);
|
||||||
|
|
||||||
|
expect('Aira', venuePage.venue.venueName);
|
||||||
|
expect('Biskopsudden', venuePage.venue.venueAddress);
|
||||||
|
expect('9', venuePage.venue.venueStreetNo);
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user