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

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;
}

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);

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),
);
}
}

View File

@ -259,7 +259,7 @@ packages:
name: firebase_auth
url: "https://pub.dartlang.org"
source: hosted
version: "0.18.3"
version: "0.18.3+1"
firebase_auth_platform_interface:
dependency: transitive
description:
@ -273,28 +273,28 @@ packages:
name: firebase_auth_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.2"
version: "0.3.2+1"
firebase_core:
dependency: "direct main"
description:
name: firebase_core
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.2"
version: "0.5.2+1"
firebase_core_platform_interface:
dependency: transitive
description:
name: firebase_core_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.0"
firebase_core_web:
dependency: transitive
description:
name: firebase_core_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.1"
version: "0.2.1+1"
firebase_messaging:
dependency: "direct main"
description:
@ -389,7 +389,7 @@ packages:
name: freezed
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.2"
version: "0.12.3"
freezed_annotation:
dependency: transitive
description:
@ -436,7 +436,7 @@ packages:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.1"
version: "0.12.2"
http_multi_server:
dependency: transitive
description:
@ -555,7 +555,7 @@ packages:
name: node_interop
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.2.1"
node_io:
dependency: transitive
description:

View File

@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.1.2+34
version: 1.1.2+35
environment:
sdk: ">=2.10.0 <3.0.0"

42
test/widget_test.db.dart Normal file
View File

@ -0,0 +1,42 @@
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:aitrainer_app/bloc/login_form_bloc.dart';
import 'package:aitrainer_app/helper/database.dart';
import 'package:aitrainer_app/library_keys.dart';
import 'package:aitrainer_app/localization/app_localization.dart';
import 'package:aitrainer_app/model/user.dart';
import 'package:aitrainer_app/repository/user_repository.dart';
import 'package:aitrainer_app/util/common.dart';
import 'package:aitrainer_app/view/login.dart';
import 'package:bloc_test/bloc_test.dart';
import 'package:flutter/material.dart';
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';
void main() {
group('SQFLite', () {
setUp(() async {
await DB().initDb();
});
tearDown(() async{
await DB().closeDb();
});
testWidgets('Test database table', (WidgetTester tester) async {
var result = await DB().getDB().rawQuery('SELECT * FROM Customer');
expect(result, [
{'col1': 2, 'col2': 2}
]);
});
});
}

View File

@ -69,7 +69,7 @@ void main() {
});
tearDown(() {
loginBloc.close();
//loginBloc.close();
});
testWidgets('Display login page', (WidgetTester tester) async {