WT1.1.0+38 Design, time_picker

This commit is contained in:
bossanyit 2020-12-10 14:19:52 +01:00
parent 85ce68a9b8
commit 81f904af2c
13 changed files with 162 additions and 69 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

View File

@ -362,7 +362,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 36;
CURRENT_PROJECT_VERSION = 38;
DEVELOPMENT_TEAM = SFJJBDCU6Z;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
@ -505,7 +505,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 36;
CURRENT_PROJECT_VERSION = 38;
DEVELOPMENT_TEAM = SFJJBDCU6Z;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
@ -540,7 +540,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 36;
CURRENT_PROJECT_VERSION = 38;
DEVELOPMENT_TEAM = SFJJBDCU6Z;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (

View File

@ -51,6 +51,7 @@ class ExerciseNewBloc extends Bloc<ExerciseNewEvent, ExerciseNewState> {
exerciseRepository.setUnit(exerciseType.unit);
exerciseRepository.setQuantity(quantity);
exerciseRepository.setUnitQuantity(unitQuantity);
exerciseRepository.exercise.exercisePlanDetailId = 0;
if (Cache().userLoggedIn != null) {
customerRepository.customer = Cache().userLoggedIn;
weight = customerRepository.customer.getProperty("Weight");

View File

@ -93,9 +93,9 @@ class MenuBloc extends Bloc<MenuEvent, MenuState> with Trans {
//await menuTreeRepository.createTree();
setMenuInfo();
exerciseDeviceRepository.setDevices(Cache().getDevices());
exerciseDeviceRepository.getGymDevices().forEach((element) {
/* exerciseDeviceRepository.getGymDevices().forEach((element) {
listFilterDevice.add(element.exerciseDeviceId);
});
}); */
yield MenuReady();
} else if (event is MenuRecreateTree) {
// ie. at language changes
@ -140,11 +140,10 @@ class MenuBloc extends Bloc<MenuEvent, MenuState> with Trans {
} else if (event is MenuFilterExerciseType) {
yield MenuLoading();
final int deviceId = event.deviceId;
print("Defilter " + deviceId.toString());
if (selectedDevice(deviceId)) {
listFilterDevice.remove(deviceId);
} else {
listFilterDevice.add(deviceId);
} else {
listFilterDevice.remove(deviceId);
}
yield MenuReady();
}
@ -170,14 +169,14 @@ class MenuBloc extends Bloc<MenuEvent, MenuState> with Trans {
}
bool selectedDevice(int deviceId) {
return listFilterDevice.contains(deviceId);
return !listFilterDevice.contains(deviceId);
}
LinkedHashMap<String, WorkoutMenuTree> getFilteredBranch(int parent) {
if (parent == null) return LinkedHashMap();
LinkedHashMap<String, WorkoutMenuTree> branch = menuTreeRepository.getBranch(parent);
if (!menuTreeRepository.isChild(parent) || ability.toString() == ExerciseAbility.none.toString()) {
if (!menuTreeRepository.isChild(parent) || ability.toString() == ExerciseAbility.none.toString() || listFilterDevice.isEmpty) {
return branch;
}
LinkedHashMap<String, WorkoutMenuTree> filtered = LinkedHashMap();

View File

@ -129,6 +129,7 @@ class Cache {
void setServerAddress(SharedPreferences prefs) {
if (this.testEnvironment == "1") {
baseUrl = 'http://aitrainer.app:8899/api/';
return;
}
final bool live = prefs.getBool(Cache.serverKey);
@ -138,6 +139,8 @@ class Cache {
liveServer = live;
if (live) {
baseUrl = 'http://aitrainer.info:8888/api/';
} else {
baseUrl = 'http://aitrainer.app:8899/api/';
}
}

View File

@ -12,6 +12,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
import 'package:aitrainer_app/library/numberpicker.dart';
import 'package:google_fonts/google_fonts.dart';
class ExerciseControlPage extends StatefulWidget {
_ExerciseControlPage createState() => _ExerciseControlPage();
@ -62,7 +63,7 @@ class _ExerciseControlPage extends State<ExerciseControlPage> with Trans {
height: MediaQuery.of(context).size.height,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('asset/image/WT_light_background.png'),
image: AssetImage('asset/image/WT_black_background.png'),
fit: BoxFit.fill,
alignment: Alignment.center,
),
@ -77,19 +78,25 @@ class _ExerciseControlPage extends State<ExerciseControlPage> with Trans {
children: <Widget>[
Text(
exerciseName,
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18, color: Colors.deepOrange),
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18, color: Colors.orange),
overflow: TextOverflow.fade,
maxLines: 1,
softWrap: true,
),
FlatButton(
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Icon(Icons.info),
Icon(
Icons.info,
color: Colors.yellow[300],
),
Flexible(
child: Text(t("Why do you need Exercise Control?"),
style: TextStyle(color: Colors.blueAccent, fontWeight: FontWeight.normal, fontSize: 14)),
style: TextStyle(color: Colors.yellow[300], fontWeight: FontWeight.normal, fontSize: 14)),
),
Icon(
Icons.arrow_forward_ios,
color: Colors.yellow[300],
),
Icon(Icons.arrow_forward_ios),
]),
textColor: Colors.blueAccent,
color: Colors.transparent,
@ -100,15 +107,16 @@ class _ExerciseControlPage extends State<ExerciseControlPage> with Trans {
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
t("Your 1RM:"),
),
Text(t("Your 1RM:"),
style: GoogleFonts.inter(
color: Colors.yellow[300],
)),
Text(
" " +
exerciseBloc.initialRM.toStringAsFixed(0) +
" " +
exerciseBloc.exerciseRepository.exerciseType.unitQuantityUnit,
style: TextStyle(fontWeight: FontWeight.bold),
style: GoogleFonts.inter(color: Colors.yellow[300], fontWeight: FontWeight.bold),
),
],
),
@ -136,18 +144,20 @@ class _ExerciseControlPage extends State<ExerciseControlPage> with Trans {
" " +
strTimes +
" " +
t("times!");
t(
"times!",
);
String title = step.toString() + ". " + t("Control Exercise:");
List<Widget> listWidgets = [
Text(
title,
style: TextStyle(fontWeight: FontWeight.bold),
style: GoogleFonts.inter(color: Colors.yellow[300], fontWeight: FontWeight.bold),
),
Text(
textInstruction,
style: TextStyle(fontSize: 12),
style: GoogleFonts.inter(color: Colors.yellow[300], fontSize: 12),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
@ -160,21 +170,30 @@ class _ExerciseControlPage extends State<ExerciseControlPage> with Trans {
step: 1,
onChanged: (value) => {exerciseBloc.add(ExerciseControlQuantityChange(quantity: value.toDouble(), step: step))},
listViewHeight: 80,
textStyleHighlighted: GoogleFonts.archivoBlack(color: Colors.orange[300], fontSize: 24),
//decoration: _decoration,
),
RaisedButton(
FlatButton(
padding: EdgeInsets.all(0),
textColor: Colors.white,
color: step == exerciseBloc.step ? Colors.blue : Colors.black26,
//color: step == exerciseBloc.step ? Colors.orange : Colors.black26,
focusColor: Colors.blueAccent,
onPressed: () => {
exerciseBloc.add(ExerciseControlSubmit(step: step)),
if (step == 3) {confirmationDialog(exerciseBloc)}
},
child: Text(
t("Save"),
style: TextStyle(fontSize: 12),
)),
child: step == exerciseBloc.step
? Stack(
alignment: Alignment.center,
children: [
Image.asset('asset/icon/gomb_orange_a.png', width: 140, height: 60),
Text(
t("Save"),
style: TextStyle(fontSize: 16, color: Colors.white),
),
],
)
: Container()),
],
),
];

View File

@ -50,8 +50,8 @@ class _ExerciseExecutePage extends State<ExerciseExecutePage> with Trans {
decoration: BoxDecoration(
image: DecorationImage(
image: customerId == Cache().userLoggedIn.customerId
? AssetImage('asset/image/WT_menu_dark.png')
: AssetImage('asset/image/WT_menu_dark.png'),
? AssetImage('asset/image/WT_black_background.png')
: AssetImage('asset/image/WT_light_background.png'),
fit: BoxFit.cover,
alignment: Alignment.center,
),

View File

@ -12,6 +12,7 @@ import 'package:aitrainer_app/widgets/app_bar.dart';
import 'package:aitrainer_app/widgets/bmi_widget.dart';
import 'package:aitrainer_app/widgets/bmr_widget.dart';
import 'package:aitrainer_app/widgets/size_widget.dart';
import 'package:aitrainer_app/widgets/time_picker.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -158,7 +159,7 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans {
child: KeyboardActions(
config: _buildConfig(context),
child: Container(
padding: const EdgeInsets.only(top: 5, left: 75, right: 75),
padding: const EdgeInsets.only(top: 5, left: 55, right: 55),
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(
@ -229,7 +230,7 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans {
),
FlatButton(
onPressed: () => {
confirmationDialog(exerciseBloc),
confirmationDialog(exerciseBloc, menuBloc),
},
child: Stack(
alignment: Alignment.center,
@ -277,6 +278,13 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans {
}
Column columnQuantity(ExerciseNewBloc bloc) {
if (bloc.exerciseRepository.exerciseType.unit == "second") {
return Column(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
TimePickerWidget(
onChange: (value) => {bloc.add(ExerciseNewQuantityChange(quantity: value))},
)
]);
}
Column row = Column(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [
TextFormField(
focusNode: _nodeText2,
@ -303,7 +311,7 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans {
return row;
}
void confirmationDialog(ExerciseNewBloc bloc) {
void confirmationDialog(ExerciseNewBloc bloc, MenuBloc menuBloc) {
LinkedHashMap args = LinkedHashMap();
print("exercise validated " + bloc.exerciseRepository.exercise.quantity.toString());
if (bloc.exerciseRepository.exercise.quantity == null) {
@ -324,7 +332,6 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans {
showCupertinoDialog(
useRootNavigator: true,
context: context,
//barrierDismissible: false,
builder: (_) => CupertinoAlertDialog(
title: Text(t("Do you save this exercise with these parameters?")),
content: Column(children: [
@ -356,14 +363,15 @@ class _ExerciseNewPageState extends State<ExerciseNewPage> with Trans {
bloc.exerciseRepository.addExercise(),
Navigator.pop(context),
Navigator.pop(context),
if (bloc.exerciseRepository.exerciseType.is1RM)
if (bloc.exerciseRepository.exerciseType.is1RM && menuBloc.ability.toString() == ExerciseAbility.oneRepMax.toString())
{
args['exerciseRepository'] = bloc.exerciseRepository,
args['percent'] = 0.75,
args['readonly'] = false,
Navigator.of(context).pushNamed('exerciseControlPage', arguments: args)
}
else if (bloc.exerciseRepository.exerciseType.isEndurance)
else if (bloc.exerciseRepository.exerciseType.isEndurance &&
menuBloc.ability.toString() == ExerciseAbility.endurance.toString())
{
args['exerciseRepository'] = bloc.exerciseRepository,
args['percent'] = 0.50,

View File

@ -52,8 +52,8 @@ class _ExercisePlanCustomPage extends State<ExercisePlanCustomPage> with Trans {
decoration: BoxDecoration(
image: DecorationImage(
image: customerId == Cache().userLoggedIn.customerId
? AssetImage('asset/image/WT_menu_dark.png')
: AssetImage('asset/image/WT_menu_dark.png'),
? AssetImage('asset/image/WT_black_background.png')
: AssetImage('asset/image/WT_light_background.png'),
fit: BoxFit.cover,
alignment: Alignment.center,
),
@ -151,7 +151,7 @@ class _ExercisePlanCustomPage extends State<ExercisePlanCustomPage> with Trans {
icon: element.selected
? Icon(
Icons.check,
color: Colors.green[600],
color: Colors.green[300],
)
: Icon(
Icons.add,
@ -187,14 +187,14 @@ class _ExercisePlanCustomPage extends State<ExercisePlanCustomPage> with Trans {
),
onTap: () => clickAddDetail(bloc, element),
),
IconButton(
/* IconButton(
padding: EdgeInsets.all(0),
icon: Icon(
Icons.info,
color: Colors.black12,
),
onPressed: () {},
),
), */
]),
)),
children: []));

View File

@ -48,7 +48,7 @@ class MenuInfoWidget extends StatelessWidget with Common {
decoration: BoxDecoration(
color: Colors.black.withOpacity(0.5),
border: Border.all(color: Colors.white60),
borderRadius: BorderRadius.all(Radius.circular(10.0)),
borderRadius: BorderRadius.all(Radius.circular(16.0)),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,

View File

@ -45,7 +45,6 @@ class MenuPageWidget extends StatelessWidget with Trans {
}
final List<Widget> _columnChildren = List();
final double distortionHeight = cHeight / baseHeight;
if (menuBloc.getFilteredBranch(menuBloc.parent).isEmpty) {
_columnChildren.add(Container(
@ -57,21 +56,6 @@ class MenuPageWidget extends StatelessWidget with Trans {
} else {
menuBloc.getFilteredBranch(menuBloc.parent).forEach((treeName, value) {
WorkoutMenuTree workoutTree = value;
/* double textLength = workoutTree.name.length * workoutTree.fontSize;
double top = textLength < cWidth - 30
? (cHeight / 3 - 2.5 * workoutTree.fontSize) / distortionHeight
: (cHeight / 3 - 3.6 * workoutTree.fontSize) / distortionHeight;
print(" dH: " +
distortionHeight.toStringAsFixed(1) +
" W: " +
cWidth.toStringAsFixed(0) +
" H: " +
cHeight.toStringAsFixed(0) +
" TOP: " +
top.toStringAsFixed(0) +
" tL: " +
textLength.toStringAsFixed(0)); */
_columnChildren.add(Container(
padding: EdgeInsets.only(top: 15.0, left: 15, right: 15),
height: 225, //cHeight / 3 * distortionHeight,
@ -94,15 +78,14 @@ class MenuPageWidget extends StatelessWidget with Trans {
onPressed: () => menuClick(workoutTree, menuBloc, context),
),
Container(
padding: EdgeInsets.only(left: 15, bottom: 10),
child: InkWell(
padding: EdgeInsets.only(left: 15, bottom: 15, right: 15),
child: GestureDetector(
onTap: () => menuClick(workoutTree, menuBloc, context),
child: Text(
workoutTree.name,
maxLines: 3,
maxLines: 4,
style: GoogleFonts.archivoBlack(color: workoutTree.color, fontSize: workoutTree.fontSize, height: 1.1),
),
highlightColor: workoutTree.color,
),
),
]))));
@ -111,12 +94,6 @@ class MenuPageWidget extends StatelessWidget with Trans {
SliverList sliverList = SliverList(
delegate: SliverChildListDelegate(_columnChildren),
/* gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 1,
mainAxisSpacing: 6.0,
crossAxisSpacing: 10.0,
childAspectRatio: cWidth > 375 ? 1.8 : 1.8,
) */
);
slivers.add(sliverList);
@ -165,7 +142,6 @@ class MenuPageWidget extends StatelessWidget with Trans {
menuBloc.exerciseDeviceRepository.getGymDevices().forEach((element) {
String deviceName = AppLanguage().appLocal == Locale('en') ? element.name : element.nameTranslation;
ChoiceChip chip = ChoiceChip(
//padding: EdgeInsets.zero,
labelPadding: EdgeInsets.only(right: 5),
avatar: Icon(
Icons.remove_circle_outline,

View File

@ -0,0 +1,85 @@
import 'package:aitrainer_app/util/trans.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class TimePickerWidget extends StatefulWidget {
final Function(double) onChange;
const TimePickerWidget({Key key, this.onChange}) : super(key: key);
@override
_TimePickerWidgetState createState() => _TimePickerWidgetState();
}
class _TimePickerWidgetState extends State<TimePickerWidget> with Trans {
Widget durationPicker({bool inSeconds = false, bool inHundredths = false}) {
double seconds = 0;
return CupertinoPicker(
scrollController: FixedExtentScrollController(initialItem: 0),
backgroundColor: Colors.transparent,
onSelectedItemChanged: (x) {
if (inSeconds) {
currentTimeInSec = x.toDouble();
} else if (inHundredths) {
currentTimeInDec = x.toDouble();
} else {
currentTimeInMin = x.toDouble();
}
seconds = currentTimeInMin * 60 + currentTimeInSec + currentTimeInDec / 100;
//print("sec" + seconds.toStringAsFixed(2));
setState(() {});
widget.onChange(seconds);
},
children: List.generate(
inSeconds
? 60
: inHundredths
? 100
: 60,
(index) => Text(
inSeconds
? '$index sec'
: inHundredths
? index.toString() + ' "'
: '$index min',
style: TextStyle(color: Colors.yellow[200]))),
itemExtent: 40,
);
}
double currentTimeInSec = 0;
double currentTimeInMin = 0;
double currentTimeInDec = 0;
@override
Widget build(BuildContext context) {
setContext(context);
return Container(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
color: Colors.transparent,
width: MediaQuery.of(context).size.width,
child: Center(
child: Container(
color: Colors.transparent,
width: MediaQuery.of(context).size.width * 0.95,
height: MediaQuery.of(context).size.height * 0.25,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(child: durationPicker()),
Expanded(child: durationPicker(inSeconds: true)),
Expanded(child: durationPicker(inHundredths: true)),
],
)),
),
),
],
),
),
);
}
}

View File

@ -42,6 +42,8 @@ dependencies:
keyboard_actions: ^3.3.1+1
dropdown_search: ^0.4.8
badges: ^1.1.4
#health: ^2.0.9
firebase_core: ^0.5.2
#firebase_analytics: ^6.2.0