workouttest_app/lib/view/myexcercise_plan_page.dart
2020-09-16 15:41:39 +02:00

197 lines
6.7 KiB
Dart

import 'dart:collection';
import 'package:aitrainer_app/model/cache.dart';
import 'package:aitrainer_app/repository/exercise_repository.dart';
import 'package:aitrainer_app/widgets/app_bar_common.dart';
import 'package:aitrainer_app/widgets/bottom_nav.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class MyExercisePlanPage extends StatefulWidget {
@override
_MyExercisePlanPage createState() => _MyExercisePlanPage();
}
class _MyExercisePlanPage extends State<MyExercisePlanPage> {
@override
Widget build(BuildContext context) {
final ExerciseRepository exerciseRepository = ExerciseRepository();
final LinkedHashMap args = LinkedHashMap();
return Scaffold(
appBar: AppBarCommonNav(),
body: Container(
padding: EdgeInsets.all(20),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('asset/image/WT_light_background.png'),
fit: BoxFit.cover,
alignment: Alignment.center,
),
),
child: CustomScrollView(
scrollDirection: Axis.vertical,
slivers:
[
SliverGrid(
delegate: SliverChildListDelegate(
[
FlatButton(
padding: EdgeInsets.all(10),
textColor: Colors.white,
color: Colors.black12,
focusColor: Colors.blueAccent,
onPressed: () =>
{
args['customerId'] = Cache().userLoggedIn.customerId,
Navigator.of(context).pushNamed('exerciseByPlanPage',
arguments: args)
},
child: Text("Execute My Selected Training Plan",
style: TextStyle(fontSize: 18),)
),
FlatButton(
padding: EdgeInsets.all(0),
textColor: Colors.white,
color: Colors.black12,
focusColor: Colors.blueAccent,
onPressed: () =>
{
args['exerciseRepository'] = exerciseRepository,
args['customerId'] = Cache().userLoggedIn.customerId,
Navigator.of(context).pushNamed('exercisePlanCustomPage',
arguments: args)
},
child: Text("Edit My Custom Plan",
style: TextStyle(fontSize: 18),)
),
FlatButton(
padding: EdgeInsets.all(20),
textColor: Colors.white,
color: Colors.black12,
focusColor: Colors.blueAccent,
onPressed: () =>
{
},
child: Text("Suggested Plan",
style: TextStyle(fontSize: 18),)
),
Stack(
fit: StackFit.passthrough,
overflow: Overflow.clip,
alignment: Alignment.topLeft,
children: [
Image.asset('asset/image/lock.png',
height: 40,
width: 40,
),
FlatButton(
padding: EdgeInsets.all(20),
textColor: Colors.white,
color: Colors.black12,
focusColor: Colors.blueAccent,
onPressed: () =>
{
},
child: Text("My Special Plan",
style: TextStyle(fontSize: 18),)
),
],
),
Stack(
fit: StackFit.passthrough,
overflow: Overflow.clip,
children: [
Image.asset('asset/image/lock.png',
height: 40,
width: 40,
),
FlatButton(
padding: EdgeInsets.all(20),
textColor: Colors.white,
color: Colors.black12,
focusColor: Colors.blueAccent,
onPressed: () =>
{
},
child: Text("My Arnold's Plan",
style: TextStyle(fontSize: 18),)
),
]
),
hiddenPlanWidget(exerciseRepository),
hiddenTrainingWidget(),
]
),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
mainAxisSpacing: 20.0,
crossAxisSpacing: 20.0,
childAspectRatio: 1.2,
),
)
]
)
),
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("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('exerciseByPlanPage',
arguments: args)
},
child: Text("Execute My Trainee's Training Plan",
style: TextStyle(fontSize: 18),)
);
} else {
return Container();
}
}
}