WT 1.1.0+35 design1
This commit is contained in:
parent
d7a1ede794
commit
f5f4ade9d5
@ -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;
|
Database getDB() => this._db;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ class WorkoutTreeRepository {
|
|||||||
treeName,
|
treeName,
|
||||||
assetImage,
|
assetImage,
|
||||||
Colors.white,
|
Colors.white,
|
||||||
20,
|
30,
|
||||||
false,
|
false,
|
||||||
0,
|
0,
|
||||||
null,
|
null,
|
||||||
@ -87,7 +87,7 @@ class WorkoutTreeRepository {
|
|||||||
bool is1RM = this.isParent1RM(exerciseType.treeId);
|
bool is1RM = this.isParent1RM(exerciseType.treeId);
|
||||||
exerciseType.is1RM = is1RM;
|
exerciseType.is1RM = is1RM;
|
||||||
this.tree[exerciseType.name] = WorkoutMenuTree(exerciseType.exerciseTypeId, exerciseType.treeId, exerciseTypeName, assetImage,
|
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);
|
Cache().setWorkoutMenuTree(tree);
|
||||||
|
@ -24,11 +24,14 @@ class MenuPageWidget extends StatelessWidget with Trans {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
MenuBloc menuBloc = BlocProvider.of<MenuBloc>(context);
|
MenuBloc menuBloc = BlocProvider.of<MenuBloc>(context);
|
||||||
setContext(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();
|
final List<Widget> _columnChildren = List();
|
||||||
|
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
@ -54,27 +57,28 @@ class MenuPageWidget extends StatelessWidget with Trans {
|
|||||||
menuBloc.menuTreeRepository.getBranch(menuBloc.parent).forEach((treeName, value) {
|
menuBloc.menuTreeRepository.getBranch(menuBloc.parent).forEach((treeName, value) {
|
||||||
WorkoutMenuTree workoutTree = value as WorkoutMenuTree;
|
WorkoutMenuTree workoutTree = value as WorkoutMenuTree;
|
||||||
_columnChildren.add(Container(
|
_columnChildren.add(Container(
|
||||||
padding: EdgeInsets.only(top: 16.0),
|
padding: EdgeInsets.only(top: 15.0),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Stack(alignment: Alignment.bottomLeft,
|
child: Stack(alignment: Alignment.bottomLeft,
|
||||||
//clipBehavior: Clip.antiAliasWithSaveLayer,
|
//clipBehavior: Clip.antiAliasWithSaveLayer,
|
||||||
children: [
|
children: [
|
||||||
FlatButton(
|
FlatButton(
|
||||||
child: badgedIcon(workoutTree),
|
child: badgedIcon(workoutTree, cWidth, cHeight),
|
||||||
padding: EdgeInsets.only(left: 0.0, bottom: 0),
|
padding: EdgeInsets.only(left: 0.0, bottom: 0),
|
||||||
shape: getShape(workoutTree),
|
shape: getShape(workoutTree),
|
||||||
onPressed: () => menuClick(workoutTree, menuBloc, context),
|
onPressed: () => menuClick(workoutTree, menuBloc, context),
|
||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
top: workoutTree.name.length > 20 ? 130 : 145,
|
top: workoutTree.name.length > 15 ?
|
||||||
left: 5,
|
workoutTree.fontSize > 25 ? 130 : 140 :
|
||||||
|
workoutTree.fontSize > 25 ? 165 : 175,
|
||||||
|
left: 8,
|
||||||
child: Container(
|
child: Container(
|
||||||
height: 300,
|
height: cWidth * .95,
|
||||||
width: 280,
|
width: 280,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () => menuClick(workoutTree, menuBloc, context),
|
onTap: () => menuClick(workoutTree, menuBloc, context),
|
||||||
child: Text(
|
child: Text(workoutTree.name,
|
||||||
" " + workoutTree.name,
|
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
style: GoogleFonts.archivoBlack(
|
style: GoogleFonts.archivoBlack(
|
||||||
color: workoutTree.color,
|
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;
|
return sliverList;
|
||||||
}
|
}
|
||||||
@ -103,7 +114,8 @@ class MenuPageWidget extends StatelessWidget with Trans {
|
|||||||
if (Cache().userLoggedIn == null) {
|
if (Cache().userLoggedIn == null) {
|
||||||
Scaffold.of(context).showSnackBar(SnackBar(
|
Scaffold.of(context).showSnackBar(SnackBar(
|
||||||
backgroundColor: Colors.orange,
|
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 {
|
} else {
|
||||||
if (workoutTree.exerciseType.name == "Custom" && Cache().userLoggedIn.admin == 1) {
|
if (workoutTree.exerciseType.name == "Custom" && Cache().userLoggedIn.admin == 1) {
|
||||||
Navigator.of(context).pushNamed('exerciseCustomPage', arguments: workoutTree.exerciseType);
|
Navigator.of(context).pushNamed('exerciseCustomPage', arguments: workoutTree.exerciseType);
|
||||||
@ -119,27 +131,31 @@ class MenuPageWidget extends StatelessWidget with Trans {
|
|||||||
dynamic returnCode = (base == true)
|
dynamic returnCode = (base == true)
|
||||||
? RoundedRectangleBorder(
|
? RoundedRectangleBorder(
|
||||||
side: BorderSide(width: 4, color: Colors.orangeAccent),
|
side: BorderSide(width: 4, color: Colors.orangeAccent),
|
||||||
)
|
borderRadius: BorderRadius.all(Radius.circular(12.0)))
|
||||||
: null;
|
: RoundedRectangleBorder(
|
||||||
|
side: BorderSide(width: 1, color: Colors.transparent),
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(8.0)));
|
||||||
return returnCode;
|
return returnCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
dynamic _getButtonImage(WorkoutMenuTree workoutTree) {
|
dynamic _getButtonImage(WorkoutMenuTree workoutTree, double cWidth, double cHeight) {
|
||||||
dynamic image;
|
dynamic image;
|
||||||
try {
|
try {
|
||||||
image = Image.asset(
|
image = ClipRRect(
|
||||||
workoutTree.imageName,
|
borderRadius: BorderRadius.circular(12.0),
|
||||||
height: 180,
|
child: Image.asset(
|
||||||
errorBuilder: (context, error, stackTrace) {
|
workoutTree.imageName,
|
||||||
String url = Cache.mediaUrl + 'images/' + workoutTree.imageName.substring(11);
|
height: cHeight * 0.85,
|
||||||
Widget image = FadeInImage.assetNetwork(
|
errorBuilder: (context, error, stackTrace) {
|
||||||
placeholder: 'asset/image/dots.gif',
|
String url = Cache.mediaUrl + 'images/' + workoutTree.imageName.substring(11);
|
||||||
image: url,
|
Widget image = FadeInImage.assetNetwork(
|
||||||
height: 180,
|
placeholder: 'asset/image/dots.gif',
|
||||||
);
|
image: url,
|
||||||
return image;
|
height: 180,
|
||||||
},
|
);
|
||||||
);
|
return image;
|
||||||
|
},
|
||||||
|
));
|
||||||
} on Exception catch (_) {
|
} on Exception catch (_) {
|
||||||
String url = Cache.mediaUrl + '/images/' + workoutTree.imageName;
|
String url = Cache.mediaUrl + '/images/' + workoutTree.imageName;
|
||||||
image = FadeInImage.assetNetwork(
|
image = FadeInImage.assetNetwork(
|
||||||
@ -152,7 +168,7 @@ class MenuPageWidget extends StatelessWidget with Trans {
|
|||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget badgedIcon(WorkoutMenuTree workoutMenuTree) {
|
Widget badgedIcon(WorkoutMenuTree workoutMenuTree, double cWidth, double cHeight) {
|
||||||
String badgeKey = workoutMenuTree.nameEnglish;
|
String badgeKey = workoutMenuTree.nameEnglish;
|
||||||
bool show = Cache().getBadges()[badgeKey] != null;
|
bool show = Cache().getBadges()[badgeKey] != null;
|
||||||
int counter = Cache().getBadges()[badgeKey] != null ? Cache().getBadges()[badgeKey] : 0;
|
int counter = Cache().getBadges()[badgeKey] != null ? Cache().getBadges()[badgeKey] : 0;
|
||||||
@ -168,7 +184,7 @@ class MenuPageWidget extends StatelessWidget with Trans {
|
|||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
)),
|
)),
|
||||||
child: _getButtonImage(workoutMenuTree),
|
child: _getButtonImage(workoutMenuTree, cWidth, cHeight),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
16
pubspec.lock
16
pubspec.lock
@ -259,7 +259,7 @@ packages:
|
|||||||
name: firebase_auth
|
name: firebase_auth
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.18.3"
|
version: "0.18.3+1"
|
||||||
firebase_auth_platform_interface:
|
firebase_auth_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -273,28 +273,28 @@ packages:
|
|||||||
name: firebase_auth_web
|
name: firebase_auth_web
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.3.2"
|
version: "0.3.2+1"
|
||||||
firebase_core:
|
firebase_core:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: firebase_core
|
name: firebase_core
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.5.2"
|
version: "0.5.2+1"
|
||||||
firebase_core_platform_interface:
|
firebase_core_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: firebase_core_platform_interface
|
name: firebase_core_platform_interface
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "2.1.0"
|
||||||
firebase_core_web:
|
firebase_core_web:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: firebase_core_web
|
name: firebase_core_web
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.2.1"
|
version: "0.2.1+1"
|
||||||
firebase_messaging:
|
firebase_messaging:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -389,7 +389,7 @@ packages:
|
|||||||
name: freezed
|
name: freezed
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.2"
|
version: "0.12.3"
|
||||||
freezed_annotation:
|
freezed_annotation:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -436,7 +436,7 @@ packages:
|
|||||||
name: http
|
name: http
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.1"
|
version: "0.12.2"
|
||||||
http_multi_server:
|
http_multi_server:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -555,7 +555,7 @@ packages:
|
|||||||
name: node_interop
|
name: node_interop
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
version: "1.2.1"
|
||||||
node_io:
|
node_io:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -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.
|
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
||||||
# Read more about iOS versioning at
|
# Read more about iOS versioning at
|
||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
version: 1.1.2+34
|
version: 1.1.2+35
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.10.0 <3.0.0"
|
sdk: ">=2.10.0 <3.0.0"
|
||||||
|
42
test/widget_test.db.dart
Normal file
42
test/widget_test.db.dart
Normal 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}
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
@ -69,7 +69,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
tearDown(() {
|
tearDown(() {
|
||||||
loginBloc.close();
|
//loginBloc.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Display login page', (WidgetTester tester) async {
|
testWidgets('Display login page', (WidgetTester tester) async {
|
||||||
|
Loading…
Reference in New Issue
Block a user