workouttest_app/lib/view/myexcercise_plan_page.dart
2020-10-21 15:08:15 +02:00

185 lines
6.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/util/trans.dart';
import 'package:aitrainer_app/widgets/app_bar.dart';
import 'package:aitrainer_app/widgets/bottom_nav.dart';
import 'package:aitrainer_app/widgets/image_button.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class MyExercisePlanPage extends StatefulWidget {
@override
_MyExercisePlanPage createState() => _MyExercisePlanPage();
}
class _MyExercisePlanPage extends State<MyExercisePlanPage> with Trans {
@override
Widget build(BuildContext context) {
final ExerciseRepository exerciseRepository = ExerciseRepository();
final LinkedHashMap args = LinkedHashMap();
setContext(context);
return Scaffold(
appBar: AppBarNav(depth: 0),
body: Container(
padding: EdgeInsets.all(20),
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(
textAlignment: Alignment.topLeft,
text: t("Execute My Selected Training Plan"),
style: TextStyle(fontSize: 14, color: Colors.orange, fontWeight: FontWeight.bold,
backgroundColor: Colors.black54.withOpacity(0.4)),
image: "asset/image/exercise_plan_execute.jpg",
top: 150,
left: 15,
onTap:() => {
args['customerId'] = Cache().userLoggedIn.customerId,
Navigator.of(context).pushNamed('exerciseExecutePlanPage',
arguments: args)
},
isLocked: false,
),
ImageButton(
textAlignment: Alignment.topLeft,
text: t("Edit My Custom Plan"),
style: TextStyle(fontSize: 14, color: Colors.orange, fontWeight: FontWeight.bold,
backgroundColor: Colors.black54.withOpacity(0.4)),
image: "asset/image/exercise_plan_custom.jpg",
top: 150,
left: 15,
onTap:() => {
args['exerciseRepository'] = exerciseRepository,
args['customerId'] = Cache().userLoggedIn.customerId,
Navigator.of(context).pushNamed('exercisePlanCustomPage',
arguments: args)
},
isLocked: false,
),
ImageButton(
textAlignment: Alignment.topLeft,
text: t("Suggested Training Plan"),
style: TextStyle(fontSize: 14, color: Colors.orange, fontWeight: FontWeight.bold,
backgroundColor: Colors.black54.withOpacity(0.4)),
image: "asset/image/exercise_plan_suggested.jpg",
top: 150,
left: 10,
onTap:() => {
},
isLocked: true,
),
ImageButton(
textAlignment: Alignment.topLeft,
text: t("My Special Plan"),
style: TextStyle(fontSize: 16, color: Colors.orange, fontWeight: FontWeight.bold,
backgroundColor: Colors.black54.withOpacity(0.4)),
image: "asset/image/exercise_plan_special.jpg",
top: 150,
left: 10,
onTap:() => {
},
isLocked: true,
),
ImageButton(
textAlignment: Alignment.topLeft,
text: t("My Arnold's Plan"),
style: TextStyle(fontSize: 14, color: Colors.orange, fontWeight: FontWeight.bold,
backgroundColor: Colors.black54.withOpacity(0.4)),
image: "asset/image/exercise_plan_stars.jpg",
top: 120,
left: 10,
onTap:() => {
},
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 ) {
print ("!!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();
}
}
}