aboutsummaryrefslogtreecommitdiffstats
path: root/lib/widgets/try_commands.dart
blob: 0670bd2064cb141d69e8b2b45fbdb4670f0422d9 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import 'package:flutter/material.dart';

class TryCommandsSection extends StatelessWidget {
  final Future<void> Function(String) onCommandTap; // Define a callback

  TryCommandsSection({required this.onCommandTap});

  @override
  Widget build(BuildContext context) {
    return SizedBox(
        width: double.infinity,
        child: Card(
          // padding: EdgeInsets.all(16),
          // decoration: BoxDecoration(
          //   borderRadius: BorderRadius.circular(12),
          // ),
          elevation: 4, // Add a subtle shadow
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(12),
          ),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Container(
                padding: EdgeInsets.fromLTRB(12, 12, 0, 0),
                child: Text(
                  "Try Commands",
                  style: TextStyle(
                    fontSize: 18,
                    fontWeight: FontWeight.bold,
                  ),
                  textAlign: TextAlign.left,
                ),
              ),
              Container(
                padding: EdgeInsets.fromLTRB(12, 0, 12, 0),
                child: Text(
                  "(Tap on any of the following commands to try them out)",
                  style: TextStyle(fontSize: 14, fontStyle: FontStyle.italic),
                  textAlign: TextAlign.left,
                ),
              ),
              SizedBox(height: 6),
              Container(
                padding: EdgeInsets.fromLTRB(12, 0, 12, 12),
                child: Wrap(
                  spacing: 10,
                  children: [
                    buildCommandButton("Set the volume to fifty percent"),
                    buildCommandButton("Set the fan speed to max"),
                    buildCommandButton(
                        "Increase the temperature by three degrees"),
                    buildCommandButton(
                        "Decrease the fan speed by five percent"),
                    buildCommandButton("Can you reduce the volume"),
                  ],
                ),
              ),
            ],
          ),
        ));
  }

  Widget buildCommandButton(String commandText) {
    return GestureDetector(
      onTap: () {
        onCommandTap(commandText);
      },
      child: Container(
        margin: EdgeInsets.all(6),
        padding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
        decoration: BoxDecoration(
          color: Colors.green.withOpacity(0.1),
          borderRadius: BorderRadius.circular(10),
          border: Border.all(color: Colors.green, width: 2),
        ),
        child: Text(
          commandText,
          style: TextStyle(
            color: Colors.green,
            fontWeight: FontWeight.bold,
          ),
        ),
      ),
    );
  }
}