From 139c13dfcd9677da3699b9fbeef7c7cb1320e33d Mon Sep 17 00:00:00 2001 From: Pablo Galve Date: Sat, 20 Nov 2021 17:21:25 +0100 Subject: [PATCH 1/7] Update License: Add Pablo --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4e94b0a9..33cacbb3 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ If this project is useful for you, please consider starring this repository and ## Contributors - Universitat Pompeu Fabra - - John Palmer + - John R.B. Palmer - [github.com/johnpalmer](https://github.com/johnpalmer) - CEAB-CSIC - Pablo Galve Millán @@ -44,7 +44,7 @@ This repository contains the source code development version of Space Mapper. Pr This project is licensed under the [GNU GENERAL PUBLIC LICENSE](https://github.com/ActivitySpaceProject/space_mapper/blob/master/LICENSE) -Copyright 2020 John R.B. Palmer +Copyright 2021 John R.B. Palmer and Pablo Galve Millán Space Mapper is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. From 0b5cb3ff25dae7ca7a307a4df74e463f13bb414e Mon Sep 17 00:00:00 2001 From: Pablo Galve Date: Sat, 20 Nov 2021 18:31:27 +0100 Subject: [PATCH 2/7] [Take Survey] Create Survey Class --- Space_Mapper/lib/models/surveys.dart | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Space_Mapper/lib/models/surveys.dart diff --git a/Space_Mapper/lib/models/surveys.dart b/Space_Mapper/lib/models/surveys.dart new file mode 100644 index 00000000..b59024f5 --- /dev/null +++ b/Space_Mapper/lib/models/surveys.dart @@ -0,0 +1,17 @@ +class Survey { + final int id; + final String name; + final String summary; + Survey(this.id, this.name, this.summary); + + Survey.blank() + : id = 0, + name = ' ', + summary = ' '; + + static Future> fetchAll() async { + // TODO: In a future version we'll fetch data from a web app + List list = []; + return list; + } +} From c083f76874549e831c254cd77deeec3d2f935cda Mon Sep 17 00:00:00 2001 From: Pablo Galve Date: Sat, 20 Nov 2021 18:32:09 +0100 Subject: [PATCH 3/7] [Take Survey] Initial list_view --- Space_Mapper/lib/ui/available_surveys.dart | 84 ++++++++++++++++++++++ Space_Mapper/lib/ui/side_drawer.dart | 9 ++- 2 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 Space_Mapper/lib/ui/available_surveys.dart diff --git a/Space_Mapper/lib/ui/available_surveys.dart b/Space_Mapper/lib/ui/available_surveys.dart new file mode 100644 index 00000000..5b6865de --- /dev/null +++ b/Space_Mapper/lib/ui/available_surveys.dart @@ -0,0 +1,84 @@ +import 'package:flutter/material.dart'; + +import '../app_localizations.dart'; +import '../models/surveys.dart'; + +class AvailableSurveysScreen extends StatefulWidget { + @override + _AvailableSurveysScreenState createState() => _AvailableSurveysScreenState(); +} + +class _AvailableSurveysScreenState extends State { + List surveys = []; + bool loading = false; + + @override + void initState() { + super.initState(); + loadData(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: + Text(AppLocalizations.of(context)!.translate("take_survey"))), + body: RefreshIndicator( + onRefresh: loadData, + child: Column( + children: [ + renderProgressBar(context), + Expanded(child: renderListView(context)) + ], + ), + )); + } + + Future loadData() async { + if (this.mounted) { + setState(() => this.loading = true); + final surveys = await Survey.fetchAll(); + setState(() { + this.surveys = surveys; + this.loading = false; + }); + } + } + + Widget renderProgressBar(BuildContext context) { + return (this.loading + ? LinearProgressIndicator( + value: null, + backgroundColor: Colors.white, + valueColor: AlwaysStoppedAnimation(Colors.grey)) + : Container()); + } + + Widget renderListView(BuildContext context) { + return ListView.builder( + itemCount: this.surveys.length, itemBuilder: _listViewItemBuilder); + } + + Widget _listViewItemBuilder(BuildContext context, int index) { + final location = this.surveys[index]; + return GestureDetector( + onTap: () => _navigationToLocationDetail(context, location.id), + child: Container( + //height: ListItemHeight, + height: 100.0, + child: Stack( + children: [ + //BannerImage(url: location.url, height: 300.0), + //_tileFooter(location), + ], + ), + ), + ); + } + + void _navigationToLocationDetail(BuildContext context, int locationID) { + //Navigator.push(context, + // MaterialPageRoute(builder: (context) => LocationDetail(locationID))); + } +} diff --git a/Space_Mapper/lib/ui/side_drawer.dart b/Space_Mapper/lib/ui/side_drawer.dart index 8a7de104..3a769ed0 100644 --- a/Space_Mapper/lib/ui/side_drawer.dart +++ b/Space_Mapper/lib/ui/side_drawer.dart @@ -3,13 +3,14 @@ import 'package:asm/app_localizations.dart'; import 'package:asm/models/list_view.dart'; import 'package:asm/ui/list_view.dart'; import 'package:asm/ui/report_an_issue.dart'; -import 'package:asm/ui/web_view.dart'; import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:share/share.dart'; import 'package:flutter_background_geolocation/flutter_background_geolocation.dart' as bg; +import 'available_surveys.dart'; + class ShareLocation { late final String _timestamp; final double _lat; @@ -82,8 +83,10 @@ class SpaceMapperSideDrawer extends StatelessWidget { title: Text( AppLocalizations.of(context)!.translate("take_survey")), onTap: () { - Navigator.push(context, - MaterialPageRoute(builder: (context) => MyWebView())); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => AvailableSurveysScreen())); })), Card( child: ListTile( From b49d8a0fe9bc0c19f89987d63023e60e1179df97 Mon Sep 17 00:00:00 2001 From: Pablo Galve Date: Sat, 20 Nov 2021 19:27:38 +0100 Subject: [PATCH 4/7] [Take Survey] Add mock data --- Space_Mapper/lib/mocks/mock_survey.dart | 33 ++++++++++++++++++++++ Space_Mapper/lib/ui/available_surveys.dart | 13 +++++---- 2 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 Space_Mapper/lib/mocks/mock_survey.dart diff --git a/Space_Mapper/lib/mocks/mock_survey.dart b/Space_Mapper/lib/mocks/mock_survey.dart new file mode 100644 index 00000000..72d6d8aa --- /dev/null +++ b/Space_Mapper/lib/mocks/mock_survey.dart @@ -0,0 +1,33 @@ +import '../models/surveys.dart'; + +mixin MockSurvey implements Survey { + static final List items = [ + Survey( + 1, + "Mosquito Alert", + "Mosquito Alert is a citizen science platform for studying and controlling the tiger mosquito (Aedes albopictus) and the yellow fever mosquito (Aedes aegypti).", + ), + Survey( + 2, + "Survey2", + "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus a dui leo. Integer volutpat ipsum sed nulla luctus porttitor. Vivamus tincidunt iaculis purus. Sed lacinia faucibus dignissim.", + ), + Survey( + 3, + "Survey3", + "Nullam ac est non ante lobortis cursus. Sed nulla leo, venenatis at enim a, iaculis venenatis purus.", + ) + ]; + + static Survey fetchFirst() { + return items[0]; + } + + static fetchAll() { + return items; + } + + static Survey fetch(int index) { + return items[index]; + } +} diff --git a/Space_Mapper/lib/ui/available_surveys.dart b/Space_Mapper/lib/ui/available_surveys.dart index 5b6865de..9498c2bd 100644 --- a/Space_Mapper/lib/ui/available_surveys.dart +++ b/Space_Mapper/lib/ui/available_surveys.dart @@ -1,8 +1,11 @@ +import 'package:asm/mocks/mock_survey.dart'; import 'package:flutter/material.dart'; import '../app_localizations.dart'; import '../models/surveys.dart'; +const ListItemHeight = 245.0; + class AvailableSurveysScreen extends StatefulWidget { @override _AvailableSurveysScreenState createState() => _AvailableSurveysScreenState(); @@ -38,7 +41,7 @@ class _AvailableSurveysScreenState extends State { Future loadData() async { if (this.mounted) { setState(() => this.loading = true); - final surveys = await Survey.fetchAll(); + final surveys = await MockSurvey.fetchAll(); setState(() { this.surveys = surveys; this.loading = false; @@ -61,14 +64,14 @@ class _AvailableSurveysScreenState extends State { } Widget _listViewItemBuilder(BuildContext context, int index) { - final location = this.surveys[index]; + final survey = this.surveys[index]; return GestureDetector( - onTap: () => _navigationToLocationDetail(context, location.id), + onTap: () => _navigationToLocationDetail(context, survey.id), child: Container( - //height: ListItemHeight, - height: 100.0, + height: ListItemHeight, child: Stack( children: [ + Text(survey.name), //BannerImage(url: location.url, height: 300.0), //_tileFooter(location), ], From 51112e67bf59633904d8be49eb8dee636759e8b7 Mon Sep 17 00:00:00 2001 From: Pablo Galve Date: Sat, 20 Nov 2021 20:06:49 +0100 Subject: [PATCH 5/7] [Take Survey] Create UI design --- Space_Mapper/lib/components/banner_image.dart | 24 +++++++ Space_Mapper/lib/components/survey_tile.dart | 40 ++++++++++++ Space_Mapper/lib/mocks/mock_survey.dart | 11 ++-- .../lib/models/{surveys.dart => survey.dart} | 4 +- Space_Mapper/lib/styles.dart | 62 +++++++++++++++++++ Space_Mapper/lib/ui/available_surveys.dart | 27 ++++++-- 6 files changed, 158 insertions(+), 10 deletions(-) create mode 100644 Space_Mapper/lib/components/banner_image.dart create mode 100644 Space_Mapper/lib/components/survey_tile.dart rename Space_Mapper/lib/models/{surveys.dart => survey.dart} (74%) create mode 100644 Space_Mapper/lib/styles.dart diff --git a/Space_Mapper/lib/components/banner_image.dart b/Space_Mapper/lib/components/banner_image.dart new file mode 100644 index 00000000..b5fd6cc6 --- /dev/null +++ b/Space_Mapper/lib/components/banner_image.dart @@ -0,0 +1,24 @@ +import 'package:flutter/material.dart'; + +class BannerImage extends StatelessWidget { + final String url; + final double height; + + BannerImage({required this.url, required this.height}); + + @override + Widget build(BuildContext context) { + if (url.isEmpty) return Container(); + Image image; + try { + image = Image.network(url, fit: BoxFit.cover); + return Container( + constraints: BoxConstraints.expand(height: height), + child: image, + ); + } catch (e) { + print('could not load image $url'); + return Container(); + } + } +} diff --git a/Space_Mapper/lib/components/survey_tile.dart b/Space_Mapper/lib/components/survey_tile.dart new file mode 100644 index 00000000..6f9c69a4 --- /dev/null +++ b/Space_Mapper/lib/components/survey_tile.dart @@ -0,0 +1,40 @@ +import 'package:flutter/material.dart'; + +import '../models/survey.dart'; +import '../styles.dart'; + +const SurveyTileHeight = 100.0; + +class SurveyTile extends StatelessWidget { + final Survey survey; + final bool darkTheme; + + SurveyTile({required this.survey, required this.darkTheme}); + + @override + Widget build(BuildContext context) { + final title = survey.name.toUpperCase(); + final summary = survey.summary; + + return Container( + padding: EdgeInsets.all(0), + height: SurveyTileHeight, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('$title', + overflow: TextOverflow.ellipsis, + maxLines: 1, + style: this.darkTheme + ? Styles.surveyTileTitleDark + : Styles.surveyTileTitleLight), + Text('$summary', + overflow: TextOverflow.ellipsis, + maxLines: 3, + style: Styles.surveyTileCaption), + ], + ), + ); + } +} diff --git a/Space_Mapper/lib/mocks/mock_survey.dart b/Space_Mapper/lib/mocks/mock_survey.dart index 72d6d8aa..87dfbf09 100644 --- a/Space_Mapper/lib/mocks/mock_survey.dart +++ b/Space_Mapper/lib/mocks/mock_survey.dart @@ -1,21 +1,24 @@ -import '../models/surveys.dart'; +import '../models/survey.dart'; mixin MockSurvey implements Survey { static final List items = [ Survey( 1, "Mosquito Alert", + "https://www.periodismociudadano.com/wp-content/uploads/2020/11/mosquito-49141_640.jpg", "Mosquito Alert is a citizen science platform for studying and controlling the tiger mosquito (Aedes albopictus) and the yellow fever mosquito (Aedes aegypti).", ), Survey( 2, - "Survey2", + "Lorem Ipsum", + "https://upload.wikimedia.org/wikipedia/commons/thumb/4/42/Kiyomizu-dera_in_Kyoto-r.jpg/800px-Kiyomizu-dera_in_Kyoto-r.jpg", "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus a dui leo. Integer volutpat ipsum sed nulla luctus porttitor. Vivamus tincidunt iaculis purus. Sed lacinia faucibus dignissim.", ), Survey( 3, - "Survey3", - "Nullam ac est non ante lobortis cursus. Sed nulla leo, venenatis at enim a, iaculis venenatis purus.", + "Dolor Sit Amet", + "https://www.yhunter.ru/wp-content/uploads/2015/06/DSC1876.jpg", + "Nullam ac est non ante lobortis cursus. Sed nulla leo, venenatis at enim a, iaculis venenatis purus.Nullam ac est non ante lobortis cursus. Sed nulla leo, venenatis at enim a, iaculis venenatis purus.Nullam ac est non ante lobortis cursus. Sed nulla leo, venenatis at enim a, iaculis venenatis purus.Nullam ac est non ante lobortis cursus. Sed nulla leo, venenatis at enim a, iaculis venenatis purus.Nullam ac est non ante lobortis cursus. Sed nulla leo, venenatis at enim a, iaculis venenatis purus.", ) ]; diff --git a/Space_Mapper/lib/models/surveys.dart b/Space_Mapper/lib/models/survey.dart similarity index 74% rename from Space_Mapper/lib/models/surveys.dart rename to Space_Mapper/lib/models/survey.dart index b59024f5..005eb1d1 100644 --- a/Space_Mapper/lib/models/surveys.dart +++ b/Space_Mapper/lib/models/survey.dart @@ -1,12 +1,14 @@ class Survey { final int id; final String name; + final String imageUrl; final String summary; - Survey(this.id, this.name, this.summary); + Survey(this.id, this.name, this.imageUrl, this.summary); Survey.blank() : id = 0, name = ' ', + imageUrl = ' ', summary = ' '; static Future> fetchAll() async { diff --git a/Space_Mapper/lib/styles.dart b/Space_Mapper/lib/styles.dart new file mode 100644 index 00000000..86286a81 --- /dev/null +++ b/Space_Mapper/lib/styles.dart @@ -0,0 +1,62 @@ +import 'package:flutter/material.dart'; + +class Styles { + static const _textSizeLarge = 25.0; + static const _textSizeDefault = 16.0; + static const _textSizeSmall = 12.0; + static const horizontalPaddingDefault = 12.0; + static final Color _textColorStrong = _hexToColor('000000'); + static final Color _textColorDefault = _hexToColor('666666'); + static final Color _textColorFaint = _hexToColor('999999'); + static final Color textColorBright = _hexToColor('FFFFFF'); + static final Color accentColor = _hexToColor('FF0000'); + static final String _fontNameDefault = 'Montserrat'; + static final navBarTitle = TextStyle( + fontFamily: _fontNameDefault, + fontWeight: FontWeight.w600, + fontSize: _textSizeDefault, + color: _textColorDefault, + ); + static final headerLarge = TextStyle( + fontFamily: _fontNameDefault, + fontSize: _textSizeLarge, + color: _textColorStrong, + ); + static final textDefault = TextStyle( + fontFamily: _fontNameDefault, + fontSize: _textSizeDefault, + color: _textColorDefault, + ); + + static final textCTAButton = TextStyle( + fontFamily: _fontNameDefault, + fontSize: _textSizeLarge, + color: textColorBright, + ); + + static final surveyTileTitleLight = TextStyle( + fontFamily: _fontNameDefault, + fontSize: _textSizeLarge, + color: _textColorStrong, + ); + static final surveyTileTitleDark = TextStyle( + fontFamily: _fontNameDefault, + fontSize: _textSizeLarge, + color: textColorBright, + ); + + static final surveyTileSubTitle = TextStyle( + fontFamily: _fontNameDefault, + fontSize: _textSizeDefault, + color: accentColor, + ); + static final surveyTileCaption = TextStyle( + fontFamily: _fontNameDefault, + fontSize: _textSizeSmall, + color: _textColorFaint, + ); + + static Color _hexToColor(String code) { + return Color(int.parse(code.substring(0, 6), radix: 16) + 0xFF000000); + } +} diff --git a/Space_Mapper/lib/ui/available_surveys.dart b/Space_Mapper/lib/ui/available_surveys.dart index 9498c2bd..19e84e40 100644 --- a/Space_Mapper/lib/ui/available_surveys.dart +++ b/Space_Mapper/lib/ui/available_surveys.dart @@ -1,8 +1,11 @@ -import 'package:asm/mocks/mock_survey.dart'; import 'package:flutter/material.dart'; import '../app_localizations.dart'; -import '../models/surveys.dart'; +import '../components/banner_image.dart'; +import '../components/survey_tile.dart'; +import '../mocks/mock_survey.dart'; +import '../models/survey.dart'; +import '../styles.dart'; const ListItemHeight = 245.0; @@ -71,9 +74,8 @@ class _AvailableSurveysScreenState extends State { height: ListItemHeight, child: Stack( children: [ - Text(survey.name), - //BannerImage(url: location.url, height: 300.0), - //_tileFooter(location), + BannerImage(url: survey.imageUrl, height: 300.0), + _tileFooter(survey), ], ), ), @@ -84,4 +86,19 @@ class _AvailableSurveysScreenState extends State { //Navigator.push(context, // MaterialPageRoute(builder: (context) => LocationDetail(locationID))); } + + Widget _tileFooter(Survey survey) { + final info = SurveyTile(survey: survey, darkTheme: true); + final overlay = Container( + padding: EdgeInsets.symmetric( + vertical: 5.0, horizontal: Styles.horizontalPaddingDefault), + decoration: BoxDecoration(color: Colors.black.withOpacity(0.5)), + child: info, + ); + return Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [overlay], + ); + } } From d6fd5ed0c6230af7d3ae26398c00d82b5a38d835 Mon Sep 17 00:00:00 2001 From: Pablo Galve Date: Sat, 20 Nov 2021 20:10:17 +0100 Subject: [PATCH 6/7] Unit tests for MockSurvey --- Space_Mapper/test/unit/mock_survey_test.dart | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Space_Mapper/test/unit/mock_survey_test.dart diff --git a/Space_Mapper/test/unit/mock_survey_test.dart b/Space_Mapper/test/unit/mock_survey_test.dart new file mode 100644 index 00000000..112fe975 --- /dev/null +++ b/Space_Mapper/test/unit/mock_survey_test.dart @@ -0,0 +1,22 @@ +import 'package:asm/mocks/mock_survey.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + test('test fetchAny', () { + final mockSurvey = MockSurvey.fetchFirst(); + expect(mockSurvey, isNotNull); + expect(mockSurvey.name, isNotEmpty); + }); + + test('test fetchAll', () { + final mockSurvey = MockSurvey.fetchAll(); + expect(mockSurvey.length, greaterThan(0)); + expect(mockSurvey[0].name, isNotEmpty); + }); + + test('test fetch', () { + final mockSurvey = MockSurvey.fetch(0); + expect(mockSurvey, isNotNull); + expect(mockSurvey.name, isNotEmpty); + }); +} From ed966047c937a3e74f8ce3c40493c2e7672b0cad Mon Sep 17 00:00:00 2001 From: Pablo Galve Date: Sat, 20 Nov 2021 20:29:56 +0100 Subject: [PATCH 7/7] [Take Survey] Open a selected survey --- Space_Mapper/lib/mocks/mock_survey.dart | 11 +++++++---- Space_Mapper/lib/models/survey.dart | 4 +++- Space_Mapper/lib/ui/available_surveys.dart | 10 ++++++---- Space_Mapper/lib/ui/web_view.dart | 10 +++++++--- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/Space_Mapper/lib/mocks/mock_survey.dart b/Space_Mapper/lib/mocks/mock_survey.dart index 87dfbf09..2439e5e3 100644 --- a/Space_Mapper/lib/mocks/mock_survey.dart +++ b/Space_Mapper/lib/mocks/mock_survey.dart @@ -5,19 +5,22 @@ mixin MockSurvey implements Survey { Survey( 1, "Mosquito Alert", + "https://play.google.com/store/apps/details?id=ceab.movelab.tigatrapp&hl=es&gl=US", "https://www.periodismociudadano.com/wp-content/uploads/2020/11/mosquito-49141_640.jpg", "Mosquito Alert is a citizen science platform for studying and controlling the tiger mosquito (Aedes albopictus) and the yellow fever mosquito (Aedes aegypti).", ), Survey( 2, - "Lorem Ipsum", - "https://upload.wikimedia.org/wikipedia/commons/thumb/4/42/Kiyomizu-dera_in_Kyoto-r.jpg/800px-Kiyomizu-dera_in_Kyoto-r.jpg", + "Max Planck Institute", + "https://www.mpg.de/institutes", + "https://upload.wikimedia.org/wikipedia/commons/thumb/f/f3/Max_Planck_Institute_for_the_Science_of_Light%2C_new_building%2C_July_2015.jpg/800px-Max_Planck_Institute_for_the_Science_of_Light%2C_new_building%2C_July_2015.jpg", "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus a dui leo. Integer volutpat ipsum sed nulla luctus porttitor. Vivamus tincidunt iaculis purus. Sed lacinia faucibus dignissim.", ), Survey( 3, - "Dolor Sit Amet", - "https://www.yhunter.ru/wp-content/uploads/2015/06/DSC1876.jpg", + "Space Mapper Form Test", + "https://ee.kobotoolbox.org/single/asCwpCjZ", + "https://raw.githubusercontent.com/ActivitySpaceProject/space_mapper/master/Assets/images/3.0.2%2B18_screenshots.png", "Nullam ac est non ante lobortis cursus. Sed nulla leo, venenatis at enim a, iaculis venenatis purus.Nullam ac est non ante lobortis cursus. Sed nulla leo, venenatis at enim a, iaculis venenatis purus.Nullam ac est non ante lobortis cursus. Sed nulla leo, venenatis at enim a, iaculis venenatis purus.Nullam ac est non ante lobortis cursus. Sed nulla leo, venenatis at enim a, iaculis venenatis purus.Nullam ac est non ante lobortis cursus. Sed nulla leo, venenatis at enim a, iaculis venenatis purus.", ) ]; diff --git a/Space_Mapper/lib/models/survey.dart b/Space_Mapper/lib/models/survey.dart index 005eb1d1..aa541057 100644 --- a/Space_Mapper/lib/models/survey.dart +++ b/Space_Mapper/lib/models/survey.dart @@ -1,13 +1,15 @@ class Survey { final int id; final String name; + final String webUrl; final String imageUrl; final String summary; - Survey(this.id, this.name, this.imageUrl, this.summary); + Survey(this.id, this.name, this.webUrl, this.imageUrl, this.summary); Survey.blank() : id = 0, name = ' ', + webUrl = ' ', imageUrl = ' ', summary = ' '; diff --git a/Space_Mapper/lib/ui/available_surveys.dart b/Space_Mapper/lib/ui/available_surveys.dart index 19e84e40..73a8f3da 100644 --- a/Space_Mapper/lib/ui/available_surveys.dart +++ b/Space_Mapper/lib/ui/available_surveys.dart @@ -1,3 +1,4 @@ +import 'package:asm/ui/web_view.dart'; import 'package:flutter/material.dart'; import '../app_localizations.dart'; @@ -5,6 +6,7 @@ import '../components/banner_image.dart'; import '../components/survey_tile.dart'; import '../mocks/mock_survey.dart'; import '../models/survey.dart'; +import '../ui/web_view.dart'; import '../styles.dart'; const ListItemHeight = 245.0; @@ -69,7 +71,7 @@ class _AvailableSurveysScreenState extends State { Widget _listViewItemBuilder(BuildContext context, int index) { final survey = this.surveys[index]; return GestureDetector( - onTap: () => _navigationToLocationDetail(context, survey.id), + onTap: () => _navigationToLocationDetail(context, survey.webUrl), child: Container( height: ListItemHeight, child: Stack( @@ -82,9 +84,9 @@ class _AvailableSurveysScreenState extends State { ); } - void _navigationToLocationDetail(BuildContext context, int locationID) { - //Navigator.push(context, - // MaterialPageRoute(builder: (context) => LocationDetail(locationID))); + void _navigationToLocationDetail(BuildContext context, String surveyWebUrl) { + Navigator.push(context, + MaterialPageRoute(builder: (context) => MyWebView(surveyWebUrl))); } Widget _tileFooter(Survey survey) { diff --git a/Space_Mapper/lib/ui/web_view.dart b/Space_Mapper/lib/ui/web_view.dart index af41efad..be1b4858 100644 --- a/Space_Mapper/lib/ui/web_view.dart +++ b/Space_Mapper/lib/ui/web_view.dart @@ -5,7 +5,7 @@ import 'package:webview_flutter/webview_flutter.dart'; const kAndroidUserAgent = 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Mobile Safari/537.36'; -const String selectedUrl = 'https://ee.kobotoolbox.org/single/asCwpCjZ'; + const String userUUID_element = '/asRrkkAw4mUtpTDkjdzZzt/group_survey/userUUID'; const String userUUID_label = userUUID_element + ':label'; @@ -17,15 +17,19 @@ final Set jsChannels = [ }), ].toSet(); +// ignore: must_be_immutable class MyWebView extends StatefulWidget { + String selectedUrl; + MyWebView(this.selectedUrl); @override - _MyWebViewState createState() => _MyWebViewState(); + _MyWebViewState createState() => _MyWebViewState(selectedUrl); } class _MyWebViewState extends State { + String selectedUrl; final Completer _controller = Completer(); - + _MyWebViewState(this.selectedUrl); @override void initState() { super.initState();