|
|
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
|
|
import 'package:diplomaticquarterapp/services/permission/permission_service.dart';
|
|
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
|
|
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
|
|
|
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
/// FloatingButton widget
|
|
|
|
/// [onTap] button function
|
|
|
|
/// [elevation] color elevation value
|
|
|
|
class FloatingButton extends StatefulWidget {
|
|
|
|
FloatingButton({Key key, this.onTap, this.elevation: true}) : super(key: key);
|
|
|
|
|
|
|
|
final VoidCallback onTap;
|
|
|
|
final bool elevation;
|
|
|
|
|
|
|
|
@override
|
|
|
|
_FloatingButtonState createState() => _FloatingButtonState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _FloatingButtonState extends State<FloatingButton>
|
|
|
|
with TickerProviderStateMixin {
|
|
|
|
double _buttonSize = 1.0;
|
|
|
|
AnimationController _animationController;
|
|
|
|
Animation _animation;
|
|
|
|
PermissionService permission = new PermissionService();
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
_animationController = AnimationController(
|
|
|
|
vsync: this,
|
|
|
|
lowerBound: 0.7,
|
|
|
|
upperBound: 1.0,
|
|
|
|
duration: Duration(milliseconds: 120));
|
|
|
|
_animation = CurvedAnimation(
|
|
|
|
parent: _animationController,
|
|
|
|
curve: Curves.easeOutQuad,
|
|
|
|
reverseCurve: Curves.easeOutQuad);
|
|
|
|
_animation.addListener(() {
|
|
|
|
setState(() {
|
|
|
|
_buttonSize = _animation.value;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
_animationController.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
ProjectViewModel projectViewModel = Provider.of(context);
|
|
|
|
return (GestureDetector(
|
|
|
|
onTapDown: (TapDownDetails tap) {
|
|
|
|
_animationController.reverse(from: 1.0);
|
|
|
|
},
|
|
|
|
onTapUp: (TapUpDetails tap) {
|
|
|
|
_animationController.forward();
|
|
|
|
},
|
|
|
|
onTapCancel: () {
|
|
|
|
_animationController.forward();
|
|
|
|
},
|
|
|
|
onTap: (){permission.vibrate(widget.onTap, context);},
|
|
|
|
behavior: HitTestBehavior.opaque,
|
|
|
|
child: Transform.scale(
|
|
|
|
scale: _buttonSize,
|
|
|
|
child: AnimatedContainer(
|
|
|
|
duration: Duration(milliseconds: 150),
|
|
|
|
margin: EdgeInsets.only(bottom: 4),
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 24, horizontal: 24),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(54.0)),
|
|
|
|
color: Theme.of(context).primaryColor,
|
|
|
|
boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
color: Color.fromRGBO(
|
|
|
|
120, 71, 80, widget.elevation ? 0.28 : 0.0),
|
|
|
|
spreadRadius:
|
|
|
|
_buttonSize < 1.0 ? -(1 - _buttonSize) * 50 : 0.0,
|
|
|
|
offset: Offset(0, 7.0),
|
|
|
|
blurRadius: 55.0)
|
|
|
|
]),
|
|
|
|
child: Container(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Icon(EvaIcons.calendar,color: Colors.white,size: 23,),
|
|
|
|
Texts(
|
|
|
|
TranslationBase.of(context).book,
|
|
|
|
bold: !projectViewModel.isArabic,
|
|
|
|
color: Colors.white,
|
|
|
|
fontSize: projectViewModel.isArabic ? 8 : 17,
|
|
|
|
),
|
|
|
|
Texts(
|
|
|
|
TranslationBase.of(context).appointmentLabel,
|
|
|
|
bold: projectViewModel.isArabic,
|
|
|
|
color: Colors.white,
|
|
|
|
fontSize:projectViewModel.isArabic ? 8.8 : 8,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
width: 54,
|
|
|
|
height: 54,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
shape: BoxShape.circle,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|