import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/services/permission/permission_service.dart'; import 'package:diplomaticquarterapp/theme/theme_value.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:provider/provider.dart'; import '../../uitl/translations_delegate_base.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 with TickerProviderStateMixin { double _buttonSize = 1.0; late AnimationController _animationController; late 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), child: Container( width: 100, height: 100, decoration: BoxDecoration( // borderRadius: BorderRadius.all(Radius.circular(70.0)), color: appColor, shape: BoxShape.circle, ), child: Padding( padding: const EdgeInsets.all(18), child: Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: [ SvgPicture.asset( "assets/images/new/book appointment.svg", width: 50, height: 30, colorFilter: ColorFilter.mode(Colors.white, BlendMode.srcIn) ), Text( TranslationBase.of(context).book, textAlign: TextAlign.center, style: TextStyle(fontSize: 11, fontWeight: FontWeight.w600, color: Colors.white,), ), Text( TranslationBase.of(context).appointmentLabel, textAlign: TextAlign.center, style: TextStyle(fontSize: 8, fontWeight: FontWeight.w400, color: Colors.white,), ), ], ), ), ) ), ))); } }