@@ -5,6 +5,7 @@ import 'package:audio_chat/src/audio_state.dart';
5
5
import 'package:audio_chat/src/globals.dart' ;
6
6
import 'package:audio_chat/src/widgets/flow_shader.dart' ;
7
7
import 'package:flutter/material.dart' ;
8
+ import 'package:flutter_vibrate/flutter_vibrate.dart' ;
8
9
import 'package:font_awesome_flutter/font_awesome_flutter.dart' ;
9
10
import 'package:record/record.dart' ;
10
11
@@ -60,15 +61,15 @@ class _RecordButtonState extends State<RecordButton> {
60
61
.animate (
61
62
CurvedAnimation (
62
63
parent: widget.controller,
63
- curve: const Interval (0.4 , 1 , curve: Curves .easeIn),
64
+ curve: const Interval (0.2 , 1 , curve: Curves .easeIn),
64
65
),
65
66
);
66
67
lockerAnimation =
67
68
Tween <double >(begin: lockerHeight + Globals .defaultPadding, end: 0 )
68
69
.animate (
69
70
CurvedAnimation (
70
71
parent: widget.controller,
71
- curve: const Interval (0.2 , 0.8 , curve: Curves .elasticInOut ),
72
+ curve: const Interval (0.2 , 1 , curve: Curves .easeIn ),
72
73
),
73
74
);
74
75
}
@@ -143,8 +144,14 @@ class _RecordButtonState extends State<RecordButton> {
143
144
mainAxisSize: MainAxisSize .max,
144
145
children: [
145
146
Text (recordDuration),
147
+ const SizedBox (width: size),
146
148
FlowShader (
147
- child: const Text ("Slide to cancel" ),
149
+ child: Row (
150
+ children: const [
151
+ Icon (Icons .keyboard_arrow_left),
152
+ Text ("Slide to cancel" )
153
+ ],
154
+ ),
148
155
duration: const Duration (seconds: 3 ),
149
156
flowColors: const [Colors .white, Colors .grey],
150
157
),
@@ -171,11 +178,13 @@ class _RecordButtonState extends State<RecordButton> {
171
178
child: GestureDetector (
172
179
behavior: HitTestBehavior .opaque,
173
180
onTap: () async {
174
- var filePath = await Record (). stop ( );
181
+ Vibrate . feedback ( FeedbackType .success );
175
182
timer? .cancel ();
176
183
timer = null ;
177
184
startTime = null ;
178
185
recordDuration = "00:00" ;
186
+
187
+ var filePath = await Record ().stop ();
179
188
AudioState .files.add (filePath! );
180
189
Globals .audioListKey.currentState!
181
190
.insertItem (AudioState .files.length - 1 );
@@ -232,7 +241,9 @@ class _RecordButtonState extends State<RecordButton> {
232
241
debugPrint ("onLongPressEnd" );
233
242
widget.controller.reverse ();
234
243
235
- if (isCancelled (details.localPosition)) {
244
+ if (isCancelled (details.localPosition, context)) {
245
+ Vibrate .feedback (FeedbackType .heavy);
246
+
236
247
timer? .cancel ();
237
248
timer = null ;
238
249
startTime = null ;
@@ -244,11 +255,15 @@ class _RecordButtonState extends State<RecordButton> {
244
255
File (filePath! ).delete ();
245
256
debugPrint ("Deleted $filePath " );
246
257
} else if (checkIsLocked (details.localPosition)) {
258
+ Vibrate .feedback (FeedbackType .heavy);
247
259
debugPrint ("Locked recording" );
260
+ debugPrint (details.localPosition.dy.toString ());
248
261
setState (() {
249
262
isLocked = true ;
250
263
});
251
264
} else {
265
+ Vibrate .feedback (FeedbackType .success);
266
+
252
267
timer? .cancel ();
253
268
timer = null ;
254
269
startTime = null ;
@@ -267,6 +282,7 @@ class _RecordButtonState extends State<RecordButton> {
267
282
},
268
283
onLongPress: () async {
269
284
debugPrint ("onLongPress" );
285
+ Vibrate .feedback (FeedbackType .success);
270
286
if (await Record ().hasPermission ()) {
271
287
record = Record ();
272
288
await record.start (
@@ -277,7 +293,7 @@ class _RecordButtonState extends State<RecordButton> {
277
293
samplingRate: 44100 ,
278
294
);
279
295
startTime = DateTime .now ();
280
- timer = Timer .periodic (const Duration (seconds: 1 ), (timer ) {
296
+ timer = Timer .periodic (const Duration (seconds: 1 ), (_ ) {
281
297
final minDur = DateTime .now ().difference (startTime! ).inMinutes;
282
298
final secDur = DateTime .now ().difference (startTime! ).inSeconds % 60 ;
283
299
String min = minDur < 10 ? "0$minDur " : minDur.toString ();
@@ -292,10 +308,10 @@ class _RecordButtonState extends State<RecordButton> {
292
308
}
293
309
294
310
bool checkIsLocked (Offset offset) {
295
- return (offset.dy < - 85 && offset.dy > - 135 );
311
+ return (offset.dy < - 35 );
296
312
}
297
313
298
- bool isCancelled (Offset offset) {
299
- return (offset.dx < - 200 );
314
+ bool isCancelled (Offset offset, BuildContext context ) {
315
+ return (offset.dx < - ( MediaQuery . of (context).size.width * 0.3 ) );
300
316
}
301
317
}
0 commit comments