LoginPage #60

Merged
maen0574 merged 6 commits from LoginPage into master 2022-06-01 22:50:13 +02:00
28 changed files with 272 additions and 410 deletions
Showing only changes of commit 8ce14be36e - Show all commits

File diff suppressed because one or more lines are too long

View File

@ -1,8 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'Map.dart'; import 'package:flutter_applicationdemo/map.dart';
import 'FavoritePage.dart'; import 'favorite_page.dart';
import 'globals.dart' as globals; import 'globals.dart' as globals;
import 'ListViewPage.dart'; import 'list_view_page.dart';
class BottomNavPage extends StatefulWidget { class BottomNavPage extends StatefulWidget {
@override @override

View File

@ -1,8 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_applicationdemo/venuePage.dart'; import 'package:flutter_applicationdemo/venue_page.dart';
import 'Venue.dart'; import 'venue.dart';
import 'globals.dart' as globals; import 'globals.dart' as globals;
import 'login/signInPage.dart'; import 'login/sign_in_page.dart';
import 'mysql.dart'; import 'mysql.dart';

View File

@ -1,8 +1,8 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_applicationdemo/mysql.dart'; import 'package:flutter_applicationdemo/mysql.dart';
import 'BottomNavPage.dart'; import 'bottom_nav_page.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'Form.dart'; import 'form.dart';
Color _backgroundColor = const Color.fromARGB(255, 190, 146, 160); Color _backgroundColor = const Color.fromARGB(255, 190, 146, 160);

View File

@ -1,14 +1,10 @@
import 'package:flutter_applicationdemo/WeatherData.dart'; import 'package:flutter_applicationdemo/weather_data.dart';
import 'venue.dart';
import 'Venue.dart'; import 'package:flutter_applicationdemo/login/user.dart';
import 'package:flutter_applicationdemo/login/User.dart'; import '../login/user.dart';
import '../login/User.dart';
import 'dart:ui'; import 'dart:ui';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'Venue.dart';
import 'main.dart';
User LOGGED_IN_USER = User(0, "", ""); User LOGGED_IN_USER = User(0, "", "");
Color BACKGROUNDCOLOR = const Color.fromARGB(255, 190, 146, 160); Color BACKGROUNDCOLOR = const Color.fromARGB(255, 190, 146, 160);

View File

@ -1,20 +1,18 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'globals.dart' as globals; import 'globals.dart' as globals;
import 'package:flutter_applicationdemo/Venue.dart'; import 'package:flutter_applicationdemo/venue.dart';
import 'VenuePage.dart'; import 'venue_page.dart';
class ListViewPage extends StatefulWidget { 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

View File

@ -1,14 +1,13 @@
// ignore_for_file: prefer_const_constructors // ignore_for_file: prefer_const_constructors
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_applicationdemo/BottomNavPage.dart'; import 'package:flutter_applicationdemo/login/encrypt_data.dart';
import 'package:flutter_applicationdemo/login/EncryptData.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import 'package:flutter_applicationdemo/mysql.dart'; import 'package:flutter_applicationdemo/mysql.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../reusables/InputField.dart'; import '../reusables/input_field.dart';
import 'User.dart'; import 'user.dart';
import '../reusables/returnButton.dart'; import '../reusables/return_button.dart';
class CreateAccountPage extends StatefulWidget { class CreateAccountPage extends StatefulWidget {
_CreateAccountPageState createState() => _CreateAccountPageState(); _CreateAccountPageState createState() => _CreateAccountPageState();

View File

@ -1,4 +1,3 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:google_sign_in/google_sign_in.dart'; import 'package:google_sign_in/google_sign_in.dart';

View File

@ -1,18 +1,14 @@
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_applicationdemo/login/EncryptData.dart'; import 'package:flutter_applicationdemo/login/encrypt_data.dart';
import 'package:flutter_applicationdemo/BottomNavPage.dart'; import 'package:flutter_applicationdemo/bottom_nav_page.dart';
import '../mysql.dart'; import '../mysql.dart';
import '../main.dart'; import 'user.dart';
import 'User.dart'; import '../reusables/input_field.dart';
import '../reusables/InputField.dart'; import '../reusables/return_button.dart';
import '../reusables/returnButton.dart';
import 'package:flutter_signin_button/flutter_signin_button.dart'; import 'package:flutter_signin_button/flutter_signin_button.dart';
import 'GoogleSignInProvider.dart'; import 'google_sign_in_provider.dart';
import 'CreateAccountPage.dart'; import 'create_account_page.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:flutter_applicationdemo/Map.dart' as map;
import 'package:flutter_applicationdemo/globals.dart' as globals; import 'package:flutter_applicationdemo/globals.dart' as globals;
class SignInPage extends StatefulWidget { class SignInPage extends StatefulWidget {
@ -136,7 +132,6 @@ class _SignInPageState extends State<SignInPage> {
onPressed: () async { onPressed: () async {
if (emailController.text.contains("'") || if (emailController.text.contains("'") ||
passwordController.text.contains("'")) { passwordController.text.contains("'")) {
print("1");
loginError(); loginError();
return; return;
} }
@ -147,7 +142,6 @@ class _SignInPageState extends State<SignInPage> {
context, context,
); );
} else { } else {
print(globals.LOGGED_IN_USER.userID);
loginError(); loginError();
} }
//print(loggedInUser.email + " " + loggedInUser.userID.toString()); //print(loggedInUser.email + " " + loggedInUser.userID.toString());

View File

@ -1,4 +1,4 @@
import 'package:flutter_applicationdemo/Venue.dart'; import 'package:flutter_applicationdemo/venue.dart';
import 'package:flutter_applicationdemo/mysql.dart'; import 'package:flutter_applicationdemo/mysql.dart';
import 'package:flutter_applicationdemo/globals.dart' as globals; import 'package:flutter_applicationdemo/globals.dart' as globals;
@ -33,9 +33,6 @@ class User{
} }
} }
}); });
for(Venue venue in likedVenuesList){
print(venue.venueName);
}
}); });
} }
} }

