diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json new file mode 100644 index 0000000..ce01aa1 --- /dev/null +++ b/.dart_tool/package_config.json @@ -0,0 +1,355 @@ +{ + "configVersion": 2, + "packages": [ + { + "name": "_fe_analyzer_shared", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-11.0.0", + "packageUri": "lib/", + "languageVersion": "2.2" + }, + { + "name": "analyzer", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.40.4", + "packageUri": "lib/", + "languageVersion": "2.7" + }, + { + "name": "args", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/args-1.6.0", + "packageUri": "lib/", + "languageVersion": "2.3" + }, + { + "name": "async", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.5.0-nullsafety.1", + "packageUri": "lib/", + "languageVersion": "2.10" + }, + { + "name": "boolean_selector", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/boolean_selector-2.1.0-nullsafety.1", + "packageUri": "lib/", + "languageVersion": "2.10" + }, + { + "name": "build", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/build-1.5.0", + "packageUri": "lib/", + "languageVersion": "2.9" + }, + { + "name": "built_collection", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/built_collection-4.3.2", + "packageUri": "lib/", + "languageVersion": "2.6" + }, + { + "name": "built_value", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/built_value-7.1.0", + "packageUri": "lib/", + "languageVersion": "2.3" + }, + { + "name": "characters", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/characters-1.1.0-nullsafety.3", + "packageUri": "lib/", + "languageVersion": "2.10" + }, + { + "name": "charcode", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/charcode-1.2.0-nullsafety.1", + "packageUri": "lib/", + "languageVersion": "2.10" + }, + { + "name": "cli_util", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/cli_util-0.2.0", + "packageUri": "lib/", + "languageVersion": "2.0" + }, + { + "name": "clock", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/clock-1.1.0-nullsafety.1", + "packageUri": "lib/", + "languageVersion": "2.10" + }, + { + "name": "code_builder", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/code_builder-3.5.0", + "packageUri": "lib/", + "languageVersion": "2.7" + }, + { + "name": "collection", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.15.0-nullsafety.3", + "packageUri": "lib/", + "languageVersion": "2.10" + }, + { + "name": "convert", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/convert-2.1.1", + "packageUri": "lib/", + "languageVersion": "1.17" + }, + { + "name": "crypto", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/crypto-2.1.5", + "packageUri": "lib/", + "languageVersion": "2.3" + }, + { + "name": "dart_style", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/dart_style-1.3.8", + "packageUri": "lib/", + "languageVersion": "2.9" + }, + { + "name": "fake_async", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/fake_async-1.2.0-nullsafety.1", + "packageUri": "lib/", + "languageVersion": "2.10" + }, + { + "name": "firebase_analytics", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_analytics-1.2.0+1", + "packageUri": "lib/", + "languageVersion": "2.0" + }, + { + "name": "firebase_auth", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.6.6", + "packageUri": "lib/", + "languageVersion": "2.0" + }, + { + "name": "firebase_core", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-0.2.5+1", + "packageUri": "lib/", + "languageVersion": "2.0" + }, + { + "name": "firebase_database", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_database-1.1.0+1", + "packageUri": "lib/", + "languageVersion": "2.0" + }, + { + "name": "fixnum", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/fixnum-0.10.11", + "packageUri": "lib/", + "languageVersion": "2.1" + }, + { + "name": "flutter", + "rootUri": "file:///C:/src/flutter/flutter/packages/flutter", + "packageUri": "lib/", + "languageVersion": "2.10" + }, + { + "name": "flutter_redux", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_redux-0.5.4", + "packageUri": "lib/", + "languageVersion": "2.0" + }, + { + "name": "flutter_test", + "rootUri": "file:///C:/src/flutter/flutter/packages/flutter_test", + "packageUri": "lib/", + "languageVersion": "2.2" + }, + { + "name": "glob", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/glob-1.2.0", + "packageUri": "lib/", + "languageVersion": "2.1" + }, + { + "name": "google_sign_in", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/google_sign_in-3.3.0+1", + "packageUri": "lib/", + "languageVersion": "2.0" + }, + { + "name": "intl", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/intl-0.15.8", + "packageUri": "lib/", + "languageVersion": "2.0" + }, + { + "name": "js", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/js-0.6.2", + "packageUri": "lib/", + "languageVersion": "2.0" + }, + { + "name": "logging", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/logging-0.11.4", + "packageUri": "lib/", + "languageVersion": "2.0" + }, + { + "name": "matcher", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.10-nullsafety.1", + "packageUri": "lib/", + "languageVersion": "2.10" + }, + { + "name": "meta", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0-nullsafety.3", + "packageUri": "lib/", + "languageVersion": "2.10" + }, + { + "name": "mockito", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/mockito-4.1.3", + "packageUri": "lib/", + "languageVersion": "2.7" + }, + { + "name": "node_interop", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/node_interop-1.1.1", + "packageUri": "lib/", + "languageVersion": "2.0" + }, + { + "name": "node_io", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/node_io-1.1.1", + "packageUri": "lib/", + "languageVersion": "2.2" + }, + { + "name": "numberpicker", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/numberpicker-0.1.7", + "packageUri": "lib/", + "languageVersion": "2.0" + }, + { + "name": "package_config", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/package_config-1.9.3", + "packageUri": "lib/", + "languageVersion": "2.7" + }, + { + "name": "path", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path-1.8.0-nullsafety.1", + "packageUri": "lib/", + "languageVersion": "2.10" + }, + { + "name": "pedantic", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/pedantic-1.9.2", + "packageUri": "lib/", + "languageVersion": "2.1" + }, + { + "name": "pub_semver", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/pub_semver-1.4.4", + "packageUri": "lib/", + "languageVersion": "2.0" + }, + { + "name": "quiver", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-2.1.3", + "packageUri": "lib/", + "languageVersion": "2.0" + }, + { + "name": "redux", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/redux-3.0.0", + "packageUri": "lib/", + "languageVersion": "1.24" + }, + { + "name": "shared_preferences", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.4.3", + "packageUri": "lib/", + "languageVersion": "2.0" + }, + { + "name": "sky_engine", + "rootUri": "file:///C:/src/flutter/flutter/bin/cache/pkg/sky_engine", + "packageUri": "lib/", + "languageVersion": "1.11" + }, + { + "name": "source_gen", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/source_gen-0.9.7+1", + "packageUri": "lib/", + "languageVersion": "2.7" + }, + { + "name": "source_span", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/source_span-1.8.0-nullsafety.2", + "packageUri": "lib/", + "languageVersion": "2.10" + }, + { + "name": "stack_trace", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.10.0-nullsafety.1", + "packageUri": "lib/", + "languageVersion": "2.10" + }, + { + "name": "stream_channel", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/stream_channel-2.1.0-nullsafety.1", + "packageUri": "lib/", + "languageVersion": "2.10" + }, + { + "name": "string_scanner", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.1.0-nullsafety.1", + "packageUri": "lib/", + "languageVersion": "2.10" + }, + { + "name": "term_glyph", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.2.0-nullsafety.1", + "packageUri": "lib/", + "languageVersion": "2.10" + }, + { + "name": "test_api", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.19-nullsafety.2", + "packageUri": "lib/", + "languageVersion": "2.10" + }, + { + "name": "tuple", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/tuple-1.0.3", + "packageUri": "lib/", + "languageVersion": "2.0" + }, + { + "name": "typed_data", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.3.0-nullsafety.3", + "packageUri": "lib/", + "languageVersion": "2.10" + }, + { + "name": "vector_math", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.1.0-nullsafety.3", + "packageUri": "lib/", + "languageVersion": "2.10" + }, + { + "name": "watcher", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/watcher-0.9.7+15", + "packageUri": "lib/", + "languageVersion": "2.2" + }, + { + "name": "yaml", + "rootUri": "file:///C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/yaml-2.2.1", + "packageUri": "lib/", + "languageVersion": "2.4" + }, + { + "name": "weight_tracker", + "rootUri": "../", + "packageUri": "lib/" + } + ], + "generated": "2020-10-23T14:31:39.393685Z", + "generator": "pub", + "generatorVersion": "2.10.2" +} diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies new file mode 100644 index 0000000..6ffa44f --- /dev/null +++ b/.flutter-plugins-dependencies @@ -0,0 +1 @@ +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"firebase_analytics","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_analytics-1.2.0+1\\\\","dependencies":[]},{"name":"firebase_auth","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_auth-0.6.6\\\\","dependencies":["firebase_core"]},{"name":"firebase_core","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core-0.2.5+1\\\\","dependencies":[]},{"name":"firebase_database","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_database-1.1.0+1\\\\","dependencies":["firebase_core"]},{"name":"google_sign_in","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_sign_in-3.3.0+1\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.4.3\\\\","dependencies":[]}],"android":[{"name":"firebase_analytics","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_analytics-1.2.0+1\\\\","dependencies":[]},{"name":"firebase_auth","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_auth-0.6.6\\\\","dependencies":["firebase_core"]},{"name":"firebase_core","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core-0.2.5+1\\\\","dependencies":[]},{"name":"firebase_database","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_database-1.1.0+1\\\\","dependencies":["firebase_core"]},{"name":"google_sign_in","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_sign_in-3.3.0+1\\\\","dependencies":[]},{"name":"shared_preferences","path":"C:\\\\src\\\\flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences-0.4.3\\\\","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"firebase_analytics","dependencies":[]},{"name":"firebase_auth","dependencies":["firebase_core"]},{"name":"firebase_core","dependencies":[]},{"name":"firebase_database","dependencies":["firebase_core"]},{"name":"google_sign_in","dependencies":[]},{"name":"shared_preferences","dependencies":[]}],"date_created":"2020-10-23 20:11:12.167080","version":"1.22.2"} \ No newline at end of file diff --git a/android/gradle.properties b/android/gradle.properties index 8bd86f6..7be3d8b 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1 +1,2 @@ org.gradle.jvmargs=-Xmx1536M +android.enableR8=true diff --git a/ios/Flutter/flutter_export_environment.sh b/ios/Flutter/flutter_export_environment.sh new file mode 100644 index 0000000..b91d457 --- /dev/null +++ b/ios/Flutter/flutter_export_environment.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# This is a generated file; do not edit or check into version control. +export "FLUTTER_ROOT=C:\src\flutter\flutter" +export "FLUTTER_APPLICATION_PATH=D:\OpenSource\weight_tracker" +export "FLUTTER_TARGET=lib\main.dart" +export "FLUTTER_BUILD_DIR=build" +export "SYMROOT=${SOURCE_ROOT}/../build\ios" +export "OTHER_LDFLAGS=$(inherited) -framework Flutter" +export "FLUTTER_FRAMEWORK_DIR=C:\src\flutter\flutter\bin\cache\artifacts\engine\ios" +export "FLUTTER_BUILD_NAME=1.0.0" +export "FLUTTER_BUILD_NUMBER=1" +export "DART_OBFUSCATION=false" +export "TRACK_WIDGET_CREATION=false" +export "TREE_SHAKE_ICONS=false" +export "PACKAGE_CONFIG=.packages" diff --git a/lib/screens/profile_view.dart b/lib/screens/profile_view.dart index 06be20a..e8daa72 100644 --- a/lib/screens/profile_view.dart +++ b/lib/screens/profile_view.dart @@ -78,7 +78,7 @@ class ProfileView extends StatelessWidget { padding: const EdgeInsets.all(16.0), child: Text( label, - style: Theme.of(context).textTheme.display1, + style: Theme.of(context).textTheme.bodyText1, ), ); } diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart index 5f32829..36adf94 100644 --- a/lib/screens/settings_screen.dart +++ b/lib/screens/settings_screen.dart @@ -45,7 +45,7 @@ class SettingsPage extends StatelessWidget { new Expanded( child: new Text( "Unit", - style: Theme.of(context).textTheme.headline, + style: Theme.of(context).textTheme.headline1, )), new DropdownButton( key: const Key('UnitDropdown'), diff --git a/lib/screens/statistics_page.dart b/lib/screens/statistics_page.dart index 0c134d4..04766b6 100644 --- a/lib/screens/statistics_page.dart +++ b/lib/screens/statistics_page.dart @@ -42,13 +42,11 @@ class StatisticsPage extends StatelessWidget { } }); List last7daysEntries = entries - .where((entry) => - entry.dateTime + .where((entry) => entry.dateTime .isAfter(new DateTime.now().subtract(new Duration(days: 7)))) .toList(); List last30daysEntries = entries - .where((entry) => - entry.dateTime + .where((entry) => entry.dateTime .isAfter(new DateTime.now().subtract(new Duration(days: 30)))) .toList(); return new _StatisticsPageViewModel( @@ -62,7 +60,7 @@ class StatisticsPage extends StatelessWidget { last30daysProgress: last30daysEntries.isEmpty ? 0.0 : (last30daysEntries.first.weight - - last30daysEntries.last.weight), + last30daysEntries.last.weight), entries: entries, unit: unit, openAddEntryDialog: () { @@ -159,11 +157,12 @@ class _StatisticCard extends StatelessWidget { final double textSizeFactor; final String unit; - _StatisticCard({this.title, - this.value, - this.unit, - this.processNumberSymbol = false, - this.textSizeFactor = 1.0}); + _StatisticCard( + {this.title, + this.value, + this.unit, + this.processNumberSymbol = false, + this.textSizeFactor = 1.0}); @override Widget build(BuildContext context) { @@ -179,10 +178,9 @@ class _StatisticCard extends StatelessWidget { new Text( numberSymbol + value.toStringAsFixed(1), textScaleFactor: textSizeFactor, - style: Theme - .of(context) + style: Theme.of(context) .textTheme - .display2 + .bodyText1 .copyWith(color: numberColor), ), new Padding( diff --git a/lib/screens/weight_entry_dialog.dart b/lib/screens/weight_entry_dialog.dart index bc50d7d..7ccc3e3 100644 --- a/lib/screens/weight_entry_dialog.dart +++ b/lib/screens/weight_entry_dialog.dart @@ -60,7 +60,7 @@ class WeightEntryDialogState extends State { weightToDisplay: store.state.unit == "kg" ? activeEntry.weight : double.parse( - (activeEntry.weight * KG_LBS_RATIO).toStringAsFixed(1)), + (activeEntry.weight * KG_LBS_RATIO).toStringAsFixed(1)), onEntryChanged: (entry) => store.dispatch(new UpdateActiveWeightEntry(entry)), onDeletePressed: () { @@ -89,9 +89,8 @@ class WeightEntryDialogState extends State { leading: new Icon(Icons.today, color: Colors.grey[500]), title: new DateTimeItem( dateTime: viewModel.weightEntry.dateTime, - onChanged: (dateTime) => - viewModel.onEntryChanged( - viewModel.weightEntry..dateTime = dateTime), + onChanged: (dateTime) => viewModel.onEntryChanged( + viewModel.weightEntry..dateTime = dateTime), ), ), new ListTile( @@ -129,11 +128,7 @@ class WeightEntryDialogState extends State { Widget _createAppBar(BuildContext context, DialogViewModel viewModel) { TextStyle actionStyle = - Theme - .of(context) - .textTheme - .subhead - .copyWith(color: Colors.white); + Theme.of(context).textTheme.headline2.copyWith(color: Colors.white); Text title = viewModel.isEditMode ? const Text("Edit entry") : const Text("New entry"); @@ -166,8 +161,7 @@ class WeightEntryDialogState extends State { _showWeightPicker(BuildContext context, DialogViewModel viewModel) { showDialog( context: context, - builder: (context) => - new NumberPickerDialog.decimal( + builder: (context) => new NumberPickerDialog.decimal( minValue: viewModel.unit == "kg" ? MIN_KG_VALUE : (MIN_KG_VALUE * KG_LBS_RATIO).toInt(), diff --git a/test/unit_tests/chart_painter_test.dart b/test/unit_tests/chart_painter_test.dart index 1069087..27126ad 100644 --- a/test/unit_tests/chart_painter_test.dart +++ b/test/unit_tests/chart_painter_test.dart @@ -1,7 +1,8 @@ import 'dart:ui'; +import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; -import 'package:test_api/test_api.dart'; +// import 'package:test_api/test_api.dart'; import 'package:weight_tracker/model/weight_entry.dart'; import 'package:weight_tracker/widgets/progress_chart.dart'; @@ -44,7 +45,7 @@ void main() { WeightEntry weightEntry2 = new WeightEntry(now.subtract(const Duration(days: 1)), 70.0, null); ChartPainter chartPainter = - new ChartPainter([weightEntry1, weightEntry2], 30, true); + new ChartPainter([weightEntry1, weightEntry2], 30, true); //when chartPainter.paint(mockCanvas, size); //then diff --git a/test/unit_tests/middleware_test.dart b/test/unit_tests/middleware_test.dart index ae3ecb1..b053cea 100644 --- a/test/unit_tests/middleware_test.dart +++ b/test/unit_tests/middleware_test.dart @@ -1,7 +1,8 @@ import 'package:firebase_database/firebase_database.dart'; +import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; import 'package:redux/redux.dart'; -import 'package:test_api/test_api.dart'; +// import 'package:test_api/test_api.dart'; import 'package:weight_tracker/logic/actions.dart'; import 'package:weight_tracker/logic/middleware.dart'; import 'package:weight_tracker/logic/redux_state.dart'; @@ -38,7 +39,7 @@ void main() { test('middleware EditEntryAction invokes child and set', () { //given DatabaseReferenceMock firebaseMock = new DatabaseReferenceMock(); - when(firebaseMock.child(typed(any))).thenReturn(firebaseMock); + when(firebaseMock.child(any)).thenReturn(firebaseMock); ReduxState state = new ReduxState( firebaseState: new FirebaseState(mainReference: firebaseMock)); @@ -58,7 +59,7 @@ void main() { test('middleware RemoveEntryAction invokes child and remove', () { //given DatabaseReferenceMock firebaseMock = new DatabaseReferenceMock(); - when(firebaseMock.child(typed(any))).thenReturn(firebaseMock); + when(firebaseMock.child(any)).thenReturn(firebaseMock); ReduxState state = new ReduxState( firebaseState: new FirebaseState(mainReference: firebaseMock)); @@ -107,8 +108,7 @@ void main() { return state; }; DatabaseReferenceMock databaseReferenceMock = new DatabaseReferenceMock(); - when(databaseReferenceMock.child(typed(any))).thenReturn( - databaseReferenceMock); + when(databaseReferenceMock.child(any)).thenReturn(databaseReferenceMock); when(databaseReferenceMock.push()).thenReturn(databaseReferenceMock); ReduxState state = new ReduxState( weightFromNotes: 70.0, @@ -132,8 +132,7 @@ void main() { return state; }; DatabaseReferenceMock databaseReferenceMock = new DatabaseReferenceMock(); - when(databaseReferenceMock.child(typed(any))).thenReturn( - databaseReferenceMock); + when(databaseReferenceMock.child(any)).thenReturn(databaseReferenceMock); when(databaseReferenceMock.push()).thenReturn(databaseReferenceMock); ReduxState state = new ReduxState( weightFromNotes: 70.0, diff --git a/test/unit_tests/progress_chart_utils_test.dart b/test/unit_tests/progress_chart_utils_test.dart index aadc075..977631a 100644 --- a/test/unit_tests/progress_chart_utils_test.dart +++ b/test/unit_tests/progress_chart_utils_test.dart @@ -1,4 +1,5 @@ -import 'package:test_api/test_api.dart'; +// import 'package:test_api/test_api.dart'; +import 'package:flutter_test/flutter_test.dart'; import 'package:weight_tracker/model/weight_entry.dart'; import 'package:weight_tracker/widgets/progress_chart_utils.dart' as utils; @@ -16,8 +17,8 @@ void main() { int daysToShow = 7; List entries = [entry1, entry2, entry3, entry4]; //when - List newEntries = - utils.prepareEntryList(entries, now.subtract(Duration(days: daysToShow-1))); + List newEntries = utils.prepareEntryList( + entries, now.subtract(Duration(days: daysToShow - 1))); //then expect(newEntries, contains(entry1)); expect(newEntries, contains(entry2)); @@ -34,8 +35,8 @@ void main() { new WeightEntry(now.subtract(new Duration(days: 2)), 90.0, null); List entries = [firstEntryAfterBorder, lastEntryBeforeBorder]; //when - List newEntries = - utils.prepareEntryList(entries, now.subtract(Duration(days: daysToShow-1))); + List newEntries = utils.prepareEntryList( + entries, now.subtract(Duration(days: daysToShow - 1))); //then expect(newEntries, contains(firstEntryAfterBorder)); expect(newEntries, isNot(contains(lastEntryBeforeBorder))); diff --git a/test/unit_tests/reducer_test.dart b/test/unit_tests/reducer_test.dart index 5d0b939..43cc771 100644 --- a/test/unit_tests/reducer_test.dart +++ b/test/unit_tests/reducer_test.dart @@ -1,7 +1,8 @@ import 'package:firebase_auth/firebase_auth.dart'; import 'package:firebase_database/firebase_database.dart'; +import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; -import 'package:test_api/test_api.dart'; +// import 'package:test_api/test_api.dart'; import 'package:weight_tracker/logic/actions.dart'; import 'package:weight_tracker/logic/reducer.dart'; import 'package:weight_tracker/logic/redux_state.dart'; @@ -49,7 +50,7 @@ void main() { ReduxState initialState = new ReduxState(); DatabaseReference databaseReference = new DatabaseReferenceMock(); AddDatabaseReferenceAction action = - new AddDatabaseReferenceAction(databaseReference); + new AddDatabaseReferenceAction(databaseReference); //when ReduxState newState = reduce(initialState, action); //then @@ -113,7 +114,7 @@ void main() { //given ReduxState initialState = new ReduxState(); WeightEntry updatedEntry = - new WeightEntry(new DateTime.now(), 60.0, "text"); + new WeightEntry(new DateTime.now(), 60.0, "text"); UpdateActiveWeightEntry action = new UpdateActiveWeightEntry(updatedEntry); //when ReduxState newState = reduce(initialState, action); @@ -125,7 +126,7 @@ void main() { //given ReduxState initialState = new ReduxState(); WeightEntry updatedEntry = - new WeightEntry(new DateTime.now(), 60.0, "text"); + new WeightEntry(new DateTime.now(), 60.0, "text"); OpenEditEntryDialog action = new OpenEditEntryDialog(updatedEntry); //when ReduxState newState = reduce(initialState, action); @@ -137,7 +138,7 @@ void main() { //given ReduxState initialState = new ReduxState(); WeightEntry updatedEntry = - new WeightEntry(new DateTime.now(), 60.0, "text"); + new WeightEntry(new DateTime.now(), 60.0, "text"); OpenEditEntryDialog action = new OpenEditEntryDialog(updatedEntry); //when ReduxState newState = reduce(initialState, action); @@ -149,7 +150,7 @@ void main() { //given ReduxState initialState = new ReduxState( weightEntryDialogState: - new WeightEntryDialogReduxState(isEditMode: true)); + new WeightEntryDialogReduxState(isEditMode: true)); OpenAddEntryDialog action = new OpenAddEntryDialog(); //when ReduxState newState = reduce(initialState, action); @@ -169,17 +170,17 @@ void main() { test( 'reducer OpenAddEntryDialog creates new entry with copied weight from first entry', - () { - //given - ReduxState initialState = new ReduxState( - entries: [new WeightEntry(new DateTime.now(), 60.0, "Text")]); - OpenAddEntryDialog action = new OpenAddEntryDialog(); - //when - ReduxState newState = reduce(initialState, action); - //then - expect(newState.weightEntryDialogState.activeEntry?.weight, 60); - expect(newState.weightEntryDialogState.activeEntry?.note, null); - }); + () { + //given + ReduxState initialState = new ReduxState( + entries: [new WeightEntry(new DateTime.now(), 60.0, "Text")]); + OpenAddEntryDialog action = new OpenAddEntryDialog(); + //when + ReduxState newState = reduce(initialState, action); + //then + expect(newState.weightEntryDialogState.activeEntry?.weight, 60); + expect(newState.weightEntryDialogState.activeEntry?.note, null); + }); test('reducer OnAddedAction adds entry to list', () { //given @@ -235,11 +236,10 @@ void main() { //then expect(newState.removedEntryState.lastRemovedEntry, entry); }); - } -WeightEntry createEntry(String key, DateTime dateTime, double weight, - String note) { +WeightEntry createEntry( + String key, DateTime dateTime, double weight, String note) { WeightEntry entry = new WeightEntry(dateTime, weight, note); entry.key = key; return entry; diff --git a/test/widget_tests/weight_entry_dialog_test.dart b/test/widget_tests/weight_entry_dialog_test.dart index a321856..d3b379e 100644 --- a/test/widget_tests/weight_entry_dialog_test.dart +++ b/test/widget_tests/weight_entry_dialog_test.dart @@ -15,13 +15,13 @@ void main() { WeightEntryDialogReduxState dialogState = new WeightEntryDialogReduxState( isEditMode: true, activeEntry: activeEntry); WeightEntryDialogReduxState dialogAddState = - dialogState.copyWith(isEditMode: false); + dialogState.copyWith(isEditMode: false); ReduxState defaultState = new ReduxState(weightEntryDialogState: dialogState); pumpSettingWidget(Store store, WidgetTester tester) async { await tester.pumpWidget(new StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new StoreProvider( + return new StoreProvider( store: store, child: new MaterialApp(home: new WeightEntryDialog()), ); @@ -40,7 +40,7 @@ void main() { await pumpSettingWidget( new Store(reduce, initialState: - defaultState.copyWith(weightEntryDialogState: dialogAddState)), + defaultState.copyWith(weightEntryDialogState: dialogAddState)), tester); expect(find.widgetWithText(AppBar, 'New entry'), findsOneWidget); }); @@ -57,7 +57,7 @@ void main() { await pumpSettingWidget( new Store(reduce, initialState: - defaultState.copyWith(weightEntryDialogState: dialogAddState)), + defaultState.copyWith(weightEntryDialogState: dialogAddState)), tester); expect(find.widgetWithText(FlatButton, 'SAVE'), findsOneWidget); }); @@ -74,7 +74,7 @@ void main() { await pumpSettingWidget( new Store(reduce, initialState: - defaultState.copyWith(weightEntryDialogState: dialogAddState)), + defaultState.copyWith(weightEntryDialogState: dialogAddState)), tester); expect(find.widgetWithText(FlatButton, 'DELETE'), findsNothing); }); @@ -89,8 +89,8 @@ void main() { testWidgets('WeightEntryDialog displays weight in lbs', (WidgetTester tester) async { await pumpSettingWidget( - new Store( - reduce, initialState: defaultState.copyWith(unit: 'lbs')), + new Store(reduce, + initialState: defaultState.copyWith(unit: 'lbs')), tester); expect(find.text('154.0 lbs'), findsOneWidget); }); @@ -104,91 +104,89 @@ void main() { //DatePickerDialog is private testWidgets('WeightEntryDialog opens MonthPicker on date click', - (WidgetTester tester) async { - await pumpSettingWidget( - new Store(reduce, initialState: defaultState), tester); - await tester.tap(find.byKey(new Key('CalendarItem'))); - await tester.pump(); - expect(find.byType(MonthPicker), findsOneWidget); - }); + (WidgetTester tester) async { + await pumpSettingWidget( + new Store(reduce, initialState: defaultState), tester); + await tester.tap(find.byKey(new Key('CalendarItem'))); + await tester.pump(); + // ignore: deprecated_member_use + expect(find.byType(MonthPicker), findsOneWidget); + }); //TimePicker is private testWidgets('WeightEntryDialog opens Dialog on time click', - (WidgetTester tester) async { - await pumpSettingWidget( - new Store(reduce, initialState: defaultState), tester); - await tester.tap(find.byKey(new Key('TimeItem'))); - await tester.pump(); - expect(find.byType(Dialog), findsOneWidget); - }); + (WidgetTester tester) async { + await pumpSettingWidget( + new Store(reduce, initialState: defaultState), tester); + await tester.tap(find.byKey(new Key('TimeItem'))); + await tester.pump(); + expect(find.byType(Dialog), findsOneWidget); + }); testWidgets('WeightEntryDialog opens NumberPickerDialog on weight click', - (WidgetTester tester) async { - await pumpSettingWidget( - new Store(reduce, initialState: defaultState), tester); - await tester.tap(find.text('70.0 kg')); - await tester.pump(); - expect(find.byType(NumberPickerDialog), findsOneWidget); - expect(find.text('70'), findsOneWidget); - expect(find.text('0'), findsOneWidget); - }); + (WidgetTester tester) async { + await pumpSettingWidget( + new Store(reduce, initialState: defaultState), tester); + await tester.tap(find.text('70.0 kg')); + await tester.pump(); + expect(find.byType(NumberPickerDialog), findsOneWidget); + expect(find.text('70'), findsOneWidget); + expect(find.text('0'), findsOneWidget); + }); testWidgets('Clicking Save on edit invokes EditEntryAction with activeEntry', - (WidgetTester tester) async { - WeightEntry entry = new WeightEntry(new DateTime.now(), 70.0, null); - var reducer = (state, action) { - expect(action, matchers.TypeMatcher()); - expect((action as EditEntryAction).weightEntry, entry); - }; - await pumpSettingWidget( - new Store( - reducer, - initialState: defaultState.copyWith( - weightEntryDialogState: dialogState.copyWith( - activeEntry: entry), - ), - ), - tester); - await tester.tap(find.text('SAVE')); - }); + (WidgetTester tester) async { + WeightEntry entry = new WeightEntry(new DateTime.now(), 70.0, null); + var reducer = (state, action) { + expect(action, matchers.TypeMatcher()); + expect((action as EditEntryAction).weightEntry, entry); + }; + await pumpSettingWidget( + new Store( + reducer, + initialState: defaultState.copyWith( + weightEntryDialogState: dialogState.copyWith(activeEntry: entry), + ), + ), + tester); + await tester.tap(find.text('SAVE')); + }); testWidgets('Clicking Save on create invokes AddEntryAction with ActiveEntry', - (WidgetTester tester) async { - WeightEntry entry = new WeightEntry(new DateTime.now(), 70.0, null); - var reducer = (state, action) { - expect(action, matchers.TypeMatcher()); - expect((action as AddEntryAction).weightEntry, entry); - }; - await pumpSettingWidget( - new Store( - reducer, - initialState: defaultState.copyWith( - weightEntryDialogState: dialogAddState.copyWith( - activeEntry: entry), - ), - ), - tester); - await tester.tap(find.text('SAVE')); - }); + (WidgetTester tester) async { + WeightEntry entry = new WeightEntry(new DateTime.now(), 70.0, null); + var reducer = (state, action) { + expect(action, matchers.TypeMatcher()); + expect((action as AddEntryAction).weightEntry, entry); + }; + await pumpSettingWidget( + new Store( + reducer, + initialState: defaultState.copyWith( + weightEntryDialogState: dialogAddState.copyWith(activeEntry: entry), + ), + ), + tester); + await tester.tap(find.text('SAVE')); + }); testWidgets('Clicking Delete invokes RemoveEntryAction with activeEntry', - (WidgetTester tester) async { - WeightEntry entry = new WeightEntry(new DateTime.now(), 70.0, null); - var reducer = (state, action) { - expect(action, matchers.TypeMatcher()); - expect((action as RemoveEntryAction).weightEntry, entry); - }; - await pumpSettingWidget( - new Store( - reducer, - initialState: defaultState.copyWith( - weightEntryDialogState: dialogState.copyWith( - activeEntry: entry), - ), - ), - tester); - await tester.tap(find.text('DELETE')); - }); + (WidgetTester tester) async { + WeightEntry entry = new WeightEntry(new DateTime.now(), 70.0, null); + var reducer = (state, action) { + expect(action, matchers.TypeMatcher()); + expect((action as RemoveEntryAction).weightEntry, entry); + }; + await pumpSettingWidget( + new Store( + reducer, + initialState: defaultState.copyWith( + weightEntryDialogState: dialogState.copyWith(activeEntry: entry), + ), + ), + tester); + await tester.tap(find.text('DELETE')); + }); testWidgets('Changing note updates activeEntry', (WidgetTester tester) async { WeightEntry entry = new WeightEntry(new DateTime.now(), 70.0, null);