first step from h2o
parent
82226e62e1
commit
b853bede68
@ -0,0 +1,28 @@
|
||||
class UserProgressForTodayDataModel {
|
||||
dynamic quantityConsumed;
|
||||
dynamic percentageConsumed;
|
||||
dynamic percentageLeft;
|
||||
dynamic quantityLimit;
|
||||
|
||||
UserProgressForTodayDataModel(
|
||||
{this.quantityConsumed,
|
||||
this.percentageConsumed,
|
||||
this.percentageLeft,
|
||||
this.quantityLimit});
|
||||
|
||||
UserProgressForTodayDataModel.fromJson(Map<String, dynamic> json) {
|
||||
quantityConsumed = json['QuantityConsumed'];
|
||||
percentageConsumed = json['PercentageConsumed'];
|
||||
percentageLeft = json['PercentageLeft'];
|
||||
quantityLimit = json['QuantityLimit'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['QuantityConsumed'] = this.quantityConsumed;
|
||||
data['PercentageConsumed'] = this.percentageConsumed;
|
||||
data['PercentageLeft'] = this.percentageLeft;
|
||||
data['QuantityLimit'] = this.quantityLimit;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
class UserProgressRequestModel {
|
||||
int progress;
|
||||
String mobileNumber;
|
||||
String identificationNo;
|
||||
double versionID;
|
||||
int channel;
|
||||
int languageID;
|
||||
String iPAdress;
|
||||
String generalid;
|
||||
int patientOutSA;
|
||||
String sessionID;
|
||||
bool isDentalAllowedBackend;
|
||||
int deviceTypeID;
|
||||
int patientID;
|
||||
String tokenID;
|
||||
int patientTypeID;
|
||||
int patientType;
|
||||
|
||||
UserProgressRequestModel(
|
||||
{this.progress,
|
||||
this.mobileNumber,
|
||||
this.identificationNo,
|
||||
this.versionID,
|
||||
this.channel,
|
||||
this.languageID,
|
||||
this.iPAdress,
|
||||
this.generalid,
|
||||
this.patientOutSA,
|
||||
this.sessionID,
|
||||
this.isDentalAllowedBackend,
|
||||
this.deviceTypeID,
|
||||
this.patientID,
|
||||
this.tokenID,
|
||||
this.patientTypeID,
|
||||
this.patientType});
|
||||
|
||||
UserProgressRequestModel.fromJson(Map<String, dynamic> json) {
|
||||
progress = json['Progress'];
|
||||
mobileNumber = json['MobileNumber'];
|
||||
identificationNo = json['IdentificationNo'];
|
||||
versionID = json['VersionID'];
|
||||
channel = json['Channel'];
|
||||
languageID = json['LanguageID'];
|
||||
iPAdress = json['IPAdress'];
|
||||
generalid = json['generalid'];
|
||||
patientOutSA = json['PatientOutSA'];
|
||||
sessionID = json['SessionID'];
|
||||
isDentalAllowedBackend = json['isDentalAllowedBackend'];
|
||||
deviceTypeID = json['DeviceTypeID'];
|
||||
patientID = json['PatientID'];
|
||||
tokenID = json['TokenID'];
|
||||
patientTypeID = json['PatientTypeID'];
|
||||
patientType = json['PatientType'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['Progress'] = this.progress;
|
||||
data['MobileNumber'] = this.mobileNumber;
|
||||
data['IdentificationNo'] = this.identificationNo;
|
||||
data['VersionID'] = this.versionID;
|
||||
data['Channel'] = this.channel;
|
||||
data['LanguageID'] = this.languageID;
|
||||
data['IPAdress'] = this.iPAdress;
|
||||
data['generalid'] = this.generalid;
|
||||
data['PatientOutSA'] = this.patientOutSA;
|
||||
data['SessionID'] = this.sessionID;
|
||||
data['isDentalAllowedBackend'] = this.isDentalAllowedBackend;
|
||||
data['DeviceTypeID'] = this.deviceTypeID;
|
||||
data['PatientID'] = this.patientID;
|
||||
data['TokenID'] = this.tokenID;
|
||||
data['PatientTypeID'] = this.patientTypeID;
|
||||
data['PatientType'] = this.patientType;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
import 'package:diplomaticquarterapp/config/config.dart';
|
||||
import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/user_progress_for_today_data_model.dart';
|
||||
import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/user_progress_request_model.dart';
|
||||
import 'package:diplomaticquarterapp/core/service/base_service.dart';
|
||||
|
||||
class H2OService extends BaseService {
|
||||
List<UserProgressForTodayDataModel> userProgressForTodayDataList = List();
|
||||
UserProgressRequestModel userProgressRequestModel =
|
||||
UserProgressRequestModel();
|
||||
|
||||
Future getUserProgressForTodayData() async {
|
||||
userProgressRequestModel.progress = 1;
|
||||
userProgressRequestModel.mobileNumber = "537503378";//super.user.mobileNumber;
|
||||
userProgressRequestModel.identificationNo = super.user.patientIdentificationNo;
|
||||
|
||||
hasError = false;
|
||||
await baseAppClient.post(H2O_GET_USER_PROGRESS,
|
||||
onSuccess: (dynamic response, int statusCode) {
|
||||
userProgressForTodayDataList.clear();
|
||||
response['UserProgressForTodayData'].forEach((progressData) {
|
||||
userProgressForTodayDataList
|
||||
.add(UserProgressForTodayDataModel.fromJson(progressData));
|
||||
});
|
||||
}, onFailure: (String error, int statusCode) {
|
||||
hasError = true;
|
||||
super.error = error;
|
||||
}, body: userProgressRequestModel.toJson());
|
||||
}
|
||||
|
||||
Future getUserProgressForWeekData() async {
|
||||
userProgressRequestModel.progress = 2;
|
||||
|
||||
hasError = false;
|
||||
// await baseAppClient.post(H2O_GET_USER_PROGRESS,
|
||||
// onSuccess: (dynamic response, int statusCode) {
|
||||
// userProgressForTodayDataList.clear();
|
||||
// response['UserProgressForWeekData'].forEach((hospital) {
|
||||
// userProgressForTodayDataList.add(PatientLabOrders.fromJson(hospital));
|
||||
// });
|
||||
// }, onFailure: (String error, int statusCode) {
|
||||
// hasError = true;
|
||||
// super.error = error;
|
||||
// }, body: {});
|
||||
}
|
||||
|
||||
Future getUserProgressForMonthData() async {
|
||||
userProgressRequestModel.progress = 2;
|
||||
|
||||
hasError = false;
|
||||
// await baseAppClient.post(H2O_GET_USER_PROGRESS,
|
||||
// onSuccess: (dynamic response, int statusCode) {
|
||||
// userProgressForTodayDataList.clear();
|
||||
// response['UserProgressForMonthData'].forEach((hospital) {
|
||||
// userProgressForTodayDataList.add(PatientLabOrders.fromJson(hospital));
|
||||
// });
|
||||
// }, onFailure: (String error, int statusCode) {
|
||||
// hasError = true;
|
||||
// super.error = error;
|
||||
// }, body: _requestPatientLabOrders.toJson());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
||||
import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/user_progress_for_today_data_model.dart';
|
||||
import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/H2O_service.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
|
||||
|
||||
import '../../../locator.dart';
|
||||
|
||||
class H2OViewModel extends BaseViewModel {
|
||||
H2OService _h2OService =
|
||||
locator<H2OService>();
|
||||
UserProgressForTodayDataModel get userProgressData => _h2OService.userProgressForTodayDataList[0];
|
||||
|
||||
Future getUserProgressForTodayData() async {
|
||||
setState(ViewState.BusyLocal);
|
||||
await _h2OService.getUserProgressForTodayData();
|
||||
if (_h2OService.hasError) {
|
||||
error = _h2OService.error;
|
||||
setState(ViewState.Error);
|
||||
} else {
|
||||
setState(ViewState.Idle);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,122 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:diplomaticquarterapp/core/viewModels/medical/prescriptions_view_model.dart';
|
||||
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/h2o/month_page.dart';
|
||||
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/h2o/today_page.dart';
|
||||
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/h2o/week_page.dart';
|
||||
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
|
||||
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class H2OPage extends StatefulWidget {
|
||||
@override
|
||||
_H2OPageState createState() => _H2OPageState();
|
||||
}
|
||||
|
||||
class _H2OPageState extends State<H2OPage>
|
||||
with SingleTickerProviderStateMixin {
|
||||
TabController _tabController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_tabController = TabController(length: 3, vsync: this);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
_tabController.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BaseView<PrescriptionsViewModel>(
|
||||
onModelReady: (model) => model.getPrescriptions(),
|
||||
builder: (_, model, widget) => AppScaffold(
|
||||
isShowAppBar: true,
|
||||
appBarTitle: TranslationBase.of(context).myDoctor,
|
||||
body: Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: PreferredSize(
|
||||
preferredSize: Size.fromHeight(65.0),
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
Positioned(
|
||||
bottom: 1,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 10, sigmaY: 10),
|
||||
child: Container(
|
||||
color: Theme.of(context)
|
||||
.scaffoldBackgroundColor
|
||||
.withOpacity(0.8),
|
||||
height: 70.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: Container(
|
||||
height: 60.0,
|
||||
margin: EdgeInsets.only(top: 10.0),
|
||||
width: MediaQuery.of(context).size.width * 0.9,
|
||||
|
||||
child: Center(
|
||||
child: TabBar(
|
||||
isScrollable: true,
|
||||
controller: _tabController,
|
||||
indicatorWeight: 5.0,
|
||||
indicatorSize: TabBarIndicatorSize.label,
|
||||
indicatorColor: Colors.red[800],
|
||||
labelColor: Theme.of(context).primaryColor,
|
||||
labelPadding:
|
||||
EdgeInsets.only(top: 4.0, left: 10.0, right: 13.0),
|
||||
unselectedLabelColor: Colors.grey[800],
|
||||
tabs: [
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width * 0.28,
|
||||
child: Center(
|
||||
child: Texts(
|
||||
"Today"),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width * 0.28,
|
||||
child: Center(
|
||||
child: Texts("Week"),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width * 0.28,
|
||||
child: Center(
|
||||
child: Texts("Month"),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
physics: BouncingScrollPhysics(),
|
||||
controller: _tabController,
|
||||
children: <Widget>[TodayPage(), WeekPage(), MonthPage()],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
class MonthPage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(child: Container(child: Text("Month Page "),));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,184 @@
|
||||
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/H2O_view_model.dart';
|
||||
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/h2o/widgets/h20_floating_action_button.dart';
|
||||
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart';
|
||||
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 {
|
||||
static const List<IconData> icons = const [
|
||||
Icons.sms,
|
||||
Icons.mail,
|
||||
Icons.phone
|
||||
];
|
||||
AnimationController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_controller = new AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 500),
|
||||
);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Color backgroundColor = Theme.of(context).cardColor;
|
||||
Color foregroundColor = Theme.of(context).accentColor;
|
||||
return BaseView<H2OViewModel>(
|
||||
onModelReady: (model) => model.getUserProgressForTodayData(),
|
||||
builder: (_, model, widget) => AppScaffold(
|
||||
isShowAppBar: false,
|
||||
appBarTitle: "Water Tracker",
|
||||
body: SingleChildScrollView(
|
||||
padding: EdgeInsets.symmetric(vertical: 12),
|
||||
child: model.state == ViewState.BusyLocal
|
||||
? Center(
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(top: 90),
|
||||
child: AppCircularProgressIndicator()))
|
||||
: Container(
|
||||
margin: EdgeInsets.only(top: 60),
|
||||
child: Column(
|
||||
children: [
|
||||
Center(
|
||||
child: CircularPercentIndicator(
|
||||
radius: 180.0,
|
||||
animation: true,
|
||||
animationDuration: 1200,
|
||||
lineWidth: 15.0,
|
||||
percent:
|
||||
(model.userProgressData.percentageConsumed /
|
||||
100),
|
||||
//,
|
||||
center: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 40,
|
||||
),
|
||||
Text(
|
||||
"Consumed",
|
||||
style: TextStyle(fontSize: 20.0),
|
||||
),
|
||||
SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
Text(
|
||||
model.userProgressData.quantityConsumed
|
||||
.toString(),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 20.0,
|
||||
color: Hexcolor("#60BCF9")),
|
||||
),
|
||||
SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
SizedBox(
|
||||
height: 5,
|
||||
width: 50,
|
||||
child: Container(
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"Remaining",
|
||||
style: TextStyle(fontSize: 20.0),
|
||||
),
|
||||
SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
Text(
|
||||
(model.userProgressData.quantityLimit -
|
||||
model.userProgressData
|
||||
.quantityConsumed)
|
||||
.toString(),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 20.0),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
circularStrokeCap: CircularStrokeCap.butt,
|
||||
backgroundColor: Hexcolor("#D1E3F6"),
|
||||
progressColor: Hexcolor("#60BCF9"),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Center(
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(left: 20),
|
||||
height: 30,
|
||||
width: 70,
|
||||
decoration: BoxDecoration(
|
||||
color: Hexcolor("#D1E3F6"),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(30))),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"Remaining % ",
|
||||
style: TextStyle(fontSize: 20.0),
|
||||
)
|
||||
],
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Center(
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(left: 20),
|
||||
height: 30,
|
||||
width: 70,
|
||||
decoration: BoxDecoration(
|
||||
color: Hexcolor("#60BCF9"),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(30))),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"Consumed % ",
|
||||
style: TextStyle(fontSize: 20.0),
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
SizedBox(
|
||||
height: 0.5,
|
||||
width: MediaQuery.of(context).size.width,
|
||||
child: Container(
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
floatingActionButton: H20FloatingActionButton(
|
||||
controller: _controller,
|
||||
backgroundColor: backgroundColor,
|
||||
foregroundColor: foregroundColor)),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
class WeekPage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(child: Container(child: Text("Week page"),));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,253 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class H20FloatingActionButton extends StatelessWidget {
|
||||
const H20FloatingActionButton({
|
||||
Key key,
|
||||
@required AnimationController controller,
|
||||
@required this.backgroundColor,
|
||||
@required this.foregroundColor,
|
||||
}) : _controller = controller,
|
||||
super(key: key);
|
||||
|
||||
final AnimationController _controller;
|
||||
final Color backgroundColor;
|
||||
final Color foregroundColor;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_showMaterialDialog(String count) {
|
||||
|
||||
|
||||
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: () {
|
||||
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Center(
|
||||
child: Texts(
|
||||
TranslationBase.of(context).ok,
|
||||
fontWeight: FontWeight.w400,
|
||||
)),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void ShowConfirmMessage(String count){
|
||||
showDialog(
|
||||
context: context,
|
||||
child: _showMaterialDialog(count)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return Container(
|
||||
margin: EdgeInsets.only(left: 20),
|
||||
child: new Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
ActionButton(
|
||||
controller: _controller,
|
||||
text: "600ml",
|
||||
onTap: () {
|
||||
ShowConfirmMessage("600ml");
|
||||
},
|
||||
),
|
||||
ActionButton(
|
||||
controller: _controller,
|
||||
text: "330ml",
|
||||
onTap: () {
|
||||
ShowConfirmMessage("330ml");
|
||||
},
|
||||
),
|
||||
ActionButton(
|
||||
controller: _controller,
|
||||
text: "200ml",
|
||||
onTap: () {
|
||||
ShowConfirmMessage("200ml");
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
FloatingActionButton(
|
||||
heroTag: null,
|
||||
child: new AnimatedBuilder(
|
||||
animation: _controller,
|
||||
builder: (BuildContext context, Widget child) {
|
||||
return new Transform(
|
||||
transform: new Matrix4.rotationZ(
|
||||
_controller.value * 0.5 * math.pi),
|
||||
alignment: FractionalOffset.center,
|
||||
child: new Icon(
|
||||
_controller.isDismissed ? Icons.add : Icons.close),
|
||||
);
|
||||
},
|
||||
),
|
||||
onPressed: () {
|
||||
if (_controller.isDismissed) {
|
||||
_controller.forward();
|
||||
} else {
|
||||
_controller.reverse();
|
||||
}
|
||||
},
|
||||
),
|
||||
new Container(
|
||||
alignment: FractionalOffset.topCenter,
|
||||
child: new ScaleTransition(
|
||||
scale: new CurvedAnimation(
|
||||
parent: _controller,
|
||||
curve: new Interval(0.0, 1.0 - 0 / 6 / 2.0,
|
||||
curve: Curves.easeOut),
|
||||
),
|
||||
child: new FloatingActionButton(
|
||||
heroTag: null,
|
||||
backgroundColor: backgroundColor,
|
||||
mini: true,
|
||||
child: Text(
|
||||
"Custom",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 14.0, color: Colors.grey),
|
||||
),
|
||||
onPressed: () {},
|
||||
),
|
||||
),
|
||||
),
|
||||
new Container(
|
||||
alignment: FractionalOffset.topCenter,
|
||||
child: new ScaleTransition(
|
||||
scale: new CurvedAnimation(
|
||||
parent: _controller,
|
||||
curve: new Interval(0.0, 1.0 - 0 / 6 / 2.0,
|
||||
curve: Curves.easeOut),
|
||||
),
|
||||
child: new FloatingActionButton(
|
||||
heroTag: null,
|
||||
backgroundColor: backgroundColor,
|
||||
mini: true,
|
||||
child: Text(
|
||||
"Undo",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 14.0, color: Colors.grey),
|
||||
),
|
||||
onPressed: () {},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
]),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ActionButton extends StatelessWidget {
|
||||
const ActionButton(
|
||||
{Key key,
|
||||
@required AnimationController controller,
|
||||
@required this.text,
|
||||
this.onTap})
|
||||
: _controller = controller,
|
||||
super(key: key);
|
||||
|
||||
final AnimationController _controller;
|
||||
final String text;
|
||||
final Function onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
alignment: FractionalOffset.topCenter,
|
||||
child: new ScaleTransition(
|
||||
scale: new CurvedAnimation(
|
||||
parent: _controller,
|
||||
curve: new Interval(0.0, 1.0 - 0 / 6 / 2.0, curve: Curves.easeOut),
|
||||
),
|
||||
child: new FloatingActionButton(
|
||||
heroTag: null,
|
||||
backgroundColor: Colors.white,
|
||||
mini: true,
|
||||
child: Text(
|
||||
text,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 14.0, color: Colors.grey),
|
||||
),
|
||||
onPressed: onTap
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue