wt1.1.2b exercise_log with the new tree_view

This commit is contained in:
Bossanyi Tibor 2020-09-28 07:09:37 +02:00
parent 89c06123d2
commit 7da1ef534c
10 changed files with 174 additions and 158 deletions

View File

@ -169,5 +169,6 @@
"Select the muscle type and tap on the exercise. One the next page enter the weight and repeat.": "Select the muscle type and tap on the exercise. One the next page enter the weight and repeat.",
"Custom Exercise Plan": "Custom Exercise Plan",
"Select manually the exercises what you would like to have in your plan. At the end don't forget to save.": "Select manually the exercises what you would like to have in your plan. At the end don't forget to save."
"Select manually the exercises what you would like to have in your plan. At the end don't forget to save.": "Select manually the exercises what you would like to have in your plan. At the end don't forget to save.",
"In this list you will find all your executed exercises grouped by the date.": "In this list you will find all your executed exercises grouped by the date."
}

View File

@ -168,6 +168,6 @@
"Execute your active Exercise Plan!": "Hajtsd végre az aktív edzéstervedet",
"Select the muscle type and tap on the exercise. One the next page enter the weight and repeat.": "Válaszd ki az izomcsoporton belül a gyakorlatot, és a következő oldalon add meg a súlyt és az ismétlés számot.",
"Custom Exercise Plan": "Egyedi edzésterv",
"Select manually the exercises what you would like to have in your plan. At the end don't forget to save.": "Válaszd ki a gyakorlatokat, amelyeket szeretnél végrehajtani a tervedben. Utána ne felejtsd el elmenteni."
"Select manually the exercises what you would like to have in your plan. At the end don't forget to save.": "Válaszd ki a gyakorlatokat, amelyeket szeretnél végrehajtani a tervedben. Utána ne felejtsd el elmenteni.",
"In this list you will find all your executed exercises grouped by the date.": "Ebben a listában találod az eddig végrehajtott gyakorlataid dátum szerint csoportosítva."
}

View File

@ -1,6 +1,5 @@
import 'dart:async';
import 'package:aitrainer_app/repository/customer_repository.dart';
import 'package:aitrainer_app/repository/exercise_repository.dart';
import 'package:aitrainer_app/repository/workout_tree_repository.dart';
import 'package:aitrainer_app/util/session.dart';
import 'package:aitrainer_app/view/account.dart';

View File

@ -197,4 +197,8 @@ class ExerciseRepository {
return actualExerciseType;
}
void sortByDate() {
exerciseList.sort( (b, a) => a.dateAdd.compareTo(b.dateAdd) );
}
}

View File

