141 lines
5.4 KiB
Dart
141 lines
5.4 KiB
Dart
import 'package:aitrainer_app/bloc/exercise_new/exercise_new_bloc.dart';
|
|
import 'package:aitrainer_app/localization/app_localization.dart';
|
|
import 'package:aitrainer_app/util/trans.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/widgets.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import 'app_bar.dart';
|
|
import 'package:keyboard_actions/keyboard_actions.dart';
|
|
|
|
// ignore: must_be_immutable
|
|
class SizeWidget extends StatefulWidget {
|
|
final ExerciseNewBloc exerciseBloc;
|
|
|
|
SizeWidget({this.exerciseBloc});
|
|
|
|
@override
|
|
_SizeState createState() => _SizeState();
|
|
}
|
|
|
|
class _SizeState extends State<SizeWidget> with Trans {
|
|
double bmr = 0;
|
|
|
|
final FocusNode _nodeText1 = FocusNode();
|
|
|
|
KeyboardActionsConfig _buildConfig(BuildContext context) {
|
|
return KeyboardActionsConfig(
|
|
keyboardActionsPlatform: KeyboardActionsPlatform.ALL,
|
|
keyboardBarColor: Colors.grey[200],
|
|
keyboardSeparatorColor: Colors.black26,
|
|
nextFocus: true,
|
|
actions: [
|
|
KeyboardActionsItem(
|
|
focusNode: _nodeText1,
|
|
toolbarButtons: [
|
|
//button 2
|
|
(node) {
|
|
return GestureDetector(
|
|
onTap: () => node.unfocus(),
|
|
child: Container(
|
|
color: Colors.orange,
|
|
padding: EdgeInsets.all(8.0),
|
|
child: Text(
|
|
AppLocalizations.of(context).translate("Done"),
|
|
style: TextStyle(color: Colors.white),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
],
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
setContext(context);
|
|
print("sex " + widget.exerciseBloc.customerRepository.sex);
|
|
return Form(
|
|
child: Scaffold(
|
|
resizeToAvoidBottomInset: true,
|
|
appBar: AppBarNav(depth: 1),
|
|
body: Container(
|
|
width: MediaQuery.of(context).size.width,
|
|
height: MediaQuery.of(context).size.height,
|
|
decoration: BoxDecoration(
|
|
image: DecorationImage(
|
|
image: AssetImage('asset/image/WT_black_background.png'),
|
|
fit: BoxFit.fill,
|
|
alignment: Alignment.center,
|
|
),
|
|
),
|
|
child: KeyboardActions(
|
|
config: _buildConfig(context),
|
|
child: Container(
|
|
padding: EdgeInsets.only(top: 10),
|
|
child:
|
|
Column(crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [
|
|
Stack(
|
|
children: [
|
|
widget.exerciseBloc.customerRepository.sex == "Man"
|
|
? Image.asset(
|
|
"asset/image/man_sizes.png",
|
|
height: MediaQuery.of(context).size.height * .85,
|
|
)
|
|
: Image.asset(
|
|
"asset/image/woman_sizes.png",
|
|
height: MediaQuery.of(context).size.height * .85,
|
|
),
|
|
Positioned(
|
|
top: 30,
|
|
left: 175,
|
|
child: Image.asset(
|
|
"asset/image/sizes_empty.png",
|
|
),
|
|
)
|
|
],
|
|
)
|
|
]))))));
|
|
}
|
|
|
|
Widget getWeightInput() {
|
|
return Container(
|
|
padding: EdgeInsets.only(top: 15, left: 65, right: 65, bottom: 10),
|
|
alignment: Alignment.center,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Flexible(
|
|
child: TextFormField(
|
|
focusNode: _nodeText1,
|
|
decoration: InputDecoration(
|
|
contentPadding: EdgeInsets.only(left: 15, top: 5, bottom: 5),
|
|
labelText: AppLocalizations.of(context).translate("Actual Weight"),
|
|
labelStyle: GoogleFonts.inter(fontSize: 16, color: Colors.yellow[50]),
|
|
fillColor: Colors.black38,
|
|
filled: true,
|
|
border: OutlineInputBorder(
|
|
gapPadding: 2.0,
|
|
borderRadius: BorderRadius.circular(12.0),
|
|
borderSide: BorderSide(color: Colors.white12, width: 0.4),
|
|
),
|
|
),
|
|
initialValue: widget.exerciseBloc.weight.toStringAsFixed(0),
|
|
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
|
textInputAction: TextInputAction.done,
|
|
style: GoogleFonts.archivoBlack(fontSize: 20, color: Colors.yellow[300]),
|
|
onChanged: (value) => {widget.exerciseBloc.add(ExerciseNewWeightChange(value: double.parse(value)))},
|
|
),
|
|
),
|
|
IconButton(
|
|
icon: Icon(Icons.save),
|
|
hoverColor: Colors.blueAccent,
|
|
color: widget.exerciseBloc.changedWeight ? Colors.blue[200] : Colors.black54,
|
|
onPressed: () => {print("Save"), widget.exerciseBloc.add(ExerciseNewSaveWeight())})
|
|
],
|
|
));
|
|
}
|
|
}
|