WT 1.1.0+35 design1
This commit is contained in:
@@ -24,11 +24,14 @@ class MenuPageWidget extends StatelessWidget with Trans {
|
||||
Widget build(BuildContext context) {
|
||||
MenuBloc menuBloc = BlocProvider.of<MenuBloc>(context);
|
||||
setContext(context);
|
||||
double cWidth = MediaQuery.of(context).size.width;
|
||||
double cHeight = MediaQuery.of(context).size.height;
|
||||
|
||||
return CustomScrollView(scrollDirection: Axis.vertical, slivers: <Widget>[buildMenuColumn(parent, context, menuBloc)]);
|
||||
return CustomScrollView(
|
||||
scrollDirection: Axis.vertical, slivers: <Widget>[buildMenuColumn(parent, context, menuBloc, cWidth, cHeight)]);
|
||||
}
|
||||
|
||||
SliverList buildMenuColumn(int parent, BuildContext context, MenuBloc menuBloc) {
|
||||
SliverGrid buildMenuColumn(int parent, BuildContext context, MenuBloc menuBloc, double cWidth, double cHeight) {
|
||||
final List<Widget> _columnChildren = List();
|
||||
|
||||
if (context != null) {
|
||||
@@ -54,27 +57,28 @@ class MenuPageWidget extends StatelessWidget with Trans {
|
||||
menuBloc.menuTreeRepository.getBranch(menuBloc.parent).forEach((treeName, value) {
|
||||
WorkoutMenuTree workoutTree = value as WorkoutMenuTree;
|
||||
_columnChildren.add(Container(
|
||||
padding: EdgeInsets.only(top: 16.0),
|
||||
padding: EdgeInsets.only(top: 15.0),
|
||||
child: Center(
|
||||
child: Stack(alignment: Alignment.bottomLeft,
|
||||
//clipBehavior: Clip.antiAliasWithSaveLayer,
|
||||
children: [
|
||||
FlatButton(
|
||||
child: badgedIcon(workoutTree),
|
||||
child: badgedIcon(workoutTree, cWidth, cHeight),
|
||||
padding: EdgeInsets.only(left: 0.0, bottom: 0),
|
||||
shape: getShape(workoutTree),
|
||||
onPressed: () => menuClick(workoutTree, menuBloc, context),
|
||||
),
|
||||
Positioned(
|
||||
top: workoutTree.name.length > 20 ? 130 : 145,
|
||||
left: 5,
|
||||
top: workoutTree.name.length > 15 ?
|
||||
workoutTree.fontSize > 25 ? 130 : 140 :
|
||||
workoutTree.fontSize > 25 ? 165 : 175,
|
||||
left: 8,
|
||||
child: Container(
|
||||
height: 300,
|
||||
height: cWidth * .95,
|
||||
width: 280,
|
||||
child: InkWell(
|
||||
onTap: () => menuClick(workoutTree, menuBloc, context),
|
||||
child: Text(
|
||||
" " + workoutTree.name,
|
||||
child: Text(workoutTree.name,
|
||||
maxLines: 2,
|
||||
style: GoogleFonts.archivoBlack(
|
||||
color: workoutTree.color,
|
||||
@@ -89,7 +93,14 @@ class MenuPageWidget extends StatelessWidget with Trans {
|
||||
]))));
|
||||
});
|
||||
|
||||
SliverList sliverList = SliverList(delegate: SliverChildListDelegate(_columnChildren));
|
||||
SliverGrid sliverList = SliverGrid(
|
||||
delegate: SliverChildListDelegate(_columnChildren),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 1,
|
||||
mainAxisSpacing: 8.0,
|
||||
crossAxisSpacing: 10.0,
|
||||
childAspectRatio: cWidth > 375 ? 1.8 : 2.0,
|
||||
));
|
||||
|
||||
return sliverList;
|
||||
}
|
||||
@@ -103,7 +114,8 @@ class MenuPageWidget extends StatelessWidget with Trans {
|
||||
if (Cache().userLoggedIn == null) {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
backgroundColor: Colors.orange,
|
||||
content: Text(AppLocalizations.of(context).translate('Please log in'), style: TextStyle(color: Colors.white))));
|
||||
content:
|
||||
Text(AppLocalizations.of(context).translate('Please log in'), style: TextStyle(color: Colors.white))));
|
||||
} else {
|
||||
if (workoutTree.exerciseType.name == "Custom" && Cache().userLoggedIn.admin == 1) {
|
||||
Navigator.of(context).pushNamed('exerciseCustomPage', arguments: workoutTree.exerciseType);
|
||||
@@ -119,27 +131,31 @@ class MenuPageWidget extends StatelessWidget with Trans {
|
||||
dynamic returnCode = (base == true)
|
||||
? RoundedRectangleBorder(
|
||||
side: BorderSide(width: 4, color: Colors.orangeAccent),
|
||||
)
|
||||
: null;
|
||||
borderRadius: BorderRadius.all(Radius.circular(12.0)))
|
||||
: RoundedRectangleBorder(
|
||||
side: BorderSide(width: 1, color: Colors.transparent),
|
||||
borderRadius: BorderRadius.all(Radius.circular(8.0)));
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
dynamic _getButtonImage(WorkoutMenuTree workoutTree) {
|
||||
dynamic _getButtonImage(WorkoutMenuTree workoutTree, double cWidth, double cHeight) {
|
||||
dynamic image;
|
||||
try {
|
||||
image = Image.asset(
|
||||
workoutTree.imageName,
|
||||
height: 180,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
String url = Cache.mediaUrl + 'images/' + workoutTree.imageName.substring(11);
|
||||
Widget image = FadeInImage.assetNetwork(
|
||||
placeholder: 'asset/image/dots.gif',
|
||||
image: url,
|
||||
height: 180,
|
||||
);
|
||||
return image;
|
||||
},
|
||||
);
|
||||
image = ClipRRect(
|
||||
borderRadius: BorderRadius.circular(12.0),
|
||||
child: Image.asset(
|
||||
workoutTree.imageName,
|
||||
height: cHeight * 0.85,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
String url = Cache.mediaUrl + 'images/' + workoutTree.imageName.substring(11);
|
||||
Widget image = FadeInImage.assetNetwork(
|
||||
placeholder: 'asset/image/dots.gif',
|
||||
image: url,
|
||||
height: 180,
|
||||
);
|
||||
return image;
|
||||
},
|
||||
));
|
||||
} on Exception catch (_) {
|
||||
String url = Cache.mediaUrl + '/images/' + workoutTree.imageName;
|
||||
image = FadeInImage.assetNetwork(
|
||||
@@ -152,7 +168,7 @@ class MenuPageWidget extends StatelessWidget with Trans {
|
||||
return image;
|
||||
}
|
||||
|
||||
Widget badgedIcon(WorkoutMenuTree workoutMenuTree) {
|
||||
Widget badgedIcon(WorkoutMenuTree workoutMenuTree, double cWidth, double cHeight) {
|
||||
String badgeKey = workoutMenuTree.nameEnglish;
|
||||
bool show = Cache().getBadges()[badgeKey] != null;
|
||||
int counter = Cache().getBadges()[badgeKey] != null ? Cache().getBadges()[badgeKey] : 0;
|
||||
@@ -168,7 +184,7 @@ class MenuPageWidget extends StatelessWidget with Trans {
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
)),
|
||||
child: _getButtonImage(workoutMenuTree),
|
||||
child: _getButtonImage(workoutMenuTree, cWidth, cHeight),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user