// Automatic FlutterFlow imports
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/widgets/index.dart'; // Imports other custom widgets
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom widget code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!
import 'package:slide_action/slide_action.dart';
class SlideToConfirm extends StatefulWidget {
const SlideToConfirm({
Key? key,
this.width,
this.height,
required this.action,
}) : super(key: key);
final double? width;
final double? height;
final Future<dynamic> Function() action;
@override
_SlideToConfirmState createState() => _SlideToConfirmState();
}
class _SlideToConfirmState extends State<SlideToConfirm>
with SingleTickerProviderStateMixin {
late AnimationController _controller;
late Animation<double> _animation;
@override
void initState() {
super.initState();
_controller = AnimationController(
duration: const Duration(seconds: 3),
vsync: this,
);
_animation = Tween(begin: -1.0, end: 1.0).animate(_controller)
..addListener(() {
setState(() {});
});
_controller.repeat(reverse: true);
}
@override
Widget build(BuildContext context) {
return Center(
child: SlideAction(
snapAnimationCurve: Curves.bounceOut,
snapAnimationDuration: const Duration(milliseconds: 1200),
stretchThumb: false,
thumbWidth: 136,
trackBuilder: (context, state) {
return Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
FlutterFlowTheme.of(context).primary,
FlutterFlowTheme.of(context).secondary,
],
stops: [0, 1],
begin: AlignmentDirectional(_animation.value, -1),
end: AlignmentDirectional(-_animation.value, 1),
),
borderRadius: BorderRadius.circular(40),
),
);
},
thumbBuilder: (context, state) {
return Padding(
padding: EdgeInsetsDirectional.fromSTEB(4, 4, 4, 4),
child: Container(
decoration: BoxDecoration(
color: FlutterFlowTheme.of(context).primaryBackground,
borderRadius: BorderRadius.circular(40),
),
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(4, 4, 4, 4),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: 44,
height: 44,
decoration: BoxDecoration(
color: FlutterFlowTheme.of(context).primary,
shape: BoxShape.circle,
),
child: Icon(
Icons.navigate_next,
color: FlutterFlowTheme.of(context).primaryBackground,
size: 24,
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(8, 0, 8, 0),
child: Text(
'slide to\nConfirm',
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Poppins',
fontWeight: FontWeight.normal,
),
),
),
],
),
),
),
);
},
action: () async {
await widget.action?.call();
},
),
);
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
}
// Set your widget name, define your parameter, and then add the
// boilerplate code using the green button on the right!