@ -104,7 +104,7 @@ class Session {
await ExerciseTreeApi().getExerciseTree();
if ( customerId > 0) {
ExerciseRepository exerciseRepository = ExerciseRepository();
exerciseRepository.getExercisesByCustomer(customerId);
await exerciseRepository.getExercisesByCustomer(customerId);
}
print("--- Session finished");

View File

@ -1,21 +1,23 @@
import 'dart:collection';
import 'package:intl/intl.dart';
import 'package:aitrainer_app/localization/app_language.dart';
import 'package:aitrainer_app/model/cache.dart';
import 'package:aitrainer_app/model/exercise.dart';
import 'package:aitrainer_app/model/exercise_type.dart';
import 'package:aitrainer_app/repository/exercise_repository.dart';
import 'package:aitrainer_app/treeview/tree_view.dart';
import 'package:aitrainer_app/util/common.dart';
import 'package:aitrainer_app/util/trans.dart';
import 'package:aitrainer_app/widgets/app_bar_common.dart';
import 'package:flutter/material.dart';
import 'package:flutter_treeview/tree_view.dart';
import 'package:aitrainer_app/widgets/exercise_type_widget.dart';
class ExerciseLogPage extends StatefulWidget {
@override
_ExerciseLogPage createState() => _ExerciseLogPage();
}
class _ExerciseLogPage extends State<ExerciseLogPage> with Trans {
class _ExerciseLogPage extends State<ExerciseLogPage> with Trans, Common {
@override
Widget build(BuildContext context) {
LinkedHashMap arguments = ModalRoute.of(context).settings.arguments;
@ -41,106 +43,138 @@ class _ExerciseLogPage extends State<ExerciseLogPage> with Trans {
}
Widget exerciseWidget(ExerciseRepository exerciseRepository, int customerId) {
TreeViewController _treeViewController =
TreeViewController(children: nodeExercises(exerciseRepository, customerId));
TreeViewTheme _treeViewTheme = TreeViewTheme(
expanderTheme: ExpanderThemeData(
type: ExpanderType.caret,
modifier: ExpanderModifier.none,
position: ExpanderPosition.start,
color: Colors.red.shade800,
size: 20,
),
labelStyle: TextStyle(
fontSize: 12,
letterSpacing: 0.1,
),
parentLabelStyle: TextStyle(
fontSize: 16,
letterSpacing: 0.1,
fontWeight: FontWeight.w800,
color: Colors.orange.shade600,
),
iconTheme: IconThemeData(
size: 18,
color: Colors.grey.shade800,
),
colorScheme: ColorScheme.light(background: Colors.transparent),
);
return TreeView(
controller: _treeViewController,
allowParentSelect: false,
supportParentDoubleTap: false,
//onExpansionChanged: _expandNodeHandler,
onNodeTap: (key) {
setState(() {
_treeViewController = _treeViewController.copyWith(selectedKey: key);
});
},
theme: _treeViewTheme,
startExpanded: false,
children: _getTreeChildren(exerciseRepository, customerId),
);
}
List<Node> nodeExercises(ExerciseRepository exerciseRepository, int customerId) {
List<Node> nodes = List<Node>();
List<Exercise> exercises;
List<Widget> _getTreeChildren(ExerciseRepository exerciseRepository, int customerId) {
if ( customerId == Cache().userLoggedIn.customerId ) {
exercises = exerciseRepository.getExerciseList();
exerciseRepository.exerciseList = exerciseRepository.getExerciseList();
} else if ( Cache().getTrainee() != null && customerId == Cache().getTrainee().customerId ) {
exercises = exerciseRepository.getExerciseListTrainee();
exerciseRepository.exerciseList = exerciseRepository.getExerciseListTrainee();
}
exerciseRepository.sortByDate();
List<Widget> listWidget = List();
String prevDay = "";
Node actualNode;
List<Node> listExercisesPerDay;
exercises.forEach((element) {
Exercise exercise = element;
ExerciseType exerciseType =
exerciseRepository.getExerciseTypeById(exercise.exerciseTypeId);
String actualDay = exercise.dateAdd.year.toString() +
"-" +
exercise.dateAdd.month.toString() +
"-" +
exercise.dateAdd.day.toString();
Card explanation = Card(
color: Colors.white60,
child: Container(
padding: EdgeInsets.only(left: 10, right: 5, top: 12, bottom: 8),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Row(
children: [
Icon(
Icons.info,
color: Colors.orangeAccent,
),
Text(" "),
Text(
t("My Exercise Logs"),
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
),
],
),
Divider(
color: Colors.transparent,
),
Text(
t("In this list you will find all your executed exercises grouped by the date."),
style: TextStyle(fontSize: 12, fontWeight: FontWeight.normal),
),
if (prevDay.compareTo(actualDay) != 0) {
listExercisesPerDay = List<Node>();
actualNode = Node(
label: actualDay,
key: exercise.dateAdd.toString(),
expanded: true,
children: listExercisesPerDay,
icon:
NodeIcon(codePoint: Icons.date_range.codePoint, color: "blue"));
nodes.add(actualNode);
prevDay = actualDay;
],
)
)
);
listWidget.add(explanation);
List<Exercise> listExercises = List();
String origDate = "";
print("start exercises");
exerciseRepository.exerciseList.forEach((exercise) {
String exerciseDate = DateFormat("yyyy-MM-dd", AppLanguage().appLocal.toString()).format(exercise.dateAdd);
if ( origDate != exerciseDate) {
if ( origDate.length == 0) {
listExercises.add(exercise);
origDate = exerciseDate;
} else {
listWidget.add(
Container(
margin: const EdgeInsets.only(left: 4.0),
child: TreeViewChild(
startExpanded: true,
parent: ExerciseTypeWidget(exerciseTypeName: exerciseDate),
children: _getChildList(listExercises, exerciseRepository),
)
)
);
listExercises = List();
}
}
origDate = exerciseDate;
listExercises.add(exercise);
String exerciseName = AppLanguage().appLocal == Locale("en")
? exerciseType.name
: exerciseType.nameTranslation;
String unitQuantity = exerciseType.unitQuantity == "1"
? exercise.unitQuantity.toStringAsFixed(0) +
" " +
t(exerciseType.unitQuantityUnit) +
" "
: "";
String labelExercise = exerciseName +
" " +
unitQuantity +
exercise.quantity.toStringAsFixed(0) +
" " +
t(exercise.unit);
listExercisesPerDay.add(Node(
label: labelExercise,
key: exercise.exerciseId.toString(),
expanded: false,
icon: NodeIcon(codePoint: Icons.repeat.codePoint, color: "blue")));
});
return nodes;
return listWidget;
}
List<Widget> _getChildList(List<Exercise> listExercises, ExerciseRepository exerciseRepository) {
List<Widget> list = List();
bool isEnglish = AppLanguage().appLocal == Locale('en');
listExercises.forEach((exercise) {
ExerciseType exerciseType = exerciseRepository.getExerciseTypeById(exercise.exerciseTypeId);
String exerciseName = isEnglish ? exerciseType.name : exerciseType.nameTranslation;
String unitQuantity = exerciseType.unitQuantity == "1"
? exercise.unitQuantity.toStringAsFixed(0) +
" " +
t(exerciseType.unitQuantityUnit) +
" "
: "";
String labelExercise =
unitQuantity +
exercise.quantity.toStringAsFixed(0) +
" " +
t(exercise.unit);
list.add(
Card(
margin: EdgeInsets.only(left: 10, top: 5),
color: Colors.white54,
child: Container(
padding: const EdgeInsets.only(left: 5, top: 0, right: 5, bottom: 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Icon(Icons.accessibility, color: Colors.black12),
SizedBox(width: 20),
Flexible(
child:
Text(
exerciseName,
textAlign: TextAlign.start,
style: TextStyle(fontSize: 12, color: Colors.black),
),
),
SizedBox(width: 20),
Text(labelExercise , style: TextStyle(fontSize: 9, color: Colors.blueAccent.shade700),) ,
]),
)
),
);
});
return list;
}
}

View File

@ -33,7 +33,7 @@ class _AppBarNav extends State<AppBarNav> with SingleTickerProviderStateMixin {
void initState() {
colorController =
AnimationController(duration: Duration(seconds: 4), vsync: this);
AnimationController(duration: Duration(seconds: 4), vsync:this);
//sizeController =
// AnimationController(duration: Duration(seconds: 3), vsync: this);

View File

@ -25,7 +25,7 @@ class _AppBarCommonNav extends State<AppBarCommonNav> with SingleTickerProvider
void initState() {
colorController =
AnimationController(duration: Duration(seconds: 4), vsync: this);
AnimationController(duration: Duration(seconds: 4),vsync: this);
colorAnim = RainbowColorTween([Colors.white70,
Colors.blueGrey,

View File

@ -35,7 +35,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.2"
version: "2.5.0-nullsafety"
bloc:
dependency: transitive
description:
@ -56,7 +56,7 @@ packages:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.0-nullsafety"
build:
dependency: transitive
description:
@ -91,14 +91,14 @@ packages:
name: build_runner
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0"
version: "1.10.2"
build_runner_core:
dependency: transitive
description:
name: build_runner_core
url: "https://pub.dartlang.org"
source: hosted
version: "5.2.0"
version: "6.0.1"
built_collection:
dependency: transitive
description:
@ -119,14 +119,14 @@ packages:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
version: "1.1.0-nullsafety.2"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.3"
version: "1.2.0-nullsafety"
checked_yaml:
dependency: transitive
description:
@ -147,7 +147,7 @@ packages:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
version: "1.1.0-nullsafety"
code_builder:
dependency: transitive
description:
@ -161,7 +161,7 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.13"
version: "1.15.0-nullsafety.2"
convert:
dependency: transitive
description:
@ -224,7 +224,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.0-nullsafety"
ffi:
dependency: transitive
description:
@ -238,7 +238,7 @@ packages:
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "5.2.1"
version: "6.0.0-nullsafety.1"
fixnum:
dependency: transitive
description:
@ -298,20 +298,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.8.0"
flutter_local_notifications:
dependency: "direct main"
description:
name: flutter_local_notifications
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.1"
flutter_local_notifications_platform_interface:
dependency: transitive
description:
name: flutter_local_notifications_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
flutter_localizations:
dependency: "direct main"
description: flutter
@ -322,13 +308,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_treeview:
dependency: "direct main"
description:
name: flutter_treeview
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.0+1"
flutter_web_plugins:
dependency: transitive
description: flutter
@ -436,7 +415,7 @@ packages:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.2"
version: "0.6.3-nullsafety.1"
json_annotation:
dependency: transitive
description:
@ -464,14 +443,14 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.8"
version: "0.12.10-nullsafety"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.8"
version: "1.3.0-nullsafety.2"
mime:
dependency: transitive
description:
@ -527,7 +506,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0-nullsafety"
path_drawing:
dependency: transitive
description:
@ -569,28 +548,28 @@ packages:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.0"
version: "1.10.0-nullsafety.1"
percent_indicator:
dependency: "direct main"
description:
name: percent_indicator
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.7+3"
version: "2.1.7+4"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.4"
version: "3.1.0"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.1"
version: "3.0.0-nullsafety.1"
plugin_platform_interface:
dependency: transitive
description:
@ -604,14 +583,14 @@ packages:
name: pool
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.0"
version: "1.5.0-nullsafety.1"
process:
dependency: transitive
description:
name: process
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.13"
version: "4.0.0-nullsafety.1"
provider:
dependency: transitive
description:
@ -756,21 +735,21 @@ packages:
name: source_map_stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.0-nullsafety.2"
source_maps:
dependency: transitive
description:
name: source_maps
url: "https://pub.dartlang.org"
source: hosted
version: "0.10.9"
version: "0.10.10-nullsafety.1"
source_span:
dependency: transitive
description:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0-nullsafety"
spider_chart:
dependency: "direct main"
description:
@ -784,14 +763,14 @@ packages:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.5"
version: "1.10.0-nullsafety"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.0-nullsafety"
stream_transform:
dependency: transitive
description:
@ -805,7 +784,7 @@ packages:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
version: "1.1.0-nullsafety"
sync_http:
dependency: transitive
description:
@ -819,28 +798,28 @@ packages:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.2.0-nullsafety"
test:
dependency: "direct dev"
description:
name: test
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.2"
version: "1.16.0-nullsafety.4"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.17"
version: "0.2.19-nullsafety"
test_core:
dependency: transitive
description:
name: test_core
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.10"
version: "0.3.12-nullsafety.4"
timing:
dependency: transitive
description:
@ -854,7 +833,7 @@ packages:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.0-nullsafety.2"
usage:
dependency: transitive
description:
@ -875,14 +854,14 @@ packages:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
version: "2.1.0-nullsafety.2"
vm_service:
dependency: transitive
description:
name: vm_service
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.0"
version: "5.2.0"
vm_service_client:
dependency: transitive
description:
@ -931,7 +910,7 @@ packages:
name: xdg_directories
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0"
version: "0.1.2"
xml:
dependency: transitive
description:
@ -947,5 +926,5 @@ packages:
source: hosted
version: "2.2.1"
sdks:
dart: ">=2.9.0-14.0.dev <3.0.0"
dart: ">=2.10.0-4.0.dev <2.10.0"
flutter: ">=1.16.0 <2.0.0"

View File

@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.1.0+22
environment:
sdk: ">=2.7.0 <3.0.0"
sdk: ">=2.7.0 <3.1.0"
dependencies:
flutter:
@ -30,7 +30,7 @@ dependencies:
devicelocale: ^0.3.2
sentry: ^3.0.1
# firebase_messaging: ^6.0.16
flutter_local_notifications: 1.1.1
#flutter_local_notifications: ^1.5.0-beta.9
flutter_facebook_login: ^3.0.0
flutter_bloc: ^6.0.5
equatable: ^1.2.5
@ -38,9 +38,8 @@ dependencies:
flutter_form_bloc: ^0.19.0
spider_chart: ^0.1.5
rainbow_color: ^0.1.1
percent_indicator: ^2.1.7+3
percent_indicator: ^2.1.7+4
gradient_bottom_navigation_bar: ^1.0.0+4
flutter_treeview: ^0.6.0+1
fl_chart: ^0.11.1
mockito: ^4.1.1