2026-04-11
This commit is contained in:
commit
27e27fb70b
270 files changed
+30296
No files matched your search
@@ -0,0 +1,696 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_riverpod/legacy.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get/get_core/src/get_main.dart';
|
||||
import 'package:taxglide/consts/app_asstes.dart';
|
||||
import 'package:taxglide/controller/api_contoller.dart';
|
||||
import 'package:taxglide/model/chat_model.dart';
|
||||
import 'package:taxglide/view/Mahi_chat/chat_profile_screen.dart';
|
||||
import 'package:taxglide/view/Mahi_chat/file_images_screen.dart';
|
||||
import 'package:taxglide/view/Mahi_chat/webscoket.dart';
|
||||
|
||||
// ⭐ Provider to hold the tagged message
|
||||
final taggedMessageProvider = StateProvider<MessageModel?>((ref) => null);
|
||||
|
||||
// ⭐ Global key map to track message positions (if you want from outside)
|
||||
final messageKeysProvider = StateProvider<Map<int, GlobalKey>>((ref) => {});
|
||||
|
||||
class CompletedLiveChatScreen extends ConsumerStatefulWidget {
|
||||
final int chatid;
|
||||
final String? fileid;
|
||||
const CompletedLiveChatScreen({
|
||||
super.key,
|
||||
required this.chatid,
|
||||
required this.fileid,
|
||||
});
|
||||
|
||||
@override
|
||||
ConsumerState<CompletedLiveChatScreen> createState() =>
|
||||
_CompletedLiveChatScreenState();
|
||||
}
|
||||
|
||||
class _CompletedLiveChatScreenState
|
||||
extends ConsumerState<CompletedLiveChatScreen>
|
||||
with AutomaticKeepAliveClientMixin, WidgetsBindingObserver {
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
final ScrollController scrollController = ScrollController();
|
||||
final ChatWebSocketService _wsService = ChatWebSocketService();
|
||||
|
||||
bool showScrollButton = false;
|
||||
bool userIsReading = false;
|
||||
bool _isInitialLoad = true;
|
||||
bool _isPaginationLoading = false;
|
||||
bool _hasNewMessage = false;
|
||||
|
||||
// For reply scroll - FIXED: Use unique key per message
|
||||
final Map<String, GlobalKey> _messageKeys = {};
|
||||
|
||||
// ⭐⭐⭐ Key variables for smooth pagination
|
||||
final double _paginationTriggerOffset = 300; // Start loading 300px before top
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
|
||||
_initializeWebSocket();
|
||||
|
||||
scrollController.addListener(_handleScroll);
|
||||
}
|
||||
|
||||
// ⭐⭐⭐ Enhanced scroll handler with early pagination trigger
|
||||
void _handleScroll() {
|
||||
if (!scrollController.hasClients) return;
|
||||
|
||||
double position = scrollController.position.pixels;
|
||||
double bottom = scrollController.position.maxScrollExtent;
|
||||
double top = scrollController.position.minScrollExtent;
|
||||
|
||||
// ⭐⭐⭐ EARLY PAGINATION: Load before reaching exact top
|
||||
if (position <= top + _paginationTriggerOffset && !_isPaginationLoading) {
|
||||
_triggerPagination();
|
||||
}
|
||||
|
||||
// Show scroll to bottom button
|
||||
if (position < bottom - 50) {
|
||||
if (!userIsReading) {
|
||||
setState(() {
|
||||
userIsReading = true;
|
||||
showScrollButton = true;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (userIsReading) {
|
||||
setState(() {
|
||||
userIsReading = false;
|
||||
showScrollButton = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ⭐⭐⭐ Smooth pagination with scroll position preservation (NO JUMP TO BOTTOM)
|
||||
Future<void> _triggerPagination() async {
|
||||
final notifier = ref.read(chatMessagesProvider(widget.chatid).notifier);
|
||||
if (!notifier.hasNextPage) return;
|
||||
if (_isPaginationLoading) return;
|
||||
if (!scrollController.hasClients) return;
|
||||
|
||||
setState(() {
|
||||
_isPaginationLoading = true;
|
||||
// userIsReading remains true while scrolling old messages
|
||||
});
|
||||
|
||||
// Save current scroll metrics BEFORE loading more messages
|
||||
final double beforeMaxExtent = scrollController.position.maxScrollExtent;
|
||||
final double currentOffset = scrollController.position.pixels;
|
||||
|
||||
try {
|
||||
await notifier.loadMessages(); // This should prepend older messages
|
||||
|
||||
// Restore scroll position after new messages loaded
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted || !scrollController.hasClients) return;
|
||||
|
||||
final double afterMaxExtent = scrollController.position.maxScrollExtent;
|
||||
final double diff = afterMaxExtent - beforeMaxExtent;
|
||||
|
||||
// Keep user at same visual message position
|
||||
final double newOffset = currentOffset + diff;
|
||||
|
||||
scrollController.jumpTo(
|
||||
newOffset.clamp(
|
||||
scrollController.position.minScrollExtent,
|
||||
scrollController.position.maxScrollExtent,
|
||||
),
|
||||
);
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isPaginationLoading = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
debugPrint("❌ Pagination error: $e");
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isPaginationLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||
super.didChangeAppLifecycleState(state);
|
||||
|
||||
debugPrint("📱 App Lifecycle State: $state");
|
||||
|
||||
if (state == AppLifecycleState.resumed) {
|
||||
debugPrint("🔄 App resumed - checking for new messages");
|
||||
|
||||
if (_hasNewMessage) {
|
||||
_silentRefresh();
|
||||
_hasNewMessage = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _silentRefresh() async {
|
||||
try {
|
||||
debugPrint("🔄 Starting silent refresh...");
|
||||
|
||||
await ref.read(chatMessagesProvider(widget.chatid).notifier).refresh();
|
||||
|
||||
debugPrint("✅ Silent refresh completed");
|
||||
|
||||
// Only auto-scroll to bottom on new messages if user is NOT reading old ones
|
||||
if (!userIsReading && mounted) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (scrollController.hasClients) {
|
||||
scrollController.animateTo(
|
||||
scrollController.position.maxScrollExtent,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeOut,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint("❌ Error during silent refresh: $e");
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _initializeWebSocket() async {
|
||||
try {
|
||||
_wsService.onMessageReceived = (Map<String, dynamic> message) async {
|
||||
debugPrint("📨 WebSocket message received: $message");
|
||||
|
||||
try {
|
||||
final event = message['event'] as String?;
|
||||
|
||||
if (event == 'message.sent' || event == 'message.received') {
|
||||
debugPrint("🔔 New message detected!");
|
||||
|
||||
if (WidgetsBinding.instance.lifecycleState ==
|
||||
AppLifecycleState.resumed) {
|
||||
debugPrint("✅ Screen active - refreshing now");
|
||||
await _silentRefresh();
|
||||
} else {
|
||||
debugPrint("⏳ Screen not active - will refresh on resume");
|
||||
_hasNewMessage = true;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint("❌ Error handling WebSocket message: $e");
|
||||
}
|
||||
};
|
||||
|
||||
_wsService.onConnected = () {
|
||||
debugPrint("✅ WebSocket Connected");
|
||||
};
|
||||
|
||||
_wsService.onDisconnected = () {
|
||||
debugPrint("🔌 WebSocket Disconnected");
|
||||
};
|
||||
|
||||
_wsService.onError = (error) {
|
||||
debugPrint("❌ WebSocket Error: $error");
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text("Connection error: $error"),
|
||||
backgroundColor: Colors.red,
|
||||
duration: const Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
await _wsService.connect(chatId: widget.chatid.toString());
|
||||
} catch (e) {
|
||||
debugPrint("❌ Error initializing WebSocket: $e");
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
_wsService.disconnect();
|
||||
scrollController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void scrollToBottom({bool animated = false}) {
|
||||
if (!scrollController.hasClients) return;
|
||||
|
||||
setState(() {
|
||||
_isPaginationLoading = false;
|
||||
userIsReading = false;
|
||||
});
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!scrollController.hasClients) return;
|
||||
|
||||
if (animated) {
|
||||
scrollController
|
||||
.animateTo(
|
||||
scrollController.position.maxScrollExtent,
|
||||
duration: const Duration(milliseconds: 400),
|
||||
curve: Curves.easeOutCubic,
|
||||
)
|
||||
.then((_) {
|
||||
Future.delayed(const Duration(milliseconds: 50), () {
|
||||
if (scrollController.hasClients && mounted) {
|
||||
scrollController.jumpTo(
|
||||
scrollController.position.maxScrollExtent,
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
scrollController.jumpTo(scrollController.position.maxScrollExtent);
|
||||
|
||||
Future.delayed(const Duration(milliseconds: 10), () {
|
||||
if (scrollController.hasClients && mounted) {
|
||||
scrollController.jumpTo(scrollController.position.maxScrollExtent);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ⭐ FIXED: Use unique string key instead of int
|
||||
void scrollToMessage(String messageKey) {
|
||||
final key = _messageKeys[messageKey];
|
||||
|
||||
if (key != null && key.currentContext != null) {
|
||||
Scrollable.ensureVisible(
|
||||
key.currentContext!,
|
||||
duration: const Duration(milliseconds: 500),
|
||||
curve: Curves.easeInOut,
|
||||
alignment: 0.3,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ⭐ FIXED: Generate unique string key for each message
|
||||
GlobalKey _getKeyForMessage(String messageKey) {
|
||||
if (!_messageKeys.containsKey(messageKey)) {
|
||||
_messageKeys[messageKey] = GlobalKey();
|
||||
}
|
||||
return _messageKeys[messageKey]!;
|
||||
}
|
||||
|
||||
// ⭐ FIXED: Generate unique key string from message
|
||||
String _getMessageKeyString(MessageModel msg, int index) {
|
||||
// Use combination of ID, index, and document count for uniqueness
|
||||
final id = msg.id;
|
||||
final docCount = msg.uploadedDocuments.length;
|
||||
final createdAt = msg.createdAt ?? '';
|
||||
return 'msg_${id}_${index}_${docCount}_$createdAt';
|
||||
}
|
||||
|
||||
String formatMessageDate(DateTime date) {
|
||||
final now = DateTime.now();
|
||||
final today = DateTime(now.year, now.month, now.day);
|
||||
final msgDay = DateTime(date.year, date.month, date.day);
|
||||
|
||||
if (msgDay == today) return "Today";
|
||||
if (msgDay == today.subtract(const Duration(days: 1))) return "Yesterday";
|
||||
return "${date.day}-${date.month}-${date.year}";
|
||||
}
|
||||
|
||||
String formatTime(DateTime time) {
|
||||
final hour = time.hour % 12 == 0 ? 12 : time.hour % 12;
|
||||
final minute = time.minute.toString().padLeft(2, '0');
|
||||
final period = time.hour >= 12 ? "PM" : "AM";
|
||||
return "$hour:$minute $period";
|
||||
}
|
||||
|
||||
Widget buildTick(int isDelivered, int isRead) {
|
||||
if (isRead == 1) {
|
||||
return const Icon(Icons.done_all, size: 16, color: Colors.blue);
|
||||
} else if (isDelivered == 1) {
|
||||
return const Icon(Icons.done_all, size: 16, color: Colors.grey);
|
||||
} else {
|
||||
return const Icon(Icons.check, size: 16, color: Colors.grey);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
|
||||
final chatAsync = ref.watch(chatMessagesProvider(widget.chatid));
|
||||
final taggedMessage = ref.watch(taggedMessageProvider);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
(widget.fileid != null &&
|
||||
widget.fileid.toString().isNotEmpty &&
|
||||
widget.fileid.toString() != "0")
|
||||
? 'File ID : ${widget.fileid.toString()}'
|
||||
: "Live Chat",
|
||||
style: const TextStyle(
|
||||
fontFamily: "Gilroy-SemiBold",
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
backgroundColor: Colors.white,
|
||||
elevation: 1,
|
||||
foregroundColor: Colors.black,
|
||||
centerTitle: true,
|
||||
|
||||
actions: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 12), // ✅ Right end spacing
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
Get.to(ChatProfileScreen(chatid: widget.chatid));
|
||||
},
|
||||
child: Container(
|
||||
width: 37.446807861328125,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFFAFAFA),
|
||||
borderRadius: BorderRadius.circular(6.81),
|
||||
border: Border.all(
|
||||
color: const Color(0xFF1E780C),
|
||||
width: 0.85,
|
||||
),
|
||||
),
|
||||
child: const Icon(Icons.person, color: Color(0xFF1E780C)),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
body: Stack(
|
||||
children: [
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage(AppAssets.backgroundimages),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: chatAsync.when(
|
||||
loading: () => const Center(child: SizedBox.shrink()),
|
||||
error: (e, _) => Center(child: Text(e.toString())),
|
||||
data: (messages) {
|
||||
// ✅ Only first load scrolls to bottom, NOT during pagination / scroll up
|
||||
if (_isInitialLoad && !_isPaginationLoading) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (scrollController.hasClients && mounted) {
|
||||
scrollController.jumpTo(
|
||||
scrollController.position.maxScrollExtent,
|
||||
);
|
||||
}
|
||||
});
|
||||
_isInitialLoad = false;
|
||||
}
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
ListView.builder(
|
||||
controller: scrollController,
|
||||
physics: const ClampingScrollPhysics(),
|
||||
padding: const EdgeInsets.only(
|
||||
left: 15,
|
||||
right: 15,
|
||||
top: 15,
|
||||
bottom: 15,
|
||||
),
|
||||
itemCount: messages.length,
|
||||
itemBuilder: (context, index) {
|
||||
final msg = messages[index];
|
||||
final msgDate = DateTime.parse(msg.createdAt!);
|
||||
|
||||
final showDateHeader =
|
||||
index == 0 ||
|
||||
formatMessageDate(
|
||||
DateTime.parse(
|
||||
messages[index - 1].createdAt!,
|
||||
),
|
||||
) !=
|
||||
formatMessageDate(msgDate);
|
||||
|
||||
// ⭐ FIXED: Generate unique key string
|
||||
final messageKeyString = _getMessageKeyString(
|
||||
msg,
|
||||
index,
|
||||
);
|
||||
|
||||
return Column(
|
||||
key: _getKeyForMessage(messageKeyString),
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
if (showDateHeader)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 10,
|
||||
),
|
||||
child: Center(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 5,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withOpacity(0.06),
|
||||
borderRadius: BorderRadius.circular(
|
||||
12,
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
formatMessageDate(msgDate),
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SwipeableMessageBubble(
|
||||
message: msg,
|
||||
msgDate: msgDate,
|
||||
formatTime: formatTime,
|
||||
buildTick: buildTick,
|
||||
onSwipe: () {
|
||||
ref
|
||||
.read(
|
||||
taggedMessageProvider.notifier,
|
||||
)
|
||||
.state =
|
||||
msg;
|
||||
},
|
||||
onParentTagTap: (tagId) {
|
||||
if (tagId != null) {
|
||||
// ⭐ FIXED: Find the message key string for the tagId
|
||||
final tagIndex = messages.indexWhere(
|
||||
(m) => m.id == tagId,
|
||||
);
|
||||
if (tagIndex != -1) {
|
||||
final taggedMsg = messages[tagIndex];
|
||||
final tagKeyString =
|
||||
_getMessageKeyString(
|
||||
taggedMsg,
|
||||
tagIndex,
|
||||
);
|
||||
scrollToMessage(tagKeyString);
|
||||
}
|
||||
}
|
||||
},
|
||||
// ⭐ FIXED: Use messageKeyString as ValueKey
|
||||
key: ValueKey(messageKeyString),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
// ⭐⭐⭐ Subtle loading indicator at top
|
||||
if (_isPaginationLoading)
|
||||
Positioned(
|
||||
top: 5,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Center(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 6,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.9),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.1),
|
||||
blurRadius: 4,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: const [
|
||||
SizedBox(
|
||||
width: 14,
|
||||
height: 14,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Text(
|
||||
"Loading...",
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
if (taggedMessage != null)
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
if (taggedMessage != null) {
|
||||
// ⭐ FIXED: Need to find the message in the list to get proper key
|
||||
final chatAsync = ref.read(
|
||||
chatMessagesProvider(widget.chatid),
|
||||
);
|
||||
chatAsync.whenData((messages) {
|
||||
final tagIndex = messages.indexWhere(
|
||||
(m) => m.id == taggedMessage.id,
|
||||
);
|
||||
if (tagIndex != -1) {
|
||||
final tagKeyString = _getMessageKeyString(
|
||||
taggedMessage,
|
||||
tagIndex,
|
||||
);
|
||||
scrollToMessage(tagKeyString);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 15,
|
||||
vertical: 8,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[200],
|
||||
border: Border(top: BorderSide(color: Colors.grey[300]!)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 4,
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF630A73),
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
taggedMessage.user?.name ?? "Unknown",
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 13,
|
||||
color: Color(0xFF630A73),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
if (taggedMessage.type == "file" &&
|
||||
taggedMessage.fileName != null)
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.attach_file,
|
||||
size: 14,
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Expanded(
|
||||
child: Text(
|
||||
taggedMessage.fileName!,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Colors.grey[700],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
else
|
||||
Text(
|
||||
taggedMessage.message,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Colors.grey[700],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close, size: 20),
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: () {
|
||||
ref.read(taggedMessageProvider.notifier).state =
|
||||
null;
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (showScrollButton)
|
||||
Positioned(
|
||||
bottom: 150,
|
||||
right: 20,
|
||||
child: FloatingActionButton(
|
||||
heroTag: "scrollBtn",
|
||||
backgroundColor: Colors.green,
|
||||
mini: true,
|
||||
onPressed: () {
|
||||
scrollToBottom(animated: true);
|
||||
},
|
||||
child: const Icon(Icons.arrow_downward, color: Colors.white),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,243 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:taxglide/consts/comman_button.dart';
|
||||
import 'package:taxglide/controller/api_contoller.dart';
|
||||
|
||||
class FlitterPopup {
|
||||
static void show(BuildContext context) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
builder: (context) {
|
||||
return const _FilterBottomSheet();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _FilterBottomSheet extends StatefulWidget {
|
||||
const _FilterBottomSheet({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<_FilterBottomSheet> createState() => _FilterBottomSheetState();
|
||||
}
|
||||
|
||||
class _FilterBottomSheetState extends State<_FilterBottomSheet>
|
||||
with SingleTickerProviderStateMixin {
|
||||
DateTime? fromDate;
|
||||
DateTime? toDate;
|
||||
|
||||
late AnimationController _controller;
|
||||
late Animation<Offset> _slideAnimation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = AnimationController(
|
||||
duration: const Duration(milliseconds: 400),
|
||||
vsync: this,
|
||||
);
|
||||
|
||||
_slideAnimation = Tween<Offset>(
|
||||
begin: const Offset(0, 1),
|
||||
end: Offset.zero,
|
||||
).animate(CurvedAnimation(parent: _controller, curve: Curves.easeOut));
|
||||
|
||||
_controller.forward();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> pickFromDate() async {
|
||||
final picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: DateTime.now(),
|
||||
firstDate: DateTime(2020),
|
||||
lastDate: DateTime(2100),
|
||||
);
|
||||
|
||||
if (picked != null) {
|
||||
setState(() => fromDate = picked);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> pickToDate() async {
|
||||
final picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: fromDate ?? DateTime.now(),
|
||||
firstDate: fromDate ?? DateTime(2020),
|
||||
lastDate: DateTime(2100),
|
||||
);
|
||||
|
||||
if (picked != null) {
|
||||
setState(() => toDate = picked);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SafeArea(
|
||||
top: false,
|
||||
child: SlideTransition(
|
||||
position: _slideAnimation,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Text(
|
||||
"Filter By Date",
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
/// FROM DATE
|
||||
InkWell(
|
||||
onTap: pickFromDate,
|
||||
child: _dateBox(title: "From Date", value: fromDate),
|
||||
),
|
||||
|
||||
const SizedBox(height: 12),
|
||||
|
||||
/// TO DATE
|
||||
InkWell(
|
||||
onTap: pickToDate,
|
||||
child: _dateBox(title: "To Date", value: toDate),
|
||||
),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
height: 57,
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(
|
||||
0xFFF7E9FF,
|
||||
), // ✅ background
|
||||
elevation: 6, // ✅ shadow depth
|
||||
shadowColor: const Color(
|
||||
0x40000000,
|
||||
), // ✅ shadow color
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(6), // ✅ radius
|
||||
side: const BorderSide(
|
||||
color: Color(0xFFD39FEA), // ✅ border color
|
||||
width: 1, // ✅ border width
|
||||
),
|
||||
),
|
||||
),
|
||||
child: const Text(
|
||||
"Cancel",
|
||||
style: TextStyle(
|
||||
fontFamily: "Gilroy-SemiBold", // ✅ Font
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 16,
|
||||
height: 1.3, // ✅ line-height 130%
|
||||
letterSpacing: 0.64, // ✅ 4%
|
||||
color: Color(0xFF61277A), // ✅ text color
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Consumer(
|
||||
builder: (context, ref, _) {
|
||||
return CommanButton(
|
||||
text: 'Submit',
|
||||
onPressed: () {
|
||||
final from = fromDate == null
|
||||
? null
|
||||
: "${fromDate!.year}-${fromDate!.month.toString().padLeft(2, '0')}-${fromDate!.day.toString().padLeft(2, '0')}";
|
||||
|
||||
final to = toDate == null
|
||||
? null
|
||||
: "${toDate!.year}-${toDate!.month.toString().padLeft(2, '0')}-${toDate!.day.toString().padLeft(2, '0')}";
|
||||
|
||||
// ✅ Apply filter to ALL TABS
|
||||
ref
|
||||
.read(
|
||||
serviceHistoryNotifierProvider(
|
||||
"pending",
|
||||
).notifier,
|
||||
)
|
||||
.applyDateFilter(from: from, to: to);
|
||||
|
||||
ref
|
||||
.read(
|
||||
serviceHistoryNotifierProvider(
|
||||
"inprogress",
|
||||
).notifier,
|
||||
)
|
||||
.applyDateFilter(from: from, to: to);
|
||||
|
||||
ref
|
||||
.read(
|
||||
serviceHistoryNotifierProvider(
|
||||
"completed",
|
||||
).notifier,
|
||||
)
|
||||
.applyDateFilter(from: from, to: to);
|
||||
|
||||
ref
|
||||
.read(
|
||||
serviceHistoryNotifierProvider(
|
||||
"cancelled",
|
||||
).notifier,
|
||||
)
|
||||
.applyDateFilter(from: from, to: to);
|
||||
|
||||
Navigator.pop(context); // ✅ Close popup
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _dateBox({required String title, DateTime? value}) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 14),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.grey),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
value == null ? title : "${value.day}-${value.month}-${value.year}",
|
||||
style: const TextStyle(fontSize: 14),
|
||||
),
|
||||
const Icon(Icons.calendar_month, size: 20),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,551 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:taxglide/controller/api_contoller.dart';
|
||||
import 'package:taxglide/view/Main_controller/main_controller.dart';
|
||||
import 'package:taxglide/view/screens/history/detail_screen.dart';
|
||||
|
||||
class PendingScreen extends ConsumerWidget {
|
||||
final String status;
|
||||
|
||||
const PendingScreen({super.key, required this.status});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final pendingAsync = ref.watch(serviceHistoryNotifierProvider(status));
|
||||
final size = MediaQuery.of(context).size;
|
||||
final width = size.width;
|
||||
final height = size.height;
|
||||
|
||||
return pendingAsync.when(
|
||||
data: (data) {
|
||||
final list = data.data ?? [];
|
||||
if (list.isEmpty) {
|
||||
// Using Get's capitalize extension explicitly
|
||||
return Center(child: Text("No ${status.capitalizeFirst} Requests"));
|
||||
}
|
||||
|
||||
return ListView.separated(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
width * 0.04,
|
||||
height * 0.01,
|
||||
width * 0.04,
|
||||
height * 0.2,
|
||||
),
|
||||
itemCount: list.length,
|
||||
separatorBuilder: (_, __) => SizedBox(height: height * 0.01),
|
||||
itemBuilder: (context, index) {
|
||||
final item = list[index];
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: const Color(0xFFE1E1E1), width: 1),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: const Color.fromARGB(117, 192, 192, 189),
|
||||
blurRadius: 15,
|
||||
offset: const Offset(0, 1),
|
||||
),
|
||||
],
|
||||
),
|
||||
padding: EdgeInsets.all(width * 0.03),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 🔹 File ID Row
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: 'File ID : ',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-SemiBold',
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: width * 0.04,
|
||||
color: const Color(0xFF111827),
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: '${item.id}',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: width * 0.04,
|
||||
color: const Color(0xFF111827),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// 🔹 Status Badges
|
||||
if (item.status == 'Waiting for Admin' ||
|
||||
item.status == 'Payment Pending' ||
|
||||
item.status == 'Cancelled By Admin')
|
||||
Container(
|
||||
width: width * 0.3,
|
||||
height: height * 0.04,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFFFE8E8),
|
||||
borderRadius: BorderRadius.circular(5.52),
|
||||
border: Border.all(
|
||||
color: const Color(0xFFFFD7D7),
|
||||
width: 1.84,
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.25),
|
||||
blurRadius: 7.17,
|
||||
offset: const Offset(0, 3.68),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
item.status.toString(),
|
||||
style: const TextStyle(
|
||||
fontFamily: 'Gilroy-SemiBold',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 11.03,
|
||||
color: Color(0xFFFF0F0F),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// 🔹 In Progress Badge
|
||||
if (item.status == 'In Progress')
|
||||
Container(
|
||||
width: 98,
|
||||
height: 34.9,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFEAFAE6),
|
||||
borderRadius: BorderRadius.circular(6.21),
|
||||
border: Border.all(
|
||||
color: const Color(0xFFDDFFDD),
|
||||
width: 2.07,
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.25),
|
||||
blurRadius: 8.08,
|
||||
offset: const Offset(0, 4.14),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
'In Progress',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-SemiBold',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 12.43,
|
||||
letterSpacing: 0.03,
|
||||
color: Color(0xFF12800C),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// 🔹 Completed Badge
|
||||
if (item.status == 'Completed')
|
||||
Container(
|
||||
width: 87,
|
||||
height: 31,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFFAF7E6),
|
||||
borderRadius: BorderRadius.circular(5.52),
|
||||
border: Border.all(
|
||||
color: const Color(0xFFFFE9DD),
|
||||
width: 1.84,
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.25),
|
||||
blurRadius: 7.17,
|
||||
offset: const Offset(0, 3.68),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
'Completed',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-SemiBold',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 11.03,
|
||||
letterSpacing: 0.03,
|
||||
color: Color(0xFFFF630F),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
SizedBox(height: height * 0.015),
|
||||
|
||||
// 🔹 Request Type
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: 'Request Type : ',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-SemiBold',
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: width * 0.035,
|
||||
color: const Color(0xFF111827),
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: item.service,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: width * 0.035,
|
||||
color: const Color(0xFF111827),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: height * 0.015),
|
||||
|
||||
// 🔹 Date and Time Row
|
||||
Row(
|
||||
children: [
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: 'Date : ',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-SemiBold',
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: width * 0.035,
|
||||
color: const Color(0xFF111827),
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: item.createdDate,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: width * 0.035,
|
||||
color: const Color(0xFF111827),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(width: width * 0.05),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: 'Time : ',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-SemiBold',
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: width * 0.035,
|
||||
color: const Color(0xFF111827),
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: item.createdTime,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: width * 0.035,
|
||||
color: const Color(0xFF111827),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
SizedBox(height: height * 0.015),
|
||||
|
||||
// 🔹 Message
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: 'Message : ',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-SemiBold',
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: width * 0.035,
|
||||
color: const Color(0xFF111827),
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: item.message,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-Medium',
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: width * 0.035,
|
||||
color: const Color(0xFF111827),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: height * 0.015),
|
||||
const Divider(),
|
||||
SizedBox(height: height * 0.015),
|
||||
|
||||
// 🔹 Conditional Buttons & Amount
|
||||
if (item.paymentStatus == "Unpaid") ...[
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Total Amount",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-SemiBold',
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: width * 0.038,
|
||||
color: const Color(0xFF111827),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'₹ ${item.paymentAmount.toString()}',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Roboto',
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: width * 0.05,
|
||||
color: const Color(0xFF111827),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: height * 0.015),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
// Add payment functionality here
|
||||
},
|
||||
child: Container(
|
||||
height: height * 0.055,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFF7E9FF),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
border: Border.all(
|
||||
color: const Color(0xFFD39FEA),
|
||||
width: 1,
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.25),
|
||||
blurRadius: 7.8,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
"Pay Now",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-SemiBold',
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 16,
|
||||
color: Color(0xFF61277A),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: width * 0.03),
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
ref.invalidate(serviceDetailProvider);
|
||||
Get.offAll(
|
||||
() => MainController(
|
||||
initialIndex: 2, // ✅ History tab
|
||||
child: DetailScreen(
|
||||
id: int.parse(item.id.toString()),
|
||||
sourceTabIndex: 2, // ✅ Remember source
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
height: height * 0.055,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF5F297B),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.25),
|
||||
blurRadius: 7.8,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
"View Details",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-SemiBold',
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 16,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
] else if (item.paymentStatus == "Paid") ...[
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Container(
|
||||
width: 149,
|
||||
height: 33,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF04690B),
|
||||
borderRadius: BorderRadius.circular(4.53),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.25),
|
||||
blurRadius: 5.89,
|
||||
offset: const Offset(0, 3.02),
|
||||
),
|
||||
],
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: const Text(
|
||||
"Payment Status: Paid",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-SemiBold',
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 12.08,
|
||||
letterSpacing: 0.04,
|
||||
height: 1.3,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
ref.invalidate(serviceDetailProvider);
|
||||
Get.offAll(
|
||||
() => MainController(
|
||||
initialIndex: 2, // ✅ History tab
|
||||
child: DetailScreen(
|
||||
id: int.parse(item.id.toString()),
|
||||
sourceTabIndex: 2, // ✅ Remember source
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
height: height * 0.055,
|
||||
width: width * 0.35,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF5F297B),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.25),
|
||||
blurRadius: 7.8,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
"View Details",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-SemiBold',
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 16,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
] else if (item.paymentStatus == "Waiting") ...[
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
ref.invalidate(serviceDetailProvider);
|
||||
Get.offAll(
|
||||
() => MainController(
|
||||
initialIndex: 2, // ✅ History tab
|
||||
child: DetailScreen(
|
||||
id: int.parse(item.id.toString()),
|
||||
sourceTabIndex: 2, // ✅ Remember source
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
height: height * 0.055,
|
||||
width: width * 0.35,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF5F297B),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.25),
|
||||
blurRadius: 7.8,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
"View Details",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-SemiBold',
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 16,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
SizedBox(height: height * 0.02),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
loading: () => const Center(child: CircularProgressIndicator()),
|
||||
error: (error, _) => Center(
|
||||
child: Text("Error: $error", style: const TextStyle(color: Colors.red)),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:taxglide/view/screens/history/flitter_popup.dart';
|
||||
import 'package:taxglide/view/screens/history/pending_screen.dart';
|
||||
|
||||
class ServicesStatusScreen extends ConsumerStatefulWidget {
|
||||
const ServicesStatusScreen({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<ServicesStatusScreen> createState() =>
|
||||
_ServicesStatusScreenState();
|
||||
}
|
||||
|
||||
class _ServicesStatusScreenState extends ConsumerState<ServicesStatusScreen>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late TabController _tabController;
|
||||
|
||||
final List<String> _tabs = [
|
||||
"Pending",
|
||||
"In Progress",
|
||||
"Completed",
|
||||
"Cancelled Request",
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_tabController = TabController(
|
||||
length: _tabs.length,
|
||||
vsync: this,
|
||||
animationDuration: Duration.zero,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_tabController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
body: SafeArea(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// ✅ Title
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 21),
|
||||
child: SizedBox(
|
||||
height: 50,
|
||||
width: double.infinity,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const SizedBox(width: 40), // ✅ Left side space balance
|
||||
// ✅ CENTER TITLE
|
||||
const Text(
|
||||
"Service Status",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Gilroy-SemiBold',
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 24,
|
||||
color: Color(0xFF111827),
|
||||
),
|
||||
),
|
||||
|
||||
// ✅ RIGHT SIDE FILTER ICON
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
FlitterPopup.show(context);
|
||||
},
|
||||
child: Container(
|
||||
width: 39,
|
||||
height: 39,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: const Color(0xFF055976),
|
||||
width: 0.8,
|
||||
),
|
||||
),
|
||||
child: const Center(
|
||||
child: Icon(
|
||||
Icons.filter_list,
|
||||
color: Color(0xFF055976),
|
||||
size: 22,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// ✅ Tabs
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(color: Color(0xFFDEDEDE), width: 1),
|
||||
),
|
||||
),
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: TabBar(
|
||||
controller: _tabController,
|
||||
isScrollable: true,
|
||||
padding: EdgeInsets.zero,
|
||||
labelPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 10,
|
||||
),
|
||||
tabAlignment: TabAlignment.start,
|
||||
splashFactory: NoSplash.splashFactory,
|
||||
overlayColor: const MaterialStatePropertyAll(
|
||||
Colors.transparent,
|
||||
),
|
||||
indicatorColor: const Color(0xFF5F297B),
|
||||
indicator: const UnderlineTabIndicator(
|
||||
borderSide: BorderSide(width: 3, color: Color(0xFF5F297B)),
|
||||
insets: EdgeInsets.fromLTRB(6, 0, 4, 10),
|
||||
),
|
||||
labelColor: const Color(0xFF5F297B),
|
||||
unselectedLabelColor: const Color(0xFF6C7278),
|
||||
labelStyle: const TextStyle(
|
||||
fontFamily: "Gilroy-SemiBold",
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 16,
|
||||
height: 1.4,
|
||||
letterSpacing: 0.03,
|
||||
color: Color(0xFF5F297B),
|
||||
),
|
||||
unselectedLabelStyle: const TextStyle(
|
||||
fontFamily: "Gilroy-Regular",
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 16,
|
||||
height: 1.4,
|
||||
letterSpacing: 0.03,
|
||||
color: Color(0xFF6C7278),
|
||||
),
|
||||
tabs: _tabs.map((tab) => Tab(text: tab)).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// ✅ Tab Views
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
children: const [
|
||||
ColoredBox(
|
||||
color: Color.fromARGB(255, 230, 229, 229),
|
||||
child: PendingScreen(status: "pending"),
|
||||
),
|
||||
ColoredBox(
|
||||
color: Color.fromARGB(255, 230, 229, 229),
|
||||
child: PendingScreen(status: "inprogress"),
|
||||
),
|
||||
ColoredBox(
|
||||
color: Color.fromARGB(255, 230, 229, 229),
|
||||
child: PendingScreen(status: "completed"),
|
||||
),
|
||||
ColoredBox(
|
||||
color: Color.fromARGB(255, 230, 229, 229),
|
||||
child: PendingScreen(status: "cancelled"),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user