You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

505 lines
18 KiB

2 months ago
import 'package:flutter/material.dart';
import 'package:supplier_new/common/settings.dart';
import 'fleet.dart';
import 'resources_drivers.dart';
import 'resources_sources.dart';
import 'package:supplier_new/resources/resources_drivers.dart';
import 'package:supplier_new/resources/resources_sources.dart';
import 'fleet.dart';void main() => runApp(const MaterialApp(home: ResourcesFleetScreen()));
class ResourcesFleetScreen extends StatefulWidget {
const ResourcesFleetScreen({super.key});
@override
State<ResourcesFleetScreen> createState() => _ResourcesFleetScreenState();
}
class _ResourcesFleetScreenState extends State<ResourcesFleetScreen> {
int selectedTab = 0;
String search = '';
final List<Map<String, dynamic>> items = [
{
'title': 'Tanker Name',
'subtitle': 'Drinking water - 10,000 L',
'status': ['filled', 'available'],
'code': 'TS 07 J 3492',
'owner': 'Ramesh Krishna'
},
{
'title': 'Drinking Water - 15,000L',
'subtitle': 'Drinking water - 15,000 L',
'status': ['empty', 'available'],
'code': 'TS 07 J 3492',
'owner': 'Ramesh Krishna'
},
{
'title': 'Tanker Name',
'subtitle': 'Drinking water - 10,000 L',
'status': ['filled', 'in-use'],
'code': 'TS 07 J 3492',
'owner': 'Ramesh Krishna'
},
{
'title': 'Drinking Water - 15,000L',
'subtitle': 'Drinking water - 15,000 L',
'status': ['empty', 'in-use'],
'code': 'TS 07 J 3492',
'owner': 'Ramesh Krishna'
},
{
'title': 'Tanker Name',
'subtitle': 'Drinking water - 10,000 L',
'status': ['filled', 'maintenance'],
'code': 'TS 07 J 3492',
'owner': 'Ramesh Krishna'
},
];
@override
Widget build(BuildContext context) {
final filtered = items.where((it) {
final q = search.trim().toLowerCase();
if (q.isEmpty) return true;
return it['title'].toLowerCase().contains(q) ||
it['subtitle'].toLowerCase().contains(q) ||
it['owner'].toLowerCase().contains(q);
}).toList();
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
backgroundColor: Colors.white,
elevation: 0.7,
leading: IconButton(
icon: const Icon(Icons.arrow_back, color: Colors.black87),
onPressed: () => Navigator.of(context).maybePop(),
),
title: Text(
'Resources',
style: fontTextStyle(16, const Color(0xFF2A2A2A), FontWeight.w600),
),
centerTitle: false,
actions: [
TextButton(
onPressed: () {},
child: Text('HELP',
style: fontTextStyle(
12, const Color(0xFF8270DB), FontWeight.w600)),
),
],
),
body: Column(
children: [
Container(
color: Colors.white,
padding: const EdgeInsets.fromLTRB(16, 12, 16, 12),
child: Column(
children: [
// Segmented pill
Container(
padding: const EdgeInsets.all(6),
child: Row(
children: List.generate(3, (i) {
final labels = ['Fleet', 'Drivers', 'Sources'];
final isSelected = selectedTab == i;
return Expanded(
child: GestureDetector(
onTap: () => setState(() => selectedTab = i),
child: Container(
padding: const EdgeInsets.symmetric(vertical: 8),
margin: const EdgeInsets.symmetric(horizontal: 4),
decoration: BoxDecoration(
color: isSelected
? const Color(0xFFF1F1F1)
: Colors.transparent,
borderRadius: BorderRadius.circular(20),
),
alignment: Alignment.center,
child: Text(
labels[i],
style: TextStyle(
color: isSelected
? const Color(0xFF101214)
: const Color(0xFF646464),
fontWeight: isSelected
? FontWeight.w600
: FontWeight.w500,
),
),
),
),
);
}),
),
),
const SizedBox(height: 12),
Container(
width: double.infinity,
padding: const EdgeInsets.all(14),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Color(0xFF939495)),
),
child: Row(
children: [
Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: 40,
height: 40,
decoration: const BoxDecoration(
color: Color(0xFFF6F0FF),
borderRadius:
BorderRadius.all(Radius.circular(8)),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Image.asset(
'images/truck.png',
fit: BoxFit.contain,
),
),
),
const SizedBox(height: 8),
Text('Total Tankers', style: fontTextStyle(12, Color(0xFF2D2E30), FontWeight.w500, // or w500 if you want slightly bolder
),
),
],
),
const Spacer(),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
children: [Text('14', style: fontTextStyle(24, const Color(0xFF0D3771), FontWeight.w500,
),
),
SizedBox(height: 6),
Text('+2 since last month',
style: fontTextStyle(10, Color(0xFF646566), FontWeight.w400,)),
],
),
],
),
),
const SizedBox(height: 12),
IntrinsicHeight(
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
child: SmallMetricBox(title: 'Active', value: '2')),
const SizedBox(width: 8),
Expanded(
child: SmallMetricBox(title: 'Inactive', value: '3')),
const SizedBox(width: 8),
Expanded(
child: SmallMetricBox(
title: 'Under Maintenances', value: '1')),
],
),
),
],
),
),
// -------- SECOND SECTION (gray background) ----------
Expanded(
child: Container(
color: const Color(0xFFF5F5F5), // Gray background
child: Padding(
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
child: Column(
children: [
Row(
children: [
SizedBox(
width: 270,
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 12, vertical: 6),
decoration: BoxDecoration(
border: Border.all(
color: Color(0xFF939495), // 👈 border color
width: 0.5, // 👈 border width
),
borderRadius: BorderRadius.circular(22),
),
child: Row(
children: [
Container(
width: 20,
height: 20,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('images/search.png'),
fit: BoxFit.contain),
),
),
const SizedBox(width: 8),
Expanded(
child: TextField(
decoration: InputDecoration(
hintText: 'Search',
hintStyle: fontTextStyle(
12,
const Color(0xFF939495),
FontWeight.w400),
border: InputBorder.none,
isDense: true,
),
onChanged: (v) =>
setState(() => search = v),
),
),
],
),
),
),
const SizedBox(width: 16),
Container(
width: 24,
height: 24,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('images/icon_tune.png'),
fit: BoxFit.contain),
),
),
const SizedBox(width: 16),
Container(
width: 24,
height: 24,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage('images/up_down arrow.png'),
fit: BoxFit.contain),
),
),
],
),
const SizedBox(height: 12),
// Cards List
Expanded(
child: ListView.separated(
itemCount: filtered.length,
separatorBuilder: (_, __) => const SizedBox(height: 10),
itemBuilder: (context, idx) {
final it = filtered[idx];
return TankCard(
title: it['title'],
subtitle: it['subtitle'],
code: it['code'],
owner: it['owner'],
status: List<String>.from(it['status']),
);
},
),
),
],
),
),
),
),
],
),
floatingActionButton: FloatingActionButton(
onPressed: () {
// TODO: Navigate to the next step/screen
Navigator.push(context, MaterialPageRoute(builder: (_) => const FleetStep1Page()));
},
backgroundColor: const Color(0xFF000000),
shape: const CircleBorder(), // ✅ ensures circle
child: const Icon(Icons.add,color: Colors.white,),
),
);
}
}
// ====== SmallMetricBox ======
class SmallMetricBox extends StatelessWidget {
final String title;
final String value;
const SmallMetricBox({super.key, required this.title, required this.value});
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Color(0xFF939495)),
color: Colors.white,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style:
fontTextStyle(12, const Color(0xFF2D2E30), FontWeight.w500)),
Text(value,
style:
fontTextStyle(24, const Color(0xFF0D3771), FontWeight.w500)),
],
),
);
}
}
// ====== TankCard ======
class TankCard extends StatelessWidget {
final String title;
final String subtitle;
final String code;
final String owner;
final List<String> status;
const TankCard({
super.key,
required this.title,
required this.subtitle,
required this.code,
required this.owner,
required this.status,
});
Color _chipColor(String s) {
switch (s) {
case 'filled':
return const Color(0xFFFFFFFF);
case 'available':
return const Color(0xFFE8F0FF);
case 'empty':
return const Color(0xFFFFEEEE);
case 'in-use':
return const Color(0xFFFFF0E6);
case 'maintenance':
return const Color(0xFFFFF4E6);
default:
return const Color(0xFFECECEC);
}
}
Color _chipTextColor(String s) {
switch (s) {
case 'filled':
return const Color(0xFF1D7AFC);
case 'available':
return const Color(0xFF0A9E04);
case 'empty':
return const Color(0xFFE2483D);
case 'in-use':
return const Color(0xFFEA843B);
case 'maintenance':
return const Color(0xFFD0AE3C);
default:
return Colors.black87;
}
}
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.grey.shade200),
),
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: status.map((s) {
final chipTextColor = _chipTextColor(s);
return Container(
margin: const EdgeInsets.only(right: 6),
padding: const EdgeInsets.symmetric(
horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: _chipColor(s),
borderRadius: BorderRadius.circular(8),
border: Border.all(color: chipTextColor, width: 1),
),
child: Text(
s, style:
fontTextStyle(10, chipTextColor, FontWeight.w400),
),
);
}).toList(),
),
const SizedBox(height: 8),
Text(title,
style: fontTextStyle(
14, const Color(0xFF343637), FontWeight.w600)),
const SizedBox(height: 6),
Text(subtitle,
style: fontTextStyle(
10, const Color(0xFF515253), FontWeight.w600)),
const SizedBox(height: 10),
Row(
children: [
ClipOval(
child: Container(
height: 12,
width: 12,
decoration: BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(
image: (AppSettings.profilePictureUrl != '' &&
AppSettings.profilePictureUrl != 'null')
? NetworkImage(AppSettings.profilePictureUrl)
as ImageProvider
: const AssetImage("images/profile_pic.png"),
fit: BoxFit.cover),
),
),
),
const SizedBox(width: 6),
Expanded(
child: Text(owner,
style: fontTextStyle(
8, const Color(0xFF646566), FontWeight.w400)),
),
],
),
],
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(code,
style: fontTextStyle(
10, const Color(0xFF515253), FontWeight.w400)),
const SizedBox(height: 28),
],
),
],
),
);
}
}