workouttest_app/lib/view/mydevelopment_page.dart
2020-10-21 21:24:43 +02:00

150 lines
5.6 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(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(
textAlignment: Alignment.topCenter,
text: t("My Exercise Logs"),
style: TextStyle(fontSize: 14, color: Colors.orange, fontWeight: FontWeight.bold, backgroundColor: Colors.black54.withOpacity(0.4)),
image: "asset/image/edzesnaplom400400.jpg",
top: 150,
left: 10,
onTap:() => this.callBackExerciseLog(exerciseRepository, customerRepository),
isLocked: false,
),
ImageButton(
textAlignment: Alignment.topLeft,
text: t("My Whole Body Development"),
style: TextStyle(fontSize: 14, color: Colors.orange, fontWeight: FontWeight.bold,
backgroundColor: Colors.black54.withOpacity(0.4)),
image: "asset/image/testemfejl400x400.jpg",
top: 150,
left: 10,
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: 14, color: Colors.orange, fontWeight: FontWeight.bold,
backgroundColor: Colors.black54.withOpacity(0.4)),
image: "asset/image/izomcsop400400.jpg",
top: 120,
left: 10,
onTap:() => {
Navigator.of(context).pushNamed('mydevelopmentMusclePage',
arguments: args)
},
isLocked: true,
),
ImageButton(
textAlignment: Alignment.topLeft,
text: t("Predictions"),
style: TextStyle(fontSize: 14, color: Colors.orange, fontWeight: FontWeight.bold,
backgroundColor: Colors.black54.withOpacity(0.4)),
image: "asset/menu/2.2.1.1RM.png",
top: 150,
onTap:() => {
},
isLocked: true,
),
hiddenWidget(customerRepository, exerciseRepository),
]
),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
mainAxisSpacing: 15.0,
crossAxisSpacing: 15.0,
childAspectRatio: 1.0,
),
)
]
)
),
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);
}
}