diff options
author | 2023-10-23 02:00:01 +0500 | |
---|---|---|
committer | 2023-10-26 21:36:57 +0500 | |
commit | 8417e9daeecbdb3847de401b0fcc6304d246a787 (patch) | |
tree | a9dafba232ee7e458358861d1356636c079a12da /lib/widgets/record_command_button.dart | |
parent | 8d38450e46ff3854ade4005c4132edfb1aabb9b4 (diff) |
Add flutter voice assistant app
A flutter based gRPC client Voice Assistant made specifically
to communicate with the Voice Agent service.
SPEC-4906
Signed-off-by: Malik Talha <talhamalik727x@gmail.com>
Change-Id: Ic4a382c1cdb78f1a79f985e3d37ce2fb06c53203
Diffstat (limited to 'lib/widgets/record_command_button.dart')
-rw-r--r-- | lib/widgets/record_command_button.dart | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/lib/widgets/record_command_button.dart b/lib/widgets/record_command_button.dart new file mode 100644 index 0000000..fdff772 --- /dev/null +++ b/lib/widgets/record_command_button.dart @@ -0,0 +1,66 @@ +import 'package:flutter/material.dart'; + +class RecordCommandButton extends StatefulWidget { + final ValueChanged<bool> onRecordingStateChanged; + + RecordCommandButton({required this.onRecordingStateChanged}); + + @override + RecordCommandButtonState createState() => RecordCommandButtonState(); +} + +class RecordCommandButtonState extends State<RecordCommandButton> { + bool isRecording = false; + + @override + Widget build(BuildContext context) { + return Column( + children: [ + AnimatedContainer( + duration: Duration(seconds: 1), + curve: Curves.easeInOut, + width: 60, // Adjust the button size as needed + height: 60, // Adjust the button size as needed + decoration: BoxDecoration( + shape: BoxShape.circle, + color: isRecording + ? Colors.red + : Colors.green, // Green when recording, red when not recording + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.5), + blurRadius: 5, + spreadRadius: 1, + ), + ], + ), + child: InkWell( + onTap: () { + // Toggle recording state + setState(() { + isRecording = !isRecording; + }); + // Call the callback function with the recording state + widget.onRecordingStateChanged(isRecording); + }, + child: Center( + child: Icon( + Icons.mic, // Microphone icon + size: 36, // Icon size + color: Colors.white, // Icon color + ), + ), + ), + ), + SizedBox(height: 8), // Add spacing between the button and text + Text( + isRecording ? 'Recording...' : 'Record Command', + style: TextStyle( + fontSize: 18, // Text size + fontWeight: FontWeight.bold, + ), + ), + ], + ); + } +} |