Skip to content

Commit

Permalink
changes in button_rows
Browse files Browse the repository at this point in the history
  • Loading branch information
Karol committed Jan 15, 2025
1 parent 80f94d8 commit 2a0888a
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 26 deletions.
4 changes: 2 additions & 2 deletions app/lib/pages/chat_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../providers/api_provider.dart';
import '../widgets/chat_bubble.dart';
import '../widgets/button_row.dart';
import '../widgets/button_row.dart'; // Import the ButtonRow widget
import 'package:file_picker/file_picker.dart';
import 'dart:typed_data';

Expand Down Expand Up @@ -119,7 +119,7 @@ class _ChatBodyState extends State<ChatBody> {
child: TextField(
controller: _controller,
style: const TextStyle(color: Colors.white),
onSubmitted: (_) => _sendMessage(), // Send message on Enter key press
onSubmitted: (_) => _sendMessage(),
decoration: const InputDecoration(
hintText: 'Type your message...',
hintStyle: TextStyle(color: Colors.white),
Expand Down
74 changes: 50 additions & 24 deletions app/lib/widgets/button_row.dart
Original file line number Diff line number Diff line change
@@ -1,40 +1,66 @@
import 'package:flutter/material.dart';

class ButtonRow extends StatelessWidget {
final void Function(String) onButtonPressed;
final Function(String) onButtonPressed;

const ButtonRow({Key? key, required this.onButtonPressed}) : super(key: key);

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildButton(context, 'Driving License'),
_buildButton(context, 'ID'),
_buildButton(context, 'Passport'),
_buildButton(context, 'Something else?'),
ElevatedButton(
onPressed: () => onButtonPressed("Driving License"),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.grey[800],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
minimumSize: const Size(100, 40), // Square button dimensions
),
child: const Text("Driving License", style: TextStyle(color: Colors.white)),
),
const SizedBox(width: 10),
ElevatedButton(
onPressed: () => onButtonPressed("ID"),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.grey[800],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
minimumSize: const Size(100, 40),
),
child: const Text("ID", style: TextStyle(color: Colors.white)),
),
const SizedBox(width: 10),
ElevatedButton(
onPressed: () => onButtonPressed("Passport"),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.grey[800],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
minimumSize: const Size(100, 40),
),
child: const Text("Passport", style: TextStyle(color: Colors.white)),
),
const SizedBox(width: 10),
ElevatedButton(
onPressed: () => onButtonPressed("Something Else"),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.grey[800],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
minimumSize: const Size(100, 40),
),
child: const Text("Something Else", style: TextStyle(color: Colors.white)),
),
],
),
);
}

Widget _buildButton(BuildContext context, String text) {
return ElevatedButton(
onPressed: () => onButtonPressed(text),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.grey[800], // Same color as the chat bubbles
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 12),
),
child: Text(
text,
style: const TextStyle(color: Colors.white),
),
);
}
}

0 comments on commit 2a0888a

Please sign in to comment.