diff --git a/emma/android/app/src/main/AndroidManifest.xml b/emma/android/app/src/main/AndroidManifest.xml
index 3d285c7..0548da0 100644
--- a/emma/android/app/src/main/AndroidManifest.xml
+++ b/emma/android/app/src/main/AndroidManifest.xml
@@ -28,6 +28,7 @@
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
+ android:value="2" />
+
diff --git a/emma/ios/Runner/Info.plist b/emma/ios/Runner/Info.plist
index 593945e..6e69dc2 100644
--- a/emma/ios/Runner/Info.plist
+++ b/emma/ios/Runner/Info.plist
@@ -47,5 +47,9 @@
UIApplicationSupportsIndirectInputEvents
+
+ com.apple.security.network.client
+
+
diff --git a/emma/lib/main.dart b/emma/lib/main.dart
index 1be0f69..c3933eb 100644
--- a/emma/lib/main.dart
+++ b/emma/lib/main.dart
@@ -1,7 +1,10 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:location/location.dart';
+import 'package:http/http.dart' as http;
import 'dart:async';
+import 'dart:convert';
+import 'dart:developer';
void main() => runApp(const MyApp());
const Duration fakeAPIDuration = Duration(milliseconds: 50);
@@ -43,8 +46,10 @@ class MyApp extends StatelessWidget {
UIData.homeRoute: (BuildContext context) =>
MyFormPage(title: 'SecondPage'), //title=AbsorbPointer()'Start'),
UIData.typeRoute: (BuildContext context) => TypePage(title: 'Type'),
- UIData.categorieRoute: (BuildContext context) =>
- CategoriePage(), //title='Kategorie'),
+ UIData.categorieFoodRoute: (BuildContext context) =>
+ CategorieFoodPage(), //title='Kategorie'),
+ UIData.categoriePartyRoute: (BuildContext context) =>
+ CategoriePartyPage(title: 'Kategorie Party'),
//UIData.teamRoute: (BuildContext context) =>TeamsPage(),
//UIData.planRoute: (BuildContext context) =>PlanPage(),
//UIData.quizRoute: (BuildContext context) =>QuizPage(),
@@ -57,13 +62,61 @@ class UIData {
//routes
static const String homeRoute = "/home";
static const String typeRoute = "/teams";
- static const String categorieRoute = "/categorie";
+ static const String categorieFoodRoute = "/categoriefood";
+ static const String categoriePartyRoute = "/categorieparty";
static const String timeRoute = "/time";
static const String resoultRoute = "/list";
static const String quizRoute = "/quiz";
static const String impressionRoute = "/impression";
}
+class Address {
+ final String display_name;
+ /*final String house_number;
+ final String roadName;
+ final String cityName;*/
+ const Address({
+ required this.display_name,
+ /*required this.house_number,
+ required this.roadName,
+ required this.cityName,*/
+ });
+ factory Address.fromJson(Map json) {
+ return switch (json) {
+ {
+ 'display_name': String display_name,
+ //'house_number': String house_number,
+ //'road': String roadName,
+ //'town': String cityName,
+ } =>
+ Address(
+ display_name: display_name,
+ /*house_number: house_number,
+ roadName: roadName,
+ cityName: cityName,*/
+ ),
+ _ => throw const FormatException('Failed to load address.'),
+ };
+ }
+}
+
+Future fetchAddress(LocationData userLocation) async {
+ final response = await http.get(Uri.parse(
+ 'https://nominatim.openstreetmap.org/reverse?lat=${userLocation.latitude}&lon=${userLocation.longitude}&format=json'));
+
+ if (response.statusCode == 200) {
+ // If the server did return a 200 OK response,
+ // then parse the JSON.
+ log("Index number is: ${response.body}");
+
+ return Address.fromJson(jsonDecode(response.body) as Map);
+ } else {
+ // If the server did not return a 200 OK response,
+ // then throw an exception.
+ throw Exception('Failed to load album');
+ }
+}
+
class MyFormPage extends StatefulWidget {
const MyFormPage({Key key = const Key('defaultKey'), required this.title})
: super(key: key);
@@ -80,6 +133,7 @@ class _MyFormPageState extends State {
late bool _serviceEnabled;
late PermissionStatus _permissionGranted;
+ late Future futureAddress;
LocationData? _userLocation;
@@ -108,11 +162,13 @@ class _MyFormPageState extends State {
final locationData = await location.getLocation();
setState(() {
_userLocation = locationData;
+ futureAddress = fetchAddress(_userLocation!);
});
}
final _formKey = GlobalKey();
double _currentSliderValue = 1;
+
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -160,9 +216,17 @@ class _MyFormPageState extends State {
_userLocation != null
? Wrap(
children: [
- Text('Your latitude: ${_userLocation?.latitude}'),
- const SizedBox(width: 10),
- Text('Your longtitude: ${_userLocation?.longitude}')
+ FutureBuilder(
+ future: futureAddress,
+ builder: (context, snapshot) {
+ if (snapshot.hasData) {
+ return Text(snapshot.data!.display_name);
+ } else if (snapshot.hasError) {
+ return Text('${snapshot.error}');
+ } // By default, show a loading spinner.
+ return const CircularProgressIndicator();
+ },
+ ),
],
)
: const Text(''),
@@ -273,7 +337,7 @@ class TypePage extends StatelessWidget {
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) {
- return CategoriePage();
+ return CategorieFoodPage();
}));
},
),
@@ -293,7 +357,7 @@ class TypePage extends StatelessWidget {
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) {
- return CategoriePage();
+ return CategoriePartyPage(title: 'Kategorie Party');
}));
},
),
@@ -313,7 +377,7 @@ class TypePage extends StatelessWidget {
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) {
- return CategoriePage();
+ return CategorieFoodPage();
}));
},
),
@@ -339,7 +403,7 @@ class TypePage extends StatelessWidget {
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) {
- return CategoriePage();
+ return CategorieFoodPage();
}));
},
),
@@ -359,7 +423,7 @@ class TypePage extends StatelessWidget {
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) {
- return CategoriePage();
+ return CategorieFoodPage();
}));
},
),
@@ -379,7 +443,7 @@ class TypePage extends StatelessWidget {
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) {
- return CategoriePage();
+ return CategorieFoodPage();
}));
},
),
@@ -418,7 +482,7 @@ class TypePage extends StatelessWidget {
onPressed: () {
// Wenn alle Validatoren der Felder des Formulars gültig sind.
Navigator.push(context, MaterialPageRoute(builder: (context) {
- return CategoriePage();
+ return CategorieFoodPage();
}));
},
child: const Text('Weiter'),
@@ -431,55 +495,21 @@ class TypePage extends StatelessWidget {
}
}
-class TypePage2 extends StatelessWidget {
- TypePage2({Key? key, required this.title}) : super(key: key);
+class CategoriePartyPage extends StatelessWidget {
+ CategoriePartyPage({Key? key, required this.title}) : super(key: key);
final String title;
final List