aboutsummaryrefslogtreecommitdiffstats
path: root/lib/widgets/record_command_button.dart
blob: fdff772c39a7fdb84712b4e4ae13be6a85fd2b53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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,
          ),
        ),
      ],
    );
  }
}