From af69ba1ef45ae0c950e4fbbcd23bbc8ca14404b8 Mon Sep 17 00:00:00 2001 From: Pablo Galve Date: Wed, 17 Nov 2021 10:30:06 +0100 Subject: [PATCH 1/2] [Location History] Swipe to remove locations --- README.md | 2 +- Space_Mapper/lib/models/list_view.dart | 16 +++++------ Space_Mapper/lib/ui/list_view.dart | 32 +++++++++++++++++++++- Space_Mapper/test/unit/list_view_test.dart | 6 ++-- 4 files changed, 43 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 4e94b0a9..14abff71 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # **Space Mapper** ## What is Space Mapper? -Space Mapper is a mobile phone application that lets you see your daily movements in a map. Additionally, you can participate in citizen science by sharing your anonymized location history with research institutions to help scientists research about human mobility. +Space Mapper is a privacy-focused mobile phone application that lets you see your daily movements in a map. Additionally, you can optionally participate in citizen science by sharing your anonymized location history with research institutions to help scientists research about human mobility. ## Screenshots diff --git a/Space_Mapper/lib/models/list_view.dart b/Space_Mapper/lib/models/list_view.dart index c409cd4f..cfa9939a 100644 --- a/Space_Mapper/lib/models/list_view.dart +++ b/Space_Mapper/lib/models/list_view.dart @@ -1,4 +1,4 @@ -import 'package:collection/collection.dart'; +//import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; import 'package:flutter_background_geolocation/flutter_background_geolocation.dart' as bg; @@ -6,27 +6,27 @@ import 'package:flutter_background_geolocation/flutter_background_geolocation.da import '../app_localizations.dart'; class CustomLocationsManager { - static List customLocations = []; + //static List customLocations = []; - static List fetchAll({required bool sortByNewest}) { + /*static List fetchAll({required bool sortByNewest}) { if (sortByNewest) { return customLocations; } else { return new List.from(customLocations.reversed); } - } + }*/ - static CustomLocation? fetchByUUID(String uuid) { + /*static CustomLocation? fetchByUUID(String uuid) { CustomLocation? ret = customLocations .firstWhereOrNull((element) => element.getUUID() == uuid); return ret; - } + }*/ - static void removeAllCustomLocations() { + /*static void removeAllCustomLocations() { print("Removing " + customLocations.length.toString() + " customLocations"); customLocations.clear(); print("All customLocations removed"); - } + }*/ /// Makes timestamp readable by a human static String formatTimestamp(String timestamp) { diff --git a/Space_Mapper/lib/ui/list_view.dart b/Space_Mapper/lib/ui/list_view.dart index b60e2ef5..f48c6c03 100644 --- a/Space_Mapper/lib/ui/list_view.dart +++ b/Space_Mapper/lib/ui/list_view.dart @@ -121,7 +121,37 @@ class _STOListViewState extends State { itemCount: snapshot.data!.length, itemBuilder: (context, index) { CustomLocation thisLocation = snapshot.data![index]; - return _tile(thisLocation, context); + return Dismissible( + child: _tile(thisLocation, context), + background: Container( + child: Container( + margin: EdgeInsets.only(right: 10.0), + alignment: Alignment.centerRight, + child: + new LayoutBuilder(builder: (context, constraint) { + return new Icon(Icons.delete_forever, + size: constraint.biggest.height * 0.5); + }), + ), + color: Colors.red, + ), + key: new UniqueKey(), + onDismissed: (direction) async => { + await thisLocation.deleteThisLocation(), + Scaffold.of(context).showSnackBar( + new SnackBar(content: new Text("Location removed"))) + }, + /*confirmDismiss: (DismissDirection direction) async { + //if(direction == DismissDirection.) + // if (direction == left) + await thisLocation.deleteThisLocation(); + setState(() { + //recalculateLocations(); + //thisLocation = snapshot.data![index]; + }); + return true; + },*/ + ); }); }, )); diff --git a/Space_Mapper/test/unit/list_view_test.dart b/Space_Mapper/test/unit/list_view_test.dart index e800d7c6..6fca3138 100644 --- a/Space_Mapper/test/unit/list_view_test.dart +++ b/Space_Mapper/test/unit/list_view_test.dart @@ -1,6 +1,6 @@ import 'package:asm/models/list_view.dart'; import 'package:test/test.dart'; -import 'package:faker/faker.dart'; +//import 'package:faker/faker.dart'; void main() { group('Locations History Screen - Unit Tests', () { @@ -94,7 +94,7 @@ void main() { }); });*/ }); - group("CustomLocationsManager class", () { + /*group("CustomLocationsManager class", () { test("fetchAll and fetchByUUID", () async { //We create 50 fake locations to do the test for (int i = 0; i < 50; i++) { @@ -150,6 +150,6 @@ void main() { } } }); - }); + });*/ }); } From caf202c2442af87543b6998364883ed66509759c Mon Sep 17 00:00:00 2001 From: Pablo Date: Fri, 19 Nov 2021 12:18:17 +0100 Subject: [PATCH 2/2] [Location History] Remove only on swipe left --- Space_Mapper/lib/ui/list_view.dart | 3 ++- Space_Mapper/pubspec.lock | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Space_Mapper/lib/ui/list_view.dart b/Space_Mapper/lib/ui/list_view.dart index f48c6c03..85b4ad97 100644 --- a/Space_Mapper/lib/ui/list_view.dart +++ b/Space_Mapper/lib/ui/list_view.dart @@ -136,9 +136,10 @@ class _STOListViewState extends State { color: Colors.red, ), key: new UniqueKey(), + direction: DismissDirection.endToStart, onDismissed: (direction) async => { await thisLocation.deleteThisLocation(), - Scaffold.of(context).showSnackBar( + ScaffoldMessenger.of(context).showSnackBar( new SnackBar(content: new Text("Location removed"))) }, /*confirmDismiss: (DismissDirection direction) async { diff --git a/Space_Mapper/pubspec.lock b/Space_Mapper/pubspec.lock index 0c419038..cd4d9b1e 100644 --- a/Space_Mapper/pubspec.lock +++ b/Space_Mapper/pubspec.lock @@ -28,7 +28,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.1" + version: "2.8.2" background_fetch: dependency: "direct main" description: @@ -70,7 +70,7 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" charcode: dependency: transitive description: @@ -328,7 +328,7 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10" + version: "0.12.11" meta: dependency: transitive description: @@ -648,21 +648,21 @@ packages: name: test url: "https://pub.dartlang.org" source: hosted - version: "1.17.10" + version: "1.17.12" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.2" + version: "0.4.3" test_core: dependency: transitive description: name: test_core url: "https://pub.dartlang.org" source: hosted - version: "0.4.0" + version: "0.4.2" transparent_image: dependency: transitive description: