You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
254 lines
7.5 KiB
Dart
254 lines
7.5 KiB
Dart
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
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|