WT 1.1.0+35 design1

This commit is contained in:
Bossanyi Tibor
2020-12-02 16:32:54 +01:00
parent d7a1ede794
commit f5f4ade9d5
7 changed files with 104 additions and 42 deletions
+5 -1
View File
@@ -29,7 +29,11 @@ class DB {
});
}
Future<void> closeDb() async => this._db.close();
Future<void> closeDb() async {
if ( _db != null ) {
this._db.close();
}
}
Database getDB() => this._db;
}
+2 -2
View File
@@ -66,7 +66,7 @@ class WorkoutTreeRepository {
treeName,
assetImage,
Colors.white,
20,
30,
false,
0,
null,
@@ -87,7 +87,7 @@ class WorkoutTreeRepository {
bool is1RM = this.isParent1RM(exerciseType.treeId);
exerciseType.is1RM = is1RM;
this.tree[exerciseType.name] = WorkoutMenuTree(exerciseType.exerciseTypeId, exerciseType.treeId, exerciseTypeName, assetImage,
Colors.white, 16, true, exerciseType.exerciseTypeId, exerciseType, exerciseType.base, is1RM, exerciseType.name);
Colors.white, 24, true, exerciseType.exerciseTypeId, exerciseType, exerciseType.base, is1RM, exerciseType.name);
});
Cache().setWorkoutMenuTree(tree);
+45 -29
View File
@@ -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),
);
}
}