workouttest_app/lib/view/mydevelopment_page.dart
2020-12-30 21:50:11 +01:00

161 lines
6.8 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/widgets/dialog_premium.dart';
import 'package:google_fonts/google_fonts.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);
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.topCenter,
text: t("My Exercise Logs"),
style: GoogleFonts.robotoMono(
textStyle: TextStyle(
fontSize: 14,
color: Colors.white,
fontWeight: FontWeight.bold,
backgroundColor: Colors.black54.withOpacity(0.4))),
image: "asset/image/edzesnaplom400400.jpg",
left: 5,
onTap: () => this.callBackExerciseLog(exerciseRepository, customerRepository),
isLocked: false,
),
ImageButton(
width: imageWidth,
textAlignment: Alignment.topLeft,
text: t("My Whole Body Development"),
style: GoogleFonts.robotoMono(
textStyle: TextStyle(
fontSize: 14, color: Colors.white, fontWeight: FontWeight.bold, backgroundColor: Colors.black54.withOpacity(0.4)),
),
image: "asset/image/testemfejl400x400.jpg",
left: 5,
onTap: () => {
args['customerId'] = Cache().userLoggedIn.customerId,
Navigator.of(context).pushNamed('mydevelopmentBodyPage', arguments: args)
},
isLocked: true,
),
ImageButton(
width: imageWidth,
textAlignment: Alignment.topLeft,
text: t("Development Of Muscles"),
style: GoogleFonts.robotoMono(
textStyle: TextStyle(
fontSize: 14,
color: Colors.white,
fontWeight: FontWeight.bold,
backgroundColor: Colors.black54.withOpacity(0.4))),
image: "asset/image/izomcsop400400.jpg",
left: 5,
onTap: () => {Navigator.of(context).pushNamed('mydevelopmentMusclePage', arguments: args)},
isLocked: true,
),
ImageButton(
width: imageWidth,
left: 5,
textAlignment: Alignment.topLeft,
text: t("Predictions"),
style: GoogleFonts.robotoMono(
textStyle: TextStyle(
fontSize: 14,
color: Colors.white,
fontWeight: FontWeight.bold,
backgroundColor: Colors.black54.withOpacity(0.4))),
image: "asset/image/predictions.jpg",
onTap: () => {
showDialog(
context: context,
builder: (BuildContext context) {
return DialogPremium(
unlocked: false,
unlockRound: 2,
function: "Predictions",
unlockedText: "",
onTap: () => {Navigator.of(context).pop()},
);
})
},
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);
}
}