Skip to content

Commit

Permalink
layout of chatscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
Hizar62 committed Sep 3, 2024
1 parent 0a5f321 commit 0dbd80f
Showing 2 changed files with 62 additions and 14 deletions.
19 changes: 19 additions & 0 deletions lib/components/chat_bubble.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:flutter/material.dart';

class chatBubble extends StatelessWidget {
final String message;
const chatBubble({super.key, required this.message});

@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8), color: Colors.blue),
child: Text(
message,
style: const TextStyle(fontSize: 16),
),
);
}
}
57 changes: 43 additions & 14 deletions lib/pages/chat_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:live/components/chat_bubble.dart';
import 'package:live/services/chat/chat_service.dart';

class ChatPage extends StatefulWidget {
@@ -95,27 +96,55 @@ class _ChatPageState extends State<ChatPage> {
Text(data['senderName'],
style: TextStyle(fontWeight: FontWeight.bold)),
SizedBox(height: 5),
Text(data[
'message']), // Corrected field name from 'messages' to 'message'
chatBubble(
message: data[
'message']) // Corrected field name from 'messages' to 'message'
],
),
);
}

// build message input
Widget _buildMessageInput() {
return Row(
children: [
Expanded(
child: TextFormField(
controller: _messageController,
obscureText: false,
decoration: const InputDecoration(hintText: 'Enter a Message'),
)),
IconButton(
onPressed: sendMessage,
icon: const Icon(Icons.arrow_upward_outlined))
],
return Padding(
padding:
const EdgeInsets.all(8.0), // Outer padding for the whole input row
child: Container(
decoration: BoxDecoration(
color: Colors.white, // Background color for the input field
borderRadius: BorderRadius.circular(30.0), // Rounded corners
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3), // Shadow position
),
],
),
child: Row(
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: TextFormField(
controller: _messageController,
obscureText: false,
decoration: const InputDecoration(
hintText: 'Enter a Message',
border: InputBorder.none, // Removes the default underline
),
),
),
),
IconButton(
onPressed: sendMessage,
icon: const Icon(Icons.arrow_upward_outlined),
color: Colors.redAccent, // Icon color
),
],
),
),
);
}
}

0 comments on commit 0dbd80f

Please sign in to comment.