223 lines
9.6 KiB
Dart
223 lines
9.6 KiB
Dart
import 'dart:collection';
|
|
import 'package:aitrainer_app/model/cache.dart';
|
|
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
|
import 'package:aitrainer_app/service/logging.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/image_button.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
|
|
class MyExercisePlanPage extends StatefulWidget {
|
|
@override
|
|
_MyExercisePlanPage createState() => _MyExercisePlanPage();
|
|
}
|
|
|
|
class _MyExercisePlanPage extends State<MyExercisePlanPage> with Trans, Logging {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final ExerciseRepository exerciseRepository = ExerciseRepository();
|
|
final LinkedHashMap args = LinkedHashMap();
|
|
setContext(context);
|
|
|
|
double mediaWidth = MediaQuery.of(context).size.width;
|
|
double imageWidth = (mediaWidth - 45) / 2;
|
|
|
|
return Scaffold(
|
|
appBar: AppBarNav(depth: 0),
|
|
body: Container(
|
|
padding: EdgeInsets.all(10),
|
|
decoration: BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage('asset/image/WT_menu_dark.png'),
|
|
fit: BoxFit.cover,
|
|
alignment: Alignment.center,
|
|
),
|
|
),
|
|
child: CustomScrollView(scrollDirection: Axis.vertical, slivers: [
|
|
SliverGrid(
|
|
delegate: SliverChildListDelegate([
|
|
ImageButton(
|
|
width: imageWidth,
|
|
textAlignment: Alignment.topLeft,
|
|
text: t("Execute My Selected Training Plan"),
|
|
style: GoogleFonts.robotoMono(
|
|
textStyle: TextStyle(
|
|
fontSize: 14,
|
|
color: Colors.orange,
|
|
fontWeight: FontWeight.bold,
|
|
backgroundColor: Colors.black54.withOpacity(0.4))),
|
|
image: "asset/image/exercise_plan_execute.jpg",
|
|
top: 130,
|
|
left: 5,
|
|
onTap: () => {
|
|
args['customerId'] = Cache().userLoggedIn.customerId,
|
|
Navigator.of(context).pushNamed('exerciseExecutePlanPage', arguments: args)
|
|
},
|
|
isLocked: false,
|
|
),
|
|
ImageButton(
|
|
width: imageWidth,
|
|
textAlignment: Alignment.topLeft,
|
|
text: t("Edit My Custom Plan"),
|
|
style: GoogleFonts.robotoMono(
|
|
textStyle: TextStyle(
|
|
fontSize: 14,
|
|
color: Colors.orange,
|
|
fontWeight: FontWeight.bold,
|
|
backgroundColor: Colors.black54.withOpacity(0.4))),
|
|
image: "asset/image/exercise_plan_custom.jpg",
|
|
left: 5,
|
|
onTap: () => {
|
|
args['exerciseRepository'] = exerciseRepository,
|
|
args['customerId'] = Cache().userLoggedIn.customerId,
|
|
Navigator.of(context).pushNamed('exercisePlanCustomPage', arguments: args)
|
|
},
|
|
isLocked: false,
|
|
),
|
|
ImageButton(
|
|
width: imageWidth,
|
|
textAlignment: Alignment.topLeft,
|
|
text: t("Suggested Training Plan"),
|
|
style: GoogleFonts.robotoMono(
|
|
textStyle: TextStyle(
|
|
fontSize: 14,
|
|
color: Colors.orange,
|
|
fontWeight: FontWeight.bold,
|
|
backgroundColor: Colors.black54.withOpacity(0.4))),
|
|
image: "asset/image/exercise_plan_suggested.jpg",
|
|
left: 5,
|
|
onTap: () => {
|
|
showDialog(
|
|
context: context,
|
|
builder: (BuildContext context) {
|
|
return DialogPremium(
|
|
title: "Go Premium",
|
|
descriptions: "Unleash your potential with WorkoutTest Premium!",
|
|
description2: "The Suggested Training Plan is reachable if you finished the first 100% test-circles",
|
|
text: "OK",
|
|
onTap: () => {Navigator.of(context).pop()},
|
|
onCancel: () => {Navigator.of(context).pop()},
|
|
);
|
|
})
|
|
},
|
|
isLocked: true,
|
|
),
|
|
ImageButton(
|
|
width: imageWidth,
|
|
textAlignment: Alignment.topLeft,
|
|
text: t("My Special Plan"),
|
|
style: GoogleFonts.robotoMono(
|
|
textStyle: TextStyle(
|
|
fontSize: 14,
|
|
color: Colors.orange,
|
|
fontWeight: FontWeight.bold,
|
|
backgroundColor: Colors.black54.withOpacity(0.4))),
|
|
image: "asset/image/exercise_plan_special.jpg",
|
|
left: 5,
|
|
onTap: () => {
|
|
showDialog(
|
|
context: context,
|
|
builder: (BuildContext context) {
|
|
return DialogPremium(
|
|
title: "Go Premium",
|
|
descriptions: "Unleash your potential with WorkoutTest Premium!",
|
|
description2: "The Special Plan is reachable if you finished the first 100% test-circles",
|
|
text: "OK",
|
|
onTap: () => {Navigator.of(context).pop()},
|
|
onCancel: () => {Navigator.of(context).pop()},
|
|
);
|
|
})
|
|
},
|
|
isLocked: true,
|
|
),
|
|
ImageButton(
|
|
width: imageWidth,
|
|
textAlignment: Alignment.topLeft,
|
|
text: t("Star's Exercise Plan"),
|
|
style: GoogleFonts.robotoMono(
|
|
textStyle: TextStyle(
|
|
fontSize: 14,
|
|
color: Colors.orange,
|
|
fontWeight: FontWeight.bold,
|
|
backgroundColor: Colors.black54.withOpacity(0.4))),
|
|
image: "asset/image/exercise_plan_stars.jpg",
|
|
left: 5,
|
|
onTap: () => {
|
|
showDialog(
|
|
context: context,
|
|
builder: (BuildContext context) {
|
|
return DialogPremium(
|
|
title: "Go Premium",
|
|
descriptions: "Unleash your potential with WorkoutTest Premium!",
|
|
description2: "The Star's Exericise Plan is reachable if you finished the second 100% test-circles",
|
|
text: "OK",
|
|
onTap: () => {Navigator.of(context).pop()},
|
|
onCancel: () => {Navigator.of(context).pop()},
|
|
);
|
|
})
|
|
},
|
|
isLocked: true,
|
|
),
|
|
hiddenPlanWidget(exerciseRepository),
|
|
hiddenTrainingWidget(),
|
|
]),
|
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
crossAxisCount: 2,
|
|
mainAxisSpacing: 15.0,
|
|
crossAxisSpacing: 15.0,
|
|
childAspectRatio: 1.0,
|
|
),
|
|
)
|
|
])),
|
|
bottomNavigationBar: BottomNavigator(bottomNavIndex: 2));
|
|
}
|
|
|
|
Widget hiddenPlanWidget(ExerciseRepository exerciseRepository) {
|
|
final LinkedHashMap args = LinkedHashMap();
|
|
if (Cache().getTrainee() != null) {
|
|
return FlatButton(
|
|
padding: EdgeInsets.all(20),
|
|
textColor: Colors.white,
|
|
color: Colors.black12,
|
|
focusColor: Colors.blueAccent,
|
|
onPressed: () => {
|
|
args['exerciseRepository'] = exerciseRepository,
|
|
args['customerId'] = Cache().getTrainee().customerId,
|
|
Navigator.of(context).pushNamed('exercisePlanCustomPage', arguments: args)
|
|
},
|
|
child: Text(
|
|
t("My Trainee's Plan"),
|
|
style: TextStyle(fontSize: 18),
|
|
));
|
|
} else {
|
|
return Container();
|
|
}
|
|
}
|
|
|
|
Widget hiddenTrainingWidget() {
|
|
final LinkedHashMap args = LinkedHashMap();
|
|
if (Cache().getTrainee() != null) {
|
|
log("!!Trainee: " + Cache().getTrainee().firstname + " " + Cache().getTrainee().name);
|
|
return FlatButton(
|
|
padding: EdgeInsets.all(20),
|
|
textColor: Colors.white,
|
|
color: Colors.black12,
|
|
focusColor: Colors.blueAccent,
|
|
onPressed: () => {
|
|
args['customerId'] = Cache().getTrainee().customerId,
|
|
Navigator.of(context).pushNamed('exerciseExecutePlanPage', arguments: args)
|
|
},
|
|
child: Text(
|
|
t("Execute My Trainee's Training Plan"),
|
|
style: TextStyle(fontSize: 18),
|
|
));
|
|
} else {
|
|
return Container();
|
|
}
|
|
}
|
|
}
|