View File

@ -4,27 +4,35 @@ import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_core/firebase_core.dart';
import 'package:flutter_applicationdemo/login/GoogleSignInProvider.dart'; import 'package:flutter_applicationdemo/shadow_detector.dart';
import 'package:flutter_applicationdemo/login/google_sign_in_provider.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'BottomNavPage.dart'; import 'bottom_nav_page.dart';
import 'WeatherData.dart'; import 'weather_data.dart';
import 'Venue.dart'; import 'venue.dart';
import 'mysql.dart'; import 'mysql.dart';
import 'globals.dart' as globals; 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(
@ -71,7 +79,7 @@ Future loadAllVenues() async {
// var sd = ShadowDetector(); // var sd = ShadowDetector();
// await sd.evaluateShadowsForAllVenues(seventyFiveVenues); // await sd.evaluateShadowsForAllVenues(seventyFiveVenues);
} else { } else {
//throw const HttpException("Problem fetching the venue data"); throw const HttpException("Problem fetching the venue data");
} }
} }

View File

@ -1,10 +1,11 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_applicationdemo/BottomNavPage.dart'; import 'package:flutter_applicationdemo/login/encrypt_data.dart';
import 'package:flutter_applicationdemo/login/EncryptData.dart'; import 'package:flutter_applicationdemo/reusables/input_field.dart';
import 'package:flutter_applicationdemo/reusables/InputField.dart';
import 'package:flutter_applicationdemo/globals.dart' as globals; import 'package:flutter_applicationdemo/globals.dart' as globals;
import 'package:flutter_applicationdemo/mysql.dart'; import 'package:flutter_applicationdemo/mysql.dart';
import 'bottom_nav_page.dart';
class ManageAccountPage extends StatefulWidget { class ManageAccountPage extends StatefulWidget {
@override @override
State<ManageAccountPage> createState() => ManageAccountPageState(); State<ManageAccountPage> createState() => ManageAccountPageState();

View File

@ -1,30 +1,18 @@
import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_applicationdemo/BottomNavPage.dart';
import 'package:flutter_applicationdemo/ListViewPage.dart';
import 'package:flutter_applicationdemo/ManageAccountPage.dart';
import 'package:flutter_applicationdemo/WeatherData.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 'dart:async'; import 'dart:async';
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 'venue_page.dart';
import 'package:intl/intl.dart'; import 'venue.dart';
import 'package:flutter_applicationdemo/login/User.dart'; import 'login/user.dart';
import 'venuePage.dart';
import 'Venue.dart';
import 'globals.dart' as globals; import 'globals.dart' as globals;
import 'package:syncfusion_flutter_sliders/sliders.dart'; import 'package:syncfusion_flutter_sliders/sliders.dart';
import 'FeedbackPage.dart'; import 'package:flutter_applicationdemo/manage_account_page.dart';
import 'login/CreateAccountPage.dart'; import 'feedback_page.dart';
import 'login/signInPage.dart'; import 'login/create_account_page.dart';
import 'login/sign_in_page.dart';
class Map extends StatefulWidget { class Map extends StatefulWidget {
@override @override
@ -33,7 +21,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;
@ -70,32 +58,6 @@ class MapState extends State<Map> {
hiddenVenues.addAll(globals.VENUES); hiddenVenues.addAll(globals.VENUES);
} }
void createBottomSheet(String venueName) async {
var webScraper = WebScraper();
await webScraper.getWebsiteData(venueName);
Scaffold.of(context).showBottomSheet<void>(
((context) {
return Container(
height: 420,
color: Colors.white,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
/*const Text('BottomSheet'),
ElevatedButton(
child: const Text('Close BottomSheet'),
onPressed: () {Navigator.pop(context);})*/
Container(
child: Text(webScraper.openingHoursThisWeek.length.toString()),
),
],
)),
);
}));
}
Future<LocationData> _getLocationPermission() async { Future<LocationData> _getLocationPermission() async {
Location location = Location(); Location location = Location();
@ -135,6 +97,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;
@ -142,28 +105,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(
zoomControlsEnabled: true,
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();
@ -182,8 +146,6 @@ class MapState extends State<Map> {
closeBottomSheetIfOpen(); closeBottomSheetIfOpen();
}, },
), ),
// ElevatedButton(onPressed: () {} //_handelPressButton
// ,child: const Text("Search Placses"))
], ],
), ),
floatingActionButtonLocation: FloatingActionButtonLocation.endTop, floatingActionButtonLocation: FloatingActionButtonLocation.endTop,
@ -325,43 +287,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(
@ -372,37 +297,48 @@ 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++) {
print(globals.VENUES[i].venueName + " " + globals.VENUES[i].venueID.toString()); if (!globals.VENUES[i].isShownOnMap &&
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)){ (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: () => createBottomSheet(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);
} }
} }
} }
createBottomDrawer(Venue venue) async { createBottomSheet(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(
context: context,
builder: (BuildContext context) {
return InkWell( return InkWell(
onTap: () { onTap: () {
Navigator.push( Navigator.push(
@ -441,7 +377,6 @@ class MapState extends State<Map> {
], ],
), ),
// columnCoveringRating(), // columnCoveringRating(),
], ],
), ),
const SizedBox( const SizedBox(
@ -452,8 +387,8 @@ class MapState extends State<Map> {
children: [ children: [
Column( Column(
children: const [ children: const [
weatherIconRow(), WeatherIconRow(),
weatherStatusRow(), WeatherStatusRow(),
], ],
), ),
columnHandlingReadMoreButton(context, venue), columnHandlingReadMoreButton(context, venue),
@ -531,45 +466,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);
@ -587,8 +491,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);
@ -627,41 +531,9 @@ Widget buildDrawerSignedIn(BuildContext context) {
], ],
), ),
), ),
ListTile( giveFeedbackTile(context),
leading: Icon(Icons.thumb_up_alt), settingsTile(context),
title: Text('Give feedback'), signOutTile(context),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => FormForFeedback(),
),
);
},
),
ListTile(
leading: Icon(Icons.settings),
title: Text('Change password'),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ManageAccountPage(),
),
);
},
),
ListTile(
leading: Icon(Icons.logout),
title: Text('Sign out'),
onTap: () {
globals.LOGGED_IN_USER = User(0, "", "");
Navigator.pop(
context,
);
(context as Element).reassemble();
},
),
], ],
), ),
); );
@ -672,9 +544,18 @@ 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),
giveFeedbackTile(context),
],
),
);
}
DrawerHeader drawerHeader() {
return DrawerHeader(
decoration: const BoxDecoration(color: Color.fromARGB(255, 190, 146, 160)),
child: Column( child: Column(
children: const <Widget>[ children: const <Widget>[
Text( Text(
@ -684,34 +565,40 @@ Widget buildDrawerSignedOut(BuildContext context) {
SizedBox(height: 30), SizedBox(height: 30),
], ],
), ),
), );
ListTile( }
leading: Icon(Icons.account_box_rounded),
title: Text('Create account'), ListTile settingsTile(BuildContext context) {
onTap: () async{ return ListTile(
await Navigator.push( leading: Icon(Icons.settings),
title: Text('Change password'),
onTap: () {
Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => CreateAccountPage(), builder: (context) => ManageAccountPage(),
), ),
); );
},
);
}
ListTile signOutTile(BuildContext context) {
return ListTile(
leading: Icon(Icons.logout),
title: Text('Sign out'),
onTap: () {
globals.LOGGED_IN_USER = User(0, "", "");
Navigator.pop(
context,
);
(context as Element).reassemble(); (context as Element).reassemble();
}, },
),
ListTile(
leading: Icon(Icons.login),
title: Text('Sign in'),
onTap: () async {
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SignInPage(),
),
); );
(context as Element).reassemble(); }
},
), ListTile giveFeedbackTile(BuildContext context) {
ListTile( return ListTile(
leading: Icon(Icons.thumb_up_alt), leading: Icon(Icons.thumb_up_alt),
title: Text('Give feedback'), title: Text('Give feedback'),
onTap: () { onTap: () {
@ -722,16 +609,37 @@ Widget buildDrawerSignedOut(BuildContext context) {
), ),
); );
}, },
),
],
),
); );
} }
class _Marker { ListTile logInTile(BuildContext context) {
var Plats_1; return ListTile(
var Gatunr_1; leading: Icon(Icons.login),
var coordinates; title: Text('Sign in'),
onTap: () async{
_Marker(this.Plats_1, this.Gatunr_1, this.coordinates); await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SignInPage(),
),
);
(context as Element).reassemble();
},
);
}
ListTile createAccountTile(BuildContext context) {
return ListTile(
leading: Icon(Icons.account_box_rounded),
title: Text('Create account'),
onTap: () async {
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CreateAccountPage(),
),
);
(context as Element).reassemble();
},
);
} }

