2026-04-11

This commit is contained in:
Sarankumar committed 2026-04-11 10:21:31 +05:30
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
+243
View File
@@ -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"),
),
],
),
),
],
),
),
);
}
}
File diff suppressed because it is too large. Load diff
+119
View File
@@ -0,0 +1,119 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:taxglide/consts/app_asstes.dart';
import 'package:taxglide/consts/comman_serivce.dart';
import 'package:taxglide/controller/api_contoller.dart';
import 'package:taxglide/model/serivce_list_model.dart';
class ListServiceScreen extends ConsumerStatefulWidget {
const ListServiceScreen({super.key});
@override
ConsumerState<ListServiceScreen> createState() => _ListServiceScreenState();
}
class _ListServiceScreenState extends ConsumerState<ListServiceScreen> {
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
final serviceAsync = ref.watch(serviceListProvider);
final screenWidth = size.width;
return Scaffold(
body: SafeArea(
child: Container(
height: size.height,
width: size.width,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage(AppAssets.backgroundimages),
fit: BoxFit.cover,
),
),
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"List of Services Offered",
style: TextStyle(
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight.w600,
fontStyle: FontStyle.normal,
fontSize: 18,
height: 1.3,
letterSpacing: 0.72,
),
textAlign: TextAlign.center,
),
const SizedBox(height: 26),
/// 🔹 Service List from API
serviceAsync.when(
data: (services) {
if (services.isEmpty) {
return const Padding(
padding: EdgeInsets.only(top: 40),
child: Center(
child: Text(
"No Services Available",
style: TextStyle(
fontSize: 16,
fontFamily: 'Gilroy-SemiBold',
color: Colors.black54,
),
),
),
);
}
return GridView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: services.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: screenWidth < 400
? 3
: screenWidth < 700
? 3
: 4,
mainAxisSpacing: 16,
crossAxisSpacing: 12,
childAspectRatio: 0.75,
),
itemBuilder: (context, index) {
return CommonServiceItem(
service: ServiceListModel(
id: services[index].id,
service: services[index].service,
icon: services[index].icon,
),
sourceTabIndex: 1,
);
},
);
},
loading: () => const Center(
child: Padding(
padding: EdgeInsets.all(20),
child: CircularProgressIndicator(),
),
),
error: (err, _) => Center(
child: Padding(
padding: const EdgeInsets.all(20),
child: Text('Error loading services: $err'),
),
),
),
],
),
),
),
),
),
);
}
}
+151
View File
@@ -0,0 +1,151 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:taxglide/controller/api_contoller.dart';
import 'package:taxglide/model/notification_model.dart';
import 'package:taxglide/view/Mahi_chat/live_chat_screen.dart';
import 'package:taxglide/view/screens/history/detail_screen.dart';
import 'package:taxglide/view/Main_controller/main_controller.dart';
class NotificationScreen extends ConsumerStatefulWidget {
const NotificationScreen({super.key});
@override
ConsumerState<NotificationScreen> createState() => _NotificationScreenState();
}
class _NotificationScreenState extends ConsumerState<NotificationScreen> {
@override
Widget build(BuildContext context) {
final state = ref.watch(notificationProvider(1)); // page = 1
return Scaffold(
body: SafeArea(
child: Column(
children: [
_buildHeader(),
Expanded(
child: state.when(
loading: () => const Center(child: CircularProgressIndicator()),
error: (e, _) => Center(child: Text("Error: $e")),
data: (list) => ListView.builder(
itemCount: list.length,
itemBuilder: (context, index) {
final item = list[index];
return _buildNotificationTile(item);
},
),
),
),
],
),
),
);
}
// HEADER UI
Widget _buildHeader() {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 21),
child: SizedBox(
height: 50,
width: double.infinity,
child: Stack(
alignment: Alignment.center,
children: [
const Text(
"Notification",
style: TextStyle(
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight.w600,
fontSize: 24,
color: Color(0xFF111827),
),
),
Positioned(
left: 0,
child: GestureDetector(
onTap: () {
// 🔥 Force refresh when user goes BACK
ref.read(notificationTriggerProvider.notifier).state++;
ref.invalidate(chatMessagesProvider);
Get.offAll(() => const MainController());
},
child: const Icon(Icons.arrow_back_ios_rounded),
),
),
],
),
),
);
}
// NOTIFICATION TILE
Widget _buildNotificationTile(NotificationModel item) {
return GestureDetector(
onTap: () {
if (item.page.isEmpty || item.pageId == null) return;
final String page = item.page.toLowerCase();
final int id = item.pageId!;
if (page == 'chat') {
// Navigate to chat
Get.to(() => LiveChatScreen(chatid: id, fileid: '0'))?.then((_) {
ref.read(notificationTriggerProvider.notifier).state++;
ref.invalidate(chatMessagesProvider);
ref.invalidate(notificationProvider);
});
} else if (page == 'service') {
// Navigate to service detail
Get.to(
() => MainController(
initialIndex: 2,
child: DetailScreen(id: id, sourceTabIndex: 2),
),
);
} else if (page.contains('profile')) {
// Navigate to profile (Assuming MainController index 3 is Profile)
Get.to(() => const MainController(initialIndex: 3));
}
},
child: Container(
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
padding: const EdgeInsets.all(14),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
boxShadow: [BoxShadow(color: Colors.black12, blurRadius: 4)],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
item.title,
style: const TextStyle(
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight.w700,
fontSize: 16,
color: Colors.black,
),
),
const SizedBox(height: 4),
Text(
item.description,
style: const TextStyle(fontSize: 14, color: Colors.grey),
),
const SizedBox(height: 8),
Text(
item.createdAt,
style: const TextStyle(fontSize: 12, color: Colors.grey),
),
],
),
),
);
}
}
@@ -0,0 +1,260 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:get/get.dart';
import 'package:taxglide/consts/app_asstes.dart';
import 'package:taxglide/controller/api_contoller.dart';
class EmployeeProfileList extends ConsumerStatefulWidget {
const EmployeeProfileList({super.key});
@override
ConsumerState<EmployeeProfileList> createState() =>
_EmployeeProfileListState();
}
class _EmployeeProfileListState extends ConsumerState<EmployeeProfileList> {
String yesNo(dynamic value) {
return value == 1 ? "Yes" : "No";
}
String statusText(dynamic value) {
return value == 1 ? "Active" : "Inactive";
}
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
final profileAsync = ref.watch(employeeProfileProvider);
return Scaffold(
body: Container(
height: size.height,
width: size.width,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage(AppAssets.backgroundimages),
fit: BoxFit.cover,
),
),
child: SafeArea(
child: profileAsync.when(
data: (profile) {
final data = profile.data;
if (data == null) {
return const Center(
child: Text(
"No profile data found",
style: TextStyle(color: Colors.white),
),
);
}
return SingleChildScrollView(
padding: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 20,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
/// ---------------- HEADER ----------------
Padding(
padding: const EdgeInsets.symmetric(vertical: 21),
child: SizedBox(
height: 50,
width: double.infinity,
child: Stack(
alignment: Alignment.center,
children: [
const Text(
"KYC Details",
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight
.w600, // equivalent to 400 (Normal)
fontStyle: FontStyle.normal,
fontSize: 24,
height: 1.3, // line-height: 130%
letterSpacing:
0.04 * 24, // 4% of font size = 0.96px
color: Color(0xFF111827), // background: #111827
),
),
Positioned(
left: 0,
child: GestureDetector(
onTap: () => Get.back(),
child: const Icon(Icons.arrow_back_ios_rounded),
),
),
],
),
),
),
const SizedBox(height: 20),
/// ---------------- CARD ----------------
Container(
width: double.infinity,
padding: const EdgeInsets.all(18),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(14),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
blurRadius: 6,
offset: const Offset(0, 3),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
"Personal Details",
style: TextStyle(
fontFamily: 'Gilroy-SemiBold',
fontSize: 20,
color: Color(0xFF111827),
),
),
const SizedBox(height: 25),
_buildDetailRow("Name : ", data.name),
const SizedBox(height: 24),
_buildDetailRow("Mobile : ", data.mobile),
const SizedBox(height: 24),
_buildDetailRow("Email : ", data.email),
const SizedBox(height: 24),
_buildDetailRow(
"Company Name : ",
data.company?.companyName ?? "N/A",
),
const SizedBox(height: 24),
_buildDetailRow(
"Service : ",
yesNo(data.createService),
),
const SizedBox(height: 24),
_buildDetailRow("Status : ", statusText(data.status)),
const SizedBox(height: 24),
_buildDetailRow(
"General Chat : ",
yesNo(data.generalChat),
),
],
),
),
const SizedBox(height: 30),
/// ---------------- COMPANY LOGO ----------------
if (data.company?.companyLogo != null)
GridView.count(
crossAxisCount: 2,
crossAxisSpacing: 15,
mainAxisSpacing: 15,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
children: [
_buildImageBox(
"Company Logo",
data.company!.companyLogo!,
),
],
),
const SizedBox(height: 40),
],
),
);
},
loading: () => const Center(
child: CircularProgressIndicator(color: Colors.white),
),
error: (e, _) => Center(
child: Text(
"Error loading profile: $e",
style: const TextStyle(color: Colors.redAccent),
),
),
),
),
),
);
}
/// ---------------- TEXT ROW ----------------
Widget _buildDetailRow(String title, String value) {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: const TextStyle(
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight.w600,
fontSize: 14,
height: 1.3,
letterSpacing: 0.64,
color: Colors.black87,
),
),
Flexible(
child: Text(
value,
softWrap: true,
overflow: TextOverflow.visible,
style: const TextStyle(
fontFamily: 'Gilroy-Regular',
fontWeight: FontWeight.w400,
fontSize: 14,
height: 1.3,
letterSpacing: 0.64,
color: Color(0xFF111827),
),
),
),
],
);
}
/// ---------------- IMAGE BOX ----------------
Widget _buildImageBox(String label, String imageUrl) {
return Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.grey.shade300),
),
child: Column(
children: [
const SizedBox(height: 10),
Text(
label,
style: const TextStyle(fontWeight: FontWeight.w600, fontSize: 13),
),
const SizedBox(height: 10),
Expanded(
child: Image.network(
imageUrl,
fit: BoxFit.contain,
errorBuilder: (_, __, ___) => const Icon(Icons.broken_image),
),
),
const SizedBox(height: 10),
],
),
);
}
}
@@ -0,0 +1,450 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.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/consts/app_colors.dart';
import 'package:taxglide/controller/api_contoller.dart';
import 'package:taxglide/controller/api_repository.dart';
import 'package:taxglide/main.dart';
import 'package:taxglide/router/consts_routers.dart';
class EmployeeProfileScreen extends ConsumerStatefulWidget {
const EmployeeProfileScreen({super.key});
@override
ConsumerState<EmployeeProfileScreen> createState() =>
_EmployeeProfileScreenState();
}
class _EmployeeProfileScreenState extends ConsumerState<EmployeeProfileScreen> {
String? selectedItem;
bool _isLoggingOut = false;
@override
Widget build(BuildContext context) {
final profileAsync = ref.watch(employeeProfileProvider);
return Scaffold(
backgroundColor: Colors.white,
body: profileAsync.when(
data: (profile) {
final data = profile.data;
return Column(
children: [
Stack(
clipBehavior: Clip.none,
children: [
Container(
width: double.infinity,
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(50),
bottomRight: Radius.circular(50),
),
),
child: ClipRRect(
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(140),
bottomRight: Radius.circular(0),
),
child: Align(
alignment: Alignment.centerRight,
child: Image.asset(
AppAssets.profilebanner,
fit: BoxFit.cover,
height: 200,
width: MediaQuery.of(context).size.width * 1.3,
),
),
),
),
Positioned(
bottom: -50,
left: 0,
right: 0,
child: Center(
child: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(color: Colors.white, width: 4),
),
child:
(data?.company?.companyLogo != null &&
data!.company!.companyLogo!.isNotEmpty)
? CircleAvatar(
radius: 50,
backgroundImage: NetworkImage(
data.company!.companyLogo!,
),
)
: Container(
width: 100,
height: 100,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: Colors.black87,
),
child: Center(
child: Text(
(data?.name != null &&
data!.name.isNotEmpty)
? data.name[0].toUpperCase()
: "M",
style: const TextStyle(
color: Colors.white,
fontSize: 40,
fontWeight: FontWeight.bold,
),
),
),
),
),
),
),
],
),
const SizedBox(height: 60),
Text(
data?.name ?? 'No Company Name',
style: const TextStyle(
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight.w600,
fontSize: 20,
color: Colors.black,
),
textAlign: TextAlign.center,
),
const SizedBox(height: 30),
Expanded(
child: ListView(
padding: const EdgeInsets.symmetric(horizontal: 20),
children: [
_buildMenuItem(
id: 'profile',
icon: Icons.person_outline,
title: 'Profile',
onTap: () {
setState(() {
selectedItem = 'profile';
});
ref.invalidate(employeeProfileProvider);
Get.toNamed(ConstRouters.employeekycdetailslist);
},
),
const SizedBox(height: 16),
_buildMenuItem(
id: 'terms',
icon: Icons.description_outlined,
title: 'Terms and Conditions',
onTap: () {
setState(() {
selectedItem = 'terms';
});
ref.invalidate(termsProvider);
Get.toNamed(ConstRouters.terms);
},
),
const SizedBox(height: 16),
_buildMenuItem(
id: 'policy',
icon: Icons.policy_outlined,
title: 'Policy',
onTap: () {
setState(() {
selectedItem = 'policy';
});
ref.invalidate(termsProvider);
Get.toNamed(ConstRouters.policy);
},
),
const SizedBox(height: 16),
_buildMenuItem(
id: 'logout',
icon: Icons.logout,
title: 'Log out',
onTap: () {
setState(() {
selectedItem = 'logout';
});
_showLogoutPopup(context);
},
),
],
),
),
],
);
},
loading: () => const Center(child: CircularProgressIndicator()),
error: (err, _) => Center(child: Text('Error: $err')),
),
);
}
/// ----------------------- LOGOUT POPUP ---------------------
void _showLogoutPopup(BuildContext context) {
showGeneralDialog(
context: context,
barrierDismissible: true,
barrierLabel: 'Logout',
barrierColor: Colors.black.withOpacity(0.2),
transitionDuration: const Duration(milliseconds: 300),
pageBuilder: (context, animation, secondaryAnimation) {
return const SizedBox.shrink();
},
transitionBuilder: (context, animation, secondaryAnimation, child) {
final offsetAnimation =
Tween<Offset>(begin: const Offset(0, -1), end: Offset.zero).animate(
CurvedAnimation(parent: animation, curve: Curves.easeOutBack),
);
return SlideTransition(
position: offsetAnimation,
child: Align(
alignment: Alignment.topCenter,
child: Padding(
padding: const EdgeInsets.only(top: 60.0),
child: Material(
color: Colors.transparent,
child: Container(
width: MediaQuery.of(context).size.width * 0.9,
height: 160,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(7.75),
border: Border.all(color: Colors.white, width: 3.87),
boxShadow: const [
BoxShadow(
color: Color(0x7A5E5E5E),
offset: Offset(0, 2.32),
blurRadius: 9.14,
spreadRadius: 3.1,
),
],
),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 16,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
"Note",
style: TextStyle(
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight.w600,
fontSize: 20,
color: Colors.black,
),
),
const Text(
"Are you sure you want to log out?",
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight.w500,
fontSize: 15,
color: Colors.black87,
),
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text(
"Cancel",
style: TextStyle(
color: Color(0xFF535A5B),
fontSize: 16,
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight.w600,
),
),
),
const SizedBox(width: 8),
TextButton(
onPressed: _isLoggingOut
? null
: () async {
Navigator.pop(context);
setState(() {
_isLoggingOut = true;
});
try {
await ApiRepository().logout();
_showSnackBar("Logout successful");
await Future.delayed(
const Duration(milliseconds: 800),
);
Get.offAllNamed(
ConstRouters.employeelogin,
);
} catch (e) {
_showSnackBar(
e.toString(),
isError: true,
);
} finally {
setState(() {
_isLoggingOut = false;
});
}
},
child: _isLoggingOut
? const SizedBox(
height: 18,
width: 18,
child: CircularProgressIndicator(
strokeWidth: 2,
color: Color(0xFF5F297B),
),
)
: const Text(
"Log Out",
style: TextStyle(
color: Color(0xFF5F297B),
fontSize: 16,
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight.w600,
),
),
),
],
),
],
),
),
),
),
),
),
);
},
);
}
/// ----------------------- MENU ITEM ---------------------
Widget _buildMenuItem({
required String id,
required IconData icon,
required String title,
required VoidCallback onTap,
}) {
final isSelected = selectedItem == id;
return InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(12),
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
child: Row(
children: [
SizedBox(
width: 24,
height: 48,
child: isSelected
? CustomPaint(
size: const Size(24, 48),
painter: BeveledTrianglePainter(),
)
: const SizedBox.shrink(),
),
Expanded(
child: Container(
height: 58,
decoration: BoxDecoration(
color: isSelected
? const Color(0xFFEEFAFF)
: Colors.transparent,
borderRadius: BorderRadius.circular(12),
),
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(
children: [
Icon(icon, size: 24, color: Colors.black87),
const SizedBox(width: 16),
Expanded(
child: Text(
title,
style: const TextStyle(
fontFamily: 'Gilroy-Medium',
fontSize: 16,
fontWeight: FontWeight.w500,
color: Colors.black87,
),
),
),
],
),
),
),
],
),
);
}
/// ----------------------- SNACK BAR ---------------------
void _showSnackBar(String msg, {bool isError = false}) {
rootScaffoldMessengerKey.currentState?.showSnackBar(
SnackBar(
duration: const Duration(seconds: 2),
backgroundColor: isError ? Colors.red : AppColors.commanbutton,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
behavior: SnackBarBehavior.floating,
margin: const EdgeInsets.symmetric(horizontal: 70, vertical: 25),
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12),
content: Row(
children: [
Image.asset(AppAssets.taxgildelogoauth, height: 18, width: 18),
const SizedBox(width: 8),
Expanded(
child: Text(
msg,
style: const TextStyle(color: Colors.white, fontSize: 12),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
],
),
),
);
}
}
class BeveledTrianglePainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()
..color = const Color(0xFF5E2976)
..style = PaintingStyle.fill;
final path = Path()
..moveTo(0, 4)
..lineTo(size.width - 6, size.height / 2)
..lineTo(0, size.height - 4)
..close();
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) => false;
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,449 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:get/get.dart';
import 'package:taxglide/consts/app_asstes.dart';
import 'package:taxglide/consts/download_helper.dart';
import 'package:taxglide/controller/api_consts.dart';
import 'package:taxglide/controller/api_contoller.dart';
import 'package:taxglide/router/consts_routers.dart';
class KycDetailsList extends ConsumerStatefulWidget {
const KycDetailsList({super.key});
@override
ConsumerState<KycDetailsList> createState() => _KycDetailsListState();
}
class _KycDetailsListState extends ConsumerState<KycDetailsList> {
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
final profileAsync = ref.watch(profileProvider);
return Scaffold(
body: Container(
height: size.height,
width: size.width,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage(AppAssets.backgroundimages),
fit: BoxFit.cover,
),
),
child: SafeArea(
child: profileAsync.when(
data: (profile) {
final data = profile.data;
if (data == null) {
return const Center(
child: Text(
"No KYC data found",
style: TextStyle(color: Colors.white),
),
);
}
return SingleChildScrollView(
physics: const BouncingScrollPhysics(),
padding: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 20,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.symmetric(vertical: 21),
child: SizedBox(
height: 50,
width: double.infinity,
child: Stack(
alignment: Alignment.center,
children: [
const Text(
"KYC Details",
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight
.w600, // equivalent to 400 (Normal)
fontStyle: FontStyle.normal,
fontSize: 24,
height: 1.3, // line-height: 130%
letterSpacing:
0.04 * 24, // 4% of font size = 0.96px
color: Color(0xFF111827), // background: #111827
),
),
Positioned(
left: 0,
child: GestureDetector(
onTap: () => Get.back(),
child: const Icon(Icons.arrow_back_ios_rounded),
),
),
],
),
),
),
const SizedBox(height: 20),
// White Card
Container(
width: double.infinity,
padding: const EdgeInsets.all(18),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(14),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
blurRadius: 6,
offset: const Offset(0, 3),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
"Personal Details",
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight
.w400, // equivalent to 400 (Normal)
fontStyle: FontStyle.normal,
fontSize: 20,
height: 1.3, // line-height: 130%
letterSpacing:
0.04 * 20, // 4% of font size = 0.8px
color: Color(
0xFF111827,
), // background: #111827
),
),
GestureDetector(
onTap: () {
Get.toNamed(ConstRouters.kycdetails);
},
child: Container(
width: 109,
padding: const EdgeInsets.symmetric(
vertical: 8,
horizontal: 12,
),
decoration: BoxDecoration(
color: const Color(
0xFFFFFFFF,
), // background: #FFFFFF
borderRadius: BorderRadius.circular(
8,
), // border-radius: 8px
border: Border.all(
color: const Color(
0xFFE3E3E3,
), // border: 1px solid #E3E3E3
width: 1,
),
boxShadow: [
BoxShadow(
color: const Color(0xFF767373)
.withOpacity(
0.25,
), // #76737340 ≈ 25% opacity
blurRadius: 10,
offset: const Offset(0, 0),
),
],
),
child: Row(
mainAxisAlignment: MainAxisAlignment
.center, // center horizontally
crossAxisAlignment: CrossAxisAlignment
.center, // center vertically
children: const [
Icon(
Icons.edit_outlined,
size: 18,
color: Color(
0xFF111827,
), // matches your text color
),
SizedBox(width: 6),
Text(
'Edit',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight.w600,
fontStyle: FontStyle.normal,
fontSize: 16,
height: 1.3, // 130%
letterSpacing: 0.04 * 16, // 4%
color: Color(0xFF111827),
),
),
],
),
),
),
],
),
SizedBox(height: 25),
_buildDetailRow('Company Name : ', data.companyName),
const SizedBox(height: 24),
_buildDetailRow('PAN Number : ', data.panNumber),
const SizedBox(height: 24),
_buildDetailRow('GST Number : ', data.gstNumber),
const SizedBox(height: 24),
_buildDetailRow(
'Year of Incorporation : ',
data.yearOfIncorporation?.toString(),
),
const SizedBox(height: 24),
_buildDetailRow('Email : ', data.companyEmail),
const SizedBox(height: 24),
_buildDetailRow(
'Phone Number : ',
data.companyMobile,
),
const SizedBox(height: 24),
_buildDetailRow('Address : ', data.companyAddress),
const SizedBox(height: 24),
_buildDetailRow('Country : ', data.countryName),
const SizedBox(height: 24),
_buildDetailRow('State : ', data.stateName),
const SizedBox(height: 24),
_buildDetailRow('City : ', data.districtName),
const SizedBox(height: 24),
_buildDetailRow('PinCode : ', data.companyPincode),
],
),
),
const SizedBox(height: 30),
// 4 Image Containers
GridView.count(
crossAxisCount: 2,
crossAxisSpacing: 15,
mainAxisSpacing: 15,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
children: [
_buildImageBox("GST Certificate ", data.gstFile),
_buildImageBox("PAN File", data.panFile),
_buildImageBox(
"Incorporation File",
data.incorporationFile,
),
_buildImageBox("Profile Image", data.logo),
],
),
const SizedBox(height: 40),
],
),
);
},
loading: () => const Center(
child: CircularProgressIndicator(color: Colors.white),
),
error: (e, st) => Center(
child: Text(
"Error loading KYC details: $e",
style: const TextStyle(color: Colors.redAccent),
),
),
),
),
),
);
}
Widget _buildDetailRow(String title, String? value) {
if (value == null || value.isEmpty) return const SizedBox.shrink();
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: const TextStyle(
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight.w600,
fontSize: 14,
height: 1.3,
letterSpacing: 0.64,
color: Colors.black87,
),
),
Flexible(
child: Text(
value,
softWrap: true,
overflow: TextOverflow.visible,
style: const TextStyle(
fontFamily: 'Gilroy-Regular',
fontWeight: FontWeight.w400,
fontSize: 14,
height: 1.3,
letterSpacing: 0.64,
color: Color(0xFF111827),
),
),
),
],
);
}
Widget _buildImageBox(String label, String? imageUrl) {
final fullUrl = imageUrl != null && imageUrl.isNotEmpty
? imageUrl.startsWith('http')
? imageUrl
: "${ConstsApi.baseUrl}/api/$imageUrl"
: null;
final isDocument =
label.toLowerCase().contains('gst') ||
label.toLowerCase().contains('pan') ||
label.toLowerCase().contains('incorporation');
return Container(
width: 175,
height: 155,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.grey.shade300),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.08),
blurRadius: 8,
offset: const Offset(0, 3),
),
],
),
child: Padding(
padding: const EdgeInsets.all(10),
child: Column(
children: [
/// ✅ LABEL
Text(
label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center,
style: const TextStyle(
fontFamily: 'Roboto',
fontWeight: FontWeight.w600,
fontSize: 13,
),
),
const SizedBox(height: 8),
/// ✅ IMAGE / DOCUMENT PREVIEW
Expanded(
child: InkWell(
onTap: fullUrl == null
? null
: () async {
await DownloadHelper.downloadFileToReceived(fullUrl);
setState(() {});
},
child: Container(
width: double.infinity,
decoration: BoxDecoration(
color: Colors.grey.shade100,
borderRadius: BorderRadius.circular(10),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(10),
child: fullUrl != null
? isDocument
? const Center(
child: Icon(
Icons.insert_drive_file_rounded,
size: 50,
color: Colors.blueGrey,
),
)
: Image.network(
fullUrl,
fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) =>
const Center(
child: Icon(Icons.broken_image),
),
)
: const Center(
child: Icon(Icons.image_not_supported, size: 40),
),
),
),
),
),
const SizedBox(height: 8),
/// ✅ DOWNLOAD / VIEW BUTTON
if (fullUrl != null)
FutureBuilder<String?>(
future: DownloadHelper.checkFileExistsInReceived(fullUrl),
builder: (context, snapshot) {
final existsPath = snapshot.data;
return SizedBox(
height: 36,
child: ElevatedButton.icon(
style: ElevatedButton.styleFrom(
elevation: 0,
backgroundColor: existsPath == null
? Colors.blue
: Colors.green,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30),
),
),
onPressed: () async {
if (existsPath == null) {
await DownloadHelper.downloadFileToReceived(fullUrl);
setState(() {});
} else {
await DownloadHelper.openDownloadedFile(existsPath);
}
},
icon: Icon(
existsPath == null
? Icons.download_rounded
: Icons.remove_red_eye_rounded,
size: 18,
color: Colors.white,
),
label: Text(
existsPath == null ? "Download" : "View",
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: Colors.white,
),
),
),
);
},
),
],
),
),
);
}
}
@@ -0,0 +1,83 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:taxglide/controller/api_contoller.dart';
class PolicyScreen extends ConsumerStatefulWidget {
const PolicyScreen({super.key});
@override
ConsumerState<PolicyScreen> createState() => _PolicyScreenState();
}
class _PolicyScreenState extends ConsumerState<PolicyScreen> {
@override
Widget build(BuildContext context) {
final policyAsync = ref.watch(policyProvider);
return Scaffold(
backgroundColor: const Color.fromARGB(255, 230, 229, 229),
body: SafeArea(
child: policyAsync.when(
data: (policy) => SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 24),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 🔹 Header Row with Back Arrow + Centered Title
Row(
children: [
GestureDetector(
onTap: () => Navigator.pop(context),
child: const Icon(
Icons.arrow_back_ios_new,
color: Colors.black,
size: 22,
),
),
Expanded(
child: Center(
child: Text(
policy.data?.title ?? 'Privacy Policy',
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.w700,
color: Colors.black,
),
),
),
),
// Invisible icon to balance the layout
const Opacity(
opacity: 0,
child: Icon(Icons.arrow_back_ios_new, size: 22),
),
],
),
const SizedBox(height: 24),
// 🔹 Policy Content
Text(
policy.data?.content ?? '',
textAlign: TextAlign.start,
style: const TextStyle(
fontSize: 16,
height: 1.6,
color: Colors.black87,
),
),
],
),
),
loading: () => const Center(child: CircularProgressIndicator()),
error: (err, _) => Center(
child: Text(
'Error: $err',
style: const TextStyle(color: Colors.red),
),
),
),
),
);
}
}
@@ -0,0 +1,539 @@
import 'dart:math' as math show sqrt;
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:get/get.dart';
import 'package:taxglide/consts/app_asstes.dart';
import 'package:taxglide/consts/app_colors.dart';
import 'package:taxglide/consts/local_store.dart';
import 'package:taxglide/controller/api_repository.dart';
import 'package:taxglide/router/consts_routers.dart';
import 'package:taxglide/controller/api_contoller.dart';
import 'package:taxglide/main.dart';
class ProfileScreen extends ConsumerStatefulWidget {
const ProfileScreen({super.key});
@override
ConsumerState<ProfileScreen> createState() => _ProfileScreenState();
}
class _ProfileScreenState extends ConsumerState<ProfileScreen> {
String? selectedItem;
bool _isLoggingOut = false;
String? userRole; // <-- role variable
@override
void initState() {
super.initState();
_loadRole(); // <-- load role on start
}
Future<void> _loadRole() async {
userRole = await LocalStore().getRole();
setState(() {});
}
@override
Widget build(BuildContext context) {
final profileAsync = ref.watch(profileProvider);
return Scaffold(
backgroundColor: Colors.white,
body: profileAsync.when(
data: (profile) {
final data = profile.data;
return SingleChildScrollView(
child: Column(
children: [
Stack(
clipBehavior: Clip.none,
children: [
Container(
width: double.infinity,
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(50),
bottomRight: Radius.circular(50),
),
),
child: ClipRRect(
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(140),
bottomRight: Radius.circular(0),
),
child: Align(
alignment: Alignment.centerRight,
child: Image.asset(
AppAssets.profilebanner,
fit: BoxFit.cover,
height: 200,
width: MediaQuery.of(context).size.width * 1.3,
),
),
),
),
Positioned(
bottom: -50,
left: 0,
right: 0,
child: Center(
child: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(color: Colors.white, width: 4),
),
child: data?.logo != null && data!.logo!.isNotEmpty
? CircleAvatar(
radius: 50,
backgroundImage: NetworkImage(data.logo!),
)
: Container(
width: 100,
height: 100,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: Colors.black87,
),
child: Center(
child: Text(
(data?.companyName != null &&
data!.companyName!.isNotEmpty)
? data.companyName![0].toUpperCase()
: "M",
style: const TextStyle(
color: Colors.white,
fontSize: 40,
fontWeight: FontWeight.bold,
),
),
),
),
),
),
),
],
),
const SizedBox(height: 60),
Text(
data?.companyName ?? 'No Company Name',
style: const TextStyle(
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight.w600,
fontSize: 20,
color: Colors.black,
),
textAlign: TextAlign.center,
),
const SizedBox(height: 30),
ListView(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
padding: const EdgeInsets.symmetric(horizontal: 20),
children: [
_buildMenuItem(
id: 'profile',
icon: Icons.person_outline,
title: 'Profile',
onTap: () {
setState(() {
selectedItem = 'profile';
});
final pan = profile.data?.panNumber ?? '';
ref.invalidate(profileProvider);
if (pan.isNotEmpty) {
Get.toNamed(ConstRouters.kycdetailslist);
} else {
Get.toNamed(ConstRouters.kycdetails);
}
},
),
const SizedBox(height: 16),
if (userRole != "employee")
_buildMenuItem(
id: 'Staff',
icon: Icons.list_alt_outlined,
title: 'Sub - Staff List',
onTap: () {
setState(() {
selectedItem = 'staff';
});
ref.invalidate(staffListProvider);
Get.toNamed(ConstRouters.staff);
},
),
const SizedBox(height: 16),
_buildMenuItem(
id: 'terms',
icon: Icons.description_outlined,
title: 'Terms and Conditions',
onTap: () {
setState(() {
selectedItem = 'terms';
});
ref.invalidate(termsProvider);
Get.toNamed(ConstRouters.terms);
},
),
const SizedBox(height: 16),
_buildMenuItem(
id: 'policy',
icon: Icons.policy_outlined,
title: 'Policy',
onTap: () {
setState(() {
selectedItem = 'policy';
});
ref.invalidate(termsProvider);
Get.toNamed(ConstRouters.policy);
},
),
const SizedBox(height: 16),
_buildMenuItem(
id: 'logout',
icon: Icons.logout,
title: 'Log out',
onTap: () {
setState(() {
selectedItem = 'logout';
});
_showLogoutPopup(context);
},
),
],
),
const SizedBox(height: 50),
],
),
);
},
loading: () => const Center(child: CircularProgressIndicator()),
error: (err, _) => Center(child: Text('Error: $err')),
),
);
}
/// ----------------------- LOGOUT POPUP ---------------------
void _showLogoutPopup(BuildContext context) {
showGeneralDialog(
context: context,
barrierDismissible: true,
barrierLabel: 'Logout',
barrierColor: Colors.black.withOpacity(0.2),
transitionDuration: const Duration(milliseconds: 300),
pageBuilder: (context, animation, secondaryAnimation) {
return const SizedBox.shrink();
},
transitionBuilder: (context, animation, secondaryAnimation, child) {
final offsetAnimation =
Tween<Offset>(begin: const Offset(0, -1), end: Offset.zero).animate(
CurvedAnimation(parent: animation, curve: Curves.easeOutBack),
);
return SlideTransition(
position: offsetAnimation,
child: Align(
alignment: Alignment.topCenter,
child: Padding(
padding: const EdgeInsets.only(top: 60.0),
child: Material(
color: Colors.transparent,
child: Container(
width: MediaQuery.of(context).size.width * 0.9,
height: 160,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(7.75),
border: Border.all(color: Colors.white, width: 3.87),
boxShadow: const [
BoxShadow(
color: Color(0x7A5E5E5E),
offset: Offset(0, 2.32),
blurRadius: 9.14,
spreadRadius: 3.1,
),
],
),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 16,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
"Note",
style: TextStyle(
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight.w600,
fontSize: 20,
color: Colors.black,
),
),
const Text(
"Are you sure you want to log out?",
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight.w500,
fontSize: 15,
color: Colors.black87,
),
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text(
"Cancel",
style: TextStyle(
color: Color(0xFF535A5B),
fontSize: 16,
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight.w600,
),
),
),
const SizedBox(width: 8),
TextButton(
onPressed: _isLoggingOut
? null
: () async {
Navigator.pop(context);
setState(() {
_isLoggingOut = true;
});
try {
await ApiRepository().logout();
_showSnackBar("Logout successful");
await Future.delayed(
const Duration(milliseconds: 800),
);
Get.offAllNamed(ConstRouters.login);
} catch (e) {
_showSnackBar(
e.toString(),
isError: true,
);
} finally {
setState(() {
_isLoggingOut = false;
});
}
},
child: _isLoggingOut
? const SizedBox(
height: 18,
width: 18,
child: CircularProgressIndicator(
strokeWidth: 2,
color: Color(0xFF5F297B),
),
)
: const Text(
"Log Out",
style: TextStyle(
color: Color(0xFF5F297B),
fontSize: 16,
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight.w600,
),
),
),
],
),
],
),
),
),
),
),
),
);
},
);
}
/// ----------------------- MENU ITEM ---------------------
Widget _buildMenuItem({
required String id,
required IconData icon,
required String title,
required VoidCallback onTap,
}) {
final isSelected = selectedItem == id;
return InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(12),
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
child: Row(
children: [
SizedBox(
width: 24,
height: 48,
child: isSelected
? CustomPaint(
size: const Size(24, 48),
painter: BeveledTrianglePainter(),
)
: const SizedBox.shrink(),
),
Expanded(
child: Container(
height: 58,
decoration: BoxDecoration(
color: isSelected
? const Color(0xFFEEFAFF)
: Colors.transparent,
borderRadius: BorderRadius.circular(12),
),
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(
children: [
Icon(icon, size: 24, color: Colors.black87),
const SizedBox(width: 16),
Expanded(
child: Text(
title,
style: const TextStyle(
fontFamily: 'Gilroy-Medium',
fontSize: 16,
fontWeight: FontWeight.w500,
color: Colors.black87,
),
),
),
],
),
),
),
],
),
);
}
/// ----------------------- SNACK BAR ---------------------
void _showSnackBar(String msg, {bool isError = false}) {
rootScaffoldMessengerKey.currentState?.showSnackBar(
SnackBar(
duration: const Duration(seconds: 2),
backgroundColor: isError ? Colors.red : AppColors.commanbutton,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
behavior: SnackBarBehavior.floating,
margin: const EdgeInsets.symmetric(horizontal: 70, vertical: 25),
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12),
content: Row(
children: [
Image.asset(AppAssets.taxgildelogoauth, height: 18, width: 18),
const SizedBox(width: 8),
Expanded(
child: Text(
msg,
style: const TextStyle(color: Colors.white, fontSize: 12),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
),
],
),
),
);
}
}
class BeveledTrianglePainter extends CustomPainter {
final double cornerRadius;
BeveledTrianglePainter({
this.cornerRadius = 4.0, // Adjust this value for more/less rounding
});
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()
..color = const Color(0xFF5E2976)
..style = PaintingStyle.fill;
// Triangle vertices
final vertices = [
Offset(0, cornerRadius), // Top left (adjusted for bevel)
Offset(size.width - 6, size.height / 2), // Right point
Offset(0, size.height - cornerRadius), // Bottom left (adjusted for bevel)
];
final path = Path();
for (int i = 0; i < vertices.length; i++) {
final current = vertices[i];
final next = vertices[(i + 1) % vertices.length];
final prev = vertices[(i - 1 + vertices.length) % vertices.length];
// Calculate direction vectors
final toCurrent = Offset(current.dx - prev.dx, current.dy - prev.dy);
final toNext = Offset(next.dx - current.dx, next.dy - current.dy);
// Normalize
final lengthToCurrent = math.sqrt(
toCurrent.dx * toCurrent.dx + toCurrent.dy * toCurrent.dy,
);
final lengthToNext = math.sqrt(
toNext.dx * toNext.dx + toNext.dy * toNext.dy,
);
final normalizedToCurrent = Offset(
toCurrent.dx / lengthToCurrent,
toCurrent.dy / lengthToCurrent,
);
final normalizedToNext = Offset(
toNext.dx / lengthToNext,
toNext.dy / lengthToNext,
);
// Points before and after the corner
final beforeCorner = Offset(
current.dx - normalizedToCurrent.dx * cornerRadius,
current.dy - normalizedToCurrent.dy * cornerRadius,
);
final afterCorner = Offset(
current.dx + normalizedToNext.dx * cornerRadius,
current.dy + normalizedToNext.dy * cornerRadius,
);
if (i == 0) {
path.moveTo(beforeCorner.dx, beforeCorner.dy);
} else {
path.lineTo(beforeCorner.dx, beforeCorner.dy);
}
// Draw rounded corner
path.quadraticBezierTo(
current.dx,
current.dy,
afterCorner.dx,
afterCorner.dy,
);
}
path.close();
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) => false;
}
@@ -0,0 +1,242 @@
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 StaffListScreen extends ConsumerStatefulWidget {
const StaffListScreen({super.key});
@override
ConsumerState<StaffListScreen> createState() => _StaffListScreenState();
}
class _StaffListScreenState extends ConsumerState<StaffListScreen> {
@override
Widget build(BuildContext context) {
final staffAsync = ref.watch(staffListProvider);
const commonTextStyle = TextStyle(
fontFamily: "Gilroy-SemiBold",
fontWeight: FontWeight.w600,
fontSize: 14.7,
height: 1.30, // 130%
letterSpacing: 0.04,
color: Color(0xFF111827),
);
const commonTextStylevalue = TextStyle(
fontFamily: "Gilroy-SemiBold",
fontWeight: FontWeight.w400,
fontSize: 14.7,
height: 1.30, // 130%
letterSpacing: 0.04,
color: Color(0xFF111827),
);
return Scaffold(
backgroundColor: const Color.fromARGB(255, 230, 229, 229),
body: SafeArea(
child: staffAsync.when(
loading: () => const Center(child: CircularProgressIndicator()),
error: (err, _) => Center(
child: Text(
'Error: $err',
style: const TextStyle(color: Colors.red),
),
),
data: (staffList) {
if (staffList.isEmpty) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
"No Staff Found",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: Colors.black87,
),
),
Padding(
padding: const EdgeInsets.all(16),
child: CommanButton(
text: 'Go Back',
onPressed: () {
Navigator.pop(context);
},
),
),
],
),
);
}
return SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 24),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
GestureDetector(
onTap: () => Navigator.pop(context),
child: const Icon(
Icons.arrow_back_ios_new,
color: Colors.black,
size: 22,
),
),
const Expanded(
child: Center(
child: Text(
'Sub - Staff List',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w700,
color: Colors.black,
),
),
),
),
const Opacity(
opacity: 0,
child: Icon(Icons.arrow_back_ios_new, size: 22),
),
],
),
const SizedBox(height: 50),
...staffList.map((staff) {
String statusText = staff.status == 1
? "Active"
: "Inactive";
String generalChatText = staff.generalChat == 1
? "Yes"
: "No";
String createServiceText = staff.createService == 1
? "Yes"
: "No";
Color statusColor = staff.status == 1
? Colors.green
: Colors.red;
return Container(
width: double.infinity,
padding: const EdgeInsets.all(16),
margin: const EdgeInsets.only(bottom: 16),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
boxShadow: const [
BoxShadow(
color: Colors.black12,
blurRadius: 4,
offset: Offset(0, 2),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
/// ✅ Name
Row(
children: [
Text("Name : ", style: commonTextStyle),
Expanded(
child: Text(
staff.name,
style: commonTextStylevalue,
),
),
],
),
const SizedBox(height: 6),
/// ✅ Mobile
Row(
children: [
Text("Mobile : ", style: commonTextStyle),
Expanded(
child: Text(
staff.mobile,
style: commonTextStylevalue,
),
),
],
),
const SizedBox(height: 6),
/// ✅ Email
Row(
children: [
Text("Email : ", style: commonTextStyle),
Expanded(
child: Text(
staff.email,
style: commonTextStylevalue,
),
),
],
),
const SizedBox(height: 10),
/// ✅ Status
Row(
children: [
Text("Status : ", style: commonTextStyle),
Text(
statusText,
style: commonTextStylevalue.copyWith(
color: statusColor,
),
),
],
),
const SizedBox(height: 6),
/// ✅ General Chat
Row(
children: [
Text("General Chat : ", style: commonTextStyle),
Text(
generalChatText,
style: commonTextStylevalue,
),
],
),
const SizedBox(height: 6),
/// ✅ Create Service
Row(
children: [
Text(
"Create Service : ",
style: commonTextStyle,
),
Text(
createServiceText,
style: commonTextStylevalue,
),
],
),
],
),
);
}).toList(),
],
),
);
},
),
),
);
}
}
@@ -0,0 +1,85 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:taxglide/controller/api_contoller.dart';
class TermsAndConditionScreen extends ConsumerStatefulWidget {
const TermsAndConditionScreen({super.key});
@override
ConsumerState<TermsAndConditionScreen> createState() =>
_TermsAndConditionScreenState();
}
class _TermsAndConditionScreenState
extends ConsumerState<TermsAndConditionScreen> {
@override
Widget build(BuildContext context) {
final termsAsync = ref.watch(termsProvider);
return Scaffold(
backgroundColor: const Color.fromARGB(255, 230, 229, 229),
body: SafeArea(
child: termsAsync.when(
data: (terms) => SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 24),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// 🔹 Header Row with Back Arrow + Centered Title
Row(
children: [
GestureDetector(
onTap: () => Navigator.pop(context),
child: const Icon(
Icons.arrow_back_ios_new,
color: Colors.black,
size: 22,
),
),
Expanded(
child: Center(
child: Text(
terms.data?.title ?? 'Terms & Conditions',
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.w700,
color: Colors.black,
),
),
),
),
// To balance layout so title stays centered
const Opacity(
opacity: 0,
child: Icon(Icons.arrow_back_ios_new, size: 22),
),
],
),
const SizedBox(height: 24),
// 🔹 Terms Content
Text(
terms.data?.content ?? '',
textAlign: TextAlign.start,
style: const TextStyle(
fontSize: 16,
height: 1.6,
color: Colors.black87,
),
),
],
),
),
loading: () => const Center(child: CircularProgressIndicator()),
error: (err, _) => Center(
child: Text(
'Error: $err',
style: const TextStyle(color: Colors.red),
),
),
),
),
);
}
}
@@ -0,0 +1,910 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:get/get.dart';
import 'package:image_picker/image_picker.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:file_picker/file_picker.dart';
import 'package:path/path.dart' as path;
import 'package:taxglide/consts/comman_button.dart';
import 'package:taxglide/consts/responsive_helper.dart';
import 'package:taxglide/controller/api_contoller.dart';
import 'package:taxglide/controller/api_repository.dart';
import 'package:taxglide/view/Main_controller/main_controller.dart';
class ServiceRequestScreen extends ConsumerStatefulWidget {
final int id;
final String service;
final String icon;
final int? returnTabIndex;
const ServiceRequestScreen({
super.key,
required this.id,
required this.service,
required this.icon,
this.returnTabIndex,
});
@override
ConsumerState<ServiceRequestScreen> createState() =>
_ServiceRequestScreenState();
}
class _ServiceRequestScreenState extends ConsumerState<ServiceRequestScreen> {
final List<File> _selectedFiles = [];
final TextEditingController _messageController = TextEditingController();
final ScrollController _scrollController = ScrollController();
bool _isFileError = false;
bool _isTermsAccepted = false;
bool _isCheckboxError = false;
@override
void dispose() {
_messageController.dispose();
_scrollController.dispose();
super.dispose();
}
void _showSnackBar(String msg, {bool isError = false}) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
duration: const Duration(seconds: 2),
backgroundColor: isError ? Colors.red : Colors.green,
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
elevation: 6,
margin: const EdgeInsets.symmetric(horizontal: 50, vertical: 25),
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12),
content: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
isError ? Icons.error_outline : Icons.check_circle_outline,
color: Colors.white,
size: 18,
),
const SizedBox(width: 8),
Expanded(
child: Text(
msg,
style: const TextStyle(color: Colors.white, fontSize: 12),
overflow: TextOverflow.ellipsis,
maxLines: 2,
),
),
],
),
),
);
}
bool _validateForm() {
setState(() {
_isFileError = false;
_isCheckboxError = false;
});
bool isValid = true;
if (_selectedFiles.isEmpty) {
setState(() => _isFileError = true);
_showSnackBar("Please upload at least one file", isError: true);
isValid = false;
}
if (!_isTermsAccepted) {
setState(() => _isCheckboxError = true);
_showSnackBar("Please accept terms and conditions", isError: true);
isValid = false;
}
return isValid;
}
Future<void> _submitRequest() async {
if (_validateForm()) {
try {
_showSnackBar("Submitting request...");
await ApiRepository().updateServiceRequest(
serviceId: widget.id,
message: _messageController.text.trim(),
documents: _selectedFiles,
);
_showSnackBar("Request submitted successfully!");
ref.invalidate(serviceHistoryNotifierProvider);
Get.offAll(() => const MainController());
} catch (e) {
debugPrint("❌ Submit error: $e");
_showSnackBar("Something went wrong. Please try again.", isError: true);
}
}
}
Future<void> _pickFile() async {
final choice = await showDialog<String>(
context: context,
builder: (ctx) => AlertDialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
title: const Text('Select File Type'),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
leading: const Icon(Icons.camera_alt, color: Colors.blue),
title: const Text('Camera'),
onTap: () => Navigator.pop(ctx, 'camera'),
),
ListTile(
leading: const Icon(Icons.photo, color: Colors.blue),
title: const Text('Gallery'),
onTap: () => Navigator.pop(ctx, 'gallery'),
),
ListTile(
leading: const Icon(Icons.picture_as_pdf, color: Colors.red),
title: const Text('Select PDF'),
onTap: () => Navigator.pop(ctx, 'pdf'),
),
ListTile(
leading: const Icon(Icons.folder_zip, color: Colors.orange),
title: const Text('Select ZIP'),
onTap: () => Navigator.pop(ctx, 'zip'),
),
],
),
),
);
if (choice == null) return;
try {
if (choice == 'camera') {
final hasPermission = await _requestPermission(ImageSource.camera);
if (!hasPermission) return;
final picked = await ImagePicker().pickImage(
source: ImageSource.camera,
);
if (picked != null) {
setState(() {
_selectedFiles.add(File(picked.path));
_isFileError = false;
});
}
} else if (choice == 'gallery') {
final hasPermission = await _requestPermission(ImageSource.gallery);
if (!hasPermission) return;
final picked = await ImagePicker().pickMultiImage();
if (picked.isNotEmpty) {
setState(() {
for (var image in picked) {
_selectedFiles.add(File(image.path));
}
_isFileError = false;
});
}
} else if (choice == 'pdf' || choice == 'zip') {
final result = await FilePicker.platform.pickFiles(
allowMultiple: true,
type: FileType.custom,
allowedExtensions: choice == 'pdf' ? ['pdf'] : ['zip', 'rar', '7z'],
);
if (result != null && result.files.isNotEmpty) {
for (var file in result.files) {
if (file.path != null) {
setState(() {
_selectedFiles.add(File(file.path!));
_isFileError = false;
});
}
}
}
}
} catch (e) {
debugPrint("❌ File picking error: $e");
_showSnackBar("Failed to pick file: $e", isError: true);
}
}
Future<void> _showSettingsDialog(String permission) async {
showDialog(
context: context,
builder: (ctx) => AlertDialog(
title: Text('$permission Permission Required'),
content: Text(
'Allow $permission access to capture and upload your documents easily. You can enable it in the app settings.',
),
actions: [
TextButton(
onPressed: () => Navigator.pop(ctx),
child: const Text('Cancel'),
),
TextButton(
onPressed: () {
Navigator.pop(ctx);
openAppSettings();
},
child: const Text('Go to Settings'),
),
],
),
);
}
Future<bool> _requestPermission(ImageSource source) async {
try {
Permission permission;
String name;
if (source == ImageSource.camera) {
permission = Permission.camera;
name = 'Camera';
} else {
if (Platform.isAndroid) {
final info = await DeviceInfoPlugin().androidInfo;
if (info.version.sdkInt >= 33) {
permission = Permission.photos;
name = 'Photos';
} else {
permission = Permission.storage;
name = 'Storage';
}
} else {
permission = Permission.photos;
name = 'Photos';
}
}
var status = await permission.status;
print("status $status");
status = await permission.request();
if (status.isGranted || status.isLimited) return true;
if (status.isPermanentlyDenied || (Platform.isIOS && status.isDenied)) {
await _showSettingsDialog(name);
return false;
}
await _showSettingsDialog(name);
return false;
} catch (e) {
debugPrint("Permission error: $e");
return Platform.isIOS;
}
}
bool _isImage(String pathStr) {
final ext = path.extension(pathStr).toLowerCase();
return ['.jpg', '.jpeg', '.png', '.gif', '.webp'].contains(ext);
}
bool _isPdf(String pathStr) =>
path.extension(pathStr).toLowerCase() == '.pdf';
bool _isZip(String pathStr) =>
['.zip', '.rar', '.7z'].contains(path.extension(pathStr).toLowerCase());
@override
Widget build(BuildContext context) {
final r = ResponsiveUtils(context);
// Responsive values
final hPadding = r.spacing(mobile: 10, tablet: 16, desktop: 24);
final hPaddingInner = r.spacing(mobile: 20, tablet: 24, desktop: 32);
final headerFontSize = r.fontSize(mobile: 20, tablet: 24, desktop: 28);
final labelFontSize = r.fontSize(mobile: 14, tablet: 16, desktop: 18);
final readOnlyFontSize = r.fontSize(mobile: 13, tablet: 14, desktop: 15);
final uploadFontSize = r.fontSize(mobile: 11.5, tablet: 12.78, desktop: 14);
final uploadSubFontSize = r.fontSize(mobile: 9, tablet: 10, desktop: 11);
final checkboxFontSize = r.fontSize(
mobile: 11.5,
tablet: 12.78,
desktop: 14,
);
final messageFontSize = r.fontSize(
mobile: 10.5,
tablet: 11.31,
desktop: 12.5,
);
final serviceNameFontSize = r.fontSize(mobile: 13, tablet: 14, desktop: 15);
final uploadedCountFontSize = r.fontSize(
mobile: 13,
tablet: 14,
desktop: 15,
);
final serviceIconContainerW = r.getValue<double>(
mobile: 90,
tablet: 110,
desktop: 130,
);
final serviceIconContainerH = r.getValue<double>(
mobile: 70,
tablet: 84,
desktop: 100,
);
final serviceIconSize = r.getValue<double>(
mobile: 36,
tablet: 42,
desktop: 50,
);
final messageBoxHeight = r.getValue<double>(
mobile: 100,
tablet: 117,
desktop: 140,
);
final fileCardWidth = r.getValue<double>(
mobile: 90,
tablet: 110,
desktop: 130,
);
final fileCardHeight = r.getValue<double>(
mobile: 100,
tablet: 120,
desktop: 140,
);
final fileIconSize = r.getValue<double>(
mobile: 34,
tablet: 40,
desktop: 46,
);
final spacingSM = r.spacing(mobile: 10, tablet: 10, desktop: 12);
final spacingMD = r.spacing(mobile: 16, tablet: 20, desktop: 24);
final spacingLG = r.spacing(mobile: 20, tablet: 20, desktop: 24);
return Scaffold(
backgroundColor: const Color.fromARGB(255, 230, 229, 229),
body: SafeArea(
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Header
Padding(
padding: EdgeInsets.symmetric(
horizontal: hPadding,
vertical: 21,
),
child: SizedBox(
height: 50,
width: double.infinity,
child: Stack(
alignment: Alignment.center,
children: [
Text(
"New Service Request",
style: TextStyle(
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight.w600,
fontSize: headerFontSize,
color: const Color(0xFF111827),
),
),
Positioned(
left: 0,
child: GestureDetector(
onTap: () => Get.offAll(() => const MainController()),
child: const Icon(Icons.arrow_back_ios_rounded),
),
),
],
),
),
),
SizedBox(height: spacingLG),
// Service icon and name
Center(
child: Column(
children: [
Container(
width: serviceIconContainerW,
height: serviceIconContainerH,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
border: Border.all(color: const Color(0xFFE1E1E1)),
boxShadow: const [
BoxShadow(
color: Color(0x66757575),
offset: Offset(0, 1),
blurRadius: 7.3,
),
],
),
padding: const EdgeInsets.all(8),
child: Image.network(
widget.icon,
width: serviceIconSize,
height: serviceIconSize,
),
),
SizedBox(height: spacingMD),
Text(
widget.service,
style: TextStyle(
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight.w600,
fontSize: serviceNameFontSize,
color: const Color(0xFF3F3F3F),
),
),
],
),
),
SizedBox(height: spacingLG),
// Request Type
_buildLabel("Request Type*", hPaddingInner, labelFontSize),
_buildReadOnlyBox(
widget.service,
hPaddingInner,
readOnlyFontSize,
),
SizedBox(height: spacingSM),
// File Upload Header
Padding(
padding: EdgeInsets.symmetric(horizontal: hPaddingInner),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"File Upload *",
style: TextStyle(
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight.w600,
fontSize: labelFontSize,
color: const Color(0xFF111827),
),
),
GestureDetector(
onTap: _pickFile,
child: Container(
width: 20,
height: 20,
decoration: const BoxDecoration(
color: Colors.black,
shape: BoxShape.circle,
),
child: const Icon(
Icons.add,
size: 18,
color: Colors.white,
),
),
),
],
),
),
SizedBox(height: spacingLG),
// Upload Box
_buildUploadBox(hPaddingInner, uploadFontSize, uploadSubFontSize),
// Selected Files
if (_selectedFiles.isNotEmpty)
_buildEnhancedSelectedFiles(
hPaddingInner,
fileCardWidth,
fileCardHeight,
fileIconSize,
uploadedCountFontSize,
),
SizedBox(height: spacingLG),
// Message
_buildLabel("Message", hPaddingInner, labelFontSize),
_buildMessageBox(
hPaddingInner,
messageBoxHeight,
messageFontSize,
),
// Terms Checkbox
Padding(
padding: EdgeInsets.symmetric(horizontal: hPadding),
child: Row(
children: [
Checkbox(
value: _isTermsAccepted,
onChanged: (v) {
setState(() {
_isTermsAccepted = v ?? false;
if (v == true) _isCheckboxError = false;
});
},
activeColor: Colors.green,
side: BorderSide(
color: _isCheckboxError ? Colors.red : Colors.grey,
width: _isCheckboxError ? 2 : 1,
),
),
Expanded(
child: Text(
"I accept the terms and conditions *",
style: TextStyle(
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight.w600,
fontStyle: FontStyle.normal,
fontSize: checkboxFontSize,
height: 25.56 / 12.78,
letterSpacing: 0.8,
color: _isCheckboxError
? Colors.red
: const Color(0xFF4F4C4C),
),
),
),
],
),
),
// Submit Button
Padding(
padding: EdgeInsets.symmetric(
horizontal: r.spacing(mobile: 30, tablet: 41, desktop: 60),
vertical: spacingLG,
),
child: CommanButton(
text: 'Submit Request',
onPressed: _submitRequest,
),
),
const SizedBox(height: 250),
],
),
),
),
);
}
Widget _buildLabel(String title, double hPadding, double fontSize) => Padding(
padding: EdgeInsets.symmetric(horizontal: hPadding),
child: Text(
title,
style: TextStyle(
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight.w600,
fontSize: fontSize,
color: const Color(0xFF111827),
),
),
);
Widget _buildReadOnlyBox(String text, double hPadding, double fontSize) =>
Padding(
padding: EdgeInsets.symmetric(horizontal: hPadding, vertical: 15),
child: Container(
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(6),
border: Border.all(color: const Color(0xFFDFDFDF)),
boxShadow: const [
BoxShadow(
color: Color(0x66BDBDBD),
offset: Offset(0, 1),
blurRadius: 7,
),
],
),
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 21),
child: Text(
text,
style: TextStyle(
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight.w600,
fontSize: fontSize,
color: const Color(0xFF3F3F3F),
),
),
),
);
Widget _buildUploadBox(
double hPadding,
double fontSize,
double subFontSize,
) => Padding(
padding: EdgeInsets.symmetric(horizontal: hPadding),
child: Container(
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(6),
border: Border.all(
color: _isFileError ? Colors.red : const Color(0xFFDFDFDF),
width: _isFileError ? 2 : 1,
),
),
padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 21),
child: Column(
children: [
Text(
"Upload PDF, IMG, JPG, ZIP",
style: TextStyle(
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight.w600,
fontSize: fontSize,
height: 25.56 / 12.78,
letterSpacing: 0.8,
color: _isFileError ? Colors.red : const Color(0xFF4F4C4C),
),
),
Text(
"(40 MB only allowed File)",
style: TextStyle(
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight.w600,
fontSize: subFontSize,
height: 25.56 / 12.78,
letterSpacing: 0.8,
color: _isFileError ? Colors.red : const Color(0xFF4F4C4C),
),
),
if (_isFileError)
const Padding(
padding: EdgeInsets.only(top: 8),
child: Text(
"Please upload at least one file",
style: TextStyle(color: Colors.red, fontSize: 11),
),
),
],
),
),
);
Widget _buildEnhancedSelectedFiles(
double hPadding,
double cardWidth,
double cardHeight,
double iconSize,
double countFontSize,
) => Container(
margin: EdgeInsets.symmetric(horizontal: hPadding, vertical: 10),
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: const Color(0xFFE1E1E1)),
boxShadow: const [
BoxShadow(
color: Color(0x1A000000),
offset: Offset(0, 2),
blurRadius: 8,
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Container(
padding: const EdgeInsets.all(6),
decoration: BoxDecoration(
color: Colors.green.shade50,
borderRadius: BorderRadius.circular(8),
),
child: Icon(
Icons.check_circle,
color: Colors.green.shade600,
size: 18,
),
),
const SizedBox(width: 8),
Text(
"Uploaded Files (${_selectedFiles.length})",
style: TextStyle(
fontFamily: 'Gilroy-SemiBold',
fontWeight: FontWeight.w600,
fontSize: countFontSize,
color: const Color(0xFF111827),
),
),
],
),
if (_selectedFiles.length > 2)
Row(
children: [
GestureDetector(
onTap: () {
_scrollController.animateTo(
_scrollController.offset - 120,
duration: const Duration(milliseconds: 300),
curve: Curves.easeInOut,
);
},
child: Container(
padding: const EdgeInsets.all(4),
decoration: BoxDecoration(
color: Colors.grey.shade200,
shape: BoxShape.circle,
),
child: const Icon(
Icons.arrow_back_ios_new,
size: 14,
color: Colors.black87,
),
),
),
const SizedBox(width: 8),
GestureDetector(
onTap: () {
_scrollController.animateTo(
_scrollController.offset + 120,
duration: const Duration(milliseconds: 300),
curve: Curves.easeInOut,
);
},
child: Container(
padding: const EdgeInsets.all(4),
decoration: BoxDecoration(
color: Colors.grey.shade200,
shape: BoxShape.circle,
),
child: const Icon(
Icons.arrow_forward_ios,
size: 14,
color: Colors.black87,
),
),
),
],
),
],
),
const SizedBox(height: 12),
SizedBox(
height: cardHeight,
child: ListView.builder(
controller: _scrollController,
scrollDirection: Axis.horizontal,
itemCount: _selectedFiles.length,
itemBuilder: (context, index) {
final file = _selectedFiles[index];
final pathStr = file.path;
Widget preview;
Color bgColor;
if (_isImage(pathStr)) {
preview = ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Image.file(
file,
fit: BoxFit.cover,
width: cardWidth,
height: cardHeight,
),
);
bgColor = Colors.transparent;
} else if (_isPdf(pathStr)) {
bgColor = Colors.red.shade50;
preview = Icon(
Icons.picture_as_pdf,
size: iconSize,
color: Colors.red.shade600,
);
} else if (_isZip(pathStr)) {
bgColor = Colors.orange.shade50;
preview = Icon(
Icons.folder_zip,
size: iconSize,
color: Colors.orange.shade600,
);
} else {
bgColor = Colors.blue.shade50;
preview = Icon(
Icons.insert_drive_file,
size: iconSize,
color: Colors.blue.shade600,
);
}
return Padding(
padding: const EdgeInsets.only(right: 12),
child: Stack(
children: [
Container(
width: cardWidth,
decoration: BoxDecoration(
color: bgColor,
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: Colors.grey.shade300,
width: 1.5,
),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.05),
offset: const Offset(0, 2),
blurRadius: 4,
),
],
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [Expanded(child: Center(child: preview))],
),
),
Positioned(
right: -2,
top: -2,
child: GestureDetector(
onTap: () {
setState(() {
_selectedFiles.removeAt(index);
if (_selectedFiles.isEmpty) _isFileError = true;
});
},
child: Container(
decoration: BoxDecoration(
color: Colors.red.shade600,
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.2),
offset: const Offset(0, 2),
blurRadius: 4,
),
],
),
padding: const EdgeInsets.all(4),
child: const Icon(
Icons.close,
size: 14,
color: Colors.white,
),
),
),
),
],
),
);
},
),
),
],
),
);
Widget _buildMessageBox(double hPadding, double boxHeight, double fontSize) =>
Padding(
padding: EdgeInsets.symmetric(horizontal: hPadding, vertical: 15),
child: Container(
width: double.infinity,
height: boxHeight,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
border: Border.all(color: const Color(0xFFCFCFCF)),
),
child: TextFormField(
controller: _messageController,
maxLines: null,
expands: true,
style: TextStyle(
fontFamily: 'Gilroy-Medium',
fontSize: fontSize,
color: const Color(0xFF6C7278),
),
decoration: const InputDecoration(
hintText: "Enter your message",
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 8),
),
),
),
);
}