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 '../../data/models/plan.dart';
|
||||
import '../../utils/auth_utils.dart';
|
||||
|
||||
class BusListWidget extends StatelessWidget {
|
||||
class BusListWidget extends StatefulWidget {
|
||||
final List<Map<String, dynamic>> busList;
|
||||
final Function(bool, Map<String, dynamic>, String) onOpen;
|
||||
final Function(Map<String, dynamic>) onDeleteBus;
|
||||
@ -17,20 +18,66 @@ class BusListWidget extends StatelessWidget {
|
||||
final Function(String, bool) onAddNew;
|
||||
final bool isViewMode;
|
||||
|
||||
const BusListWidget(
|
||||
{super.key,
|
||||
required this.busList,
|
||||
required this.onOpen,
|
||||
required this.onDeleteBus,
|
||||
required this.onAddNew,
|
||||
required this.isViewMode});
|
||||
const BusListWidget({
|
||||
super.key,
|
||||
required this.busList,
|
||||
required this.onOpen,
|
||||
required this.onDeleteBus,
|
||||
required this.onAddNew,
|
||||
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
|
||||
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(
|
||||
@ -40,7 +87,7 @@ class BusListWidget extends StatelessWidget {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
if ((!isDesktop) && busList.isNotEmpty)
|
||||
if ((!isDesktop) && widget.busList.isNotEmpty)
|
||||
Text(
|
||||
" ",
|
||||
style: const TextStyle(
|
||||
@ -50,16 +97,18 @@ class BusListWidget extends StatelessWidget {
|
||||
),
|
||||
|
||||
MouseRegion(
|
||||
cursor: isViewMode
|
||||
? SystemMouseCursors.forbidden
|
||||
: SystemMouseCursors.click,
|
||||
cursor:
|
||||
widget.isViewMode
|
||||
? SystemMouseCursors.forbidden
|
||||
: SystemMouseCursors.click,
|
||||
child: GestureDetector(
|
||||
onTap: isViewMode
|
||||
? null
|
||||
: () {
|
||||
print("New data");
|
||||
onAddNew("Bus", true);
|
||||
},
|
||||
onTap:
|
||||
widget.isViewMode
|
||||
? null
|
||||
: () {
|
||||
print("New data");
|
||||
widget.onAddNew("Bus", true);
|
||||
},
|
||||
child: Row(
|
||||
mainAxisSize:
|
||||
MainAxisSize.min, // Ensures content fits nicely
|
||||
@ -73,7 +122,7 @@ class BusListWidget extends StatelessWidget {
|
||||
Icons.add_circle_sharp,
|
||||
size: 30,
|
||||
color: Color(0xFF114D8B),
|
||||
)
|
||||
),
|
||||
// Container(
|
||||
// decoration: BoxDecoration(
|
||||
// shape: BoxShape.circle,
|
||||
@ -130,9 +179,9 @@ class BusListWidget extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
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) {
|
||||
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");
|
||||
|
||||
// String formatDate(String dateString) {
|
||||
@ -191,8 +240,11 @@ class BusListWidget 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");
|
||||
@ -218,14 +270,17 @@ class BusListWidget 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
|
||||
@ -234,7 +289,7 @@ class BusListWidget extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(12),
|
||||
padding: isDesktop ? EdgeInsets.all(12) : EdgeInsets.all(8),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@ -246,25 +301,27 @@ class BusListWidget extends StatelessWidget {
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w800,
|
||||
color:
|
||||
!isDesktop ? Color(0xFF114D8B) : Color(0xFF575A74),
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
GestureDetector(
|
||||
onTap: () => onOpen(true, item, "Bus"),
|
||||
onTap: () => widget.onOpen(true, item, "Bus"),
|
||||
child: Tooltip(
|
||||
message: 'Delete Edit Details',
|
||||
message: 'Edit Bus Details',
|
||||
child: Image.asset(
|
||||
'assets/images/IconsImg/edit.png',
|
||||
width: 20,
|
||||
height: 15,
|
||||
// color: Color(0xFF114D8B),
|
||||
color: !isDesktop ? Color(0xFF114D8B) : Color(0xFF575A74)
|
||||
color: !isDesktop ? Colors.black : Color(0xFF575A74),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
GestureDetector(
|
||||
onTap: () => onDeleteBus(item),
|
||||
onTap: () => widget.onDeleteBus(item),
|
||||
child: Tooltip(
|
||||
message: 'Delete Bus Details',
|
||||
child: Image.asset(
|
||||
@ -277,137 +334,149 @@ class BusListWidget extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
Divider(
|
||||
color: Colors.blueGrey.shade50,
|
||||
),
|
||||
// Divider(color: Colors.blueGrey.shade50),
|
||||
SizedBox(height: 4),
|
||||
isDesktop
|
||||
? Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Text(
|
||||
" Planned Trips",
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 11,
|
||||
),
|
||||
)),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Text(
|
||||
" Date",
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 11,
|
||||
),
|
||||
)),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Text(
|
||||
" Comments",
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 11,
|
||||
),
|
||||
)),
|
||||
],
|
||||
)
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Text(
|
||||
"Planned Trips",
|
||||
style: GoogleFonts.poppins(fontSize: 11),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Text(
|
||||
" Date",
|
||||
style: GoogleFonts.poppins(fontSize: 11),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Text(
|
||||
" Comments",
|
||||
style: GoogleFonts.poppins(fontSize: 11),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: SizedBox.shrink(),
|
||||
SizedBox(height: 4),
|
||||
isDesktop
|
||||
? Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Text(
|
||||
"${item["from"]} - ${item["to"]} ",
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Text(
|
||||
"${formatDate(item["date"]!)} ${formatTime(item["time"]!)}",
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: _buildComments(
|
||||
"Comments:", item["comments"] ?? "N/A"),
|
||||
),
|
||||
],
|
||||
)
|
||||
:
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Top Row (Country, Currency, Total)
|
||||
Wrap(
|
||||
spacing: 20, // horizontal space between items
|
||||
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",
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Text(
|
||||
"${item["from"]} - ${item["to"]} ",
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Text(
|
||||
"${formatDate(item["date"]!)} ${formatTime(item["time"]!)}",
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
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(
|
||||
"PlannedTrips",
|
||||
'${item["from"]!} - ${item["to"]!}',
|
||||
),
|
||||
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: 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("From:", item["from"]),
|
||||
// SizedBox(width: 10),
|
||||
// _buildRow("To:", item["to"]!),
|
||||
// SizedBox(width: 10),
|
||||
// _buildDateTimeRow(
|
||||
// "Date:",
|
||||
// formatDate(item["date"]!),
|
||||
// formatTime(item["time"]!),
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// // Top Row (Country, Currency, Total)
|
||||
// Wrap(
|
||||
// spacing: 20, // horizontal space between items
|
||||
// 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",
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// const SizedBox(height: 16),
|
||||
//
|
||||
// // Comment label
|
||||
// Text(
|
||||
// "Comment",
|
||||
// style: GoogleFonts.poppins(
|
||||
// fontSize: 14,
|
||||
// fontWeight: FontWeight.w600,
|
||||
// ),
|
||||
// _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)),
|
||||
// ],
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -434,16 +503,14 @@ class BusListWidget 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 _buildComments(String title, String value) {
|
||||
// Define character limits based on title
|
||||
Map<String, int> limits = {
|
||||
@ -464,31 +531,35 @@ class BusListWidget 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,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
@ -513,36 +584,38 @@ class BusListWidget 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: GoogleFonts.poppins(
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
)
|
||||
: Text(value, style: GoogleFonts.poppins(fontSize: 12)),
|
||||
),
|
||||
],
|
||||
);
|
||||
@ -552,21 +625,19 @@ class BusListWidget 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: Text(
|
||||
"$date, $time",
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
child: Text("$date, $time", style: GoogleFonts.poppins(fontSize: 12)),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@ -3,6 +3,7 @@ import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import '../../services/apiService.dart';
|
||||
import '../../utils/auth_utils.dart';
|
||||
|
||||
class TrainListWidget extends StatefulWidget {
|
||||
final bool hasAction;
|
||||
@ -36,12 +37,46 @@ class _TrainListWidgetState extends State<TrainListWidget> {
|
||||
// late Map<String, String> countryMap;
|
||||
Map<String, String> countryMap = {};
|
||||
|
||||
Color? layoutColor;
|
||||
Color? secondColor;
|
||||
Color? thridColor;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
loadInitialData();
|
||||
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() {
|
||||
if (widget.hasAction) {
|
||||
if (widget.tripType?.isNotEmpty == true) {
|
||||
@ -99,7 +134,8 @@ class _TrainListWidgetState extends State<TrainListWidget> {
|
||||
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(
|
||||
@ -315,14 +351,17 @@ class _TrainListWidgetState extends State<TrainListWidget> {
|
||||
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
|
||||
@ -331,7 +370,7 @@ class _TrainListWidgetState extends State<TrainListWidget> {
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(12),
|
||||
padding: isDesktop ? EdgeInsets.all(12) : EdgeInsets.all(8),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@ -343,7 +382,8 @@ class _TrainListWidgetState extends State<TrainListWidget> {
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: !isDesktop ? Color(0xFF114D8B) : Color(0xFF575A74)
|
||||
color:
|
||||
!isDesktop ? Color(0xFF114D8B) : Color(0xFF575A74),
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
@ -355,7 +395,7 @@ class _TrainListWidgetState extends State<TrainListWidget> {
|
||||
'assets/images/IconsImg/edit.png',
|
||||
width: 20,
|
||||
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),
|
||||
isDesktop
|
||||
? Row(
|
||||
@ -382,7 +422,7 @@ class _TrainListWidgetState extends State<TrainListWidget> {
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text(
|
||||
" Class",
|
||||
"Class",
|
||||
style: GoogleFonts.poppins(fontSize: 11),
|
||||
),
|
||||
),
|
||||
@ -539,72 +579,102 @@ class _TrainListWidgetState extends State<TrainListWidget> {
|
||||
),
|
||||
],
|
||||
)
|
||||
:
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// First row: City & Location
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
: Container(
|
||||
color: Colors.white,
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_infoColumn("Class", getRequestForTrainClass(item["class"]!.toString()) ?? "N/A"),
|
||||
_infoColumn("From", item["from_station"]! ?? "N/A"),
|
||||
_infoColumn("To", item["to_station"]! ?? "N/A",alignEnd: true),
|
||||
_buildRow(
|
||||
"Class",
|
||||
getRequestForTrainClass(item["class"]!.toString()),
|
||||
),
|
||||
_buildRow("From", item["from_station"]!),
|
||||
_buildRow("To", item["to_station"]!),
|
||||
_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(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// _buildRow(
|
||||
// "Class:",
|
||||
// getRequestForTrainClass(item["class"]!.toString()),
|
||||
// // First row: City & Location
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// _infoColumn(
|
||||
// "Class",
|
||||
// getRequestForTrainClass(
|
||||
// item["class"]!.toString(),
|
||||
// ) ??
|
||||
// "N/A",
|
||||
// ),
|
||||
// _infoColumn("From", item["from_station"]! ?? "N/A"),
|
||||
// _infoColumn(
|
||||
// "To",
|
||||
// item["to_station"]! ?? "N/A",
|
||||
// alignEnd: true,
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// _buildRow("From:", item["from_station"]!),
|
||||
// _buildRow("To:", item["to_station"]!),
|
||||
// _buildDateTimeRow(
|
||||
// "Date:",
|
||||
// formatDate(item["date"]!),
|
||||
// formatTime(item["time"]!),
|
||||
// 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,
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// _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),
|
||||
//
|
||||
// // 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(
|
||||
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(
|
||||
@ -725,7 +801,7 @@ class _TrainListWidgetState extends State<TrainListWidget> {
|
||||
return Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
alignEnd ? CrossAxisAlignment.end : CrossAxisAlignment.start,
|
||||
alignEnd ? CrossAxisAlignment.end : CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
@ -738,21 +814,22 @@ class _TrainListWidgetState extends State<TrainListWidget> {
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
value,
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 12,
|
||||
color: Colors.black87,
|
||||
),
|
||||
style: GoogleFonts.poppins(fontSize: 12, color: Colors.black87),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDateTimeRow(String title, String date, String time) {
|
||||
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(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
|
||||
the `--base-href` argument provided to `flutter build`.
|
||||
--> TSTAT_TEST_19July.
|
||||
-->
|
||||
<base href="/tstat/">
|
||||
|
||||
<meta charset="UTF-8">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user