206 lines
5.6 KiB
Dart
206 lines
5.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:Ulak/modules/messages/pages/chat_controller.dart';
|
|
|
|
class ChatPage extends GetView<ChatController> {
|
|
const ChatPage({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text("${Get.parameters['chatTitle']}"),
|
|
backgroundColor: Colors.amber,
|
|
),
|
|
body: Column(
|
|
children: [
|
|
ChatZone(messages: "controller.messages.value"),
|
|
MessageWriteBox(
|
|
messages: "controller.messages.value",
|
|
onChanged: (value) => {},
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class ChatZone extends StatelessWidget {
|
|
final String messages;
|
|
const ChatZone({super.key, required this.messages});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Expanded(
|
|
child: Container(
|
|
padding: EdgeInsets.symmetric(vertical: 10),
|
|
child: SingleChildScrollView(
|
|
child: Column(
|
|
spacing: 10,
|
|
|
|
children: [
|
|
Text(messages),
|
|
SendMessageBox(),
|
|
MyMessageBox(),
|
|
SendMessageBox(),
|
|
MyMessageBox(),
|
|
SendMessageBox(),
|
|
SendMessageBox(),
|
|
MyMessageBox(),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class SendMessageBox extends StatelessWidget {
|
|
const SendMessageBox({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
alignment: Alignment.centerLeft,
|
|
child: ConstrainedBox(
|
|
constraints: BoxConstraints(
|
|
maxWidth: MediaQuery.of(context).size.width / 1.4,
|
|
),
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(10),
|
|
),
|
|
margin: EdgeInsets.symmetric(horizontal: 10),
|
|
padding: EdgeInsets.all(10),
|
|
child: Column(
|
|
spacing: 10,
|
|
children: [
|
|
Container(
|
|
alignment: Alignment.centerLeft,
|
|
child: Text(
|
|
"Batuxan Coşkun",
|
|
style: TextStyle(fontWeight: FontWeight.bold),
|
|
),
|
|
),
|
|
Text(
|
|
"datadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadata",
|
|
),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: Text("14:53", style: TextStyle(fontSize: 12)),
|
|
),
|
|
Container(
|
|
alignment: AlignmentGeometry.centerStart,
|
|
child: Icon(Icons.remove_red_eye_sharp, size: 15),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class MyMessageBox extends StatelessWidget {
|
|
const MyMessageBox({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
alignment: Alignment.centerRight,
|
|
child: ConstrainedBox(
|
|
constraints: BoxConstraints(
|
|
maxWidth: MediaQuery.of(context).size.width / 1.4,
|
|
),
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors.amber,
|
|
borderRadius: BorderRadius.circular(10),
|
|
),
|
|
margin: EdgeInsets.symmetric(horizontal: 10),
|
|
padding: EdgeInsets.all(10),
|
|
child: Column(
|
|
spacing: 10,
|
|
children: [
|
|
Container(
|
|
alignment: Alignment.centerLeft,
|
|
child: Text(
|
|
"Batuxan Coşkun",
|
|
style: TextStyle(fontWeight: FontWeight.bold),
|
|
),
|
|
),
|
|
Text(
|
|
"datadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadata",
|
|
),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: Container(
|
|
alignment: AlignmentGeometry.centerStart,
|
|
child: Icon(Icons.remove_red_eye_sharp, size: 15),
|
|
),
|
|
),
|
|
Text("14:53", style: TextStyle(fontSize: 12)),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class MessageWriteBox extends StatelessWidget {
|
|
final String messages;
|
|
final Function(String) onChanged;
|
|
|
|
late final _textController = TextEditingController();
|
|
|
|
MessageWriteBox({super.key, required this.messages, required this.onChanged});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
padding: EdgeInsets.all(7),
|
|
child: SafeArea(
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: TextField(
|
|
decoration: InputDecoration(border: OutlineInputBorder()),
|
|
controller: _textController,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(width: 7),
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors.amber,
|
|
borderRadius: BorderRadius.circular(24),
|
|
),
|
|
child: IconButton(
|
|
onPressed: () {
|
|
onChanged(_textController.text);
|
|
},
|
|
icon: Icon(Icons.send_rounded),
|
|
color: Colors.black,
|
|
splashColor: Colors.amber,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|