232 lines
9.0 KiB
Dart
232 lines
9.0 KiB
Dart
import 'dart:collection';
|
|
|
|
import 'package:aitrainer_app/model/cache.dart';
|
|
import 'package:aitrainer_app/repository/customer_repository.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 MyDevelopmentPage extends StatefulWidget {
|
|
@override
|
|
_MyDevelopmentPage createState() => _MyDevelopmentPage();
|
|
}
|
|
|
|
class _MyDevelopmentPage extends State<MyDevelopmentPage> with Trans {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final ExerciseRepository exerciseRepository = ExerciseRepository();
|
|
final CustomerRepository customerRepository = CustomerRepository();
|
|
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_light_background.png'),
|
|
fit: BoxFit.cover,
|
|
alignment: Alignment.center,
|
|
),
|
|
),
|
|
child: CustomScrollView(
|
|
scrollDirection: Axis.vertical,
|
|
slivers:
|
|
[
|
|
SliverGrid(
|
|
delegate: SliverChildListDelegate(
|
|
[
|
|
ImageButton(
|
|
textAlignment: Alignment.topCenter,
|
|
text: t("My Exercise Logs"),
|
|
style: TextStyle(fontSize: 20, color: Colors.orange, fontWeight: FontWeight.bold, backgroundColor: Colors.black54.withOpacity(0.4)),
|
|
image: "asset/image/exercise_log.jpg",
|
|
top: 40,
|
|
onTap:() => this.callBackExerciseLog(exerciseRepository, customerRepository),
|
|
isLocked: false,
|
|
),
|
|
/*FlatButton(
|
|
padding: EdgeInsets.all(0),
|
|
textColor: Colors.white,
|
|
color: Colors.black12,
|
|
focusColor: Colors.blueAccent,
|
|
onPressed: () =>
|
|
{
|
|
args['exerciseRepository'] = exerciseRepository,
|
|
args['customerRepository'] = customerRepository,
|
|
args['customerId'] = Cache().userLoggedIn.customerId,
|
|
Navigator.of(context).pushNamed('exerciseLogPage',
|
|
arguments: args)
|
|
},
|
|
child: Text(t("My Exercise Logs"),
|
|
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: () =>
|
|
{
|
|
args['customerId'] = Cache().userLoggedIn.customerId,
|
|
Navigator.of(context).pushNamed('mydevelopmentBodyPage',
|
|
arguments: args)
|
|
},
|
|
child: Text(t("My Whole Body Development"),
|
|
style: TextStyle(fontSize: 18),)
|
|
),
|
|
|
|
],
|
|
),*/
|
|
ImageButton(
|
|
textAlignment: Alignment.topLeft,
|
|
text: t("My Whole Body Development"),
|
|
style: TextStyle(fontSize: 20, color: Colors.orange, fontWeight: FontWeight.bold,
|
|
backgroundColor: Colors.black54.withOpacity(0.4)),
|
|
image: "asset/menu/3.1.BMI.png",
|
|
top: 50,
|
|
onTap:() => {
|
|
args['customerId'] = Cache().userLoggedIn.customerId,
|
|
Navigator.of(context).pushNamed('mydevelopmentBodyPage',
|
|
arguments: args)
|
|
},
|
|
isLocked: true,
|
|
),
|
|
ImageButton(
|
|
textAlignment: Alignment.topLeft,
|
|
text: t("Development Of Muscles"),
|
|
style: TextStyle(fontSize: 20, color: Colors.orange, fontWeight: FontWeight.bold,
|
|
backgroundColor: Colors.black54.withOpacity(0.4)),
|
|
image: "asset/image/development_muscles.jpg",
|
|
top: 50,
|
|
onTap:() => {
|
|
Navigator.of(context).pushNamed('mydevelopmentMusclePage',
|
|
arguments: args)
|
|
},
|
|
isLocked: true,
|
|
),
|
|
/*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: () =>
|
|
{
|
|
Navigator.of(context).pushNamed('mydevelopmentMusclePage',
|
|
arguments: args)
|
|
},
|
|
child: Text(t("Development Of Muscles"),
|
|
style: TextStyle(fontSize: 18),)
|
|
),
|
|
|
|
]
|
|
),*/
|
|
ImageButton(
|
|
textAlignment: Alignment.topLeft,
|
|
text: t("Predictions"),
|
|
style: TextStyle(fontSize: 20, color: Colors.orange, fontWeight: FontWeight.bold,
|
|
backgroundColor: Colors.black54.withOpacity(0.4)),
|
|
image: "asset/menu/2.2.1.1RM.png",
|
|
top: 50,
|
|
onTap:() => {
|
|
|
|
},
|
|
isLocked: true,
|
|
),
|
|
/*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(t("Predictions"),
|
|
style: TextStyle(fontSize: 18),)
|
|
),
|
|
]
|
|
),*/
|
|
hiddenWidget(customerRepository, exerciseRepository),
|
|
]
|
|
),
|
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
crossAxisCount: 2,
|
|
mainAxisSpacing: 20.0,
|
|
crossAxisSpacing: 20.0,
|
|
childAspectRatio: 1.2,
|
|
),
|
|
)
|
|
]
|
|
)
|
|
),
|
|
bottomNavigationBar: BottomNavigator(bottomNavIndex: 1));
|
|
}
|
|
|
|
Widget hiddenWidget(CustomerRepository customerRepository, 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['customerRepository'] = customerRepository,
|
|
args['customerId'] = Cache().getTrainee().customerId,
|
|
Navigator.of(context).pushNamed('exerciseLogPage',
|
|
arguments: args)
|
|
},
|
|
child: Text(t("My Trainee's Exercise Logs"),
|
|
style: TextStyle(fontSize: 18),)
|
|
);
|
|
} else {
|
|
return Container();
|
|
}
|
|
}
|
|
|
|
void callBackExerciseLog(ExerciseRepository exerciseRepository, CustomerRepository customerRepository) {
|
|
final LinkedHashMap args = LinkedHashMap();
|
|
args['exerciseRepository'] = exerciseRepository;
|
|
args['customerRepository'] = customerRepository;
|
|
args['customerId'] = Cache().userLoggedIn.customerId;
|
|
Navigator.of(context).pushNamed('exerciseLogPage',
|
|
arguments: args);
|
|
}
|
|
|
|
}
|
|
|
|
|