Aidra Connect 10.0.2+16
Aidra Connect Mobile Application
Loading...
Searching...
No Matches
custom_action_slider.dart
Go to the documentation of this file.
1import 'package:action_slider/action_slider.dart';
2
3import 'package:flutter/material.dart';
4import 'package:flutter_screenutil/flutter_screenutil.dart';
5import 'package:hugeicons/hugeicons.dart';
6
7class CustomActionSlider extends StatefulWidget {
8 final Function(ActionSliderController) action;
9 final String label;
10
12 super.key,
13 required this.action,
14 required this.label,
15 });
16
17 @override
18 State<CustomActionSlider> createState() => _CustomActionSliderState();
19}
20
21class _CustomActionSliderState extends State<CustomActionSlider> {
22 ActionSliderController actionSliderController = ActionSliderController();
23 @override
24 void dispose() {
25 actionSliderController.dispose();
26 super.dispose();
27 }
28
29 @override
30 Widget build(BuildContext context) {
31 final bool isRTL = Directionality.of(context) == TextDirection.rtl;
32
33 return ActionSlider.custom(
34 boxShadow: const [
35 BoxShadow(
36 spreadRadius: 0,
37 blurRadius: 0,
38 ),
39 ],
40 width: MediaQuery.of(context).size.width,
41 controller: actionSliderController,
42 toggleWidth: 90.0.sp,
43 sliderBehavior: SliderBehavior.move,
44 height: 60.0.sp,
45 backgroundColor: Theme.of(context).colorScheme.primary.withOpacity(0.11),
46 foregroundChild: Container(
47 width: 100.sp,
48 decoration: BoxDecoration(
49 color: Theme.of(context).colorScheme.primary,
50 borderRadius: const BorderRadius.all(Radius.circular(28)),
51 boxShadow: [
52 BoxShadow(
53 color: Theme.of(context).primaryColor.withOpacity(0.3),
54 spreadRadius: 2,
55 blurRadius: 7,
56 offset: const Offset(0, 3),
57 ),
58 ],
59 ),
60 child: Center(
61 child: Container(
62 width: 6.sp,
63 height: 20.sp,
64 decoration: BoxDecoration(
65 color: Theme.of(context).colorScheme.primary,
66 borderRadius: const BorderRadius.all(Radius.circular(28)),
67 ),
68 ),
69 ),
70 ),
71 foregroundBuilder: (context, state, child) => child!,
72 backgroundChild: Row(
73 mainAxisAlignment: MainAxisAlignment.center,
74 crossAxisAlignment: CrossAxisAlignment.center,
75 children: [
76 Row(
77 children: List.generate(
78 3,
79 (index) => Icon(
80 isRTL ? Icons.arrow_back_ios_outlined : Icons.arrow_forward_ios_outlined,
81 size: 11.sp,
82 color: Theme.of(context).hintColor,
83 ),
84 ),
85 ),
86 SizedBox(width: 10.sp),
87 Text(
88 widget.label.toUpperCase(),
89 style: Theme.of(context)
90 .textTheme
91 .displaySmall
92 ?.copyWith(color: Colors.grey, fontSize: 14.sp),
93 ),
94 ],
95 ),
96 backgroundBuilder: (context, state, child) => ClipRect(
97 child: OverflowBox(
98 maxWidth: state.standardSize.width,
99 maxHeight: state.toggleSize.height,
100 minWidth: state.standardSize.width,
101 minHeight: state.toggleSize.height,
102 child: child!,
103 ),
104 ),
105 backgroundBorderRadius: BorderRadius.circular(100.0),
106 action: widget.action,
107 direction: isRTL ? TextDirection.rtl : TextDirection.ltr,
108 );
109 }
110}
111
112class CustomSliderV2 extends StatelessWidget {
113 final String text;
114 final dynamic Function(ActionSliderController)? action;
115 final Color? color;
116
118 super.key,
119 required this.text,
120 required this.action,
121 this.color,
122 });
123
124 @override
125 Widget build(BuildContext context) {
126 final bool isRTL = Directionality.of(context) == TextDirection.rtl;
127
128 return ActionSlider.standard(
129 foregroundBorderRadius: BorderRadius.circular(10),
130 backgroundBorderRadius: BorderRadius.circular(10),
131 boxShadow: [
132 BoxShadow(
133 color: Theme.of(context).colorScheme.surface,
134 blurRadius: 0,
135 offset: const Offset(0, 0),
136 ),
137 ],
138 icon: Icon(
139 isRTL ? HugeIcons.strokeRoundedSwipeLeft03 : HugeIcons.strokeRoundedSwipeRight03,
140 color: color ?? Theme.of(context).colorScheme.primary,
141 size: 24.sp,
142 ),
143 toggleColor: Theme.of(context).colorScheme.surface,
144 sliderBehavior: SliderBehavior.stretch,
145 backgroundColor: color ?? Theme.of(context).primaryColor,
146 action: action,
147 direction: isRTL ? TextDirection.rtl : TextDirection.ltr,
148 child: Text(
149 text,
150 style: Theme.of(context).textTheme.bodySmall?.copyWith(
151 fontSize: 12.5.sp,
152 color: Theme.of(context).colorScheme.surface,
153 fontWeight: FontWeight.bold,
154 ),
155 ),
156 );
157 }
158}
override State< CustomActionSlider > createState()
final Function(ActionSliderController) action
const CustomActionSlider({ super.key, required this.action, required this.label, })
final IconData icon
final Widget child
override Widget build(BuildContext context)
const CustomSliderV2({ super.key, required this.text, required this.action, this.color, })
final dynamic Function(ActionSliderController)? action
class CustomActionSlider extends StatefulWidget actionSliderController
override void dispose()
final Widget child
final Color backgroundColor
final Color color
Definition failures.dart:1
override Widget build(BuildContext context)