View File

@ -1,4 +1,3 @@
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:html/dom.dart' as dom; import 'package:html/dom.dart' as dom;

View File

@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class ReturnButton extends StatelessWidget { class ReturnButton extends StatelessWidget {

View File

@ -2,15 +2,14 @@
import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:http/http.dart'; import 'package:http/http.dart';
import 'dart:async'; import 'dart:async';
import 'Venue.dart'; import 'venue.dart';
class ShadowDetector { class ShadowDetector {
List<Venue> venuesInShade = []; List<Venue> venuesInShade = [];
ShadowDetector() { ShadowDetector();
}
//Called like "new ShadowDetector.fromShadowDetector(List of venues here);" //Called like "new ShadowDetector.fromShadowDetector(List of venues here);"
ShadowDetector.fromShadowDetector(venues) { ShadowDetector.fromShadowDetector(venues) {
evaluateShadowsForAllVenues(venues); evaluateShadowsForAllVenues(venues);

View File

@ -1,6 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_applicationdemo/ShadowDetector.dart'; import 'package:flutter_applicationdemo/shadow_detector.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:flutter_applicationdemo/globals.dart' as globals; import 'package:flutter_applicationdemo/globals.dart' as globals;

View File

@ -1,11 +1,10 @@
import 'dart:convert'; import 'dart:convert';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:html/dom.dart' as dom;
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'dart:io'; import 'dart:io';
import 'Venue.dart'; import 'venue.dart';
class VenueInfo { class VenueInfo {
@ -66,55 +65,6 @@ class VenueInfo {
} }
} }
/*Future getVenueInfo(String venueName) async {
final fourSquareURL =
Uri.parse('https://foursquare.com/explore?mode=url&near=Stockholm%2C%20Sweden&nearGeoId=72057594040601666&q=$venueName');
final response1 = await http.get(fourSquareURL);
if(response1.statusCode == 200) {
dom.Document html = dom.Document.html(response1.body);
var fsqId = html.getElementsByClassName('card singleRecommendation hasPhoto tipWithLogging leftPhotoLayout').map((e) => e.attributes['data-id']).toList()[0];
final response2 = await http.get(
Uri.parse('https://api.foursquare.com/v3/places/$fsqId?fields=price%2Crating%2Cphotos%2Chours%2Cstats%2Ctastes'),
headers: {
HttpHeaders.authorizationHeader: 'fsq3LBbeZ8imQK8X1hov7DTb9F64Xs1fs2bojHQ99QNm4TE='
},
);
if(response2.statusCode == 200) {
Map data = jsonDecode(response2.body);
if(data['price'] != null) {
_priceClass = data['price'];
}
if(data['rating'] != null) {
_rating = data['rating'];
}
if(data['photos'][0] != null) {
_photos = data['photos'][0];
}
if(data['hours']['open now'] != null) {
_openNow = data['hours']['open_now'];
}
if(data['stats']['total_ratings'] != null) {
_totalRatings = data['stats']['total_ratings'];
}
if(data['hours']['display'] != null) {
_openHoursToday = data['hours']['display'];
}
}
else {
throw const HttpException("No connection to api.foursquare.com");
}
}
else {
throw const HttpException("No connection to foursquare.com");
}
}*/
String getPopularHoursToday() { String getPopularHoursToday() {
var today = DateFormat('EEEE').format(DateTime.now()); var today = DateFormat('EEEE').format(DateTime.now());
if(_hoursPopular.isEmpty) { if(_hoursPopular.isEmpty) {
@ -189,17 +139,4 @@ class VenueInfo {
String getVenueURL () { String getVenueURL () {
return 'https://api.foursquare.com$_fsqLink'; return 'https://api.foursquare.com$_fsqLink';
} }
}
enum WeekDays {
monday,
tuesday,
wednesday,
thursday,
friday,
saturday,
sunday,
} }

View File

@ -1,14 +1,14 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:share_plus/share_plus.dart'; import 'package:share_plus/share_plus.dart';
import 'package:flutter_applicationdemo/Venue.dart'; import 'package:flutter_applicationdemo/venue.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'VenueInfo.dart'; import 'venue_info.dart';
import 'WeatherData.dart'; import 'weather_data.dart';
import 'globals.dart' as globals; import 'globals.dart' as globals;
import 'Venue.dart'; import 'venue.dart';
// Color _backgroundColor = const Color(0xffac7b84); // Color _backgroundColor = const Color(0xffac7b84);
@ -18,24 +18,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() {
@ -43,9 +37,9 @@ class _VenuePageState extends State<VenuePage> {
} }
Future gatherVenueInfo() async { Future gatherVenueInfo() async {
VenueInfo vu = VenueInfo(); VenueInfo vi = VenueInfo();
venueInfo = vu; venueInfo = vi;
venueInfo = await vu.getVenueInfo(venue); venueInfo = await vi.getVenueInfo(venue);
} }
Future refreshWeather() async { Future refreshWeather() async {
@ -63,7 +57,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");
@ -269,7 +263,7 @@ class LikeVenueButton extends StatelessWidget {
), ),
label: const Text('Like place'), label: const Text('Like place'),
style: TextButton.styleFrom( style: TextButton.styleFrom(
primary: Color(0xff4f6272), primary: const Color(0xff4f6272),
), ),
)): Expanded( )): Expanded(
child: TextButton.icon( child: TextButton.icon(

View File

@ -0,0 +1,17 @@
import 'package:flutter_applicationdemo/list_view_page.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);
});
}

View File

@ -1,5 +1,5 @@
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'package:flutter_applicationdemo/ManageAccountPage.dart'; import 'package:flutter_applicationdemo/manage_account_page.dart';
void main() { void main() {
group('ManageAccountPage', () { group('ManageAccountPage', () {

View File

@ -1,6 +1,6 @@
import 'package:flutter_applicationdemo/Venue.dart'; import 'package:flutter_applicationdemo/venue.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_applicationdemo/VenueInfo.dart'; import 'package:flutter_applicationdemo/venue_info.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart';
main() { main() {

18
test/venue_page_test.dart Normal file
View File

@ -0,0 +1,18 @@
import 'package:flutter_applicationdemo/list_view_page.dart';
import 'package:flutter_applicationdemo/venue.dart';
import 'package:flutter_applicationdemo/weather_data.dart';
import 'package:flutter_applicationdemo/venue_page.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);
});
}