wt1.1b exercise description, bug fixing + custom exercise fix
This commit is contained in:
@@ -6,95 +6,104 @@ import 'package:aitrainer_app/model/auth.dart';
|
||||
import 'package:aitrainer_app/model/workout_tree.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/painting.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class MenuPageWidget extends StatelessWidget {
|
||||
int parent;
|
||||
|
||||
MenuPageWidget({this.parent});
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
MenuBloc menuBloc = BlocProvider.of<MenuBloc>(context);
|
||||
|
||||
return CustomScrollView(
|
||||
scrollDirection: Axis.vertical,
|
||||
slivers: <Widget>[
|
||||
buildMenuColumn(parent, context, menuBloc)
|
||||
]
|
||||
);
|
||||
slivers: <Widget>[buildMenuColumn(parent, context, menuBloc)]);
|
||||
}
|
||||
|
||||
SliverList buildMenuColumn(int parent, BuildContext context, MenuBloc menuBloc) {
|
||||
SliverList buildMenuColumn(
|
||||
int parent, BuildContext context, MenuBloc menuBloc) {
|
||||
final List<Widget> _columnChildren = List();
|
||||
|
||||
menuBloc.menuTreeRepository.getBranch(menuBloc.parent).forEach((treeName, value) {
|
||||
menuBloc.menuTreeRepository
|
||||
.getBranch(menuBloc.parent)
|
||||
.forEach((treeName, value) {
|
||||
WorkoutTree workoutTree = value as WorkoutTree;
|
||||
_columnChildren.add(
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 16.0),
|
||||
child: Center(
|
||||
child: Stack(
|
||||
alignment: Alignment.bottomLeft,
|
||||
overflow: Overflow.visible,
|
||||
children: [
|
||||
FlatButton(
|
||||
child: _getButtonImage(workoutTree),
|
||||
padding: EdgeInsets.all(0.0),
|
||||
onPressed:() =>
|
||||
{
|
||||
print("Hi!, Menu clicked " + workoutTree.id.toString()),
|
||||
if ( workoutTree.child == false ) {
|
||||
menuBloc.add(MenuTreeDown(parent: workoutTree.id)),
|
||||
_columnChildren.add(Container(
|
||||
padding: EdgeInsets.only(top: 16.0),
|
||||
child: Center(
|
||||
child: Stack(
|
||||
alignment: Alignment.bottomLeft,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
fit: StackFit.loose,
|
||||
children: [
|
||||
FlatButton(
|
||||
child: _getButtonImage(workoutTree),
|
||||
padding: EdgeInsets.only(left: 0.0, bottom: 0),
|
||||
shape: getShape(workoutTree),
|
||||
onPressed: () => menuClick(workoutTree, menuBloc, context),
|
||||
),
|
||||
InkWell(
|
||||
onTap:() => menuClick(workoutTree, menuBloc, context),
|
||||
child: Text(
|
||||
" " + workoutTree.name,
|
||||
maxLines: 2,
|
||||
style: TextStyle(
|
||||
color: workoutTree.color,
|
||||
fontSize: workoutTree.fontSize,
|
||||
fontFamily: 'Arial',
|
||||
fontWeight: FontWeight.w900),
|
||||
),
|
||||
highlightColor: workoutTree.color,
|
||||
),
|
||||
|
||||
} else {
|
||||
menuBloc.add(MenuClickExercise(exerciseTypeId: workoutTree.id)),
|
||||
if ( Auth().userLoggedIn == null ) {
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
backgroundColor: Colors.orange,
|
||||
content: Text(
|
||||
AppLocalizations.of(context).translate('Please log in'),
|
||||
style: TextStyle(color: Colors.white))
|
||||
))
|
||||
} else {
|
||||
if ( workoutTree.exerciseType.name == "Custom") {
|
||||
Navigator.of(context).pushNamed(
|
||||
'exerciseCustomPage',
|
||||
arguments: workoutTree.exerciseType),
|
||||
} else {
|
||||
Navigator.of(context).pushNamed(
|
||||
'exerciseNewPage',
|
||||
arguments: workoutTree.exerciseType),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
),
|
||||
InkWell(
|
||||
child: Text(workoutTree.name, style: TextStyle(color: workoutTree.color, fontSize: workoutTree.fontSize, fontFamily: 'Arial', fontWeight: FontWeight.w900 ),),
|
||||
highlightColor: workoutTree.color,
|
||||
)]
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
]))));
|
||||
});
|
||||
//_columnChildren.add(Spacer(flex: 3));
|
||||
|
||||
SliverList sliverList =
|
||||
SliverList(
|
||||
delegate: SliverChildListDelegate(
|
||||
_columnChildren
|
||||
)
|
||||
);
|
||||
SliverList(delegate: SliverChildListDelegate(_columnChildren));
|
||||
|
||||
return sliverList;
|
||||
}
|
||||
|
||||
void menuClick(
|
||||
WorkoutTree workoutTree, MenuBloc menuBloc, BuildContext context) {
|
||||
print("Hi!, Menu clicked " + workoutTree.id.toString());
|
||||
if (workoutTree.child == false) {
|
||||
menuBloc.add(MenuTreeDown(parent: workoutTree.id));
|
||||
} else {
|
||||
menuBloc.add(MenuClickExercise(exerciseTypeId: workoutTree.id));
|
||||
if (Auth().userLoggedIn == null) {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
backgroundColor: Colors.orange,
|
||||
content: Text(
|
||||
AppLocalizations.of(context).translate('Please log in'),
|
||||
style: TextStyle(color: Colors.white))));
|
||||
} else {
|
||||
if (workoutTree.exerciseType.name == "Custom") {
|
||||
Navigator.of(context).pushNamed('exerciseCustomPage',
|
||||
arguments: workoutTree.exerciseType);
|
||||
} else {
|
||||
Navigator.of(context).pushNamed('exerciseNewPage',
|
||||
arguments: workoutTree.exerciseType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dynamic getShape(WorkoutTree workoutTree) {
|
||||
bool base = workoutTree.base;
|
||||
dynamic returnCode = (base == true)
|
||||
? RoundedRectangleBorder(
|
||||
side: BorderSide(width: 4, color: Colors.orangeAccent),
|
||||
)
|
||||
: null;
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
dynamic _getButtonImage(WorkoutTree workoutTree) {
|
||||
dynamic image;
|
||||
/*String url = workoutTree.imageName;
|
||||
@@ -112,17 +121,18 @@ class MenuPageWidget extends StatelessWidget {
|
||||
image = Image.asset(
|
||||
workoutTree.imageName,
|
||||
height: 180,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
String url = Auth.mediaUrl + 'images/' + workoutTree.imageName.substring(11);
|
||||
Widget image = FadeInImage.assetNetwork(
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
String url =
|
||||
Auth.mediaUrl + 'images/' + workoutTree.imageName.substring(11);
|
||||
Widget image = FadeInImage.assetNetwork(
|
||||
placeholder: 'asset/image/dots.gif',
|
||||
image: url,
|
||||
height: 180,
|
||||
);
|
||||
return image;
|
||||
return image;
|
||||
},
|
||||
);
|
||||
} on Exception catch(_) {
|
||||
} on Exception catch (_) {
|
||||
String url = Auth.mediaUrl + '/images/' + workoutTree.imageName;
|
||||
image = FadeInImage.assetNetwork(
|
||||
placeholder: 'asset/image/dots.gif',
|
||||
@@ -133,4 +143,4 @@ class MenuPageWidget extends StatelessWidget {
|
||||
|
||||
return image;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user