UI_SERVICES_MOBILE
This commit is contained in:
parent
4960c472be
commit
9c910f020c
@ -8,8 +8,9 @@ import 'package:shared_preferences/shared_preferences.dart';
|
|||||||
|
|
||||||
import '../../config/apiUrl.dart';
|
import '../../config/apiUrl.dart';
|
||||||
import '../../data/models/plan.dart';
|
import '../../data/models/plan.dart';
|
||||||
|
import '../../utils/auth_utils.dart';
|
||||||
|
|
||||||
class BusListWidget extends StatelessWidget {
|
class BusListWidget extends StatefulWidget {
|
||||||
final List<Map<String, dynamic>> busList;
|
final List<Map<String, dynamic>> busList;
|
||||||
final Function(bool, Map<String, dynamic>, String) onOpen;
|
final Function(bool, Map<String, dynamic>, String) onOpen;
|
||||||
final Function(Map<String, dynamic>) onDeleteBus;
|
final Function(Map<String, dynamic>) onDeleteBus;
|
||||||
@ -17,20 +18,66 @@ class BusListWidget extends StatelessWidget {
|
|||||||
final Function(String, bool) onAddNew;
|
final Function(String, bool) onAddNew;
|
||||||
final bool isViewMode;
|
final bool isViewMode;
|
||||||
|
|
||||||
const BusListWidget(
|
const BusListWidget({
|
||||||
{super.key,
|
super.key,
|
||||||
required this.busList,
|
required this.busList,
|
||||||
required this.onOpen,
|
required this.onOpen,
|
||||||
required this.onDeleteBus,
|
required this.onDeleteBus,
|
||||||
required this.onAddNew,
|
required this.onAddNew,
|
||||||
required this.isViewMode});
|
required this.isViewMode,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<BusListWidget> createState() => _BusListWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _BusListWidgetState extends State<BusListWidget> {
|
||||||
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final isDesktop = MediaQuery.of(context).size.width > 1024;
|
final isDesktop = MediaQuery.of(context).size.width > 1024;
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding:
|
||||||
|
isDesktop ? const EdgeInsets.all(16.0) : const EdgeInsets.all(5.0),
|
||||||
child: Container(
|
child: Container(
|
||||||
margin: const EdgeInsets.only(top: 16.0),
|
margin: const EdgeInsets.only(top: 16.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
@ -40,7 +87,7 @@ class BusListWidget extends StatelessWidget {
|
|||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
if ((!isDesktop) && busList.isNotEmpty)
|
if ((!isDesktop) && widget.busList.isNotEmpty)
|
||||||
Text(
|
Text(
|
||||||
" ",
|
" ",
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
@ -50,15 +97,17 @@ class BusListWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
|
|
||||||
MouseRegion(
|
MouseRegion(
|
||||||
cursor: isViewMode
|
cursor:
|
||||||
|
widget.isViewMode
|
||||||
? SystemMouseCursors.forbidden
|
? SystemMouseCursors.forbidden
|
||||||
: SystemMouseCursors.click,
|
: SystemMouseCursors.click,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: isViewMode
|
onTap:
|
||||||
|
widget.isViewMode
|
||||||
? null
|
? null
|
||||||
: () {
|
: () {
|
||||||
print("New data");
|
print("New data");
|
||||||
onAddNew("Bus", true);
|
widget.onAddNew("Bus", true);
|
||||||
},
|
},
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize:
|
mainAxisSize:
|
||||||
@ -73,7 +122,7 @@ class BusListWidget extends StatelessWidget {
|
|||||||
Icons.add_circle_sharp,
|
Icons.add_circle_sharp,
|
||||||
size: 30,
|
size: 30,
|
||||||
color: Color(0xFF114D8B),
|
color: Color(0xFF114D8B),
|
||||||
)
|
),
|
||||||
// Container(
|
// Container(
|
||||||
// decoration: BoxDecoration(
|
// decoration: BoxDecoration(
|
||||||
// shape: BoxShape.circle,
|
// shape: BoxShape.circle,
|
||||||
@ -130,9 +179,9 @@ class BusListWidget extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
// Scroll behavior based on device
|
|
||||||
|
|
||||||
_buildData(context, isDesktop)
|
// Scroll behavior based on device
|
||||||
|
_buildData(context, isDesktop),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -141,7 +190,7 @@ class BusListWidget extends StatelessWidget {
|
|||||||
|
|
||||||
Widget _buildData(BuildContext context, bool isDesktop) {
|
Widget _buildData(BuildContext context, bool isDesktop) {
|
||||||
List<Map<String, dynamic>> filteredList =
|
List<Map<String, dynamic>> filteredList =
|
||||||
busList.where((item) => item["is_active"] == "1").toList();
|
widget.busList.where((item) => item["is_active"] == "1").toList();
|
||||||
print("filteredList- $filteredList");
|
print("filteredList- $filteredList");
|
||||||
|
|
||||||
// String formatDate(String dateString) {
|
// String formatDate(String dateString) {
|
||||||
@ -191,8 +240,11 @@ class BusListWidget extends StatelessWidget {
|
|||||||
|
|
||||||
if (hour == 24 && minute == 0) {
|
if (hour == 24 && minute == 0) {
|
||||||
// 24:00 is treated as 00:00 on the next day
|
// 24:00 is treated as 00:00 on the next day
|
||||||
dateTime = DateTime(now.year, now.month, now.day)
|
dateTime = DateTime(
|
||||||
.add(const Duration(days: 1));
|
now.year,
|
||||||
|
now.month,
|
||||||
|
now.day,
|
||||||
|
).add(const Duration(days: 1));
|
||||||
} else {
|
} else {
|
||||||
if (hour < 0 || hour > 23 || minute < 0 || minute > 59) {
|
if (hour < 0 || hour > 23 || minute < 0 || minute > 59) {
|
||||||
throw FormatException("Invalid hour or minute");
|
throw FormatException("Invalid hour or minute");
|
||||||
@ -218,14 +270,17 @@ class BusListWidget extends StatelessWidget {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
// color: Colors.orange.shade50,
|
// color: Colors.orange.shade50,
|
||||||
color: Colors.white,
|
color: isDesktop ? Colors.white : thridColor,
|
||||||
boxShadow: [
|
boxShadow:
|
||||||
|
isDesktop
|
||||||
|
? [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
color: Colors.black12,
|
color: Colors.black12,
|
||||||
blurRadius: 3,
|
blurRadius: 3,
|
||||||
offset: Offset(0, 1),
|
offset: Offset(0, 1),
|
||||||
),
|
),
|
||||||
],
|
]
|
||||||
|
: [],
|
||||||
border: Border(
|
border: Border(
|
||||||
top: BorderSide(
|
top: BorderSide(
|
||||||
color: Colors.white70, // Change color to match your theme
|
color: Colors.white70, // Change color to match your theme
|
||||||
@ -234,7 +289,7 @@ class BusListWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(12),
|
padding: isDesktop ? EdgeInsets.all(12) : EdgeInsets.all(8),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@ -246,25 +301,27 @@ class BusListWidget extends StatelessWidget {
|
|||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.w800,
|
fontWeight: FontWeight.w800,
|
||||||
|
color:
|
||||||
|
!isDesktop ? Color(0xFF114D8B) : Color(0xFF575A74),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Spacer(),
|
Spacer(),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => onOpen(true, item, "Bus"),
|
onTap: () => widget.onOpen(true, item, "Bus"),
|
||||||
child: Tooltip(
|
child: Tooltip(
|
||||||
message: 'Delete Edit Details',
|
message: 'Edit Bus Details',
|
||||||
child: Image.asset(
|
child: Image.asset(
|
||||||
'assets/images/IconsImg/edit.png',
|
'assets/images/IconsImg/edit.png',
|
||||||
width: 20,
|
width: 20,
|
||||||
height: 15,
|
height: 15,
|
||||||
// color: Color(0xFF114D8B),
|
// color: Color(0xFF114D8B),
|
||||||
color: !isDesktop ? Color(0xFF114D8B) : Color(0xFF575A74)
|
color: !isDesktop ? Colors.black : Color(0xFF575A74),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: 10),
|
SizedBox(width: 10),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => onDeleteBus(item),
|
onTap: () => widget.onDeleteBus(item),
|
||||||
child: Tooltip(
|
child: Tooltip(
|
||||||
message: 'Delete Bus Details',
|
message: 'Delete Bus Details',
|
||||||
child: Image.asset(
|
child: Image.asset(
|
||||||
@ -277,9 +334,7 @@ class BusListWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Divider(
|
// Divider(color: Colors.blueGrey.shade50),
|
||||||
color: Colors.blueGrey.shade50,
|
|
||||||
),
|
|
||||||
SizedBox(height: 4),
|
SizedBox(height: 4),
|
||||||
isDesktop
|
isDesktop
|
||||||
? Row(
|
? Row(
|
||||||
@ -287,27 +342,24 @@ class BusListWidget extends StatelessWidget {
|
|||||||
Expanded(
|
Expanded(
|
||||||
flex: 3,
|
flex: 3,
|
||||||
child: Text(
|
child: Text(
|
||||||
" Planned Trips",
|
"Planned Trips",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(fontSize: 11),
|
||||||
fontSize: 11,
|
),
|
||||||
),
|
),
|
||||||
)),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 3,
|
flex: 3,
|
||||||
child: Text(
|
child: Text(
|
||||||
" Date",
|
" Date",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(fontSize: 11),
|
||||||
fontSize: 11,
|
),
|
||||||
),
|
),
|
||||||
)),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 3,
|
flex: 3,
|
||||||
child: Text(
|
child: Text(
|
||||||
" Comments",
|
" Comments",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(fontSize: 11),
|
||||||
fontSize: 11,
|
),
|
||||||
),
|
),
|
||||||
)),
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: SizedBox.shrink(),
|
: SizedBox.shrink(),
|
||||||
@ -340,74 +392,91 @@ class BusListWidget extends StatelessWidget {
|
|||||||
Expanded(
|
Expanded(
|
||||||
flex: 3,
|
flex: 3,
|
||||||
child: _buildComments(
|
child: _buildComments(
|
||||||
"Comments:", item["comments"] ?? "N/A"),
|
"Comments:",
|
||||||
|
item["comments"] ?? "N/A",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
:
|
: Container(
|
||||||
Column(
|
color: Colors.white,
|
||||||
|
padding: const EdgeInsets.all(4.0),
|
||||||
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
// Top Row (Country, Currency, Total)
|
_buildRow(
|
||||||
Wrap(
|
"PlannedTrips",
|
||||||
spacing: 20, // horizontal space between items
|
'${item["from"]!} - ${item["to"]!}',
|
||||||
runSpacing: 10, // vertical space between rows
|
|
||||||
// Row(
|
|
||||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
_infoBlock("From", item["from"] ?? "N/A"),
|
|
||||||
_infoBlock("To", item["to"]! ?? "N/A"),
|
|
||||||
_infoBlock("Date",
|
|
||||||
(item["date"] != null && item["time"] != null)
|
|
||||||
? "${formatDate(item["date"]!)} ${formatTime(item["time"]!)}"
|
|
||||||
: "N/A",
|
|
||||||
),
|
),
|
||||||
|
SizedBox(height: 5),
|
||||||
|
// _buildRow("To", item["to"]!),
|
||||||
|
// SizedBox(width: 10),
|
||||||
|
_buildDateTimeRow(
|
||||||
|
"Date",
|
||||||
|
formatDate(item["date"]!),
|
||||||
|
formatTime(item["time"]!),
|
||||||
|
),
|
||||||
|
SizedBox(height: 5),
|
||||||
|
_buildRow("Comments", item["comments"] ?? "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), ),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
// Column(
|
// Column(
|
||||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
// children: [
|
// children: [
|
||||||
// _buildRow("From:", item["from"]),
|
// // Top Row (Country, Currency, Total)
|
||||||
// SizedBox(width: 10),
|
// Wrap(
|
||||||
// _buildRow("To:", item["to"]!),
|
// spacing: 20, // horizontal space between items
|
||||||
// SizedBox(width: 10),
|
// runSpacing: 10, // vertical space between rows
|
||||||
// _buildDateTimeRow(
|
// // Row(
|
||||||
// "Date:",
|
// // mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
// formatDate(item["date"]!),
|
// children: [
|
||||||
// formatTime(item["time"]!),
|
// _infoBlock("From", item["from"] ?? "N/A"),
|
||||||
|
// _infoBlock("To", item["to"]! ?? "N/A"),
|
||||||
|
// _infoBlock(
|
||||||
|
// "Date",
|
||||||
|
// (item["date"] != null && item["time"] != null)
|
||||||
|
// ? "${formatDate(item["date"]!)} ${formatTime(item["time"]!)}"
|
||||||
|
// : "N/A",
|
||||||
// ),
|
// ),
|
||||||
// _buildRow("Comments:", item["comments"] ?? "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)),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -434,16 +503,14 @@ class BusListWidget extends StatelessWidget {
|
|||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Text(
|
Text(
|
||||||
value,
|
value,
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(fontSize: 12, color: Colors.black87),
|
||||||
fontSize: 12,
|
|
||||||
color: Colors.black87,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildComments(String title, String value) {
|
Widget _buildComments(String title, String value) {
|
||||||
// Define character limits based on title
|
// Define character limits based on title
|
||||||
Map<String, int> limits = {
|
Map<String, int> limits = {
|
||||||
@ -464,23 +531,27 @@ class BusListWidget extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: exceedsLimit
|
child:
|
||||||
|
exceedsLimit
|
||||||
? Tooltip(
|
? Tooltip(
|
||||||
message: wrapText(value, 50),
|
message: wrapText(value, 50),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.grey.shade200, // Black background
|
color: Colors.grey.shade200, // Black background
|
||||||
borderRadius: BorderRadius.circular(6),
|
borderRadius: BorderRadius.circular(6),
|
||||||
),
|
),
|
||||||
textStyle:
|
textStyle: TextStyle(
|
||||||
TextStyle(color: Colors.black), // Tooltip text color
|
color: Colors.black,
|
||||||
|
), // Tooltip text color
|
||||||
padding: EdgeInsets.all(8),
|
padding: EdgeInsets.all(8),
|
||||||
preferBelow: false,
|
preferBelow: false,
|
||||||
child: Text(value.substring(0, limit) + "...",
|
child: Text(
|
||||||
|
value.substring(0, limit) + "...",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
),
|
),
|
||||||
overflow: TextOverflow.ellipsis),
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
: Text(
|
: Text(
|
||||||
value,
|
value,
|
||||||
@ -513,36 +584,38 @@ class BusListWidget extends StatelessWidget {
|
|||||||
return Row(
|
return Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
SizedBox(
|
||||||
|
width: 100,
|
||||||
|
child: Text(
|
||||||
title,
|
title,
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
SizedBox(width: 8),
|
SizedBox(width: 8),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: exceedsLimit
|
child:
|
||||||
|
exceedsLimit
|
||||||
? Tooltip(
|
? Tooltip(
|
||||||
message: wrapText(value, 50),
|
message: wrapText(value, 50),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.grey.shade200, // Black background
|
color: Colors.grey.shade200, // Black background
|
||||||
borderRadius: BorderRadius.circular(6),
|
borderRadius: BorderRadius.circular(6),
|
||||||
),
|
),
|
||||||
textStyle:
|
textStyle: TextStyle(
|
||||||
TextStyle(color: Colors.black), // Tooltip text color
|
color: Colors.black,
|
||||||
|
), // Tooltip text color
|
||||||
padding: EdgeInsets.all(8),
|
padding: EdgeInsets.all(8),
|
||||||
preferBelow: false,
|
preferBelow: false,
|
||||||
child: Text(value.substring(0, limit) + "...",
|
child: Text(
|
||||||
|
value.substring(0, limit) + "...",
|
||||||
style: TextStyle(fontSize: 12),
|
style: TextStyle(fontSize: 12),
|
||||||
overflow: TextOverflow.ellipsis),
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
: Text(
|
: Text(value, style: GoogleFonts.poppins(fontSize: 12)),
|
||||||
value,
|
|
||||||
style: GoogleFonts.poppins(
|
|
||||||
fontSize: 12,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@ -552,21 +625,19 @@ class BusListWidget extends StatelessWidget {
|
|||||||
return Row(
|
return Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
SizedBox(
|
||||||
|
width: 100,
|
||||||
|
child: Text(
|
||||||
title,
|
title,
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
SizedBox(width: 8),
|
SizedBox(width: 8),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text("$date, $time", style: GoogleFonts.poppins(fontSize: 12)),
|
||||||
"$date, $time",
|
|
||||||
style: GoogleFonts.poppins(
|
|
||||||
fontSize: 12,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import 'package:google_fonts/google_fonts.dart';
|
|||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
import '../../services/apiService.dart';
|
import '../../services/apiService.dart';
|
||||||
|
import '../../utils/auth_utils.dart';
|
||||||
|
|
||||||
class TrainListWidget extends StatefulWidget {
|
class TrainListWidget extends StatefulWidget {
|
||||||
final bool hasAction;
|
final bool hasAction;
|
||||||
@ -36,12 +37,46 @@ class _TrainListWidgetState extends State<TrainListWidget> {
|
|||||||
// late Map<String, String> countryMap;
|
// late Map<String, String> countryMap;
|
||||||
Map<String, String> countryMap = {};
|
Map<String, String> countryMap = {};
|
||||||
|
|
||||||
|
Color? layoutColor;
|
||||||
|
Color? secondColor;
|
||||||
|
Color? thridColor;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
loadInitialData();
|
||||||
loadCountryList(); // Call your method here
|
loadCountryList(); // Call your method here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void checkClass() {
|
void checkClass() {
|
||||||
if (widget.hasAction) {
|
if (widget.hasAction) {
|
||||||
if (widget.tripType?.isNotEmpty == true) {
|
if (widget.tripType?.isNotEmpty == true) {
|
||||||
@ -99,7 +134,8 @@ class _TrainListWidgetState extends State<TrainListWidget> {
|
|||||||
final isDesktop = MediaQuery.of(context).size.width > 1024;
|
final isDesktop = MediaQuery.of(context).size.width > 1024;
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding:
|
||||||
|
isDesktop ? const EdgeInsets.all(16.0) : const EdgeInsets.all(5.0),
|
||||||
child: Container(
|
child: Container(
|
||||||
margin: const EdgeInsets.only(top: 16.0),
|
margin: const EdgeInsets.only(top: 16.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
@ -315,14 +351,17 @@ class _TrainListWidgetState extends State<TrainListWidget> {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
// color: Colors.orange.shade50,
|
// color: Colors.orange.shade50,
|
||||||
color: Colors.white,
|
color: isDesktop ? Colors.white : thridColor,
|
||||||
boxShadow: [
|
boxShadow:
|
||||||
|
isDesktop
|
||||||
|
? [
|
||||||
BoxShadow(
|
BoxShadow(
|
||||||
color: Colors.black12,
|
color: Colors.black12,
|
||||||
blurRadius: 3,
|
blurRadius: 3,
|
||||||
offset: Offset(0, 1),
|
offset: Offset(0, 1),
|
||||||
),
|
),
|
||||||
],
|
]
|
||||||
|
: [],
|
||||||
border: Border(
|
border: Border(
|
||||||
top: BorderSide(
|
top: BorderSide(
|
||||||
color: Colors.white70, // Change color to match your theme
|
color: Colors.white70, // Change color to match your theme
|
||||||
@ -331,7 +370,7 @@ class _TrainListWidgetState extends State<TrainListWidget> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(12),
|
padding: isDesktop ? EdgeInsets.all(12) : EdgeInsets.all(8),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@ -343,7 +382,8 @@ class _TrainListWidgetState extends State<TrainListWidget> {
|
|||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.w800,
|
fontWeight: FontWeight.w800,
|
||||||
color: !isDesktop ? Color(0xFF114D8B) : Color(0xFF575A74)
|
color:
|
||||||
|
!isDesktop ? Color(0xFF114D8B) : Color(0xFF575A74),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Spacer(),
|
Spacer(),
|
||||||
@ -355,7 +395,7 @@ class _TrainListWidgetState extends State<TrainListWidget> {
|
|||||||
'assets/images/IconsImg/edit.png',
|
'assets/images/IconsImg/edit.png',
|
||||||
width: 20,
|
width: 20,
|
||||||
height: 15,
|
height: 15,
|
||||||
color: Color(0xFF114D8B),
|
color: isDesktop ? Color(0xFF114D8B) : Colors.black,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -374,7 +414,7 @@ class _TrainListWidgetState extends State<TrainListWidget> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Divider(color: Colors.blueGrey.shade50),
|
// Divider(color: Colors.blueGrey.shade50),
|
||||||
SizedBox(height: 4),
|
SizedBox(height: 4),
|
||||||
isDesktop
|
isDesktop
|
||||||
? Row(
|
? Row(
|
||||||
@ -382,7 +422,7 @@ class _TrainListWidgetState extends State<TrainListWidget> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
child: Text(
|
child: Text(
|
||||||
" Class",
|
"Class",
|
||||||
style: GoogleFonts.poppins(fontSize: 11),
|
style: GoogleFonts.poppins(fontSize: 11),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -539,72 +579,102 @@ class _TrainListWidgetState extends State<TrainListWidget> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
:
|
: Container(
|
||||||
Column(
|
color: Colors.white,
|
||||||
|
padding: const EdgeInsets.all(4.0),
|
||||||
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
// First row: City & Location
|
_buildRow(
|
||||||
Row(
|
"Class",
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
getRequestForTrainClass(item["class"]!.toString()),
|
||||||
children: [
|
),
|
||||||
_infoColumn("Class", getRequestForTrainClass(item["class"]!.toString()) ?? "N/A"),
|
_buildRow("From", item["from_station"]!),
|
||||||
_infoColumn("From", item["from_station"]! ?? "N/A"),
|
_buildRow("To", item["to_station"]!),
|
||||||
_infoColumn("To", item["to_station"]! ?? "N/A",alignEnd: true),
|
_buildDateTimeRow(
|
||||||
|
"Date",
|
||||||
|
formatDate(item["date"]!),
|
||||||
|
formatTime(item["time"]!),
|
||||||
|
),
|
||||||
|
_buildRow("Comments", item["comments"] ?? "N/A"),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
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), ),
|
|
||||||
|
|
||||||
] )
|
|
||||||
// Column(
|
// Column(
|
||||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
// children: [
|
// children: [
|
||||||
// _buildRow(
|
// // First row: City & Location
|
||||||
// "Class:",
|
// Row(
|
||||||
// getRequestForTrainClass(item["class"]!.toString()),
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
// children: [
|
||||||
|
// _infoColumn(
|
||||||
|
// "Class",
|
||||||
|
// getRequestForTrainClass(
|
||||||
|
// item["class"]!.toString(),
|
||||||
|
// ) ??
|
||||||
|
// "N/A",
|
||||||
// ),
|
// ),
|
||||||
// _buildRow("From:", item["from_station"]!),
|
// _infoColumn("From", item["from_station"]! ?? "N/A"),
|
||||||
// _buildRow("To:", item["to_station"]!),
|
// _infoColumn(
|
||||||
// _buildDateTimeRow(
|
// "To",
|
||||||
// "Date:",
|
// item["to_station"]! ?? "N/A",
|
||||||
// formatDate(item["date"]!),
|
// alignEnd: true,
|
||||||
// formatTime(item["time"]!),
|
|
||||||
// ),
|
// ),
|
||||||
// _buildRow("Comments:", item["comments"] ?? "N/A"),
|
// ],
|
||||||
|
// ),
|
||||||
|
// 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)),
|
||||||
// ],
|
// ],
|
||||||
// ),
|
// ),
|
||||||
],
|
],
|
||||||
@ -690,9 +760,15 @@ class _TrainListWidgetState extends State<TrainListWidget> {
|
|||||||
return Row(
|
return Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
SizedBox(
|
||||||
|
width: 100,
|
||||||
|
child: Text(
|
||||||
title,
|
title,
|
||||||
style: GoogleFonts.poppins(fontSize: 12, fontWeight: FontWeight.w600),
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: 8),
|
SizedBox(width: 8),
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -738,22 +814,23 @@ class _TrainListWidgetState extends State<TrainListWidget> {
|
|||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Text(
|
Text(
|
||||||
value,
|
value,
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(fontSize: 12, color: Colors.black87),
|
||||||
fontSize: 12,
|
|
||||||
color: Colors.black87,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildDateTimeRow(String title, String date, String time) {
|
Widget _buildDateTimeRow(String title, String date, String time) {
|
||||||
return Row(
|
return Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
SizedBox(
|
||||||
|
width: 100,
|
||||||
|
child: Text(
|
||||||
title,
|
title,
|
||||||
style: TextStyle(fontWeight: FontWeight.w600, fontSize: 12),
|
style: TextStyle(fontWeight: FontWeight.w600, fontSize: 12),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
SizedBox(width: 8),
|
SizedBox(width: 8),
|
||||||
Expanded(child: Text("$date, $time", style: TextStyle(fontSize: 12))),
|
Expanded(child: Text("$date, $time", style: TextStyle(fontSize: 12))),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
This is a placeholder for base href that will be replaced by the value of
|
This is a placeholder for base href that will be replaced by the value of
|
||||||
the `--base-href` argument provided to `flutter build`.
|
the `--base-href` argument provided to `flutter build`.
|
||||||
--> TSTAT_TEST_19July.
|
-->
|
||||||
<base href="/tstat/">
|
<base href="/tstat/">
|
||||||
|
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user