settings modal | get location

This commit is contained in:
2020-10-28 20:38:49 +01:00
parent 735f0eadfd
commit aa5d142a4f
7 changed files with 212 additions and 99 deletions

View File

@@ -5,7 +5,11 @@
In most cases you can leave this as-is, but you if you want to provide In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. --> FlutterApplication and put your custom class here. -->
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application <application
android:name="io.flutter.app.FlutterApplication" android:name="io.flutter.app.FlutterApplication"
android:label="menui_mobile" android:label="menui_mobile"

View File

@@ -0,0 +1,128 @@
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'searchBar.dart';
class HomePage extends StatefulWidget {
HomePage({Key key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
void getLocation() async {
Position currentLocation = await Geolocator.getCurrentPosition();
print(currentLocation);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("img/bg_tile.jpg"), fit: BoxFit.cover)),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image.asset(
"img/logo_mint.png",
width: 160,
),
MenuiSearchBar(),
Text(
'lub',
style: TextStyle(color: Colors.grey[500]),
),
RaisedButton.icon(
color: Colors.grey[850],
onPressed: getLocation,
icon: Icon(
Icons.my_location,
color: Colors.orange,
),
label: Text(
'Pokaż w pobliżu',
style: TextStyle(color: Colors.grey[400]),
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12)),
)
],
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
showSettings();
},
child: Icon(
Icons.settings,
color: Colors.orange,
),
backgroundColor: Colors.grey[850],
),
);
}
showSettings() {
showModalBottomSheet(
backgroundColor: Colors.transparent,
context: context,
builder: (BuildContext context) {
return ClipRRect(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20), topRight: Radius.circular(20)),
child: Container(
height: 260,
decoration: BoxDecoration(color: Colors.grey[850]),
child: ListView(
children: <Widget>[
ListTile(
title: Text(
'Język',
style: TextStyle(color: Colors.grey),
),
leading: Icon(
Icons.language,
color: Colors.orange,
),
onTap: () {}),
ListTile(
title: Text(
'Promień lokalizacji',
style: TextStyle(color: Colors.grey),
),
leading: Icon(
Icons.location_searching_rounded,
color: Colors.orange,
),
onTap: () {}),
ListTile(
title: Text(
'Proponuj restauracje',
style: TextStyle(color: Colors.grey),
),
leading: Icon(
Icons.restaurant,
color: Colors.orange,
),
onTap: () {}),
ListTile(
title: Text(
'O aplikacji',
style: TextStyle(color: Colors.grey),
),
leading: Icon(
Icons.info,
color: Colors.grey,
),
onTap: () {}),
],
),
),
);
});
}
}

View File

@@ -1,6 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:menui_mobile/main.dart';
import '../services.dart'; import '../services.dart';
import 'searchResults.dart';
class MenuiSearchBar extends StatefulWidget { class MenuiSearchBar extends StatefulWidget {
@override @override

View File

@@ -0,0 +1,54 @@
import '../services.dart';
import 'package:flutter/material.dart';
import 'package:menui_mobile/components/restaurantCard.dart';
import 'searchBar.dart';
class SearchResults extends StatelessWidget {
final List<Restaurant> restaurants;
SearchResults({@required this.restaurants});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("img/bg_tile.jpg"), fit: BoxFit.cover)),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
SizedBox(
height: 30,
),
Image.asset(
"img/logo_mint.png",
width: 60,
),
MenuiSearchBar(),
Row(children: <Widget>[
Container(
padding: EdgeInsets.only(left: 12),
child: Text(
'Znaleziono: ${restaurants.length}',
style: TextStyle(color: Colors.grey),
),
)
]),
Expanded(
child: ListView.builder(
itemCount: restaurants.length,
itemBuilder: (context, index) {
return RestaurantCard(
restaurant: restaurants[index],
);
},
))
],
),
),
),
);
}
}

View File

@@ -1,7 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:menui_mobile/components/restaurantCard.dart'; import "components/homeScreen.dart";
import 'components/searchBar.dart';
import 'services.dart';
void main() { void main() {
runApp(App()); runApp(App());
@@ -18,7 +16,7 @@ class App extends StatelessWidget {
} }
}, },
child: MaterialApp( child: MaterialApp(
title: 'Menui', title: 'Menui - food guide',
themeMode: ThemeMode.dark, themeMode: ThemeMode.dark,
theme: ThemeData( theme: ThemeData(
platform: TargetPlatform.iOS, platform: TargetPlatform.iOS,
@@ -32,97 +30,3 @@ class App extends StatelessWidget {
)); ));
} }
} }
// ROUTE --- HOME
class HomePage extends StatefulWidget {
HomePage({Key key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("img/bg_tile.jpg"), fit: BoxFit.cover)),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image.asset(
"img/logo_mint.png",
width: 160,
),
MenuiSearchBar()
],
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: Icon(
Icons.settings,
color: Colors.orange,
),
backgroundColor: Colors.grey[850],
),
);
}
}
// ROUTE --- SEARCH RESULTS
class SearchResults extends StatelessWidget {
final List<Restaurant> restaurants;
SearchResults({@required this.restaurants});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("img/bg_tile.jpg"), fit: BoxFit.cover)),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
SizedBox(
height: 30,
),
Image.asset(
"img/logo_mint.png",
width: 60,
),
MenuiSearchBar(),
Row(children: <Widget>[
Container(
padding: EdgeInsets.only(left: 12),
child: Text(
'Znaleziono: ${restaurants.length}',
style: TextStyle(color: Colors.grey),
),
)
]),
Expanded(
child: ListView.builder(
itemCount: restaurants.length,
itemBuilder: (context, index) {
return RestaurantCard(
restaurant: restaurants[index],
);
},
))
],
),
),
),
);
}
}

View File

@@ -67,6 +67,20 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
geolocator:
dependency: "direct main"
description:
name: geolocator
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.1"
geolocator_platform_interface:
dependency: transitive
description:
name: geolocator_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
http: http:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -109,6 +123,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.9.2" version: "1.9.2"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
@@ -172,3 +193,4 @@ packages:
version: "2.1.0-nullsafety.3" version: "2.1.0-nullsafety.3"
sdks: sdks:
dart: ">=2.10.0-110 <2.11.0" dart: ">=2.10.0-110 <2.11.0"
flutter: ">=1.10.0"

View File

@@ -22,6 +22,7 @@ environment:
dependencies: dependencies:
http: ^0.12.2 http: ^0.12.2
geolocator: ^6.1.0
flutter: flutter:
sdk: flutter sdk: flutter