minor changes
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1,4 +1,4 @@
|
|||||||
class ApiConfig {
|
class ApiConfig {
|
||||||
static const String baseUrl = "http://10.119.0.74:8000/api";
|
static const String baseUrl = "http://192.168.0.105:8000/api";
|
||||||
static const String fileBaseUrl = "http://10.119.0.74:8000/";
|
static const String fileBaseUrl = "http://192.168.0.105:8000/";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ class AppConfig {
|
|||||||
static const String logoUrlEmulator = "http://10.0.2.2:8000/images/kent_logo2.png";
|
static const String logoUrlEmulator = "http://10.0.2.2:8000/images/kent_logo2.png";
|
||||||
|
|
||||||
// For Physical Device (Replace with your actual PC local IP)
|
// For Physical Device (Replace with your actual PC local IP)
|
||||||
static const String logoUrlDevice = "http://10.119.0.74:8000/images/kent_logo2.png";
|
static const String logoUrlDevice = "http://192.168.0.105:8000/images/kent_logo2.png";
|
||||||
|
|
||||||
// Which one to use?
|
// Which one to use?
|
||||||
static const String logoUrl = logoUrlDevice; // CHANGE THIS WHEN TESTING ON REAL DEVICE
|
static const String logoUrl = logoUrlDevice; // CHANGE THIS WHEN TESTING ON REAL DEVICE
|
||||||
|
|||||||
@@ -1,18 +1,14 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
import 'dart:io';
|
||||||
|
import 'package:file_selector/file_selector.dart';
|
||||||
|
|
||||||
import '../services/chat_service.dart';
|
import '../services/chat_service.dart';
|
||||||
import '../services/reverb_socket_service.dart';
|
import '../services/reverb_socket_service.dart';
|
||||||
import '../services/dio_client.dart';
|
import '../services/dio_client.dart';
|
||||||
import '../providers/chat_unread_provider.dart';
|
import '../providers/chat_unread_provider.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
|
||||||
import 'dart:io';
|
|
||||||
import 'package:file_selector/file_selector.dart';
|
|
||||||
import 'chat_file_viewer.dart';
|
|
||||||
import '../widgets/chat_file_preview.dart';
|
import '../widgets/chat_file_preview.dart';
|
||||||
|
import 'chat_file_viewer.dart';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ChatScreen extends StatefulWidget {
|
class ChatScreen extends StatefulWidget {
|
||||||
const ChatScreen({super.key});
|
const ChatScreen({super.key});
|
||||||
@@ -24,6 +20,7 @@ class ChatScreen extends StatefulWidget {
|
|||||||
class _ChatScreenState extends State<ChatScreen> {
|
class _ChatScreenState extends State<ChatScreen> {
|
||||||
final TextEditingController _messageCtrl = TextEditingController();
|
final TextEditingController _messageCtrl = TextEditingController();
|
||||||
final ScrollController _scrollCtrl = ScrollController();
|
final ScrollController _scrollCtrl = ScrollController();
|
||||||
|
|
||||||
Map<String, dynamic>? uploadingMessage;
|
Map<String, dynamic>? uploadingMessage;
|
||||||
|
|
||||||
late ChatService _chatService;
|
late ChatService _chatService;
|
||||||
@@ -33,22 +30,18 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
List<Map<String, dynamic>> messages = [];
|
List<Map<String, dynamic>> messages = [];
|
||||||
bool isLoading = true;
|
bool isLoading = true;
|
||||||
|
|
||||||
// ============================
|
|
||||||
// INIT STATE
|
|
||||||
// ============================
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
_chatService = ChatService(DioClient.getInstance(context));
|
_chatService = ChatService(DioClient.getInstance(context));
|
||||||
|
|
||||||
// 🔔 Mark chat as OPEN (important)
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
context.read<ChatUnreadProvider>().setChatOpen(true);
|
context.read<ChatUnreadProvider>().setChatOpen(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
_initChat();
|
_initChat();
|
||||||
}
|
}
|
||||||
|
|
||||||
String _guessMimeType(String path) {
|
String _guessMimeType(String path) {
|
||||||
final lower = path.toLowerCase();
|
final lower = path.toLowerCase();
|
||||||
if (lower.endsWith('.jpg') || lower.endsWith('.png')) return 'image/*';
|
if (lower.endsWith('.jpg') || lower.endsWith('.png')) return 'image/*';
|
||||||
@@ -63,7 +56,6 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
|
|
||||||
final file = File(picked.path);
|
final file = File(picked.path);
|
||||||
|
|
||||||
// 1️⃣ Show uploading UI
|
|
||||||
setState(() {
|
setState(() {
|
||||||
uploadingMessage = {
|
uploadingMessage = {
|
||||||
'local_file': file,
|
'local_file': file,
|
||||||
@@ -72,44 +64,26 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
// 2️⃣ Upload (NO adding message)
|
|
||||||
await _chatService.sendFile(
|
await _chatService.sendFile(
|
||||||
ticketId!,
|
ticketId!,
|
||||||
file,
|
file,
|
||||||
onProgress: (progress) {
|
onProgress: (progress) {
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
setState(() {
|
setState(() => uploadingMessage!['progress'] = progress);
|
||||||
uploadingMessage!['progress'] = progress;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// 3️⃣ Remove sending bubble ONLY
|
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
setState(() {
|
setState(() => uploadingMessage = null);
|
||||||
uploadingMessage = null;
|
|
||||||
});
|
|
||||||
|
|
||||||
// 🚫 DO NOT add message here
|
|
||||||
// WebSocket will handle it
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ============================
|
|
||||||
// INIT CHAT
|
|
||||||
// ============================
|
|
||||||
Future<void> _initChat() async {
|
Future<void> _initChat() async {
|
||||||
// 1️⃣ Start chat
|
|
||||||
final ticketRes = await _chatService.startChat();
|
final ticketRes = await _chatService.startChat();
|
||||||
ticketId = ticketRes['ticket']['id'];
|
ticketId = ticketRes['ticket']['id'];
|
||||||
|
|
||||||
// 2️⃣ Load messages
|
|
||||||
final msgs = await _chatService.getMessages(ticketId!);
|
final msgs = await _chatService.getMessages(ticketId!);
|
||||||
messages = List<Map<String, dynamic>>.from(msgs);
|
messages = List<Map<String, dynamic>>.from(msgs);
|
||||||
|
|
||||||
// 3️⃣ Realtime socket
|
|
||||||
await _socket.connect(
|
await _socket.connect(
|
||||||
context: context,
|
context: context,
|
||||||
ticketId: ticketId!,
|
ticketId: ticketId!,
|
||||||
@@ -117,20 +91,12 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
final incomingClientId = msg['client_id'];
|
final incomingClientId = msg['client_id'];
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
// 🧹 Remove local temp message with same client_id
|
messages.removeWhere((m) => m['client_id'] == incomingClientId);
|
||||||
messages.removeWhere(
|
|
||||||
(m) => m['client_id'] != null &&
|
|
||||||
m['client_id'] == incomingClientId,
|
|
||||||
);
|
|
||||||
|
|
||||||
// ✅ Add confirmed socket message
|
|
||||||
messages.add(msg);
|
messages.add(msg);
|
||||||
});
|
});
|
||||||
|
|
||||||
_scrollToBottom();
|
_scrollToBottom();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
onAdminMessage: () {
|
onAdminMessage: () {
|
||||||
if (!mounted) {
|
if (!mounted) {
|
||||||
context.read<ChatUnreadProvider>().increment();
|
context.read<ChatUnreadProvider>().increment();
|
||||||
@@ -138,37 +104,30 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
setState(() => isLoading = false);
|
setState(() => isLoading = false);
|
||||||
_scrollToBottom();
|
_scrollToBottom();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================
|
|
||||||
// SCROLL
|
|
||||||
// ============================
|
|
||||||
void _scrollToBottom() {
|
void _scrollToBottom() {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
if (_scrollCtrl.hasClients) {
|
if (_scrollCtrl.hasClients) {
|
||||||
_scrollCtrl.jumpTo(_scrollCtrl.position.maxScrollExtent);
|
_scrollCtrl.animateTo(
|
||||||
|
_scrollCtrl.position.maxScrollExtent,
|
||||||
|
duration: const Duration(milliseconds: 250),
|
||||||
|
curve: Curves.easeOut,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================
|
|
||||||
// SEND MESSAGE
|
|
||||||
// ============================
|
|
||||||
Future<void> _sendMessage() async {
|
Future<void> _sendMessage() async {
|
||||||
final text = _messageCtrl.text.trim();
|
final text = _messageCtrl.text.trim();
|
||||||
if (text.isEmpty || ticketId == null) return;
|
if (text.isEmpty || ticketId == null) return;
|
||||||
|
|
||||||
_messageCtrl.clear();
|
_messageCtrl.clear();
|
||||||
|
|
||||||
final clientId = DateTime.now().millisecondsSinceEpoch.toString();
|
final clientId = DateTime.now().millisecondsSinceEpoch.toString();
|
||||||
|
|
||||||
// 1️⃣ ADD LOCAL MESSAGE IMMEDIATELY
|
|
||||||
setState(() {
|
setState(() {
|
||||||
messages.add({
|
messages.add({
|
||||||
'client_id': clientId,
|
'client_id': clientId,
|
||||||
@@ -182,7 +141,6 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
|
|
||||||
_scrollToBottom();
|
_scrollToBottom();
|
||||||
|
|
||||||
// 2️⃣ SEND TO SERVER
|
|
||||||
await _chatService.sendMessage(
|
await _chatService.sendMessage(
|
||||||
ticketId!,
|
ticketId!,
|
||||||
message: text,
|
message: text,
|
||||||
@@ -190,28 +148,68 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ============================
|
|
||||||
// DISPOSE
|
|
||||||
// ============================
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
// 🔕 Mark chat CLOSED
|
|
||||||
context.read<ChatUnreadProvider>().setChatOpen(false);
|
context.read<ChatUnreadProvider>().setChatOpen(false);
|
||||||
|
|
||||||
_socket.disconnect();
|
_socket.disconnect();
|
||||||
_messageCtrl.dispose();
|
_messageCtrl.dispose();
|
||||||
_scrollCtrl.dispose();
|
_scrollCtrl.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================
|
|
||||||
// UI
|
|
||||||
// ============================
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(title: const Text("Support Chat")),
|
appBar: PreferredSize(
|
||||||
|
preferredSize: const Size.fromHeight(56),
|
||||||
|
child: AnimatedContainer(
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
curve: Curves.easeInOut,
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
gradient: LinearGradient(
|
||||||
|
colors: [
|
||||||
|
Color(0xFF2196F3),
|
||||||
|
Color(0xFF1565C0),
|
||||||
|
],
|
||||||
|
begin: Alignment.topLeft,
|
||||||
|
end: Alignment.bottomRight,
|
||||||
|
),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black26,
|
||||||
|
blurRadius: 10,
|
||||||
|
offset: Offset(0, 3),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: AppBar(
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
elevation: 0,
|
||||||
|
leading: Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 12),
|
||||||
|
child: CircleAvatar(
|
||||||
|
radius: 18,
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
child: Icon(
|
||||||
|
Icons.support_agent,
|
||||||
|
color: Colors.blue,
|
||||||
|
size: 20,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
title: const Text(
|
||||||
|
"Support Chat",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
fontSize: 18,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
centerTitle: false,
|
||||||
|
iconTheme: const IconThemeData(color: Colors.white),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
body: isLoading
|
body: isLoading
|
||||||
? const Center(child: CircularProgressIndicator())
|
? const Center(child: CircularProgressIndicator())
|
||||||
: Column(
|
: Column(
|
||||||
@@ -223,100 +221,54 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Future<void> _openUrl(String url) async {
|
|
||||||
// final uri = Uri.parse(url);
|
|
||||||
//
|
|
||||||
// if (await canLaunchUrl(uri)) {
|
|
||||||
// await launchUrl(
|
|
||||||
// uri,
|
|
||||||
// mode: LaunchMode.externalApplication,
|
|
||||||
// );
|
|
||||||
// } else {
|
|
||||||
// debugPrint("❌ Cannot launch URL: $url");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Widget _buildMessageContent({
|
|
||||||
String? message,
|
|
||||||
String? filePath,
|
|
||||||
String? fileType,
|
|
||||||
required bool isUser,
|
|
||||||
}) {
|
|
||||||
final textColor = isUser ? Colors.white : Colors.black;
|
|
||||||
|
|
||||||
if (filePath == null) {
|
|
||||||
return Text(message ?? '', style: TextStyle(color: textColor));
|
|
||||||
}
|
|
||||||
|
|
||||||
final url = "${DioClient.baseUrl}/storage/$filePath";
|
|
||||||
|
|
||||||
return GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
ChatFileViewer.open(
|
|
||||||
context,
|
|
||||||
url: url,
|
|
||||||
fileType: fileType ?? '',
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Icon(_iconForFile(fileType), color: textColor),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Text(
|
|
||||||
_labelForFile(fileType),
|
|
||||||
style: TextStyle(color: textColor),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
IconData _iconForFile(String? type) {
|
|
||||||
if (type == null) return Icons.insert_drive_file;
|
|
||||||
if (type.startsWith('image/')) return Icons.image;
|
|
||||||
if (type.startsWith('video/')) return Icons.play_circle_fill;
|
|
||||||
if (type == 'application/pdf') return Icons.picture_as_pdf;
|
|
||||||
return Icons.insert_drive_file;
|
|
||||||
}
|
|
||||||
|
|
||||||
String _labelForFile(String? type) {
|
|
||||||
if (type == null) return "File";
|
|
||||||
if (type.startsWith('image/')) return "Image";
|
|
||||||
if (type.startsWith('video/')) return "Video";
|
|
||||||
if (type == 'application/pdf') return "PDF";
|
|
||||||
return "Download file";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Widget _buildMessages() {
|
Widget _buildMessages() {
|
||||||
return ListView(
|
return ListView(
|
||||||
controller: _scrollCtrl,
|
controller: _scrollCtrl,
|
||||||
padding: const EdgeInsets.all(12),
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||||
children: [
|
children: [
|
||||||
// EXISTING MESSAGES
|
|
||||||
...messages.map((msg) {
|
...messages.map((msg) {
|
||||||
final isUser = msg['sender_type'] == 'App\\Models\\User';
|
final isUser = msg['sender_type'] == 'App\\Models\\User';
|
||||||
|
|
||||||
return Align(
|
return Align(
|
||||||
alignment: isUser ? Alignment.centerRight : Alignment.centerLeft,
|
alignment:
|
||||||
|
isUser ? Alignment.centerRight : Alignment.centerLeft,
|
||||||
child: Container(
|
child: Container(
|
||||||
|
constraints: const BoxConstraints(maxWidth: 280),
|
||||||
margin: const EdgeInsets.symmetric(vertical: 6),
|
margin: const EdgeInsets.symmetric(vertical: 6),
|
||||||
padding: const EdgeInsets.all(10),
|
padding: const EdgeInsets.all(12),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: isUser ? Colors.blue : Colors.grey.shade300,
|
color: isUser ? null : Colors.white,
|
||||||
borderRadius: BorderRadius.circular(12),
|
gradient: isUser
|
||||||
|
? LinearGradient(
|
||||||
|
colors: [
|
||||||
|
Colors.lightBlueAccent,
|
||||||
|
Colors.blue.shade700,
|
||||||
|
],
|
||||||
|
begin: Alignment.topLeft,
|
||||||
|
end: Alignment.bottomRight,
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
borderRadius: BorderRadius.only(
|
||||||
|
topLeft: const Radius.circular(16),
|
||||||
|
topRight: const Radius.circular(16),
|
||||||
|
bottomLeft:
|
||||||
|
isUser ? const Radius.circular(16) : Radius.zero,
|
||||||
|
bottomRight:
|
||||||
|
isUser ? Radius.zero : const Radius.circular(16),
|
||||||
|
),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black.withOpacity(0.05),
|
||||||
|
blurRadius: 6,
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
child: msg['file_path'] == null
|
child: msg['file_path'] == null
|
||||||
? Text(
|
? Text(
|
||||||
msg['message'] ?? '',
|
msg['message'] ?? '',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: isUser ? Colors.white : Colors.black,
|
color: isUser ? Colors.white : Colors.blue,
|
||||||
|
fontSize: 15,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: ChatFilePreview(
|
: ChatFilePreview(
|
||||||
@@ -327,53 +279,26 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
// ⏳ UPLOADING MESSAGE
|
|
||||||
if (uploadingMessage != null)
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.centerRight,
|
|
||||||
child: Container(
|
|
||||||
margin: const EdgeInsets.symmetric(vertical: 6),
|
|
||||||
padding: const EdgeInsets.all(10),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.blue,
|
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
ChatFilePreview(
|
|
||||||
filePath: uploadingMessage!['local_file'].path,
|
|
||||||
fileType: uploadingMessage!['file_type'],
|
|
||||||
isUser: true,
|
|
||||||
isLocal: true,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
LinearProgressIndicator(
|
|
||||||
value: uploadingMessage!['progress'],
|
|
||||||
backgroundColor: Colors.white24,
|
|
||||||
valueColor:
|
|
||||||
const AlwaysStoppedAnimation(Colors.white),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
const Text(
|
|
||||||
"Sending…",
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 12,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Widget _buildInput() {
|
Widget _buildInput() {
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(24),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black.withOpacity(0.05),
|
||||||
|
blurRadius: 6,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
IconButton(
|
IconButton(
|
||||||
@@ -384,18 +309,19 @@ class _ChatScreenState extends State<ChatScreen> {
|
|||||||
child: TextField(
|
child: TextField(
|
||||||
controller: _messageCtrl,
|
controller: _messageCtrl,
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
hintText: "Type message",
|
hintText: "Type a message…",
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.send),
|
icon: const Icon(Icons.send, color: Colors.blue),
|
||||||
onPressed: _sendMessage,
|
onPressed: _sendMessage,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -541,7 +541,22 @@ class _DashboardScreenState extends State<DashboardScreen>
|
|||||||
vertical: 6 * scale,
|
vertical: 6 * scale,
|
||||||
),
|
),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white.withOpacity(.2),
|
gradient: (m['status'] ?? '')
|
||||||
|
.toString()
|
||||||
|
.toLowerCase() ==
|
||||||
|
'active'
|
||||||
|
? const LinearGradient(
|
||||||
|
colors: [
|
||||||
|
Color(0xFF2ECC71), // Green
|
||||||
|
Color(0xFF16A085), // Teal Green
|
||||||
|
],
|
||||||
|
)
|
||||||
|
: const LinearGradient(
|
||||||
|
colors: [
|
||||||
|
Color(0xFFE74C3C), // Red
|
||||||
|
Color(0xFFC0392B), // Dark Red
|
||||||
|
],
|
||||||
|
),
|
||||||
borderRadius: BorderRadius.circular(8 * scale),
|
borderRadius: BorderRadius.circular(8 * scale),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -552,7 +567,7 @@ class _DashboardScreenState extends State<DashboardScreen>
|
|||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -24,19 +24,16 @@ class _MarkListScreenState extends State<MarkListScreen> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final marks = Provider.of<MarkListProvider>(context);
|
final marks = Provider.of<MarkListProvider>(context);
|
||||||
|
|
||||||
// Responsive scale factor
|
|
||||||
final screenWidth = MediaQuery.of(context).size.width;
|
final screenWidth = MediaQuery.of(context).size.width;
|
||||||
final scale = (screenWidth / 390).clamp(0.82, 1.35);
|
final scale = (screenWidth / 390).clamp(0.82, 1.35);
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
|
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
iconTheme: const IconThemeData(color: Colors.black),
|
iconTheme: const IconThemeData(color: Colors.black),
|
||||||
|
|
||||||
title: Text(
|
title: Text(
|
||||||
"All Mark Numbers",
|
"All Mark Numbers",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
@@ -50,14 +47,31 @@ class _MarkListScreenState extends State<MarkListScreen> {
|
|||||||
body: marks.loading
|
body: marks.loading
|
||||||
? const Center(child: CircularProgressIndicator())
|
? const Center(child: CircularProgressIndicator())
|
||||||
: ListView.builder(
|
: ListView.builder(
|
||||||
padding: EdgeInsets.all(10 * scale), // smaller padding
|
padding: EdgeInsets.all(10 * scale),
|
||||||
itemCount: marks.marks.length,
|
itemCount: marks.marks.length,
|
||||||
itemBuilder: (_, i) {
|
itemBuilder: (_, i) {
|
||||||
final m = marks.marks[i];
|
final m = marks.marks[i];
|
||||||
|
final status =
|
||||||
|
(m['status'] ?? '').toString().toLowerCase();
|
||||||
|
|
||||||
|
final LinearGradient statusGradient =
|
||||||
|
status == 'active'
|
||||||
|
? const LinearGradient(
|
||||||
|
colors: [
|
||||||
|
Color(0xFF2ECC71), // Green
|
||||||
|
Color(0xFF1E8449), // Deep Emerald
|
||||||
|
],
|
||||||
|
)
|
||||||
|
: const LinearGradient(
|
||||||
|
colors: [
|
||||||
|
Color(0xFFE74C3C), // Red
|
||||||
|
Color(0xFFC0392B), // Dark Red
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
margin: EdgeInsets.only(bottom: 10 * scale), // reduced margin
|
margin: EdgeInsets.only(bottom: 10 * scale),
|
||||||
padding: EdgeInsets.all(12 * scale), // smaller padding
|
padding: EdgeInsets.all(12 * scale),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: const LinearGradient(
|
gradient: const LinearGradient(
|
||||||
colors: [
|
colors: [
|
||||||
@@ -67,16 +81,15 @@ class _MarkListScreenState extends State<MarkListScreen> {
|
|||||||
begin: Alignment.topLeft,
|
begin: Alignment.topLeft,
|
||||||
end: Alignment.bottomRight,
|
end: Alignment.bottomRight,
|
||||||
),
|
),
|
||||||
borderRadius: BorderRadius.circular(14 * scale), // smaller radius
|
borderRadius: BorderRadius.circular(14 * scale),
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
color: Colors.black.withOpacity(0.06),
|
color: Colors.black.withOpacity(0.06),
|
||||||
blurRadius: 5 * scale, // smaller shadow
|
blurRadius: 5 * scale,
|
||||||
offset: Offset(0, 2 * scale),
|
offset: Offset(0, 2 * scale),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@@ -85,24 +98,20 @@ class _MarkListScreenState extends State<MarkListScreen> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
// MARK NUMBER
|
|
||||||
Text(
|
Text(
|
||||||
m['mark_no'],
|
m['mark_no'],
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 16 * scale, // reduced font
|
fontSize: 16 * scale,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
SizedBox(height: 3 * scale),
|
SizedBox(height: 3 * scale),
|
||||||
|
|
||||||
// ROUTE
|
|
||||||
Text(
|
Text(
|
||||||
"${m['origin']} → ${m['destination']}",
|
"${m['origin']} → ${m['destination']}",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 13 * scale, // reduced font
|
fontSize: 13 * scale,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -110,21 +119,21 @@ class _MarkListScreenState extends State<MarkListScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
// STATUS BADGE
|
// STATUS BADGE (GREEN / RED)
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
horizontal: 10 * scale,
|
horizontal: 10 * scale,
|
||||||
vertical: 5 * scale, // smaller badge
|
vertical: 5 * scale,
|
||||||
),
|
),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white.withOpacity(0.92),
|
gradient: statusGradient,
|
||||||
borderRadius: BorderRadius.circular(24 * scale),
|
borderRadius: BorderRadius.circular(20 * scale),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
m['status'],
|
m['status'],
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 11.5 * scale,
|
fontSize: 11.5 * scale,
|
||||||
color: Colors.black87,
|
color: Colors.white,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ class _OrderInvoiceScreenState extends State<OrderInvoiceScreen>
|
|||||||
children: [
|
children: [
|
||||||
_headerCard(scale),
|
_headerCard(scale),
|
||||||
|
|
||||||
// SUMMARY SECTION
|
|
||||||
_sectionHeader("Invoice Summary", Icons.receipt, s1, () {
|
_sectionHeader("Invoice Summary", Icons.receipt, s1, () {
|
||||||
setState(() => s1 = !s1);
|
setState(() => s1 = !s1);
|
||||||
}, scale),
|
}, scale),
|
||||||
@@ -92,12 +91,8 @@ class _OrderInvoiceScreenState extends State<OrderInvoiceScreen>
|
|||||||
_detailRow(Icons.numbers, "Invoice No", invoice['invoice_number'], scale),
|
_detailRow(Icons.numbers, "Invoice No", invoice['invoice_number'], scale),
|
||||||
_detailRow(Icons.calendar_month, "Invoice Date", invoice['invoice_date'], scale),
|
_detailRow(Icons.calendar_month, "Invoice Date", invoice['invoice_date'], scale),
|
||||||
_detailRow(Icons.date_range, "Due Date", invoice['due_date'], scale),
|
_detailRow(Icons.date_range, "Due Date", invoice['due_date'], scale),
|
||||||
// _detailRow(Icons.payment, "Payment Method", invoice['payment_method'], scale),
|
|
||||||
// _detailRow(Icons.confirmation_number, "Reference No",
|
|
||||||
// invoice['reference_no'], scale),
|
|
||||||
], scale),
|
], scale),
|
||||||
|
|
||||||
// AMOUNT SECTION
|
|
||||||
_sectionHeader("Amount Details", Icons.currency_rupee, s2, () {
|
_sectionHeader("Amount Details", Icons.currency_rupee, s2, () {
|
||||||
setState(() => s2 = !s2);
|
setState(() => s2 = !s2);
|
||||||
}, scale),
|
}, scale),
|
||||||
@@ -109,7 +104,6 @@ class _OrderInvoiceScreenState extends State<OrderInvoiceScreen>
|
|||||||
invoice['final_amount_with_gst'], scale),
|
invoice['final_amount_with_gst'], scale),
|
||||||
], scale),
|
], scale),
|
||||||
|
|
||||||
// CUSTOMER SECTION
|
|
||||||
_sectionHeader("Customer Details", Icons.person, s3, () {
|
_sectionHeader("Customer Details", Icons.person, s3, () {
|
||||||
setState(() => s3 = !s3);
|
setState(() => s3 = !s3);
|
||||||
}, scale),
|
}, scale),
|
||||||
@@ -121,7 +115,6 @@ class _OrderInvoiceScreenState extends State<OrderInvoiceScreen>
|
|||||||
_detailRow(Icons.location_on, "Address", invoice['customer_address'], scale),
|
_detailRow(Icons.location_on, "Address", invoice['customer_address'], scale),
|
||||||
], scale),
|
], scale),
|
||||||
|
|
||||||
// ITEMS SECTION
|
|
||||||
_sectionHeader("Invoice Items", Icons.shopping_cart, s4, () {
|
_sectionHeader("Invoice Items", Icons.shopping_cart, s4, () {
|
||||||
setState(() => s4 = !s4);
|
setState(() => s4 = !s4);
|
||||||
}, scale),
|
}, scale),
|
||||||
@@ -139,44 +132,63 @@ class _OrderInvoiceScreenState extends State<OrderInvoiceScreen>
|
|||||||
|
|
||||||
// ---------------- HEADER CARD ----------------
|
// ---------------- HEADER CARD ----------------
|
||||||
Widget _headerCard(double scale) {
|
Widget _headerCard(double scale) {
|
||||||
|
final statusColor = getInvoiceStatusColor(invoice["status"]);
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.all(18 * scale),
|
padding: EdgeInsets.all(18 * scale),
|
||||||
margin: EdgeInsets.only(bottom: 18 * scale),
|
margin: EdgeInsets.only(bottom: 18 * scale),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient:
|
gradient: LinearGradient(
|
||||||
LinearGradient(colors: [Colors.indigo.shade400, Colors.blue.shade600]),
|
colors: [Colors.indigo.shade400, Colors.blue.shade600],
|
||||||
|
),
|
||||||
borderRadius: BorderRadius.circular(16 * scale),
|
borderRadius: BorderRadius.circular(16 * scale),
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
blurRadius: 10 * scale,
|
blurRadius: 10 * scale,
|
||||||
color: Colors.black.withOpacity(.15),
|
color: Colors.black.withOpacity(.15),
|
||||||
offset: Offset(0, 3 * scale))
|
offset: Offset(0, 3 * scale),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text("Invoice #${invoice['invoice_number'] ?? '-'}",
|
Text(
|
||||||
|
"Invoice #${invoice['invoice_number'] ?? '-'}",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 22 * scale,
|
fontSize: 22 * scale,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: Colors.white)),
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
SizedBox(height: 6 * scale),
|
SizedBox(height: 6 * scale),
|
||||||
Text("Date: ${invoice['invoice_date'] ?? '-'}",
|
Text(
|
||||||
style: TextStyle(color: Colors.white70, fontSize: 14 * scale)),
|
"Date: ${invoice['invoice_date'] ?? '-'}",
|
||||||
|
style: TextStyle(color: Colors.white70, fontSize: 14 * scale),
|
||||||
|
),
|
||||||
SizedBox(height: 10 * scale),
|
SizedBox(height: 10 * scale),
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
vertical: 6 * scale, horizontal: 14 * scale),
|
vertical: 6 * scale, horizontal: 14 * scale),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white.withOpacity(.2),
|
color: Colors.white, // ✅ Always white
|
||||||
borderRadius: BorderRadius.circular(50 * scale),
|
borderRadius: BorderRadius.circular(50 * scale),
|
||||||
|
border: Border.all(
|
||||||
|
color: statusColor, // ✅ Different for each status
|
||||||
|
width: 1.4 * scale,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
invoice["status"]?.toString() ?? "Unknown",
|
(invoice["status"] ?? "Unknown").toString().toUpperCase(),
|
||||||
style: TextStyle(color: Colors.white, fontSize: 14 * scale),
|
style: TextStyle(
|
||||||
|
color: statusColor, // ✅ Text color changes
|
||||||
|
fontSize: 14 * scale,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
letterSpacing: 0.5,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -199,11 +211,14 @@ class _OrderInvoiceScreenState extends State<OrderInvoiceScreen>
|
|||||||
children: [
|
children: [
|
||||||
Icon(icon, color: Colors.white, size: 20 * scale),
|
Icon(icon, color: Colors.white, size: 20 * scale),
|
||||||
SizedBox(width: 10 * scale),
|
SizedBox(width: 10 * scale),
|
||||||
Text(title,
|
Text(
|
||||||
|
title,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
fontSize: 15 * scale,
|
fontSize: 15 * scale,
|
||||||
color: Colors.white)),
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
AnimatedRotation(
|
AnimatedRotation(
|
||||||
turns: expanded ? .5 : 0,
|
turns: expanded ? .5 : 0,
|
||||||
@@ -236,7 +251,8 @@ class _OrderInvoiceScreenState extends State<OrderInvoiceScreen>
|
|||||||
BoxShadow(
|
BoxShadow(
|
||||||
blurRadius: 8 * scale,
|
blurRadius: 8 * scale,
|
||||||
offset: Offset(0, 3 * scale),
|
offset: Offset(0, 3 * scale),
|
||||||
color: Colors.black.withOpacity(.08)),
|
color: Colors.black.withOpacity(.08),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
child: Column(children: children),
|
child: Column(children: children),
|
||||||
@@ -256,16 +272,19 @@ class _OrderInvoiceScreenState extends State<OrderInvoiceScreen>
|
|||||||
Icon(icon, color: Colors.blueGrey, size: 20 * scale),
|
Icon(icon, color: Colors.blueGrey, size: 20 * scale),
|
||||||
SizedBox(width: 10 * scale),
|
SizedBox(width: 10 * scale),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(label,
|
child: Text(
|
||||||
style: TextStyle(
|
label,
|
||||||
color: Colors.grey.shade700, fontSize: 14 * scale)),
|
style: TextStyle(color: Colors.grey.shade700, fontSize: 14 * scale),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
value?.toString() ?? "N/A",
|
value?.toString() ?? "N/A",
|
||||||
textAlign: TextAlign.end,
|
textAlign: TextAlign.end,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold, fontSize: 15 * scale),
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 15 * scale,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
@@ -289,14 +308,14 @@ class _OrderInvoiceScreenState extends State<OrderInvoiceScreen>
|
|||||||
BoxShadow(
|
BoxShadow(
|
||||||
blurRadius: 8 * scale,
|
blurRadius: 8 * scale,
|
||||||
offset: Offset(0, 3 * scale),
|
offset: Offset(0, 3 * scale),
|
||||||
color: Colors.black.withOpacity(.08)),
|
color: Colors.black.withOpacity(.08),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
border: Border.all(color: Colors.grey.shade300, width: 1),
|
border: Border.all(color: Colors.grey.shade300, width: 1),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
// TITLE
|
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
@@ -313,15 +332,14 @@ class _OrderInvoiceScreenState extends State<OrderInvoiceScreen>
|
|||||||
child: Text(
|
child: Text(
|
||||||
item['description'] ?? "Item",
|
item['description'] ?? "Item",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 16 * scale, fontWeight: FontWeight.w600),
|
fontSize: 16 * scale,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
SizedBox(height: 14 * scale),
|
SizedBox(height: 14 * scale),
|
||||||
|
|
||||||
// QTY & PRICE
|
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
@@ -329,10 +347,7 @@ class _OrderInvoiceScreenState extends State<OrderInvoiceScreen>
|
|||||||
_itemBadge(Icons.currency_rupee, "Price", "₹$price", false, scale),
|
_itemBadge(Icons.currency_rupee, "Price", "₹$price", false, scale),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
SizedBox(height: 12 * scale),
|
SizedBox(height: 12 * scale),
|
||||||
|
|
||||||
// TOTAL
|
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
vertical: 10 * scale, horizontal: 14 * scale),
|
vertical: 10 * scale, horizontal: 14 * scale),
|
||||||
@@ -385,7 +400,8 @@ class _OrderInvoiceScreenState extends State<OrderInvoiceScreen>
|
|||||||
color: highlight ? Colors.indigo.shade50 : Colors.grey.shade100,
|
color: highlight ? Colors.indigo.shade50 : Colors.grey.shade100,
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: highlight ? Colors.indigo : Colors.grey.shade300,
|
color: highlight ? Colors.indigo : Colors.grey.shade300,
|
||||||
width: highlight ? 1.5 * scale : 1),
|
width: highlight ? 1.5 * scale : 1,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
@@ -414,3 +430,22 @@ class _OrderInvoiceScreenState extends State<OrderInvoiceScreen>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------- STATUS COLOR HELPER ----------------
|
||||||
|
|
||||||
|
Color getInvoiceStatusColor(String? status) {
|
||||||
|
final s = (status ?? '')
|
||||||
|
.toLowerCase()
|
||||||
|
.replaceAll('_', ' ')
|
||||||
|
.replaceAll('-', ' ')
|
||||||
|
.trim();
|
||||||
|
|
||||||
|
if (s == 'paid') return Colors.green.shade600;
|
||||||
|
if (s == 'pending') return Colors.orange.shade600;
|
||||||
|
if (s == 'overdue') return Colors.red.shade600;
|
||||||
|
if (s == 'cancelled' || s == 'canceled') return Colors.grey.shade600;
|
||||||
|
if (s == 'in progress') return Colors.blue.shade600;
|
||||||
|
if (s == 'draft') return Colors.purple.shade600;
|
||||||
|
|
||||||
|
return Colors.blueGrey;
|
||||||
|
}
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ class _OrdersScreenState extends State<OrdersScreen> {
|
|||||||
final screenWidth = MediaQuery.of(context).size.width;
|
final screenWidth = MediaQuery.of(context).size.width;
|
||||||
final scale = (screenWidth / 420).clamp(0.85, 1.15);
|
final scale = (screenWidth / 420).clamp(0.85, 1.15);
|
||||||
|
|
||||||
// FILTER ORDERS
|
|
||||||
final filteredOrders = provider.orders.where((o) {
|
final filteredOrders = provider.orders.where((o) {
|
||||||
final q = searchQuery.toLowerCase();
|
final q = searchQuery.toLowerCase();
|
||||||
return o["order_id"].toString().toLowerCase().contains(q) ||
|
return o["order_id"].toString().toLowerCase().contains(q) ||
|
||||||
@@ -45,7 +44,7 @@ class _OrdersScreenState extends State<OrdersScreen> {
|
|||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
// ⭐⭐ WHITE ELEVATED SEARCH BAR ⭐⭐
|
// SEARCH BAR
|
||||||
Container(
|
Container(
|
||||||
margin: EdgeInsets.fromLTRB(16 * scale, 16 * scale, 16 * scale, 10 * scale),
|
margin: EdgeInsets.fromLTRB(16 * scale, 16 * scale, 16 * scale, 10 * scale),
|
||||||
padding: EdgeInsets.symmetric(horizontal: 14 * scale),
|
padding: EdgeInsets.symmetric(horizontal: 14 * scale),
|
||||||
@@ -63,11 +62,8 @@ class _OrdersScreenState extends State<OrdersScreen> {
|
|||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.search,
|
Icon(Icons.search, size: 22 * scale, color: Colors.grey.shade700),
|
||||||
size: 22 * scale, color: Colors.grey.shade700),
|
|
||||||
|
|
||||||
SizedBox(width: 10 * scale),
|
SizedBox(width: 10 * scale),
|
||||||
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
onChanged: (value) => setState(() => searchQuery = value),
|
onChanged: (value) => setState(() => searchQuery = value),
|
||||||
@@ -86,7 +82,7 @@ class _OrdersScreenState extends State<OrdersScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
// LIST OF ORDERS
|
// ORDER LIST
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
padding: EdgeInsets.all(16 * scale),
|
padding: EdgeInsets.all(16 * scale),
|
||||||
@@ -101,7 +97,6 @@ class _OrdersScreenState extends State<OrdersScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ORDER CARD UI
|
|
||||||
Widget _orderCard(Map<String, dynamic> o, double scale) {
|
Widget _orderCard(Map<String, dynamic> o, double scale) {
|
||||||
final progress = getProgress(o['status']);
|
final progress = getProgress(o['status']);
|
||||||
final badgeColor = getStatusColor(o['status']);
|
final badgeColor = getStatusColor(o['status']);
|
||||||
@@ -118,7 +113,6 @@ class _OrdersScreenState extends State<OrdersScreen> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
// TOP ROW
|
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
@@ -151,12 +145,7 @@ class _OrdersScreenState extends State<OrdersScreen> {
|
|||||||
),
|
),
|
||||||
|
|
||||||
SizedBox(height: 10 * scale),
|
SizedBox(height: 10 * scale),
|
||||||
|
Text(o['description'], style: TextStyle(fontSize: 14 * scale)),
|
||||||
Text(
|
|
||||||
o['description'],
|
|
||||||
style: TextStyle(fontSize: 14 * scale),
|
|
||||||
),
|
|
||||||
|
|
||||||
SizedBox(height: 5 * scale),
|
SizedBox(height: 5 * scale),
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
@@ -168,12 +157,9 @@ class _OrdersScreenState extends State<OrdersScreen> {
|
|||||||
),
|
),
|
||||||
|
|
||||||
SizedBox(height: 18 * scale),
|
SizedBox(height: 18 * scale),
|
||||||
|
|
||||||
_AnimatedProgressBar(progress: progress, scale: scale),
|
_AnimatedProgressBar(progress: progress, scale: scale),
|
||||||
|
|
||||||
SizedBox(height: 18 * scale),
|
SizedBox(height: 18 * scale),
|
||||||
|
|
||||||
// BUTTONS
|
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
@@ -193,21 +179,14 @@ class _OrdersScreenState extends State<OrdersScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// BUTTON UI
|
|
||||||
Widget _btn(IconData icon, String text, Color fg, Color bg,
|
Widget _btn(IconData icon, String text, Color fg, Color bg,
|
||||||
VoidCallback onTap, double scale) {
|
VoidCallback onTap, double scale) {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
borderRadius: BorderRadius.circular(12 * scale),
|
borderRadius: BorderRadius.circular(12 * scale),
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(horizontal: 20 * scale, vertical: 12 * scale),
|
||||||
horizontal: 20 * scale,
|
decoration: BoxDecoration(color: bg, borderRadius: BorderRadius.circular(12 * scale)),
|
||||||
vertical: 12 * scale,
|
|
||||||
),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: bg,
|
|
||||||
borderRadius: BorderRadius.circular(12 * scale),
|
|
||||||
),
|
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(icon, size: 18 * scale, color: fg),
|
Icon(icon, size: 18 * scale, color: fg),
|
||||||
@@ -226,30 +205,24 @@ class _OrdersScreenState extends State<OrdersScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NAVIGATION
|
|
||||||
void _openOrderDetails(String id) {
|
void _openOrderDetails(String id) {
|
||||||
Navigator.push(
|
Navigator.push(context,
|
||||||
context,
|
MaterialPageRoute(builder: (_) => OrderDetailScreen(orderId: id)));
|
||||||
MaterialPageRoute(builder: (_) => OrderDetailScreen(orderId: id)),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _openInvoice(String id) {
|
void _openInvoice(String id) {
|
||||||
Navigator.push(
|
Navigator.push(context,
|
||||||
context,
|
MaterialPageRoute(builder: (_) => OrderInvoiceScreen(orderId: id)));
|
||||||
MaterialPageRoute(builder: (_) => OrderInvoiceScreen(orderId: id)),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _openTrack(String id) {
|
void _openTrack(String id) {
|
||||||
Navigator.push(
|
Navigator.push(context,
|
||||||
context,
|
MaterialPageRoute(builder: (_) => OrderTrackScreen(orderId: id)));
|
||||||
MaterialPageRoute(builder: (_) => OrderTrackScreen(orderId: id)),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PROGRESS BAR
|
// ================= PROGRESS BAR =================
|
||||||
|
|
||||||
class _AnimatedProgressBar extends StatelessWidget {
|
class _AnimatedProgressBar extends StatelessWidget {
|
||||||
final double progress;
|
final double progress;
|
||||||
final double scale;
|
final double scale;
|
||||||
@@ -258,10 +231,7 @@ class _AnimatedProgressBar extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return LayoutBuilder(
|
return LayoutBuilder(builder: (context, constraints) {
|
||||||
builder: (context, constraints) {
|
|
||||||
final maxW = constraints.maxWidth;
|
|
||||||
|
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
@@ -275,7 +245,7 @@ class _AnimatedProgressBar extends StatelessWidget {
|
|||||||
duration: const Duration(milliseconds: 650),
|
duration: const Duration(milliseconds: 650),
|
||||||
curve: Curves.easeInOut,
|
curve: Curves.easeInOut,
|
||||||
height: 10 * scale,
|
height: 10 * scale,
|
||||||
width: maxW * progress,
|
width: constraints.maxWidth * progress,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(20 * scale),
|
borderRadius: BorderRadius.circular(20 * scale),
|
||||||
gradient: const LinearGradient(
|
gradient: const LinearGradient(
|
||||||
@@ -288,31 +258,38 @@ class _AnimatedProgressBar extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// PROGRESS VALUES
|
// ================= FIXED STATUS LOGIC =================
|
||||||
|
|
||||||
double getProgress(String? status) {
|
double getProgress(String? status) {
|
||||||
final s = (status ?? '').toLowerCase();
|
final s = (status ?? '')
|
||||||
|
.toLowerCase()
|
||||||
|
.replaceAll('_', ' ')
|
||||||
|
.replaceAll('-', ' ')
|
||||||
|
.trim();
|
||||||
|
|
||||||
if (s == "pending") return 0.25;
|
if (s == "pending") return 0.25;
|
||||||
if (s == "loading") return 0.40;
|
if (s == "loading") return 0.40;
|
||||||
if (s == "in transit" || s == "intransit") return 0.65;
|
if (s.contains("transit")) return 0.65;
|
||||||
if (s == "dispatched") return 0.85;
|
if (s == "dispatched") return 0.85;
|
||||||
if (s == "delivered") return 1.0;
|
if (s == "delivered") return 1.0;
|
||||||
|
|
||||||
return 0.05;
|
return 0.05;
|
||||||
}
|
}
|
||||||
|
|
||||||
// STATUS COLORS
|
|
||||||
Color getStatusColor(String? status) {
|
Color getStatusColor(String? status) {
|
||||||
final s = (status ?? '').toLowerCase();
|
final s = (status ?? '')
|
||||||
|
.toLowerCase()
|
||||||
|
.replaceAll('_', ' ')
|
||||||
|
.replaceAll('-', ' ')
|
||||||
|
.trim();
|
||||||
|
|
||||||
if (s == "pending") return Colors.orange;
|
if (s == "pending") return Colors.orange;
|
||||||
if (s == "loading") return Colors.amber.shade800;
|
if (s == "loading") return Colors.amber.shade800;
|
||||||
if (s == "in transit" || s == "intransit") return Colors.red;
|
if (s.contains("transit")) return Colors.red;
|
||||||
if (s == "dispatched") return Colors.blue.shade700;
|
if (s == "dispatched") return Colors.blue.shade700;
|
||||||
if (s == "delivered") return Colors.green.shade700;
|
if (s == "delivered") return Colors.green.shade700;
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ class _InvoiceDetailViewState extends State<InvoiceDetailView>
|
|||||||
bool s1 = true;
|
bool s1 = true;
|
||||||
bool s2 = false;
|
bool s2 = false;
|
||||||
bool s3 = false;
|
bool s3 = false;
|
||||||
bool s4 = false;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -27,8 +26,12 @@ class _InvoiceDetailViewState extends State<InvoiceDetailView>
|
|||||||
duration: const Duration(milliseconds: 350),
|
duration: const Duration(milliseconds: 350),
|
||||||
);
|
);
|
||||||
|
|
||||||
_slideAnimation = Tween(begin: const Offset(0, -0.1), end: Offset.zero)
|
_slideAnimation = Tween(
|
||||||
.animate(CurvedAnimation(parent: _controller, curve: Curves.easeOut));
|
begin: const Offset(0, -0.1),
|
||||||
|
end: Offset.zero,
|
||||||
|
).animate(
|
||||||
|
CurvedAnimation(parent: _controller, curve: Curves.easeOut),
|
||||||
|
);
|
||||||
|
|
||||||
_controller.forward();
|
_controller.forward();
|
||||||
}
|
}
|
||||||
@@ -40,13 +43,93 @@ class _InvoiceDetailViewState extends State<InvoiceDetailView>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
// HEADER SUMMARY CARD
|
// STATUS BADGE (WHITE + GRADIENT BORDER)
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
Widget statusBadge(String status, double scale) {
|
||||||
|
final s = status.toLowerCase();
|
||||||
|
|
||||||
|
LinearGradient gradient;
|
||||||
|
Color textColor;
|
||||||
|
|
||||||
|
switch (s) {
|
||||||
|
case 'paid':
|
||||||
|
gradient = const LinearGradient(
|
||||||
|
colors: [Color(0xFF2ECC71), Color(0xFF27AE60)],
|
||||||
|
);
|
||||||
|
textColor = const Color(0xFF27AE60);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'pending':
|
||||||
|
gradient = const LinearGradient(
|
||||||
|
colors: [
|
||||||
|
Color(0xFF5B8DEF), // Soft Blue
|
||||||
|
Color(0xFF7B5CFA), // Purple Blue
|
||||||
|
],
|
||||||
|
);
|
||||||
|
textColor = const Color(0xFF5B8DEF);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'overdue':
|
||||||
|
gradient = const LinearGradient(
|
||||||
|
colors: [
|
||||||
|
Color(0xFFFFB300), // Amber
|
||||||
|
Color(0xFFFF6F00), // Deep Orange
|
||||||
|
],
|
||||||
|
);
|
||||||
|
textColor = const Color(0xFFFF6F00);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'cancelled':
|
||||||
|
case 'failed':
|
||||||
|
gradient = const LinearGradient(
|
||||||
|
colors: [Color(0xFFE74C3C), Color(0xFFC0392B)],
|
||||||
|
);
|
||||||
|
textColor = const Color(0xFFE74C3C);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
gradient = const LinearGradient(
|
||||||
|
colors: [Color(0xFF95A5A6), Color(0xFF7F8C8D)],
|
||||||
|
);
|
||||||
|
textColor = Colors.grey.shade700;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.all(1.5),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
gradient: gradient,
|
||||||
|
borderRadius: BorderRadius.circular(20 * scale),
|
||||||
|
),
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
horizontal: 14 * scale,
|
||||||
|
vertical: 6 * scale,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(18 * scale),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
status.toUpperCase(),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12 * scale,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
color: textColor,
|
||||||
|
letterSpacing: .6,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// HEADER CARD
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
Widget headerCard(Map invoice, double scale) {
|
Widget headerCard(Map invoice, double scale) {
|
||||||
return Container(
|
return Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
padding: EdgeInsets.all(16 * scale), // tighter
|
padding: EdgeInsets.all(16 * scale),
|
||||||
margin: EdgeInsets.only(bottom: 14 * scale), // closer
|
margin: EdgeInsets.only(bottom: 14 * scale),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
colors: [Colors.blue.shade400, Colors.indigo.shade600],
|
colors: [Colors.blue.shade400, Colors.indigo.shade600],
|
||||||
@@ -76,40 +159,34 @@ class _InvoiceDetailViewState extends State<InvoiceDetailView>
|
|||||||
"Date: ${invoice['invoice_date']}",
|
"Date: ${invoice['invoice_date']}",
|
||||||
style: TextStyle(color: Colors.white70, fontSize: 13 * scale),
|
style: TextStyle(color: Colors.white70, fontSize: 13 * scale),
|
||||||
),
|
),
|
||||||
SizedBox(height: 8 * scale),
|
SizedBox(height: 10 * scale),
|
||||||
Container(
|
|
||||||
padding: EdgeInsets.symmetric(
|
/// STATUS BADGE
|
||||||
vertical: 5 * scale, horizontal: 12 * scale),
|
statusBadge(invoice['status'] ?? 'Unknown', scale),
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white.withOpacity(.2),
|
|
||||||
borderRadius: BorderRadius.circular(40 * scale),
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
invoice['status'] ?? "Unknown",
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 13 * scale,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
// SECTION HEADER (Closer Spacing)
|
// SECTION HEADER
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
Widget sectionHeader(
|
Widget sectionHeader(
|
||||||
String title, IconData icon, bool expanded, Function() tap, double scale) {
|
String title,
|
||||||
|
IconData icon,
|
||||||
|
bool expanded,
|
||||||
|
VoidCallback tap,
|
||||||
|
double scale,
|
||||||
|
) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: tap,
|
onTap: tap,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.all(12 * scale), // tighter
|
padding: EdgeInsets.all(12 * scale),
|
||||||
margin: EdgeInsets.only(bottom: 8 * scale), // closer
|
margin: EdgeInsets.only(bottom: 8 * scale),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
colors: [Colors.indigo.shade500, Colors.blue.shade400]),
|
colors: [Colors.indigo.shade500, Colors.blue.shade400],
|
||||||
|
),
|
||||||
borderRadius: BorderRadius.circular(12 * scale),
|
borderRadius: BorderRadius.circular(12 * scale),
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
@@ -128,14 +205,18 @@ class _InvoiceDetailViewState extends State<InvoiceDetailView>
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 15 * scale,
|
fontSize: 15 * scale,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontWeight: FontWeight.bold),
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
AnimatedRotation(
|
AnimatedRotation(
|
||||||
turns: expanded ? .5 : 0,
|
turns: expanded ? .5 : 0,
|
||||||
duration: const Duration(milliseconds: 250),
|
duration: const Duration(milliseconds: 250),
|
||||||
child: Icon(Icons.keyboard_arrow_down,
|
child: Icon(
|
||||||
color: Colors.white, size: 20 * scale),
|
Icons.keyboard_arrow_down,
|
||||||
|
color: Colors.white,
|
||||||
|
size: 20 * scale,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -144,7 +225,7 @@ class _InvoiceDetailViewState extends State<InvoiceDetailView>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
// SECTION BODY (Closer Spacing)
|
// SECTION BODY
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
Widget sectionBody(bool visible, List<Widget> children, double scale) {
|
Widget sectionBody(bool visible, List<Widget> children, double scale) {
|
||||||
return AnimatedCrossFade(
|
return AnimatedCrossFade(
|
||||||
@@ -155,9 +236,8 @@ class _InvoiceDetailViewState extends State<InvoiceDetailView>
|
|||||||
secondChild: SlideTransition(
|
secondChild: SlideTransition(
|
||||||
position: _slideAnimation,
|
position: _slideAnimation,
|
||||||
child: Container(
|
child: Container(
|
||||||
width: double.infinity,
|
padding: EdgeInsets.all(14 * scale),
|
||||||
padding: EdgeInsets.all(14 * scale), // tighter
|
margin: EdgeInsets.only(bottom: 10 * scale),
|
||||||
margin: EdgeInsets.only(bottom: 10 * scale), // closer
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).cardColor,
|
color: Theme.of(context).cardColor,
|
||||||
borderRadius: BorderRadius.circular(12 * scale),
|
borderRadius: BorderRadius.circular(12 * scale),
|
||||||
@@ -165,7 +245,8 @@ class _InvoiceDetailViewState extends State<InvoiceDetailView>
|
|||||||
BoxShadow(
|
BoxShadow(
|
||||||
blurRadius: 7 * scale,
|
blurRadius: 7 * scale,
|
||||||
offset: Offset(0, 2 * scale),
|
offset: Offset(0, 2 * scale),
|
||||||
color: Colors.black.withOpacity(.07))
|
color: Colors.black.withOpacity(.07),
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
child: Column(children: children),
|
child: Column(children: children),
|
||||||
@@ -175,11 +256,11 @@ class _InvoiceDetailViewState extends State<InvoiceDetailView>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
// DETAIL ROW (Closer Spacing)
|
// DETAIL ROW
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
Widget detailRow(IconData icon, String label, dynamic value, double scale) {
|
Widget detailRow(IconData icon, String label, dynamic value, double scale) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.symmetric(vertical: 5 * scale), // closer
|
padding: EdgeInsets.symmetric(vertical: 5 * scale),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(icon, size: 18 * scale, color: Colors.blueGrey),
|
Icon(icon, size: 18 * scale, color: Colors.blueGrey),
|
||||||
@@ -196,11 +277,18 @@ class _InvoiceDetailViewState extends State<InvoiceDetailView>
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 4,
|
flex: 4,
|
||||||
child: Text(
|
child: label == "Status"
|
||||||
|
? Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: statusBadge(value ?? 'Unknown', scale),
|
||||||
|
)
|
||||||
|
: Text(
|
||||||
value?.toString() ?? "N/A",
|
value?.toString() ?? "N/A",
|
||||||
textAlign: TextAlign.right,
|
textAlign: TextAlign.right,
|
||||||
style:
|
style: TextStyle(
|
||||||
TextStyle(fontSize: 14 * scale, fontWeight: FontWeight.bold),
|
fontSize: 14 * scale,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
@@ -208,60 +296,6 @@ class _InvoiceDetailViewState extends State<InvoiceDetailView>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
|
||||||
// TIMELINE (Closer Spacing)
|
|
||||||
// ------------------------------------------------------------------
|
|
||||||
Widget invoiceTimeline(double scale) {
|
|
||||||
final steps = ["Invoice Created", "Payment Received", "Out for Delivery", "Completed"];
|
|
||||||
final icons = [Icons.receipt_long, Icons.payments, Icons.local_shipping, Icons.verified];
|
|
||||||
|
|
||||||
return Container(
|
|
||||||
padding: EdgeInsets.all(16 * scale),
|
|
||||||
margin: EdgeInsets.only(bottom: 16 * scale), // closer
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Theme.of(context).cardColor,
|
|
||||||
borderRadius: BorderRadius.circular(14 * scale),
|
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
blurRadius: 7 * scale,
|
|
||||||
color: Colors.black.withOpacity(.1),
|
|
||||||
offset: Offset(0, 3 * scale),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
children: List.generate(steps.length, (i) {
|
|
||||||
return Padding(
|
|
||||||
padding: EdgeInsets.symmetric(vertical: 4 * scale), // closer
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Column(
|
|
||||||
children: [
|
|
||||||
Icon(icons[i], size: 22 * scale, color: Colors.indigo),
|
|
||||||
if (i < steps.length - 1)
|
|
||||||
Container(
|
|
||||||
height: 28 * scale,
|
|
||||||
width: 2 * scale,
|
|
||||||
color: Colors.indigo.shade300,
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SizedBox(width: 10 * scale),
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
steps[i],
|
|
||||||
style:
|
|
||||||
TextStyle(fontSize: 14 * scale, fontWeight: FontWeight.w600),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
// MAIN BUILD
|
// MAIN BUILD
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
@@ -272,21 +306,30 @@ class _InvoiceDetailViewState extends State<InvoiceDetailView>
|
|||||||
final scale = (width / 390).clamp(0.85, 1.25);
|
final scale = (width / 390).clamp(0.85, 1.25);
|
||||||
|
|
||||||
return ListView(
|
return ListView(
|
||||||
padding: EdgeInsets.all(14 * scale), // slightly tighter
|
padding: EdgeInsets.all(14 * scale),
|
||||||
children: [
|
children: [
|
||||||
headerCard(invoice, scale),
|
headerCard(invoice, scale),
|
||||||
invoiceTimeline(scale),
|
|
||||||
|
|
||||||
sectionHeader("Invoice Summary", Icons.receipt_long, s1,
|
sectionHeader(
|
||||||
() => setState(() => s1 = !s1), scale),
|
"Invoice Summary",
|
||||||
|
Icons.receipt_long,
|
||||||
|
s1,
|
||||||
|
() => setState(() => s1 = !s1),
|
||||||
|
scale,
|
||||||
|
),
|
||||||
sectionBody(s1, [
|
sectionBody(s1, [
|
||||||
detailRow(Icons.numbers, "Invoice No", invoice['invoice_number'], scale),
|
detailRow(Icons.numbers, "Invoice No", invoice['invoice_number'], scale),
|
||||||
detailRow(Icons.calendar_today, "Date", invoice['invoice_date'], scale),
|
detailRow(Icons.calendar_today, "Date", invoice['invoice_date'], scale),
|
||||||
detailRow(Icons.label, "Status", invoice['status'], scale),
|
detailRow(Icons.label, "Status", invoice['status'], scale),
|
||||||
], scale),
|
], scale),
|
||||||
|
|
||||||
sectionHeader("Customer Details", Icons.person, s2,
|
sectionHeader(
|
||||||
() => setState(() => s2 = !s2), scale),
|
"Customer Details",
|
||||||
|
Icons.person,
|
||||||
|
s2,
|
||||||
|
() => setState(() => s2 = !s2),
|
||||||
|
scale,
|
||||||
|
),
|
||||||
sectionBody(s2, [
|
sectionBody(s2, [
|
||||||
detailRow(Icons.person_outline, "Name", invoice['customer_name'], scale),
|
detailRow(Icons.person_outline, "Name", invoice['customer_name'], scale),
|
||||||
detailRow(Icons.mail, "Email", invoice['customer_email'], scale),
|
detailRow(Icons.mail, "Email", invoice['customer_email'], scale),
|
||||||
@@ -294,22 +337,19 @@ class _InvoiceDetailViewState extends State<InvoiceDetailView>
|
|||||||
detailRow(Icons.location_on, "Address", invoice['customer_address'], scale),
|
detailRow(Icons.location_on, "Address", invoice['customer_address'], scale),
|
||||||
], scale),
|
], scale),
|
||||||
|
|
||||||
sectionHeader("Amount Details", Icons.currency_rupee, s3,
|
sectionHeader(
|
||||||
() => setState(() => s3 = !s3), scale),
|
"Amount Details",
|
||||||
|
Icons.currency_rupee,
|
||||||
|
s3,
|
||||||
|
() => setState(() => s3 = !s3),
|
||||||
|
scale,
|
||||||
|
),
|
||||||
sectionBody(s3, [
|
sectionBody(s3, [
|
||||||
detailRow(Icons.money, "Amount", invoice['final_amount'], scale),
|
detailRow(Icons.money, "Amount", invoice['final_amount'], scale),
|
||||||
detailRow(Icons.percent, "GST percent %", invoice['gst_percent'], scale),
|
detailRow(Icons.percent, "GST %", invoice['gst_percent'], scale),
|
||||||
detailRow(Icons.percent, "GST amount %", invoice['gst_amount'], scale),
|
detailRow(Icons.percent, "GST Amount", invoice['gst_amount'], scale),
|
||||||
detailRow(Icons.summarize, "Total", invoice['final_amount_with_gst'], scale),
|
detailRow(Icons.summarize, "Total", invoice['final_amount_with_gst'], scale),
|
||||||
], scale),
|
], scale),
|
||||||
|
|
||||||
// sectionHeader("Payment Details", Icons.payment, s4,
|
|
||||||
// () => setState(() => s4 = !s4), scale),
|
|
||||||
// sectionBody(s4, [
|
|
||||||
// detailRow(Icons.credit_card, "Method", invoice['payment_method'], scale),
|
|
||||||
// detailRow(Icons.confirmation_number, "Reference",
|
|
||||||
// invoice['reference_no'], scale),
|
|
||||||
// ], scale),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
24
pubspec.lock
24
pubspec.lock
@@ -388,26 +388,26 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: leak_tracker
|
name: leak_tracker
|
||||||
sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0"
|
sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "10.0.9"
|
version: "11.0.2"
|
||||||
leak_tracker_flutter_testing:
|
leak_tracker_flutter_testing:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: leak_tracker_flutter_testing
|
name: leak_tracker_flutter_testing
|
||||||
sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
|
sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.9"
|
version: "3.0.10"
|
||||||
leak_tracker_testing:
|
leak_tracker_testing:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: leak_tracker_testing
|
name: leak_tracker_testing
|
||||||
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
|
sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.1"
|
version: "3.0.2"
|
||||||
lints:
|
lints:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -436,10 +436,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
|
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.16.0"
|
version: "1.17.0"
|
||||||
mime:
|
mime:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -777,10 +777,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd
|
sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.4"
|
version: "0.7.7"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -865,10 +865,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vector_math
|
name: vector_math
|
||||||
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
|
sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.4"
|
version: "2.2.0"
|
||||||
video_player:
|
video_player:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|||||||
Reference in New Issue
Block a user