Refactor today page

er_location
Elham Rababah 4 years ago
parent 9aa217c247
commit fdc8ef36ef

@ -248,7 +248,7 @@ const GET_PATIENT_ALLERGIES = 'Services/Patients.svc/REST/GetPatientAllergies';
// H2O
const H2O_GET_USER_PROGRESS = "/Services/H2ORemainder.svc/REST/H2O_GetUserProgress";
const H2O_GET_USER_PROGRESS = "Services/H2ORemainder.svc/REST/H2O_GetUserProgress";
const H2O_INSERT_USER_ACTIVITY="Services/H2ORemainder.svc/REST/H2O_InsertUserActivity";

@ -6,28 +6,10 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:percent_indicator/circular_percent_indicator.dart';
class TodayPage extends StatefulWidget {
@override
_TodayPageState createState() => _TodayPageState();
}
class _TodayPageState extends State<TodayPage> with TickerProviderStateMixin {
AnimationController _controller;
@override
void initState() {
_controller = new AnimationController(
vsync: this,
duration: const Duration(milliseconds: 500),
);
super.initState();
}
class TodayPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BaseView<H2OViewModel>(
return BaseView<H2OViewModel>(
onModelReady: (model) => model.getUserProgressForTodayData(),
builder: (_, model, widget) => AppScaffold(
isShowAppBar: false,
@ -65,8 +47,8 @@ class _TodayPageState extends State<TodayPage> with TickerProviderStateMixin {
height: 4,
),
Text(model.userProgressData ==null ?"0.0":
model.userProgressData.quantityConsumed
.toString() + 'ml',
model.userProgressData.quantityConsumed
.toString() + 'ml',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20.0,
@ -93,12 +75,12 @@ class _TodayPageState extends State<TodayPage> with TickerProviderStateMixin {
height: 4,
),
Text(model.userProgressData ==null ?"0.0":
(model.userProgressData.quantityLimit -
model.userProgressData
.quantityConsumed) < 0 ? "0 ml" :
(model.userProgressData.quantityLimit -
model.userProgressData
.quantityConsumed).toString() + ' ml',
(model.userProgressData.quantityLimit -
model.userProgressData
.quantityConsumed) < 0 ? "0 ml" :
(model.userProgressData.quantityLimit -
model.userProgressData
.quantityConsumed).toString() + ' ml',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18.0),
@ -174,11 +156,11 @@ class _TodayPageState extends State<TodayPage> with TickerProviderStateMixin {
),
),
floatingActionButton: H20FloatingActionButton(
controller: _controller,
// controller: _controller,
model: model,
),
),
);
}
}

@ -11,114 +11,34 @@ import 'package:flutter/material.dart';
import '../add_custom_amount.dart';
class H20FloatingActionButton extends StatelessWidget {
class H20FloatingActionButton extends StatefulWidget {
const H20FloatingActionButton({
Key key,
@required AnimationController controller,
@required this.model
}) : _controller = controller,
}) :
super(key: key);
final AnimationController _controller;
final H2OViewModel model;
@override
_H20FloatingActionButtonState createState() => _H20FloatingActionButtonState();
}
class _H20FloatingActionButtonState extends State<H20FloatingActionButton> with TickerProviderStateMixin {
AnimationController _controller;
@override
void initState() {
_controller = new AnimationController(
vsync: this,
duration: const Duration(milliseconds: 500),
);
super.initState();
}
@override
Widget build(BuildContext context) {
// _showMaterialDialog(String count, H2OViewModel model) {
// return SimpleDialog(
// contentPadding: EdgeInsets.fromLTRB(28.0, 24.0, 28.0, 0.0),
// title: Center(
// child: Texts(
// "Confirm",
// color: Colors.black,
// ),
// ),
// children: [
// Column(
// children: [
// Divider(),
// Center(
// child: Texts(
// "Are you sure you want to Add $count ?",
// color: Colors.grey,
// ),
// ),
// SizedBox(
// height: 5.0,
// ),
// Row(
// // mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: <Widget>[
// Expanded(
// flex: 1,
// child: InkWell(
// onTap: () {
// Navigator.pop(context);
// },
// child: Padding(
// padding: const EdgeInsets.all(8.0),
// child: Container(
// child: Center(
// child: Texts(
// TranslationBase.of(context).cancel.toUpperCase(),
// color: Colors.red,
// ),
// ),
// ),
// ),
// ),
// ),
// Container(
// width: 1,
// height: 30,
// color: Colors.grey[500],
// ),
// Expanded(
// flex: 1,
// child: InkWell(
// onTap: () async{
// // insertUserActivity
// int addedValue;
//
// switch(count) {
// case "600ml": {
// addedValue = 600;
// }
// break;
//
// case "330ml": {
// addedValue = 330;
//
// }
// break;
// case "200ml": {
// addedValue = 200;
// }
// break;
//
// }
//
// InsertUserActivityRequestModel insertUserActivityRequestModel= InsertUserActivityRequestModel(quantityIntake:addedValue );
// await model.insertUserActivity(insertUserActivityRequestModel);
// Navigator.pop(context);
// },
// child: Padding(
// padding: const EdgeInsets.all(8.0),
// child: Center(
// child: Texts(
// TranslationBase.of(context).ok,
// fontWeight: FontWeight.w400,
// )),
// ),
// ),
// ),
// ],
// )
// ],
// )
// ],
// );
// }
void showConfirmMessage(int amount, H2OViewModel model) {
showDialog(context: context, child: ConfirmAddAmountDialog(model: model,amount:amount,));
@ -137,21 +57,21 @@ class H20FloatingActionButton extends StatelessWidget {
controller: _controller,
text: "600ml",
onTap: () {
showConfirmMessage(600, model);
showConfirmMessage(600, widget.model);
},
),
ActionButton(
controller: _controller,
text: "330ml",
onTap: () {
showConfirmMessage(330, model);
showConfirmMessage(330, widget.model);
},
),
ActionButton(
controller: _controller,
text: "200ml",
onTap: () {
showConfirmMessage(200, model);
showConfirmMessage(200, widget.model);
},
),
],
@ -205,7 +125,7 @@ class H20FloatingActionButton extends StatelessWidget {
context,
FadePage(
page: AddCustomAmount(
model: model,
model: widget.model,
),
),
);

Loading…
Cancel
Save