MIF_E31222653/adminkurir/lib/screens/courier/courier_chat_detail_screen....

189 lines
5.9 KiB
Dart

import 'package:flutter/material.dart';
class CourierChatDetailScreen extends StatelessWidget {
final String name;
final Widget avatar;
final String phone;
const CourierChatDetailScreen({
Key? key,
required this.name,
required this.avatar,
required this.phone,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
backgroundColor: Colors.white,
elevation: 0,
leading: IconButton(
icon: const Icon(Icons.arrow_back, color: Colors.black),
onPressed: () => Navigator.of(context).pop(),
),
titleSpacing: 0,
title: Row(
children: [
avatar,
const SizedBox(width: 10),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(name, style: const TextStyle(fontWeight: FontWeight.bold, color: Colors.black, fontSize: 16)),
Text(phone, style: const TextStyle(fontSize: 12, color: Colors.grey)),
],
),
],
),
actions: [
IconButton(
icon: const Icon(Icons.call, color: Colors.blue),
onPressed: () {},
),
IconButton(
icon: const Icon(Icons.more_vert, color: Colors.black),
onPressed: () {},
),
],
),
body: Stack(
children: [
// Background motif (pakai asset atau motif sederhana)
Positioned.fill(
child: Opacity(
opacity: 0.08,
child: Image.asset(
'assets/images/chat_bg.png',
fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) => Container(),
),
),
),
Column(
children: [
Expanded(
child: ListView(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
children: [
Align(
alignment: Alignment.centerRight,
child: _bubble(
text: 'Titik sesuai lokasi ya!',
time: '09:29',
isMe: true,
isRead: true,
),
),
const SizedBox(height: 8),
Align(
alignment: Alignment.centerLeft,
child: _bubble(
text: 'Ok, ditunggu yaa',
time: '09:30',
isMe: false,
isRead: false,
),
),
],
),
),
_inputBar(),
],
),
],
),
);
}
Widget _bubble({required String text, required String time, required bool isMe, required bool isRead}) {
return Container(
constraints: const BoxConstraints(maxWidth: 260),
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
decoration: BoxDecoration(
color: isMe ? Colors.blue : Colors.grey[200],
borderRadius: BorderRadius.only(
topLeft: const Radius.circular(16),
topRight: const Radius.circular(16),
bottomLeft: Radius.circular(isMe ? 16 : 4),
bottomRight: Radius.circular(isMe ? 4 : 16),
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
text,
style: TextStyle(
color: isMe ? Colors.white : Colors.black87,
fontSize: 14,
),
),
const SizedBox(height: 4),
Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(time, style: TextStyle(fontSize: 11, color: isMe ? Colors.white70 : Colors.grey)),
if (isMe) ...[
const SizedBox(width: 4),
Icon(Icons.done_all, size: 15, color: Colors.white70),
],
],
),
],
),
);
}
Widget _inputBar() {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 8),
color: Colors.white,
child: Row(
children: [
Expanded(
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 12),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(24),
border: Border.all(color: Colors.grey[300]!),
),
child: Row(
children: [
Icon(Icons.emoji_emotions_outlined, color: Colors.grey[500], size: 22),
const SizedBox(width: 6),
Expanded(
child: TextField(
decoration: const InputDecoration(
hintText: 'Ketik pesan di sini...',
border: InputBorder.none,
isDense: true,
contentPadding: EdgeInsets.symmetric(vertical: 8),
),
),
),
Icon(Icons.attach_file, color: Colors.grey[500], size: 20),
const SizedBox(width: 4),
Icon(Icons.camera_alt_outlined, color: Colors.grey[500], size: 20),
],
),
),
),
const SizedBox(width: 8),
Container(
decoration: const BoxDecoration(
color: Colors.blue,
shape: BoxShape.circle,
),
child: IconButton(
icon: const Icon(Icons.send, color: Colors.white),
onPressed: () {},
),
),
],
),
);
}
}