2025-12-03 11:57:05 +05:30
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import '../providers/mark_list_provider.dart';
|
|
|
|
|
|
|
|
|
|
class MarkListScreen extends StatefulWidget {
|
|
|
|
|
const MarkListScreen({super.key});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<MarkListScreen> createState() => _MarkListScreenState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _MarkListScreenState extends State<MarkListScreen> {
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
|
final provider = Provider.of<MarkListProvider>(context, listen: false);
|
|
|
|
|
provider.init(context);
|
2025-12-11 18:36:11 +05:30
|
|
|
provider.loadMarks(context);
|
2025-12-03 11:57:05 +05:30
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final marks = Provider.of<MarkListProvider>(context);
|
|
|
|
|
|
2025-12-11 18:36:11 +05:30
|
|
|
final screenWidth = MediaQuery.of(context).size.width;
|
|
|
|
|
final scale = (screenWidth / 390).clamp(0.82, 1.35);
|
|
|
|
|
|
2025-12-03 11:57:05 +05:30
|
|
|
return Scaffold(
|
2025-12-11 18:36:11 +05:30
|
|
|
backgroundColor: Colors.white,
|
2025-12-03 11:57:05 +05:30
|
|
|
appBar: AppBar(
|
2025-12-11 18:36:11 +05:30
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
elevation: 0,
|
|
|
|
|
centerTitle: true,
|
|
|
|
|
iconTheme: const IconThemeData(color: Colors.black),
|
|
|
|
|
title: Text(
|
|
|
|
|
"All Mark Numbers",
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: Colors.black,
|
|
|
|
|
fontSize: 20 * scale,
|
|
|
|
|
fontWeight: FontWeight.w700,
|
|
|
|
|
),
|
|
|
|
|
),
|
2025-12-03 11:57:05 +05:30
|
|
|
),
|
|
|
|
|
|
|
|
|
|
body: marks.loading
|
|
|
|
|
? const Center(child: CircularProgressIndicator())
|
|
|
|
|
: ListView.builder(
|
2025-12-23 11:44:56 +05:30
|
|
|
padding: EdgeInsets.all(10 * scale),
|
2025-12-03 11:57:05 +05:30
|
|
|
itemCount: marks.marks.length,
|
|
|
|
|
itemBuilder: (_, i) {
|
|
|
|
|
final m = marks.marks[i];
|
2025-12-23 11:44:56 +05:30
|
|
|
final status =
|
|
|
|
|
(m['status'] ?? '').toString().toLowerCase();
|
|
|
|
|
|
|
|
|
|
final LinearGradient statusGradient =
|
|
|
|
|
status == 'active'
|
|
|
|
|
? const LinearGradient(
|
|
|
|
|
colors: [
|
|
|
|
|
Color(0xFF2ECC71), // Green
|
|
|
|
|
Color(0xFF1E8449), // Deep Emerald
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
: const LinearGradient(
|
|
|
|
|
colors: [
|
|
|
|
|
Color(0xFFE74C3C), // Red
|
|
|
|
|
Color(0xFFC0392B), // Dark Red
|
|
|
|
|
],
|
|
|
|
|
);
|
2025-12-03 11:57:05 +05:30
|
|
|
|
2025-12-11 18:36:11 +05:30
|
|
|
return Container(
|
2025-12-23 11:44:56 +05:30
|
|
|
margin: EdgeInsets.only(bottom: 10 * scale),
|
|
|
|
|
padding: EdgeInsets.all(12 * scale),
|
2025-12-11 18:36:11 +05:30
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
gradient: const LinearGradient(
|
|
|
|
|
colors: [
|
|
|
|
|
Color(0xFF2196F3),
|
|
|
|
|
Color(0xFF64B5F6),
|
|
|
|
|
],
|
|
|
|
|
begin: Alignment.topLeft,
|
|
|
|
|
end: Alignment.bottomRight,
|
2025-12-03 11:57:05 +05:30
|
|
|
),
|
2025-12-23 11:44:56 +05:30
|
|
|
borderRadius: BorderRadius.circular(14 * scale),
|
2025-12-11 18:36:11 +05:30
|
|
|
boxShadow: [
|
|
|
|
|
BoxShadow(
|
|
|
|
|
color: Colors.black.withOpacity(0.06),
|
2025-12-23 11:44:56 +05:30
|
|
|
blurRadius: 5 * scale,
|
2025-12-11 18:36:11 +05:30
|
|
|
offset: Offset(0, 2 * scale),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
// LEFT TEXT
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
m['mark_no'],
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: Colors.white,
|
2025-12-23 11:44:56 +05:30
|
|
|
fontSize: 16 * scale,
|
2025-12-11 18:36:11 +05:30
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(height: 3 * scale),
|
|
|
|
|
Text(
|
|
|
|
|
"${m['origin']} → ${m['destination']}",
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: Colors.white,
|
2025-12-23 11:44:56 +05:30
|
|
|
fontSize: 13 * scale,
|
2025-12-11 18:36:11 +05:30
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|
2025-12-23 11:44:56 +05:30
|
|
|
// STATUS BADGE (GREEN / RED)
|
2025-12-11 18:36:11 +05:30
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
|
horizontal: 10 * scale,
|
2025-12-23 11:44:56 +05:30
|
|
|
vertical: 5 * scale,
|
2025-12-11 18:36:11 +05:30
|
|
|
),
|
|
|
|
|
decoration: BoxDecoration(
|
2025-12-23 11:44:56 +05:30
|
|
|
gradient: statusGradient,
|
|
|
|
|
borderRadius: BorderRadius.circular(20 * scale),
|
2025-12-11 18:36:11 +05:30
|
|
|
),
|
|
|
|
|
child: Text(
|
|
|
|
|
m['status'],
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 11.5 * scale,
|
2025-12-23 11:44:56 +05:30
|
|
|
color: Colors.white,
|
2025-12-11 18:36:11 +05:30
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
2025-12-03 11:57:05 +05:30
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|