WT 1.1.25+2 training log search

This commit is contained in:
bossanyit
2021-11-28 12:08:03 +01:00
parent 4d22d98ae0
commit 72ae1c8f8c
10 changed files with 344 additions and 90 deletions
+26
View File
@@ -219,6 +219,32 @@ class _CustomerGoalPage extends State<CustomerGoalPage> with Trans {
SizedBox(
height: h,
), */
InkWell(
child: Text(
t('Login'),
style: GoogleFonts.inter(
decoration: TextDecoration.underline,
color: Colors.white,
fontWeight: FontWeight.w500,
shadows: <Shadow>[
Shadow(
offset: Offset(3.0, 3.0),
blurRadius: 6.0,
color: Colors.black54,
),
Shadow(
offset: Offset(-3.0, 3.0),
blurRadius: 6.0,
color: Colors.black54,
),
],
),
),
onTap: () => Navigator.of(context).pushNamed('login'),
),
SizedBox(
height: 30,
)
],
),
));
+2
View File
@@ -669,6 +669,8 @@ class EvaluationPage extends StatelessWidget with Trans {
exerciseElement = t("2nd Control") + ": ";
} else if (index == 3) {
exerciseElement = t("3rd Control") + ": ";
} else {
exerciseElement = "$index. " + t("exercise") + ": ";
}
index++;
resultList.add(RichText(
+222 -75
View File
@@ -1,10 +1,21 @@
import 'dart:collection';
import 'package:aitrainer_app/bloc/menu/menu_bloc.dart';
import 'package:flutter/cupertino.dart';
import 'package:intl/intl.dart';
import 'package:aitrainer_app/bloc/training_log/training_log_bloc.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/model/training_result.dart';
import 'package:aitrainer_app/repository/exercise_repository.dart';
import 'package:aitrainer_app/util/app_language.dart';
import 'package:aitrainer_app/util/common.dart';
import 'package:aitrainer_app/util/trans.dart';
import 'package:aitrainer_app/widgets/app_bar.dart';
import 'package:aitrainer_app/widgets/bottom_nav.dart';
import 'package:aitrainer_app/widgets/dialog_premium.dart';
import 'package:aitrainer_app/widgets/menu_search_bar.dart';
import 'package:badges/badges.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:google_fonts/google_fonts.dart';
@@ -27,9 +38,9 @@ class MyDevelopmentLog extends StatelessWidget with Trans, Common {
SnackBar(backgroundColor: Colors.orange, content: Text(state.message, style: TextStyle(color: Colors.white))));
}
}, builder: (context, state) {
final exerciseBloc = BlocProvider.of<TrainingLogBloc>(context);
final bloc = BlocProvider.of<TrainingLogBloc>(context);
return ModalProgressHUD(
child: getTrainingLog(exerciseBloc),
child: getTrainingLog(bloc),
inAsyncCall: state is TrainingLogLoading,
opacity: 0.5,
color: Colors.black54,
@@ -54,7 +65,7 @@ class MyDevelopmentLog extends StatelessWidget with Trans, Common {
child: Container(
padding: EdgeInsets.only(left: 10, right: 10),
child: Column(children: [
getHeader(),
getHeader(bloc),
getCalendar(bloc),
]),
)),
@@ -62,10 +73,16 @@ class MyDevelopmentLog extends StatelessWidget with Trans, Common {
);
}
Widget getSearchBar() {
Widget getSearchBar(TrainingLogBloc bloc) {
final MenuBloc menuBloc = BlocProvider.of<MenuBloc>(context);
return MenuSearchBar(
listItems: [],
onFind: (value) {},
listItems: menuBloc.menuTreeRepository.menuAsExercise,
onFind: (value) {
print("Found exercise $value");
if (value != null) {
bloc.add(TrainingLogSearch(exerciseTypeId: value.exerciseTypeId));
}
},
);
}
@@ -74,13 +91,12 @@ class MyDevelopmentLog extends StatelessWidget with Trans, Common {
child: SfCalendarTheme(
data: SfCalendarThemeData(brightness: Brightness.dark, backgroundColor: Colors.transparent),
child: SfCalendar(
dataSource: TrainingDataSource(bloc.getTrainingResults()),
view: CalendarView.month,
dataSource: TrainingDataSource(bloc.results),
allowedViews: [
CalendarView.day,
CalendarView.week,
CalendarView.month,
CalendarView.day,
],
view: CalendarView.month,
monthViewSettings: MonthViewSettings(
showAgenda: true,
appointmentDisplayMode: MonthAppointmentDisplayMode.appointment,
@@ -91,87 +107,218 @@ class MyDevelopmentLog extends StatelessWidget with Trans, Common {
firstDayOfWeek: 1, // Monday
selectionDecoration: BoxDecoration(
color: Colors.transparent,
border: Border.all(color: Colors.red, width: 2),
border: Border.all(color: Color(0xffb4f500), width: 2),
borderRadius: const BorderRadius.all(Radius.circular(4)),
shape: BoxShape.rectangle,
),
todayHighlightColor: Color(0xffb4f500),
showNavigationArrow: true,
showDatePickerButton: true,
showDatePickerButton: false,
allowViewNavigation: true,
onTap: (detail) => {
print("${detail.appointments}"),
},
appointmentBuilder: (BuildContext context, CalendarAppointmentDetails details) {
final TrainingResult result = details.appointments.first;
return Container(
padding: EdgeInsets.only(left: 8, top: 5, right: 5, bottom: 5),
height: 70,
color: result.isTest ? Colors.blue : Colors.orange,
child: Row(mainAxisAlignment: MainAxisAlignment.start, children: [
Flexible(
fit: FlexFit.tight,
flex: 30,
child: Text(result.eventName, style: GoogleFonts.inter(fontSize: 14, color: Colors.white, fontWeight: FontWeight.bold)),
),
Flexible(
fit: FlexFit.tight,
flex: 25,
child: Text(
result.summary == null ? "" : result.summary!,
style: TextStyle(fontSize: 12, color: Colors.white),
)),
IconButton(
padding: EdgeInsets.zero,
icon: Icon(Icons.info_outline, color: Color(0xffb4f500)),
onPressed: () {},
),
IconButton(
padding: EdgeInsets.zero,
icon: Icon(Icons.delete, color: Colors.black12),
onPressed: () {},
)
]));
return ClipRRect(
borderRadius: BorderRadius.circular(6.0),
child: Badge(
elevation: 0,
padding: EdgeInsets.all(0),
position: BadgePosition.topEnd(top: -15, end: -17),
animationDuration: Duration(milliseconds: 1500),
animationType: BadgeAnimationType.fade,
badgeColor: Colors.transparent,
showBadge: true,
badgeContent: result.isExercise
? IconButton(
padding: EdgeInsets.zero,
iconSize: 20,
icon: Icon(Icons.delete, color: Colors.black26),
onPressed: () => deleteConfirmation(bloc, result.exercise!),
)
: Offstage(),
child: Container(
padding: EdgeInsets.only(left: 8, top: 5, right: 5, bottom: 5),
width: details.bounds.width,
height: details.bounds.height * 1.5,
color: result.background,
child: Row(mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: [
Flexible(
fit: FlexFit.tight,
flex: 30,
child: Text(result.eventName,
style: GoogleFonts.inter(
fontSize: result.isExercise ? 14 : 16, color: Colors.white, fontWeight: FontWeight.bold)),
),
Visibility(
visible: result.isExercise,
child: Flexible(
fit: FlexFit.tight,
flex: 25,
child: Text(
result.summary == null ? "" : result.summary!,
style: TextStyle(fontSize: 12, color: Colors.white),
))),
IconButton(
padding: EdgeInsets.zero,
icon: Icon(Icons.info_outline, color: Color(0xffb4f500)),
onPressed: () => result.isExercise ? evaluation(bloc.exerciseRepository, result.exercise!) : trainingEvaluation(),
),
/* */
])),
));
}),
));
}
Widget getHeader() {
void deleteConfirmation(TrainingLogBloc bloc, Exercise exercise) {
ExerciseType? exerciseType = bloc.exerciseRepository.getExerciseTypeById(exercise.exerciseTypeId!);
String exerciseName = AppLanguage().appLocal == Locale("en") ? exerciseType!.name : exerciseType!.nameTranslation;
String strDate = AppLanguage().appLocal == Locale("en")
? "on the " + DateFormat(DateFormat.YEAR_MONTH_DAY, AppLanguage().appLocal.toString()).format(exercise.dateAdd!.toUtc())
: DateFormat(DateFormat.YEAR_MONTH_DAY, AppLanguage().appLocal.toString()).format(exercise.dateAdd!.toUtc()) + "-n";
final String unitQuantity = exercise.unitQuantity == null ? "" : "x" + exercise.unitQuantity!.toStringAsFixed(0);
showCupertinoDialog(
useRootNavigator: true,
context: context,
//barrierDismissible: false,
builder: (_) => CupertinoAlertDialog(
title: Text(t("Are you sure to delete this exercise?")),
content: Column(children: [
Divider(),
Text(
t("Exercise") + ": " + exerciseName,
style: (TextStyle(color: Colors.blue)),
),
Text(
exercise.quantity!.toStringAsFixed(0) + unitQuantity + " ",
style: (TextStyle(color: Colors.deepOrange)),
),
Text(
strDate,
style: (TextStyle(color: Colors.deepOrange)),
),
]),
actions: [
TextButton(
child: Text(t("No")),
onPressed: () => Navigator.pop(context),
),
TextButton(
child: Text(t("Yes")),
onPressed: () {
Navigator.pop(context);
if (!Cache().hasPurchased) {
showDialog(
context: context,
builder: (BuildContext context) {
return DialogPremium(
unlocked: Cache().hasPurchased,
unlockRound: 1,
unlockedText: t("Enjoy also this premium fetaure to delete mistyped old exercises."),
function: "Delete Exercise",
onTap: () => {Navigator.of(context).pop()},
onCancel: () => {Navigator.of(context).pop()},
);
});
} else {
bloc.add(TrainingLogDelete(exercise: exercise));
}
},
)
],
));
}
void trainingEvaluation() {}
void evaluation(ExerciseRepository exerciseRepository, Exercise exercise) {
if (Cache().userLoggedIn != null) {
if (!Cache().hasPurchased) {
showDialog(
context: context,
builder: (BuildContext context) {
return DialogPremium(
unlocked: Cache().hasPurchased,
unlockRound: 1,
unlockedText: t("Enjoy also this premium feature to show all old evaluation data of your successful exercises."),
function: "My Exercise Logs",
onTap: () => {Navigator.of(context).pop()},
onCancel: () => {Navigator.of(context).pop()},
);
});
} else {
LinkedHashMap args = LinkedHashMap();
args['exerciseRepository'] = exerciseRepository;
args['exercise'] = exercise;
args['past'] = true;
Navigator.of(context).pushNamed('evaluationPage', arguments: args);
}
}
}
Widget getHeader(TrainingLogBloc bloc) {
return Card(
color: Colors.white60,
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('asset/image/WT_plainblack_background.jpg'),
fit: BoxFit.cover,
alignment: Alignment.center,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('asset/image/WT_plainblack_background.jpg'),
fit: BoxFit.cover,
alignment: Alignment.center,
),
),
),
padding: EdgeInsets.only(left: 10, right: 5, top: 12, bottom: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Icon(
Icons.info,
color: Colors.orangeAccent,
padding: EdgeInsets.only(left: 10, right: 5, top: 12, bottom: 8),
child: Column(children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Icon(
Icons.info,
color: Colors.orangeAccent,
),
Text(" "),
Text(
t("My Exercise Logs"),
style: GoogleFonts.inter(
fontSize: 16,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
Divider(),
Flexible(
fit: FlexFit.tight,
flex: 5,
child: getSearchBar(bloc),
)
],
),
Text(" "),
Text(
t("My Exercise Logs"),
style: GoogleFonts.inter(
fontSize: 16,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
Divider(),
Flexible(
fit: FlexFit.tight,
flex: 5,
child: getSearchBar(),
)
],
),
));
bloc.search
? RichText(
text: TextSpan(
style: GoogleFonts.inter(
fontSize: 14,
fontWeight: FontWeight.normal,
color: Colors.white,
),
children: [
TextSpan(text: t("The found exercises are")),
TextSpan(text: " "),
TextSpan(
text: t("in red"),
style: GoogleFonts.inter(
fontSize: 14,
fontWeight: FontWeight.normal,
color: Colors.redAccent,
),
),
TextSpan(text: " "),
TextSpan(text: t("in your calendar")),
]),
)
: Offstage()
])));
}
}