UI_CHANGE_MOBILE

This commit is contained in:
venbaittech 2025-07-30 18:09:46 +05:30
parent 6c98829a21
commit 4960c472be
9 changed files with 2648 additions and 2604 deletions

File diff suppressed because it is too large Load Diff

View File

@ -320,7 +320,7 @@ class _AccomodationListWidgetState extends State<AccomodationListWidget> {
style: GoogleFonts.poppins(
fontSize: 14,
fontWeight:
isDesktop ? FontWeight.w800 : FontWeight.w500,
isDesktop ? FontWeight.w800 : FontWeight.w600,
color: !isDesktop ? Colors.black : Color(0xFF575A74),
),
),

View File

@ -423,7 +423,7 @@ class _FlightListWidgetState extends State<FlightListWidget> {
style: GoogleFonts.poppins(
fontSize: 14,
fontWeight:
isDesktop ? FontWeight.w800 : FontWeight.w500,
isDesktop ? FontWeight.w800 : FontWeight.w600,
color: !isDesktop ? Colors.black : Color(0xFF575A74),
// Color(0xFF114D8B)

View File

@ -181,7 +181,7 @@ class _ForexListWidgetState extends State<ForexListWidget> {
// // ),
// ],
// ),
const SizedBox(height: 16),
SizedBox(height: isDesktop ? 16 : 4),
// Scroll behavior based on device
_buildData(context, isDesktop),
@ -324,8 +324,10 @@ class _ForexListWidgetState extends State<ForexListWidget> {
Text(
getRequestForCountry(item["country_code"]!.toString()),
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
fontSize: 14,
fontWeight:
isDesktop ? FontWeight.w800 : FontWeight.w600,
color: !isDesktop ? Colors.black : Color(0xFF575A74),
),
),
Spacer(),
@ -377,7 +379,7 @@ class _ForexListWidgetState extends State<ForexListWidget> {
: SizedBox.shrink(), // or Container()
],
),
Divider(color: Colors.blueGrey.shade50),
// Divider(color: Colors.blueGrey.shade50),
// SizedBox(height: 4),
isDesktop
? Row(
@ -771,7 +773,7 @@ class _ForexListWidgetState extends State<ForexListWidget> {
title,
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w500,
fontWeight: FontWeight.w600,
),
),
),

View File

@ -4,7 +4,9 @@ import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart';
class InsuranceListWidget extends StatelessWidget {
import '../../utils/auth_utils.dart';
class InsuranceListWidget extends StatefulWidget {
final List<Map<String, dynamic>> insuranceList;
final Function(bool, Map<String, dynamic>, String) onOpen;
final Function(Map<String, dynamic>) onDeleteInsurance;
@ -13,21 +15,67 @@ class InsuranceListWidget extends StatelessWidget {
final Function(String, bool) onAddNew;
final bool isViewMode;
const InsuranceListWidget(
{super.key,
required this.insuranceList,
required this.onOpen,
required this.apiData,
required this.onDeleteInsurance,
required this.onAddNew,
required this.isViewMode});
const InsuranceListWidget({
super.key,
required this.insuranceList,
required this.onOpen,
required this.apiData,
required this.onDeleteInsurance,
required this.onAddNew,
required this.isViewMode,
});
@override
State<InsuranceListWidget> createState() => _InsuranceListWidgetState();
}
class _InsuranceListWidgetState extends State<InsuranceListWidget> {
Color? layoutColor;
Color? secondColor;
Color? thridColor;
@override
void initState() {
super.initState();
loadInitialData();
}
void loadInitialData() async {
String? layoutString = await getLayoutColor();
String? secondString = await getSecondaryColor();
String? thridString = await getTernaryColor();
// String? bodyStringColor = await getBodyColor();
setState(() {
layoutColor =
layoutString != null
? Color(int.parse(layoutString))
: Colors.redAccent;
secondColor =
layoutString != null
? Color(int.parse(secondString!))
: Colors.orange;
thridColor =
layoutString != null
? Color(int.parse(thridString!))
: Colors.orangeAccent;
// bodyColor =
// bodyStringColor != null
// ? Color(int.parse(bodyStringColor))
// : Colors.white;
});
}
@override
Widget build(BuildContext context) {
final isDesktop = MediaQuery.of(context).size.width > 1024;
return Padding(
padding: const EdgeInsets.all(16.0),
padding:
isDesktop ? const EdgeInsets.all(16.0) : const EdgeInsets.all(5.0),
child: Container(
margin: const EdgeInsets.only(top: 16.0),
child: Column(
@ -107,10 +155,10 @@ class InsuranceListWidget extends StatelessWidget {
// ),
// ],
// ),
const SizedBox(height: 16),
// Scroll behavior based on device
// const SizedBox(height: 16),
_buildData(context, isDesktop)
// Scroll behavior based on device
_buildData(context, isDesktop),
],
),
),
@ -119,11 +167,11 @@ class InsuranceListWidget extends StatelessWidget {
Widget _buildData(BuildContext context, bool isDesktop) {
List<Map<String, dynamic>> filteredList =
insuranceList.where((item) => item["is_active"] == "1").toList();
widget.insuranceList.where((item) => item["is_active"] == "1").toList();
print("filteredList- $filteredList");
List<dynamic> insurancetypeList =
apiData?['insurance_type_of_insurance'] ?? [];
widget.apiData?['insurance_type_of_insurance'] ?? [];
String getRequestForInsuranceType(String? specialRequestKey) {
if (specialRequestKey == null) return "N/A";
@ -146,7 +194,7 @@ class InsuranceListWidget extends StatelessWidget {
String getRequestValue(String? specialRequestKey) {
if (specialRequestKey == null) return "N/A";
return (apiData?['miscellaneous_special_request'] ?? [])
return (widget.apiData?['miscellaneous_special_request'] ?? [])
.firstWhere(
(element) =>
element["dropdown_key"].toString() == specialRequestKey,
@ -177,14 +225,18 @@ class InsuranceListWidget extends StatelessWidget {
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
// color: Colors.orange.shade50,
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black12,
blurRadius: 3,
offset: Offset(0, 1),
),
],
// color: Colors.white,
color: isDesktop ? Colors.white : thridColor,
boxShadow:
isDesktop
? [
BoxShadow(
color: Colors.black12,
blurRadius: 3,
offset: Offset(0, 1),
),
]
: [],
border: Border(
top: BorderSide(
color: Colors.white70, // Change color to match your theme
@ -193,176 +245,206 @@ class InsuranceListWidget extends StatelessWidget {
),
),
child: Padding(
padding: EdgeInsets.all(12),
padding: isDesktop ? EdgeInsets.all(12) : EdgeInsets.all(8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(
getRequestForInsuranceType(item["type_of_insurance"]!.toString()),
style: GoogleFonts.poppins(
fontSize: 14,
fontWeight: FontWeight.w800,
color: !isDesktop ? Color(0xFF114D8B) : Color(0xFF575A74)
Expanded(
flex: 1,
child: Text(
getRequestForInsuranceType(
item["type_of_insurance"]!.toString(),
),
style: GoogleFonts.poppins(
fontSize: 14,
fontWeight:
isDesktop ? FontWeight.w800 : FontWeight.w600,
color: !isDesktop ? Colors.black : Color(0xFF575A74),
),
),
),
Spacer(),
GestureDetector(
onTap: () => onOpen(true, item, "Insurance"),
onTap: () => widget.onOpen(true, item, "Insurance"),
child: Tooltip(
message: 'Edit Insurance Details',
child: Image.asset(
'assets/images/IconsImg/edit.png',
width: 20,
height: 15,
color: Color(0xFF114D8B),
color: isDesktop ? Color(0xFF114D8B) : Colors.black,
),
),
),
SizedBox(width: 10),
GestureDetector(
onTap: () => widget.onDeleteInsurance(item),
child: Tooltip(
message: 'Delete Insurance Details',
child: Image.asset(
'assets/images/IconsImg/delete.png',
width: 20,
height: 15,
color: Colors.red,
),
),
),
// SizedBox(width: 10),
// GestureDetector(
// onTap: () => onDeleteInsurance(item),
// child: Tooltip(
// message: 'Delete Insurance Details',
// child: Image.asset(
// 'assets/images/IconsImg/delete.png',
// width: 20,
// height: 15,
// color: Colors.red,
// ),
// ),
// ),
],
),
SizedBox(height: 4),
Divider(
color: Colors.blueGrey.shade50,
),
SizedBox(height: 4),
// Divider(color: Colors.blueGrey.shade50),
// SizedBox(height: 4),
isDesktop
? Row(
children: [
Expanded(
flex: 2,
child: Text(
" InsuranceType",
style: GoogleFonts.poppins(
fontSize: 11,
),
)),
Expanded(
flex: 2,
child: Text(
" Time Period ",
style: GoogleFonts.poppins(
fontSize: 11,
),
)),
Expanded(
flex: 2,
child: Text(
" Comments",
style: GoogleFonts.poppins(
fontSize: 11,
),
)),
],
)
children: [
Expanded(
flex: 2,
child: Text(
" InsuranceType",
style: GoogleFonts.poppins(fontSize: 11),
),
),
Expanded(
flex: 2,
child: Text(
" Time Period ",
style: GoogleFonts.poppins(fontSize: 11),
),
),
Expanded(
flex: 2,
child: Text(
" Comments",
style: GoogleFonts.poppins(fontSize: 11),
),
),
],
)
: SizedBox.shrink(),
isDesktop
? Row(
children: [
Expanded(
flex: 2,
child: Text(
getRequestForInsuranceType(
item["type_of_insurance"]!.toString()),
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
),
SizedBox(width: 10),
Expanded(
flex: 2,
child: Text(
"${formatDate(item["start_date"]!)} - ${formatDate(item["end_date"]!)}",
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
),
SizedBox(width: 10),
Expanded(
flex: 2,
child: _buildComments(
"Comments:", item["comments"] ?? "N/A"),
),
],
)
:
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Top Row (Country, Currency, Total)
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
Wrap(
spacing: 20, // horizontal space between items
runSpacing: 10, // vertical space between rows
children: [
_infoBlock("Insurance Type", getRequestForInsuranceType(item["type_of_insurance"]!.toString()) ?? "N/A"),
_infoBlock("Start Date", formatDate(item["start_date"]!) ?? "N/A"),
_infoBlock("End Date", formatDate(item["end_date"]) ?? "N/A"),
Expanded(
flex: 2,
child: Text(
getRequestForInsuranceType(
item["type_of_insurance"]!.toString(),
),
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
),
SizedBox(width: 10),
Expanded(
flex: 2,
child: Text(
"${formatDate(item["start_date"]!)} - ${formatDate(item["end_date"]!)}",
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
),
SizedBox(width: 10),
Expanded(
flex: 2,
child: _buildComments(
"Comments:",
item["comments"] ?? "N/A",
),
),
],
),
const SizedBox(height: 16),
)
: Container(
color: Colors.white,
padding: const EdgeInsets.all(4.0),
child: Column(
children: [
_buildRow(
"InsuranceType",
getRequestForInsuranceType(
item["type_of_insurance"]!.toString(),
),
),
SizedBox(width: 10),
_buildRow(
"TimePeriod",
'${formatDate(item["start_date"]!)} - ${formatDate(item["end_date"])} ',
),
// Comment label
Text(
"Comment",
style: GoogleFonts.poppins(
fontSize: 14,
fontWeight: FontWeight.w600,
SizedBox(width: 10),
_buildRow("Comments", item["comments"] ?? "N/A"),
],
),
),
const SizedBox(height: 8),
if (item["comments"] != null && item["comments"].toString().trim().isNotEmpty)
Container(
width: double.infinity,
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
border: Border.all(color: const Color(0xFF7098DD), width: 1),
borderRadius: BorderRadius.circular(6),
),
child: Text(
item["comments"] ?? "N/A",
style: GoogleFonts.poppins(fontSize: 12, color: Colors.black87),
),
)
else
const Text( "N/A", style: TextStyle(fontSize: 12), ),
],
),
// Column(
// children: [
// _buildRow(
// "InsuranceType:",
// getRequestForInsuranceType(
// item["type_of_insurance"]!.toString())),
// SizedBox(width: 10),
// _buildRow(
// "StartDate:", formatDate(item["start_date"]!)),
// SizedBox(width: 10),
// _buildRow("EndDate:", formatDate(item["end_date"])),
// SizedBox(width: 10),
// _buildRow("Comments:", item["comments"] ?? "N/A"),
// ],
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// // Top Row (Country, Currency, Total)
// // Row(
// // mainAxisAlignment: MainAxisAlignment.spaceBetween,
// Wrap(
// spacing: 20, // horizontal space between items
// runSpacing: 10, // vertical space between rows
// children: [
// _infoBlock(
// "Insurance Type",
// getRequestForInsuranceType(
// item["type_of_insurance"]!.toString(),
// ) ??
// "N/A",
// ),
// _infoBlock(
// "Start Date",
// formatDate(item["start_date"]!) ?? "N/A",
// ),
// _infoBlock(
// "End Date",
// formatDate(item["end_date"]) ?? "N/A",
// ),
// ],
// ),
// const SizedBox(height: 16),
//
// // Comment label
// Text(
// "Comment",
// style: GoogleFonts.poppins(
// fontSize: 14,
// fontWeight: FontWeight.w600,
// ),
// ),
// const SizedBox(height: 8),
// if (item["comments"] != null &&
// item["comments"].toString().trim().isNotEmpty)
// Container(
// width: double.infinity,
// padding: const EdgeInsets.all(12),
// decoration: BoxDecoration(
// border: Border.all(
// color: const Color(0xFF7098DD),
// width: 1,
// ),
// borderRadius: BorderRadius.circular(6),
// ),
// child: Text(
// item["comments"] ?? "N/A",
// style: GoogleFonts.poppins(
// fontSize: 12,
// color: Colors.black87,
// ),
// ),
// )
// else
// const Text("N/A", style: TextStyle(fontSize: 12)),
// ],
// ),
],
),
),
@ -391,31 +473,35 @@ class InsuranceListWidget extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: exceedsLimit
? Tooltip(
message: wrapText(value, 50),
decoration: BoxDecoration(
color: Colors.grey.shade200, // Black background
borderRadius: BorderRadius.circular(6),
),
textStyle:
TextStyle(color: Colors.black), // Tooltip text color
padding: EdgeInsets.all(8),
preferBelow: false,
child: Text(value.substring(0, limit) + "...",
child:
exceedsLimit
? Tooltip(
message: wrapText(value, 50),
decoration: BoxDecoration(
color: Colors.grey.shade200, // Black background
borderRadius: BorderRadius.circular(6),
),
textStyle: TextStyle(
color: Colors.black,
), // Tooltip text color
padding: EdgeInsets.all(8),
preferBelow: false,
child: Text(
value.substring(0, limit) + "...",
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
),
overflow: TextOverflow.ellipsis),
)
: Text(
value,
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
overflow: TextOverflow.ellipsis,
),
)
: Text(
value,
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
),
),
],
);
@ -439,16 +525,14 @@ class InsuranceListWidget extends StatelessWidget {
const SizedBox(height: 4),
Text(
value,
style: GoogleFonts.poppins(
fontSize: 12,
color: Colors.black87,
),
style: GoogleFonts.poppins(fontSize: 12, color: Colors.black87),
),
],
),
),
);
}
Widget _buildRow(String title, String value) {
// Define character limits based on title
Map<String, int> limits = {
@ -468,40 +552,39 @@ class InsuranceListWidget extends StatelessWidget {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
SizedBox(
width: 100,
child: Text(
title,
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
),
SizedBox(width: 8),
Expanded(
child: exceedsLimit
? Tooltip(
message: wrapText(value, 50),
decoration: BoxDecoration(
color: Colors.grey.shade200, // Black background
borderRadius: BorderRadius.circular(6),
),
textStyle: TextStyle(
color: Colors.black, fontSize: 12), // Tooltip text color
padding: EdgeInsets.all(8),
preferBelow: false,
child: Text(
value.substring(0, limit) + "...",
style: GoogleFonts.poppins(
fontSize: 12,
child:
exceedsLimit
? Tooltip(
message: wrapText(value, 50),
decoration: BoxDecoration(
color: Colors.grey.shade200, // Black background
borderRadius: BorderRadius.circular(6),
),
overflow: TextOverflow.ellipsis,
),
)
: Text(
value,
style: GoogleFonts.poppins(
fontSize: 12,
),
),
textStyle: TextStyle(
color: Colors.black,
fontSize: 12,
), // Tooltip text color
padding: EdgeInsets.all(8),
preferBelow: false,
child: Text(
value.substring(0, limit) + "...",
style: GoogleFonts.poppins(fontSize: 12),
overflow: TextOverflow.ellipsis,
),
)
: Text(value, style: GoogleFonts.poppins(fontSize: 12)),
),
],
);
@ -509,11 +592,11 @@ class InsuranceListWidget extends StatelessWidget {
List<DataRow> _buildDataRows() {
List<Map<String, dynamic>> filteredList =
insuranceList.where((item) => item["is_active"] == "1").toList();
widget.insuranceList.where((item) => item["is_active"] == "1").toList();
print("filteredList- $filteredList");
List<dynamic> insurancetypeList =
apiData?['insurance_type_of_insurance'] ?? [];
widget.apiData?['insurance_type_of_insurance'] ?? [];
String getRequestForInsuranceType(String? specialRequestKey) {
if (specialRequestKey == null) return "N/A";
@ -529,47 +612,55 @@ class InsuranceListWidget extends StatelessWidget {
return filteredList.asMap().entries.map((entry) {
Map<String, dynamic> item = entry.value;
return DataRow(cells: [
// DataCell(Text(item["indx"]?.toString() ?? "N/A")), // Index column
// DataCell(Text(item["type_of_insurance"]!)),
DataCell(Text(
getRequestForInsuranceType(item["type_of_insurance"]!.toString()))),
DataCell(Text(item["start_date"]!)),
DataCell(Text(item["end_date"]!)),
DataCell(Row(
children: [
GestureDetector(
onTap: () => onOpen(true, item, "Insurance"),
child: Tooltip(
message: 'Edit Insurance Details',
child: Image.asset(
'assets/images/IconsImg/edit.png',
width: 20,
height: 15,
return DataRow(
cells: [
// DataCell(Text(item["indx"]?.toString() ?? "N/A")), // Index column
// DataCell(Text(item["type_of_insurance"]!)),
DataCell(
Text(
getRequestForInsuranceType(item["type_of_insurance"]!.toString()),
),
),
DataCell(Text(item["start_date"]!)),
DataCell(Text(item["end_date"]!)),
DataCell(
Row(
children: [
GestureDetector(
onTap: () => widget.onOpen(true, item, "Insurance"),
child: Tooltip(
message: 'Edit Insurance Details',
child: Image.asset(
'assets/images/IconsImg/edit.png',
width: 20,
height: 15,
),
),
),
),
),
SizedBox(width: 10),
GestureDetector(
onTap: () => onDeleteInsurance(item),
child: Tooltip(
message: 'Delete Insurance Details',
child: Image.asset(
'assets/images/IconsImg/delete.png',
width: 20,
height: 15,
SizedBox(width: 10),
GestureDetector(
onTap: () => widget.onDeleteInsurance(item),
child: Tooltip(
message: 'Delete Insurance Details',
child: Image.asset(
'assets/images/IconsImg/delete.png',
width: 20,
height: 15,
),
),
),
),
IconButton(
icon: Icon(
Icons.keyboard_arrow_down_outlined,
size: 28,
color: Color(0xFF475569),
),
onPressed: () {
// Expand logic
},
),
],
),
IconButton(
icon: Icon(Icons.keyboard_arrow_down_outlined,
size: 28, color: Color(0xFF475569)),
onPressed: () {
// Expand logic
},
),
],
)
// Row(
// children: [
@ -593,9 +684,9 @@ class InsuranceListWidget extends StatelessWidget {
// ),
// ],
// )
),
]);
),
],
);
}).toList();
}
}

View File

@ -1,7 +1,9 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class MiscellaneousListWidget extends StatelessWidget {
import '../../utils/auth_utils.dart';
class MiscellaneousListWidget extends StatefulWidget {
final List<Map<String, dynamic>> miscellaneousList;
final Function(bool, Map<String, dynamic>, String) onOpen;
final Function(Map<String, dynamic>) onDeleteMiscellaneous;
@ -19,12 +21,58 @@ class MiscellaneousListWidget extends StatelessWidget {
required this.isViewMode,
});
@override
State<MiscellaneousListWidget> createState() =>
_MiscellaneousListWidgetState();
}
class _MiscellaneousListWidgetState extends State<MiscellaneousListWidget> {
Color? layoutColor;
Color? secondColor;
Color? thridColor;
@override
void initState() {
super.initState();
loadInitialData();
}
void loadInitialData() async {
String? layoutString = await getLayoutColor();
String? secondString = await getSecondaryColor();
String? thridString = await getTernaryColor();
// String? bodyStringColor = await getBodyColor();
setState(() {
layoutColor =
layoutString != null
? Color(int.parse(layoutString))
: Colors.redAccent;
secondColor =
layoutString != null
? Color(int.parse(secondString!))
: Colors.orange;
thridColor =
layoutString != null
? Color(int.parse(thridString!))
: Colors.orangeAccent;
// bodyColor =
// bodyStringColor != null
// ? Color(int.parse(bodyStringColor))
// : Colors.white;
});
}
@override
Widget build(BuildContext context) {
final isDesktop = MediaQuery.of(context).size.width > 1024;
return Padding(
padding: const EdgeInsets.all(16.0),
padding:
isDesktop ? const EdgeInsets.all(16.0) : const EdgeInsets.all(5.0),
child: Container(
margin: const EdgeInsets.only(top: 16.0),
child: Column(
@ -34,7 +82,7 @@ class MiscellaneousListWidget extends StatelessWidget {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if ((!isDesktop) && miscellaneousList.isNotEmpty)
if ((!isDesktop) && widget.miscellaneousList.isNotEmpty)
Text(
" ",
style: const TextStyle(
@ -44,20 +92,20 @@ class MiscellaneousListWidget extends StatelessWidget {
),
MouseRegion(
cursor:
isViewMode
? SystemMouseCursors.forbidden
: SystemMouseCursors.click,
widget.isViewMode
? SystemMouseCursors.forbidden
: SystemMouseCursors.click,
child: GestureDetector(
onTap:
isViewMode
? null
: () {
print("New data");
onAddNew("Miscellaneous", true);
},
widget.isViewMode
? null
: () {
print("New data");
widget.onAddNew("Miscellaneous", true);
},
child: Row(
mainAxisSize:
MainAxisSize.min, // Ensures content fits nicely
MainAxisSize.min, // Ensures content fits nicely
children: [
// Text(
// "Add New",
@ -133,7 +181,9 @@ class MiscellaneousListWidget extends StatelessWidget {
Widget _buildData(BuildContext context, bool isDesktop) {
List<Map<String, dynamic>> filteredList =
miscellaneousList.where((item) => item["is_active"] == "1").toList();
widget.miscellaneousList
.where((item) => item["is_active"] == "1")
.toList();
return ListView.builder(
shrinkWrap: true,
@ -144,12 +194,12 @@ class MiscellaneousListWidget extends StatelessWidget {
String getRequestValue(String? specialRequestKey) {
if (specialRequestKey == null) return "N/A";
return (apiData?['miscellaneous_special_request'] ?? [])
return (widget.apiData?['miscellaneous_special_request'] ?? [])
.firstWhere(
(element) =>
element["dropdown_key"].toString() == specialRequestKey,
orElse: () => {"dropdown_value": "N/A"},
)["dropdown_value"]
element["dropdown_key"].toString() == specialRequestKey,
orElse: () => {"dropdown_value": "N/A"},
)["dropdown_value"]
.toString();
}
@ -158,14 +208,17 @@ class MiscellaneousListWidget extends StatelessWidget {
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
// color: Colors.yellow.shade50,
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black12,
blurRadius: 3,
offset: Offset(0, 1),
),
],
color: isDesktop ? Colors.white : thridColor,
boxShadow:
isDesktop
? [
BoxShadow(
color: Colors.black12,
blurRadius: 3,
offset: Offset(0, 1),
),
]
: [],
border: Border(
top: BorderSide(
color: Colors.white70, // Change color to match your theme
@ -174,7 +227,7 @@ class MiscellaneousListWidget extends StatelessWidget {
),
),
child: Padding(
padding: EdgeInsets.all(12),
padding: isDesktop ? EdgeInsets.all(12) : EdgeInsets.all(8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -185,26 +238,28 @@ class MiscellaneousListWidget extends StatelessWidget {
getRequestValue(item["special_request"]?.toString()),
style: GoogleFonts.poppins(
fontSize: 14,
fontWeight: FontWeight.w800,
fontWeight:
isDesktop ? FontWeight.w800 : FontWeight.w600,
color: !isDesktop ? Colors.black : Color(0xFF575A74),
),
),
Spacer(),
GestureDetector(
onTap: () => onOpen(true, item, "Miscellaneous"),
onTap: () => widget.onOpen(true, item, "Miscellaneous"),
child: Tooltip(
message: 'Edit Miscellaneous Details',
child: Image.asset(
'assets/images/IconsImg/edit.png',
width: 20,
height: 15,
color: Color(0xFF114D8B),
color: isDesktop ? Color(0xFF114D8B) : Colors.black,
),
),
),
SizedBox(width: 10),
GestureDetector(
// onTap: () => onOpen(true, item, "Miscellaneous"),
onTap: () => onDeleteMiscellaneous(item),
onTap: () => widget.onDeleteMiscellaneous(item),
child: Tooltip(
message: 'Delete Miscellaneous Details',
child: Image.asset(
@ -217,95 +272,69 @@ class MiscellaneousListWidget extends StatelessWidget {
),
],
),
Divider(color: Colors.blueGrey.shade50),
SizedBox(height: 4),
// Divider(color: Colors.blueGrey.shade50),
// SizedBox(height: 4),
isDesktop
? Row(
children: [
Expanded(
flex: 2,
child: Text(
"Special Request",
style: GoogleFonts.poppins(fontSize: 11),
),
),
Expanded(
flex: 3,
child: Text(
" Comments",
style: GoogleFonts.poppins(fontSize: 11),
),
),
],
)
// : SizedBox.shrink(),
// isDesktop
// ? Row(
// children: [
// Expanded(
// flex: 2,
// child: Text(
// getRequestValue(
// item["special_request"]?.toString(),
// ),
// style: GoogleFonts.poppins(
// fontSize: 12,
// fontWeight: FontWeight.w600,
// ),
// ),
// ),
// Expanded(
// flex: 3,
// child: Text(
// item["comments"],
// style: GoogleFonts.poppins(
// fontSize: 12,
// fontWeight: FontWeight.w600,
// ),
// ),
// ),
// ],
// )
:
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Comment label
Text(
"Comment",
style: GoogleFonts.poppins(
fontSize: 14,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 8),
if (item["comments"] != null && item["comments"].toString().trim().isNotEmpty)
Container(
width: double.infinity,
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
border: Border.all(color: const Color(0xFF7098DD), width: 1),
borderRadius: BorderRadius.circular(6),
children: [
Expanded(
flex: 2,
child: Text(
"Special Request",
style: GoogleFonts.poppins(fontSize: 11),
),
),
child: Text(
item["comments"] ?? "N/A",
style: GoogleFonts.poppins(fontSize: 12, color: Colors.black87),
Expanded(
flex: 3,
child: Text(
" Comments",
style: GoogleFonts.poppins(fontSize: 11),
),
),
)
else
const Text( "N/A", style: TextStyle(fontSize: 12), ),
],
),
// Column(
// children: [
// _buildRow(
// "Special Request:",
// getRequestValue(item["special_request"]?.toString()),
// ),
// SizedBox(width: 10),
// _buildRow("Comments:", item["comments"] ?? "N/A"),
// ],
// ),
],
)
: SizedBox.shrink(),
isDesktop
? Row(
children: [
Expanded(
flex: 2,
child: Text(
getRequestValue(
item["special_request"]?.toString(),
),
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
),
Expanded(
flex: 3,
child: Text(
item["comments"],
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
),
],
)
: Container(
color: Colors.white,
padding: const EdgeInsets.all(4.0),
child: Column(
children: [
// _buildRow(
// "Special Request",
// getRequestValue(item["special_request"]?.toString()),
// ),
SizedBox(width: 10),
_buildRow("Comments", item["comments"] ?? "N/A"),
],
),
),
],
),
),
@ -335,34 +364,34 @@ class MiscellaneousListWidget extends StatelessWidget {
children: [
Expanded(
child:
exceedsLimit
? Tooltip(
message: wrapText(value, 50),
decoration: BoxDecoration(
color: Colors.grey.shade200, // Black background
borderRadius: BorderRadius.circular(6),
),
textStyle: TextStyle(
color: Colors.black,
), // Tooltip text color
padding: EdgeInsets.all(8),
preferBelow: false,
child: Text(
value.substring(0, limit) + "...",
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
),
overflow: TextOverflow.ellipsis,
),
)
: Text(
value,
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
exceedsLimit
? Tooltip(
message: wrapText(value, 50),
decoration: BoxDecoration(
color: Colors.grey.shade200, // Black background
borderRadius: BorderRadius.circular(6),
),
textStyle: TextStyle(
color: Colors.black,
), // Tooltip text color
padding: EdgeInsets.all(8),
preferBelow: false,
child: Text(
value.substring(0, limit) + "...",
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
),
overflow: TextOverflow.ellipsis,
),
)
: Text(
value,
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
),
],
);
@ -387,102 +416,108 @@ class MiscellaneousListWidget extends StatelessWidget {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: GoogleFonts.poppins(fontSize: 12, fontWeight: FontWeight.w600),
SizedBox(
width: 100,
child: Text(
title,
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
),
SizedBox(width: 8),
Expanded(
child:
exceedsLimit
? Tooltip(
message: wrapText(value, 50),
decoration: BoxDecoration(
color: Colors.grey.shade200, // Black background
borderRadius: BorderRadius.circular(6),
),
textStyle: TextStyle(
color: Colors.black,
fontSize: 12,
), // Tooltip text color
padding: EdgeInsets.all(8),
preferBelow: false,
child: Text(
value.substring(0, limit) + "...",
overflow: TextOverflow.ellipsis,
),
)
: Text(value),
exceedsLimit
? Tooltip(
message: wrapText(value, 50),
decoration: BoxDecoration(
color: Colors.grey.shade200, // Black background
borderRadius: BorderRadius.circular(6),
),
textStyle: TextStyle(
color: Colors.black,
fontSize: 12,
), // Tooltip text color
padding: EdgeInsets.all(8),
preferBelow: false,
child: Text(
value.substring(0, limit) + "...",
overflow: TextOverflow.ellipsis,
),
)
: Text(value),
),
],
);
}
//
// Widget _buildData(BuildContext context) {
// return Container(
// width: MediaQuery.of(context).size.width,
// child: DataTable(
// border: TableBorder(
// bottom: BorderSide(color: Colors.black12),
// horizontalInside: BorderSide(color: Colors.black12),
// ),
// columns: const [
// DataColumn(label: Text('Special Request')),
// DataColumn(label: Text('Comments')),
// DataColumn(label: Text('Actions')),
// ],
// rows: _buildDataRows(),
// ),
// );
// }
//
// List<DataRow> _buildDataRows() {
// List<dynamic> purposeList = apiData?['miscellaneous_special_request'] ?? [];
//
// String getRequestValue(String? specialRequestKey) {
// if (specialRequestKey == null) return "N/A";
// return purposeList
// .firstWhere(
// (element) =>
// element["dropdown_key"].toString() == specialRequestKey,
// orElse: () => {"dropdown_value": "N/A"},
// )["dropdown_value"]
// .toString();
// }
//
// List<Map<String, dynamic>> filteredList =
// miscellaneousList.where((item) => item["is_active"] == "1").toList();
//
// return filteredList.asMap().entries.map((entry) {
// Map<String, dynamic> item = entry.value;
//
// return DataRow(cells: [
// DataCell(Text(getRequestValue(item["special_request"]?.toString()))),
// DataCell(Text(item["comments"] ?? "N/A")),
// DataCell(Row(
// children: [
// GestureDetector(
// onTap: () => onOpen(true, item, "Miscellaneous"),
// child: Image.asset('assets/images/IconsImg/edit.png',
// width: 20, height: 15),
// ),
// SizedBox(width: 10),
// GestureDetector(
// onTap: () => onOpen(true, item, "Miscellaneous"),
// child: Image.asset('assets/images/IconsImg/delete.png',
// width: 20, height: 15),
// ),
// IconButton(
// icon: Icon(Icons.keyboard_arrow_down_outlined,
// size: 28, color: Color(0xFF475569)),
// onPressed: () {
// // Expand logic (optional)
// },
// ),
// ],
// )),
// ]);
// }).toList();
// }
}
//
// Widget _buildData(BuildContext context) {
// return Container(
// width: MediaQuery.of(context).size.width,
// child: DataTable(
// border: TableBorder(
// bottom: BorderSide(color: Colors.black12),
// horizontalInside: BorderSide(color: Colors.black12),
// ),
// columns: const [
// DataColumn(label: Text('Special Request')),
// DataColumn(label: Text('Comments')),
// DataColumn(label: Text('Actions')),
// ],
// rows: _buildDataRows(),
// ),
// );
// }
//
// List<DataRow> _buildDataRows() {
// List<dynamic> purposeList = apiData?['miscellaneous_special_request'] ?? [];
//
// String getRequestValue(String? specialRequestKey) {
// if (specialRequestKey == null) return "N/A";
// return purposeList
// .firstWhere(
// (element) =>
// element["dropdown_key"].toString() == specialRequestKey,
// orElse: () => {"dropdown_value": "N/A"},
// )["dropdown_value"]
// .toString();
// }
//
// List<Map<String, dynamic>> filteredList =
// miscellaneousList.where((item) => item["is_active"] == "1").toList();
//
// return filteredList.asMap().entries.map((entry) {
// Map<String, dynamic> item = entry.value;
//
// return DataRow(cells: [
// DataCell(Text(getRequestValue(item["special_request"]?.toString()))),
// DataCell(Text(item["comments"] ?? "N/A")),
// DataCell(Row(
// children: [
// GestureDetector(
// onTap: () => onOpen(true, item, "Miscellaneous"),
// child: Image.asset('assets/images/IconsImg/edit.png',
// width: 20, height: 15),
// ),
// SizedBox(width: 10),
// GestureDetector(
// onTap: () => onOpen(true, item, "Miscellaneous"),
// child: Image.asset('assets/images/IconsImg/delete.png',
// width: 20, height: 15),
// ),
// IconButton(
// icon: Icon(Icons.keyboard_arrow_down_outlined,
// size: 28, color: Color(0xFF475569)),
// onPressed: () {
// // Expand logic (optional)
// },
// ),
// ],
// )),
// ]);
// }).toList();
// }
}

View File

@ -2,7 +2,9 @@ import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart';
class TaxiListWidget extends StatelessWidget {
import '../../utils/auth_utils.dart';
class TaxiListWidget extends StatefulWidget {
final List<Map<String, dynamic>> taxiList;
final Function(bool, Map<String, dynamic>, String) onOpen;
final Function(Map<String, dynamic>) onDeleteTaxi;
@ -21,12 +23,57 @@ class TaxiListWidget extends StatelessWidget {
required this.isViewMode,
});
@override
State<TaxiListWidget> createState() => _TaxiListWidgetState();
}
class _TaxiListWidgetState extends State<TaxiListWidget> {
Color? layoutColor;
Color? secondColor;
Color? thridColor;
@override
void initState() {
super.initState();
loadInitialData();
}
void loadInitialData() async {
String? layoutString = await getLayoutColor();
String? secondString = await getSecondaryColor();
String? thridString = await getTernaryColor();
// String? bodyStringColor = await getBodyColor();
setState(() {
layoutColor =
layoutString != null
? Color(int.parse(layoutString))
: Colors.redAccent;
secondColor =
layoutString != null
? Color(int.parse(secondString!))
: Colors.orange;
thridColor =
layoutString != null
? Color(int.parse(thridString!))
: Colors.orangeAccent;
// bodyColor =
// bodyStringColor != null
// ? Color(int.parse(bodyStringColor))
// : Colors.white;
});
}
@override
Widget build(BuildContext context) {
final isDesktop = MediaQuery.of(context).size.width > 1024;
return Padding(
padding: const EdgeInsets.all(16.0),
padding:
isDesktop ? const EdgeInsets.all(16.0) : const EdgeInsets.all(5.0),
child: Container(
margin: const EdgeInsets.only(top: 16.0),
child: Column(
@ -36,7 +83,7 @@ class TaxiListWidget extends StatelessWidget {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if ((!isDesktop) && taxiList.isNotEmpty)
if ((!isDesktop) && widget.taxiList.isNotEmpty)
Text(
" ",
style: const TextStyle(
@ -46,17 +93,17 @@ class TaxiListWidget extends StatelessWidget {
),
MouseRegion(
cursor:
isViewMode
widget.isViewMode
? SystemMouseCursors.forbidden
: SystemMouseCursors.click,
child: GestureDetector(
onTap:
isViewMode
widget.isViewMode
? null
: () {
print("New data");
onAddNew("Taxi", true);
widget.onAddNew("Taxi", true);
},
child: Row(
mainAxisSize:
@ -121,11 +168,12 @@ class TaxiListWidget extends StatelessWidget {
Widget _buildData(BuildContext context, bool isDesktop) {
List<Map<String, dynamic>> filteredList =
taxiList.where((item) => item["is_active"] == "1").toList();
widget.taxiList.where((item) => item["is_active"] == "1").toList();
print("filteredList- $filteredList");
List<dynamic> taxiClassList = apiData?['taxt_car_type'] ?? [];
List<dynamic> taxirequiredFor = apiData?['taxi_car_required_for'] ?? [];
List<dynamic> taxiClassList = widget.apiData?['taxt_car_type'] ?? [];
List<dynamic> taxirequiredFor =
widget.apiData?['taxi_car_required_for'] ?? [];
String getRequestForTaxiClass(String? specialRequestKey) {
if (specialRequestKey == null) return "N/A";
@ -228,14 +276,17 @@ class TaxiListWidget extends StatelessWidget {
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
// color: Colors.orange.shade50,
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black12,
blurRadius: 3,
offset: Offset(0, 1),
),
],
color: isDesktop ? Colors.white : thridColor,
boxShadow:
isDesktop
? [
BoxShadow(
color: Colors.black12,
blurRadius: 3,
offset: Offset(0, 1),
),
]
: [],
border: Border(
top: BorderSide(
color: Colors.white70, // Change color to match your theme
@ -244,37 +295,41 @@ class TaxiListWidget extends StatelessWidget {
),
),
child: Padding(
padding: EdgeInsets.all(12),
padding: isDesktop ? EdgeInsets.all(12) : EdgeInsets.all(8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(
"${getRequestForTaxiClass(item["car_type"]!.toString())} For ${item["no_of_passengers"]!} Passenger",
style: GoogleFonts.poppins(
fontSize: 13,
fontWeight: FontWeight.w800,
color: !isDesktop ? Color(0xFF114D8B) : Color(0xFF575A74)
Expanded(
flex: 1,
child: Text(
"${getRequestForTaxiClass(item["car_type"]!.toString())} For ${item["no_of_passengers"]!} Passenger",
style: GoogleFonts.poppins(
fontSize: 13,
fontWeight:
isDesktop ? FontWeight.w800 : FontWeight.w600,
color: !isDesktop ? Colors.black : Color(0xFF575A74),
),
),
),
Spacer(),
GestureDetector(
onTap: () => onOpen(true, item, "Taxi"),
onTap: () => widget.onOpen(true, item, "Taxi"),
child: Tooltip(
message: 'Edit Taxi Details',
child: Image.asset(
'assets/images/IconsImg/edit.png',
width: 20,
height: 15,
color: Color(0xFF114D8B),
color: isDesktop ? Color(0xFF114D8B) : Colors.black,
),
),
),
SizedBox(width: 10),
GestureDetector(
onTap: () => onDeleteTaxi(item),
onTap: () => widget.onDeleteTaxi(item),
child: Tooltip(
message: 'Delete Taxi Details',
child: Image.asset(
@ -287,7 +342,7 @@ class TaxiListWidget extends StatelessWidget {
),
],
),
Divider(color: Colors.blueGrey.shade50),
// Divider(color: Colors.blueGrey.shade50),
SizedBox(height: 4),
isDesktop
? Row(
@ -369,72 +424,75 @@ class TaxiListWidget extends StatelessWidget {
),
],
)
:
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// First row: City & Location
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
_infoColumn("City", item["destination_city"] ?? "N/A"),
_infoColumn("Location", item["location_of_pickup"] ?? "N/A",alignEnd: true),
],
: Container(
color: Colors.white,
padding: const EdgeInsets.all(4.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildRow("City", item["destination_city"]),
SizedBox(width: 10),
_buildRow("Location", item["location_of_pickup"]!),
SizedBox(width: 10),
_buildDateTimeRow(
"Date",
formatDate(item["date"]!),
formatTime(item["time"]!),
),
const SizedBox(height: 16),
_buildRow("Comments", item["comments"] ?? "N/A"),
],
),
// Second row: Date & Time
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
_infoColumn("Date", "${formatDate(item["date"]!)}" ?? "N/A"),
_infoColumn("Time", "${formatTime(item["time"]!)}" ?? "N/A",alignEnd: true),
],
),
const SizedBox(height: 16),
// Comment label
Text(
"Comment",
style: GoogleFonts.poppins(
fontSize: 14,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 8),
// Comment box
if (item["comments"] != null && item["comments"].toString().trim().isNotEmpty)
Container(
width: double.infinity,
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
border: Border.all(color: const Color(0xFF7098DD), width: 1),
borderRadius: BorderRadius.circular(6),
),
child: Text(
item["comments"] ?? "N/A",
style: GoogleFonts.poppins(fontSize: 12, color: Colors.black87),
),
)else const Text( "N/A", style: TextStyle(fontSize: 12), ),
] )
// Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// _buildRow("City:", item["destination_city"]),
// SizedBox(width: 10),
// _buildRow("Pickup:", item["location_of_pickup"]!),
// SizedBox(width: 10),
// _buildDateTimeRow(
// "Date:",
// formatDate(item["date"]!),
// formatTime(item["time"]!),
// ),
// _buildRow("TaxiFor:", item["car_required_for"]!),
// _buildRow("Comments:", item["comments"] ?? "N/A"),
// ],
// ),
// Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// // First row: City & Location
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// _infoColumn("City", item["destination_city"] ?? "N/A"),
// _infoColumn("Location", item["location_of_pickup"] ?? "N/A",alignEnd: true),
// ],
// ),
// const SizedBox(height: 16),
//
// // Second row: Date & Time
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// _infoColumn("Date", "${formatDate(item["date"]!)}" ?? "N/A"),
// _infoColumn("Time", "${formatTime(item["time"]!)}" ?? "N/A",alignEnd: true),
// ],
// ),
// const SizedBox(height: 16),
//
// // Comment label
// Text(
// "Comment",
// style: GoogleFonts.poppins(
// fontSize: 14,
// fontWeight: FontWeight.w600,
// ),
// ),
// const SizedBox(height: 8),
//
// // Comment box
// if (item["comments"] != null && item["comments"].toString().trim().isNotEmpty)
// Container(
// width: double.infinity,
// padding: const EdgeInsets.all(12),
// decoration: BoxDecoration(
// border: Border.all(color: const Color(0xFF7098DD), width: 1),
// borderRadius: BorderRadius.circular(6),
// ),
// child: Text(
// item["comments"] ?? "N/A",
// style: GoogleFonts.poppins(fontSize: 12, color: Colors.black87),
// ),
// )else const Text( "N/A", style: TextStyle(fontSize: 12), ),
//
// ] ),
),
],
),
),
@ -516,9 +574,12 @@ class TaxiListWidget extends StatelessWidget {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: TextStyle(fontWeight: FontWeight.w600, fontSize: 12),
SizedBox(
width: 100,
child: Text(
title,
style: TextStyle(fontWeight: FontWeight.w600, fontSize: 12),
),
),
SizedBox(width: 8),
Expanded(
@ -551,9 +612,15 @@ class TaxiListWidget extends StatelessWidget {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: GoogleFonts.poppins(fontSize: 12, fontWeight: FontWeight.w600),
SizedBox(
width: 100,
child: Text(
title,
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
),
SizedBox(width: 8),
Expanded(
@ -562,30 +629,27 @@ class TaxiListWidget extends StatelessWidget {
],
);
}
Widget _infoColumn(String label, String value, {bool alignEnd = false}) {
return Column(
// crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment:
alignEnd ? CrossAxisAlignment.end : CrossAxisAlignment.start,
children: [
Text(
label,
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
color: Colors.black87,
),
),
const SizedBox(height: 4),
Text(
value,
style: GoogleFonts.poppins(
fontSize: 12,
color: Colors.black87,
),
),
],
);
}
Widget _infoColumn(String label, String value, {bool alignEnd = false}) {
return Column(
// crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment:
alignEnd ? CrossAxisAlignment.end : CrossAxisAlignment.start,
children: [
Text(
label,
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
color: Colors.black87,
),
),
const SizedBox(height: 4),
Text(
value,
style: GoogleFonts.poppins(fontSize: 12, color: Colors.black87),
),
],
);
}
}

View File

@ -2,7 +2,9 @@ import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart';
class VisaListWidget extends StatelessWidget {
import '../../utils/auth_utils.dart';
class VisaListWidget extends StatefulWidget {
final List<Map<String, dynamic>> visaList;
final Function(bool, Map<String, dynamic>, String) onOpen;
final Function(Map<String, dynamic>) onDeleteMiscellaneous;
@ -12,91 +14,138 @@ class VisaListWidget extends StatelessWidget {
final Function(String, bool) onAddNew;
final bool isViewMode;
const VisaListWidget(
{super.key,
required this.visaList,
required this.onOpen,
required this.onDeleteMiscellaneous,
required this.apiData,
required this.apiCountryData,
required this.onAddNew,
required this.isViewMode});
const VisaListWidget({
super.key,
required this.visaList,
required this.onOpen,
required this.onDeleteMiscellaneous,
required this.apiData,
required this.apiCountryData,
required this.onAddNew,
required this.isViewMode,
});
State<VisaListWidget> createState() => _VisaListWidgetState();
}
class _VisaListWidgetState extends State<VisaListWidget> {
Color? layoutColor;
Color? secondColor;
Color? thridColor;
@override
void initState() {
super.initState();
loadInitialData();
}
void loadInitialData() async {
String? layoutString = await getLayoutColor();
String? secondString = await getSecondaryColor();
String? thridString = await getTernaryColor();
// String? bodyStringColor = await getBodyColor();
setState(() {
layoutColor =
layoutString != null
? Color(int.parse(layoutString))
: Colors.redAccent;
secondColor =
layoutString != null
? Color(int.parse(secondString!))
: Colors.orange;
thridColor =
layoutString != null
? Color(int.parse(thridString!))
: Colors.orangeAccent;
// bodyColor =
// bodyStringColor != null
// ? Color(int.parse(bodyStringColor))
// : Colors.white;
});
}
@override
Widget build(BuildContext context) {
final isDesktop = MediaQuery.of(context).size.width > 1024;
return Padding(
padding: const EdgeInsets.all(16.0),
padding:
isDesktop ? const EdgeInsets.all(16.0) : const EdgeInsets.all(5.0),
child: Container(
margin: const EdgeInsets.only(top: 16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Header with title and button
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if ((!isDesktop) && visaList.isNotEmpty)
Text(
" ",
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
MouseRegion(
cursor: isViewMode
? SystemMouseCursors.forbidden
: SystemMouseCursors.click,
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// if ((!isDesktop) && widget.visaList.isNotEmpty)
// Text(
// " ",
// style: const TextStyle(
// fontSize: 18,
// fontWeight: FontWeight.bold,
// ),
// ),
// MouseRegion(
// cursor:
// widget.isViewMode
// ? SystemMouseCursors.forbidden
// : SystemMouseCursors.click,
//
// child: GestureDetector(
// onTap:
// widget.isViewMode
// ? null
// : () {
// print("New data");
// widget.onAddNew("Visa", true);
// },
// child: Row(
// mainAxisSize:
// MainAxisSize.min, // Ensures content fits nicely
// children: [
// // Text(
// // "Add New",
// // style: TextStyle(fontSize: 13),
// // ),
// // SizedBox(width: 8), // spacing between icon and text
// // Icon(
// // Icons.add_circle_sharp,
// // size: 30,
// // color: Color(0xFF114D8B),
// // )
// ],
// ),
// ),
// // onPressed: isViewMode
// // ? null
// // : () {
// // print("New data");
// //
// // },
// // child: Row(
// // mainAxisSize: MainAxisSize.min,
// // children: [
// // Icon(
// // Icons.add_circle_sharp,
// // size: 30,
// // color: Color(0xFF114D8B),
// // )
// // ],
// // ),
// ),
// ],
// ),
// const SizedBox(height: 16),
child: GestureDetector(
onTap: isViewMode
? null
: () {
print("New data");
onAddNew("Visa", true);
},
child: Row(
mainAxisSize:
MainAxisSize.min, // Ensures content fits nicely
children: [
// Text(
// "Add New",
// style: TextStyle(fontSize: 13),
// ),
// SizedBox(width: 8), // spacing between icon and text
// Icon(
// Icons.add_circle_sharp,
// size: 30,
// color: Color(0xFF114D8B),
// )
],
),
),
// onPressed: isViewMode
// ? null
// : () {
// print("New data");
//
// },
// child: Row(
// mainAxisSize: MainAxisSize.min,
// children: [
// Icon(
// Icons.add_circle_sharp,
// size: 30,
// color: Color(0xFF114D8B),
// )
// ],
// ),
),
],
),
const SizedBox(height: 16),
// Scroll behavior based on device
_buildData(context, isDesktop)
_buildData(context, isDesktop),
],
),
),
@ -191,11 +240,11 @@ class VisaListWidget extends StatelessWidget {
Widget _buildData(BuildContext context, bool isDesktop) {
List<Map<String, dynamic>> filteredList =
visaList.where((item) => item["is_active"] == "1").toList();
widget.visaList.where((item) => item["is_active"] == "1").toList();
print("filteredList- $filteredList");
List<dynamic> visatypeList = apiData?['visa_type_of_visa'] ?? [];
List<dynamic> countryList = apiCountryData ?? [];
List<dynamic> visatypeList = widget.apiData?['visa_type_of_visa'] ?? [];
List<dynamic> countryList = widget.apiCountryData ?? [];
String getRequestForVisa(String? specialRequestKey) {
if (specialRequestKey == null) return "N/A";
@ -249,8 +298,11 @@ class VisaListWidget extends StatelessWidget {
if (hour == 24 && minute == 0) {
// 24:00 is treated as 00:00 on the next day
dateTime = DateTime(now.year, now.month, now.day)
.add(const Duration(days: 1));
dateTime = DateTime(
now.year,
now.month,
now.day,
).add(const Duration(days: 1));
} else {
if (hour < 0 || hour > 23 || minute < 0 || minute > 59) {
throw FormatException("Invalid hour or minute");
@ -276,14 +328,17 @@ class VisaListWidget extends StatelessWidget {
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
// color: Colors.orange.shade50,
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black12,
blurRadius: 3,
offset: Offset(0, 1),
),
],
color: isDesktop ? Colors.white : thridColor,
boxShadow:
isDesktop
? [
BoxShadow(
color: Colors.black12,
blurRadius: 3,
offset: Offset(0, 1),
),
]
: [],
border: Border(
top: BorderSide(
color: Colors.white70, // Change color to match your theme
@ -292,7 +347,7 @@ class VisaListWidget extends StatelessWidget {
),
),
child: Padding(
padding: EdgeInsets.all(12),
padding: isDesktop ? EdgeInsets.all(12) : EdgeInsets.all(8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -303,26 +358,27 @@ class VisaListWidget extends StatelessWidget {
getRequestForVisa(item["type_of_visa"]!.toString()),
style: GoogleFonts.poppins(
fontSize: 14,
fontWeight: FontWeight.w800,
color: !isDesktop ? Color(0xFF114D8B) : Color(0xFF575A74)
fontWeight:
isDesktop ? FontWeight.w800 : FontWeight.w600,
color: !isDesktop ? Colors.black : Color(0xFF575A74),
),
),
Spacer(),
GestureDetector(
onTap: () => onOpen(true, item, "Visa"),
onTap: () => widget.onOpen(true, item, "Visa"),
child: Tooltip(
message: 'Edit Visa Details',
child: Image.asset(
'assets/images/IconsImg/edit.png',
width: 20,
height: 15,
color: Color(0xFF114D8B),
color: isDesktop ? Color(0xFF114D8B) : Colors.black,
),
),
),
SizedBox(width: 10),
GestureDetector(
onTap: () => onDeleteMiscellaneous(item),
onTap: () => widget.onDeleteMiscellaneous(item),
child: Tooltip(
message: 'Delete Visa Details',
child: Image.asset(
@ -335,155 +391,179 @@ class VisaListWidget extends StatelessWidget {
),
],
),
Divider(
color: Colors.blueGrey.shade50,
),
// Divider(color: Colors.blueGrey.shade50),
SizedBox(height: 4),
isDesktop
? Row(
children: [
Expanded(
flex: 2,
child: Text(
" Country",
style: GoogleFonts.poppins(
fontSize: 11,
),
)),
Expanded(
flex: 2,
child: Text(
" Visa Type",
style: GoogleFonts.poppins(
fontSize: 11,
),
)),
Expanded(
flex: 2,
child: Text(
" Date",
style: GoogleFonts.poppins(
fontSize: 11,
),
)),
Expanded(
flex: 2,
child: Text(
" Comments",
style: GoogleFonts.poppins(
fontSize: 11,
),
)),
],
)
children: [
Expanded(
flex: 2,
child: Text(
" Country",
style: GoogleFonts.poppins(fontSize: 11),
),
),
Expanded(
flex: 2,
child: Text(
" Visa Type",
style: GoogleFonts.poppins(fontSize: 11),
),
),
Expanded(
flex: 2,
child: Text(
" Date",
style: GoogleFonts.poppins(fontSize: 11),
),
),
Expanded(
flex: 2,
child: Text(
" Comments",
style: GoogleFonts.poppins(fontSize: 11),
),
),
],
)
: SizedBox.shrink(),
isDesktop
? Row(
children: [
Expanded(
flex: 2,
child: Text(
getRequestForCountry(
item["country_code"]!.toString()),
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
),
SizedBox(width: 10),
Expanded(
flex: 2,
child: Text(
getRequestForVisa(
item["type_of_visa"]!.toString()),
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
),
SizedBox(width: 10),
Expanded(
flex: 2,
child: Text(
formatDate(item["start_date"]!),
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
),
SizedBox(width: 10),
Expanded(
flex: 2,
child: _buildComments(
"Comments:", item["comments"] ?? "N/A"),
),
],
)
:
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Top Row (Country, Currency, Total)
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
Wrap(
spacing: 20, // horizontal space between items
runSpacing: 10, // vertical space between rows
children: [
_infoBlock("Visa Type", getRequestForCountry(item["country_code"]!.toString()) ?? "N/A"),
_infoBlock("Country", getRequestForCountry(item["country_code"]!.toString()) ?? "N/A"),
_infoBlock("Start Date", formatDate(item["start_date"]!) ?? "N/A"),
Expanded(
flex: 2,
child: Text(
getRequestForCountry(
item["country_code"]!.toString(),
),
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
),
SizedBox(width: 10),
Expanded(
flex: 2,
child: Text(
getRequestForVisa(item["type_of_visa"]!.toString()),
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
),
SizedBox(width: 10),
Expanded(
flex: 2,
child: Text(
formatDate(item["start_date"]!),
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
),
SizedBox(width: 10),
Expanded(
flex: 2,
child: _buildComments(
"Comments:",
item["comments"] ?? "N/A",
),
),
],
),
const SizedBox(height: 16),
// Comment label
Text(
"Comment",
style: GoogleFonts.poppins(
fontSize: 14,
fontWeight: FontWeight.w600,
)
: Container(
color: Colors.white,
padding: const EdgeInsets.all(4.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildRow(
"VisaType",
getRequestForVisa(item["type_of_visa"]!.toString()),
),
SizedBox(height: 6),
_buildRow(
"Country",
getRequestForCountry(
item["country_code"]!.toString(),
),
),
SizedBox(height: 6),
_buildRow("StartDate", item["start_date"]!),
SizedBox(height: 6),
_buildRow("Comments", item["comments"] ?? "N/A"),
],
),
),
const SizedBox(height: 8),
if (item["comments"] != null && item["comments"].toString().trim().isNotEmpty)
Container(
width: double.infinity,
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
border: Border.all(color: const Color(0xFF7098DD), width: 1),
borderRadius: BorderRadius.circular(6),
),
child: Text(
item["comments"] ?? "N/A",
style: GoogleFonts.poppins(fontSize: 12, color: Colors.black87),
),
)
else
const Text( "N/A", style: TextStyle(fontSize: 12), ),
],
),
// Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// _buildRow(
// "VisaType:",
// getRequestForVisa(
// item["type_of_visa"]!.toString())),
// SizedBox(height: 6),
// _buildRow(
// "Country:",
// getRequestForCountry(
// item["country_code"]!.toString())),
// SizedBox(height: 6),
// _buildRow("StartDate:", item["start_date"]!),
// SizedBox(height: 6),
// _buildRow("Comments:", item["comments"] ?? "N/A"),
// ],
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// // Top Row (Country, Currency, Total)
// // Row(
// // mainAxisAlignment: MainAxisAlignment.spaceBetween,
// Wrap(
// spacing: 20, // horizontal space between items
// runSpacing: 10, // vertical space between rows
// children: [
// _infoBlock(
// "Visa Type",
// getRequestForCountry(
// item["country_code"]!.toString(),
// ) ??
// "N/A",
// ),
// _infoBlock(
// "Country",
// getRequestForCountry(
// item["country_code"]!.toString(),
// ) ??
// "N/A",
// ),
// _infoBlock(
// "Start Date",
// formatDate(item["start_date"]!) ?? "N/A",
// ),
// ],
// ),
// const SizedBox(height: 16),
//
// // Comment label
// Text(
// "Comment",
// style: GoogleFonts.poppins(
// fontSize: 14,
// fontWeight: FontWeight.w600,
// ),
// ),
// const SizedBox(height: 8),
// if (item["comments"] != null &&
// item["comments"].toString().trim().isNotEmpty)
// Container(
// width: double.infinity,
// padding: const EdgeInsets.all(12),
// decoration: BoxDecoration(
// border: Border.all(
// color: const Color(0xFF7098DD),
// width: 1,
// ),
// borderRadius: BorderRadius.circular(6),
// ),
// child: Text(
// item["comments"] ?? "N/A",
// style: GoogleFonts.poppins(
// fontSize: 12,
// color: Colors.black87,
// ),
// ),
// )
// else
// const Text("N/A", style: TextStyle(fontSize: 12)),
// ],
// ),
],
),
),
@ -512,31 +592,37 @@ class VisaListWidget extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: exceedsLimit
? Tooltip(
message: wrapText(value, 50),
decoration: BoxDecoration(
color: Colors.grey.shade200, // Black background
borderRadius: BorderRadius.circular(6),
),
textStyle:
TextStyle(color: Colors.black), // Tooltip text color
padding: EdgeInsets.all(8),
preferBelow: false,
child: Text(value.substring(0, limit) + "...",
child:
exceedsLimit
? Tooltip(
message: wrapText(value, 50),
decoration: BoxDecoration(
color: Colors.grey.shade200, // Black background
borderRadius: BorderRadius.circular(6),
),
textStyle: TextStyle(
color: Colors.black,
), // Tooltip text color
padding: EdgeInsets.all(8),
preferBelow: false,
child: Text(
value.substring(0, limit) + "...",
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
fontFamily: "Archivo"),
overflow: TextOverflow.ellipsis),
)
: Text(
value,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
fontFamily: "Archivo",
),
overflow: TextOverflow.ellipsis,
),
)
: Text(
value,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
fontFamily: "Archivo"),
),
fontFamily: "Archivo",
),
),
),
],
);
@ -560,16 +646,14 @@ class VisaListWidget extends StatelessWidget {
const SizedBox(height: 4),
Text(
value,
style: GoogleFonts.poppins(
fontSize: 12,
color: Colors.black87,
),
style: GoogleFonts.poppins(fontSize: 12, color: Colors.black87),
),
],
),
),
);
}
Widget _buildRow(String title, String value) {
// Define character limits based on title
Map<String, int> limits = {
@ -589,34 +673,38 @@ class VisaListWidget extends StatelessWidget {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
SizedBox(
width: 100,
child: Text(
title,
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
),
SizedBox(width: 8),
Expanded(
child: exceedsLimit
? Tooltip(
message: wrapText(value, 50),
decoration: BoxDecoration(
color: Colors.grey.shade200, // Black background
borderRadius: BorderRadius.circular(6),
),
textStyle:
TextStyle(color: Colors.black), // Tooltip text color
padding: EdgeInsets.all(8),
preferBelow: false,
child: Text(value.substring(0, limit) + "...",
child:
exceedsLimit
? Tooltip(
message: wrapText(value, 50),
decoration: BoxDecoration(
color: Colors.grey.shade200, // Black background
borderRadius: BorderRadius.circular(6),
),
textStyle: TextStyle(
color: Colors.black,
), // Tooltip text color
padding: EdgeInsets.all(8),
preferBelow: false,
child: Text(
value.substring(0, limit) + "...",
style: TextStyle(fontSize: 12),
overflow: TextOverflow.ellipsis),
)
: Text(
value,
style: TextStyle(fontSize: 12),
),
overflow: TextOverflow.ellipsis,
),
)
: Text(value, style: TextStyle(fontSize: 12)),
),
],
);

View File

@ -13,7 +13,7 @@
This is a placeholder for base href that will be replaced by the value of
the `--base-href` argument provided to `flutter build`.
-->
--> TSTAT_TEST_19July.
<base href="/tstat/">
<meta charset="UTF-8">