diff --git a/lib/main.dart b/lib/main.dart index 21b548f..5f0a845 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; -import 'poi_view.dart'; -import 'pois_list_view.dart'; +import 'ui/poi_view.dart'; +import 'ui/pois_list_view.dart'; void main() { runApp(const MyApp()); diff --git a/lib/poi_view.dart b/lib/poi_view.dart deleted file mode 100644 index d83e535..0000000 --- a/lib/poi_view.dart +++ /dev/null @@ -1,108 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:mobile_mission_tic_flutter/models/poi.dart'; -import 'package:get/get.dart'; - -import 'maps.dart'; - -class POIView extends StatelessWidget { - POIView({Key? key}) : super(key: key); - - final POI currentPOI = Get.arguments; - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text(currentPOI.name) - ), - body: SingleChildScrollView( - child: Wrap( - children: [ - Image.asset('lib/assets/test/' + currentPOI.img + ".jpg", width: 400, height: 200, fit: BoxFit.cover), - galleryPOI(context), - infoPOI(currentPOI), - descriptionPOI(currentPOI), - SizedBox( - height: MediaQuery.of(context).size.width / 2, - width: MediaQuery.of(context).size.width, - child: Maps(data: {"lat": currentPOI.lat, "lng": currentPOI.long, "markerId": currentPOI.name}), - ) - ], - ), - ) - ); - } -} - -Widget infoPOI(POI currentPOI){ - return Container( - margin: const EdgeInsets.all(16), - child: Row( - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - padding: const EdgeInsets.only(bottom: 5), - child: Text( - currentPOI.name, - style: const TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold, - ), - ), - ), - Text( - currentPOI.location, - style: const TextStyle( - color: Colors.grey, - ), - ), - ], - ), - ), - const Icon( - Icons.star, - color: Colors.amber, - ), - const Text('4.5'), - ] - ), - ); -} - -Widget descriptionPOI(POI currentPOI){ - return Container( - margin: const EdgeInsets.all(16), - child: Text(currentPOI.detail), - ); - -} - -Widget galleryPOI(context){ - bool isLandscape = MediaQuery.of(context).orientation == Orientation.landscape; - - return Container( - height: isLandscape ? 100 : 60, - margin: const EdgeInsets.all(16), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Expanded( - child: Image.asset('lib/assets/versailles_0.jpg', fit: BoxFit.fill), - ), - Expanded( - child: Image.asset('lib/assets/versailles_1.jpg', fit: BoxFit.fill), - ), - Expanded( - child: Image.asset('lib/assets/versailles_2.jpg', fit: BoxFit.fill), - ), - Expanded( - child: Image.asset('lib/assets/versailles_3.jpg', fit: BoxFit.fill), - ), - ] - ), - ); -} \ No newline at end of file diff --git a/lib/ui/poi_view.dart b/lib/ui/poi_view.dart new file mode 100644 index 0000000..509efca --- /dev/null +++ b/lib/ui/poi_view.dart @@ -0,0 +1,119 @@ +import 'package:flutter/material.dart'; +import 'package:mobile_mission_tic_flutter/models/poi.dart'; +import 'package:get/get.dart'; +import 'package:mobile_mission_tic_flutter/widgets/info_poi.dart'; + +import '../widgets/maps.dart'; + +class POIView extends StatelessWidget { + POIView({Key? key}) : super(key: key); + + final POI currentPOI = Get.arguments; + + @override + Widget build(BuildContext context) { + Widget galleryPOIs = Container( + margin: const EdgeInsets.only(bottom: 16), + child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + _imageGallery('lib/assets/versailles_0.jpg', context), + _imageGallery('lib/assets/versailles_1.jpg', context), + _imageGallery('lib/assets/versailles_2.jpg', context), + _imageGallery('lib/assets/versailles_3.jpg', context), + ]), + ); + + Widget descriptionPOI(POI currentPOI) { + return Container( + margin: const EdgeInsets.symmetric(vertical: 16), + child: Text(currentPOI.detail), + ); + } + + return Scaffold( + appBar: AppBar(title: Text(currentPOI.name)), + body: ListView( + children: [ + Image.asset('lib/assets/test/' + currentPOI.img + ".jpg", + width: double.infinity, height: 200, fit: BoxFit.cover), + Container( + margin: const EdgeInsets.all(16), + child: Wrap( + runSpacing: 10, + children: [ + galleryPOIs, + InfoPOI( + name: currentPOI.name, + location: currentPOI.location, + rating: currentPOI.rating), + descriptionPOI(currentPOI), + SizedBox( + height: MediaQuery.of(context).size.width / 2, + width: MediaQuery.of(context).size.width, + child: Maps(data: { + "lat": currentPOI.lat, + "lng": currentPOI.long, + "markerId": currentPOI.name + }), + ) + ], + ), + ), + ], + )); + } +} + +Flexible _imageGallery(String urlImg, context) { + bool isLandscape = + MediaQuery.of(context).orientation == Orientation.landscape; + + return Flexible( + flex: 1, + child: Container( + height: isLandscape ? 100 : 50, + margin: const EdgeInsets.only(right: 5.0), + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage(urlImg), + fit: BoxFit.fill, + ), + borderRadius: const BorderRadius.all(Radius.circular(5))), + )); +} + +/*Widget galleryPOI(context){ + bool isLandscape = MediaQuery.of(context).orientation == Orientation.landscape; + + return Container( + height: isLandscape ? 100 : 60, + margin: const EdgeInsets.only(bottom: 16), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Flexible( + flex: 1, + child: Container( + height: 50, + margin: const EdgeInsets.only(right: 5.0), + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage('lib/assets/versailles_1.jpg'), + fit: BoxFit.fitHeight, + ), + borderRadius: BorderRadius.all(Radius.circular(5))), + ) + ), + Expanded( + child: Image.asset('lib/assets/versailles_1.jpg', fit: BoxFit.fill), + ), + Expanded( + child: Image.asset('lib/assets/versailles_2.jpg', fit: BoxFit.fill), + ), + Expanded( + child: Image.asset('lib/assets/versailles_3.jpg', fit: BoxFit.fill), + ), + ] + ), + ); +}*/ diff --git a/lib/pois_list_view.dart b/lib/ui/pois_list_view.dart similarity index 54% rename from lib/pois_list_view.dart rename to lib/ui/pois_list_view.dart index fc1344f..c1a33ba 100644 --- a/lib/pois_list_view.dart +++ b/lib/ui/pois_list_view.dart @@ -1,11 +1,14 @@ +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:mobile_mission_tic_flutter/models/poi_list.dart'; -import 'package:mobile_mission_tic_flutter/poi_view.dart'; +import 'package:mobile_mission_tic_flutter/ui/poi_view.dart'; import 'package:mobile_mission_tic_flutter/remote/api.dart'; import 'package:get/get.dart'; +import 'package:mobile_mission_tic_flutter/ui/settings.dart'; +import 'package:mobile_mission_tic_flutter/widgets/info_poi.dart'; -import 'models/poi.dart'; +import '../models/poi.dart'; class POISListView extends StatefulWidget { const POISListView({Key? key}) : super(key: key); @@ -17,7 +20,6 @@ class POISListView extends StatefulWidget { class _POISListViewState extends State { late Future futureList; - @override void initState() { super.initState(); @@ -29,33 +31,41 @@ class _POISListViewState extends State { return Scaffold( appBar: AppBar( title: const Text("POIS List View"), + actions: [ + IconButton( + onPressed: () { + Get.to(const Settings()); + }, + icon: const Icon(Icons.settings)) + ], ), - body: SingleChildScrollView( - padding: const EdgeInsets.symmetric(vertical: 10.0), - child: FutureBuilder( - future: futureList, - builder: (context, AsyncSnapshot snapshot) { - if (snapshot.hasData) { - List elements = []; - snapshot.data!.pois.forEach((element) { - elements.add(itemCard(element, context)); - }); - return Wrap( - runSpacing: 10, - children: elements, - ); + body: FutureBuilder( + future: futureList, + builder: (context, AsyncSnapshot snapshot) { + if (snapshot.hasData) { + List elements = []; + + for (var element in snapshot.data!.pois) { + elements.add(itemCard(element)); } - return const CircularProgressIndicator(); - }, - ), + return OrientationBuilder(builder: (context, orientation) { + return GridView.count( + crossAxisCount: orientation == Orientation.portrait ? 1 : 2, + children: elements); + }); + } + + return const CircularProgressIndicator(); + }, ), ); } } -Widget itemCard(POI cardContent, BuildContext context) { +Widget itemCard(POI cardContent) { return Card( + margin: const EdgeInsets.all(10), elevation: 5.0, clipBehavior: Clip.antiAlias, shape: RoundedRectangleBorder( @@ -79,21 +89,10 @@ Widget itemCard(POI cardContent, BuildContext context) { child: Wrap( runSpacing: 10, children: [ - Align( - alignment: Alignment.centerLeft, - child: Text( - cardContent.name, - style: const TextStyle(fontWeight: FontWeight.bold), - textScaleFactor: 1.5, - ), - ), - Align( - alignment: Alignment.centerLeft, - child: Text( - cardContent.detail, - textScaleFactor: 1.0, - ), - ), + InfoPOI( + name: cardContent.name, + location: cardContent.location, + rating: cardContent.rating), ], ), ), @@ -101,4 +100,4 @@ Widget itemCard(POI cardContent, BuildContext context) { ), ), ); -} \ No newline at end of file +} diff --git a/lib/ui/settings.dart b/lib/ui/settings.dart new file mode 100644 index 0000000..04e11ad --- /dev/null +++ b/lib/ui/settings.dart @@ -0,0 +1,43 @@ +import 'package:flutter/material.dart'; + +class Settings extends StatefulWidget { + const Settings({Key? key}) : super(key: key); + + @override + State createState() => _Settings(); +} + +class _Settings extends State { + bool _notifications = false; + bool _sound = false; + + @override + Widget build(BuildContext context) { + + return Scaffold( + appBar: AppBar(title: const Text('Settings')), + body: Column( + children: [ + SwitchListTile( + value: _notifications, + title: const Text('Allow notifications'), + secondary: const Icon(Icons.notifications), + onChanged: (bool value) { + setState(() => _notifications = value); + } + ), + SwitchListTile( + value: _sound, + title: const Text('Allow sound'), + secondary: const Icon(Icons.surround_sound), + onChanged: (bool value) { + setState(() => { + _sound = !_notifications ? false : value + }); + } + ), + ], + ) + ); + } +} \ No newline at end of file diff --git a/lib/widgets/info_poi.dart b/lib/widgets/info_poi.dart new file mode 100644 index 0000000..6951100 --- /dev/null +++ b/lib/widgets/info_poi.dart @@ -0,0 +1,45 @@ +import 'package:flutter/material.dart'; + +class InfoPOI extends StatelessWidget { + const InfoPOI({Key? key, required this.name, required this.location, required this.rating}) : super(key: key); + + final String name; + final String location; + final String rating; + + @override + Widget build(BuildContext context) { + return Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: const EdgeInsets.only(bottom: 5), + child: Text( + name, + style: const TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + ), + Text( + location, + style: const TextStyle( + color: Colors.grey, + ), + ), + ], + ), + ), + const Icon( + Icons.star, + color: Colors.amber, + ), + Text(rating), + ] + ); + } +} \ No newline at end of file diff --git a/lib/maps.dart b/lib/widgets/maps.dart similarity index 96% rename from lib/maps.dart rename to lib/widgets/maps.dart index 33ac17a..fbccef4 100644 --- a/lib/maps.dart +++ b/lib/widgets/maps.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; -import 'ask_location_permission.dart'; +import '../ask_location_permission.dart'; class Maps extends StatefulWidget { final Map data;