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.
PatientApp-KKUMC/lib/widgets/buttons/floatingActionButton.dart

116 lines
3.7 KiB
Dart

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<FloatingButton>
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: 102,
height: 102,
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: 13, fontWeight: FontWeight.w600, color: Colors.white,),
), Text(
TranslationBase.of(context).appointmentLabel,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 8, fontWeight: FontWeight.w400, color: Colors.white,),
),
],
),
),
)
),
)));
}
}