Initial commit of Flutter project

This commit is contained in:
2025-09-19 11:30:38 +05:30
parent 1f0ec17edc
commit 4a9ae0a3b3
28 changed files with 2033 additions and 594 deletions

View File

@@ -1,10 +1,31 @@
import 'package:flutter/material.dart';
import 'package:glowwheels/helpers/shopid_helper.dart';
import 'package:provider/provider.dart';
import '../provider/serviceboy_provider.dart';
import 'add_serviceboy_screen.dart';
import 'edit_serviceboy_screen.dart';
import 'package:google_fonts/google_fonts.dart';
class ServiceBoyScreen extends StatelessWidget {
class ServiceBoyScreen extends StatefulWidget {
@override
State<ServiceBoyScreen> createState() => _ServiceBoyScreenState();
}
late String shopId='';
class _ServiceBoyScreenState extends State<ServiceBoyScreen> {
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
shopId = getShopId(context)!;
if (shopId != null) {
Provider.of<ServiceBoyProvider>(context, listen: false)
.fetchServiceBoys(shopId);
} else {
print("Shop ID is null");
}
});
}
@override
Widget build(BuildContext context) {
final provider = Provider.of<ServiceBoyProvider>(context);
@@ -13,7 +34,6 @@ class ServiceBoyScreen extends StatelessWidget {
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Color.fromRGBO(208, 235, 255, 1), Colors.white],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
@@ -26,54 +46,64 @@ class ServiceBoyScreen extends StatelessWidget {
SizedBox(height: 40),
Text(
'GLOWWHEELS',
style: GoogleFonts.inter(
fontSize: 32,color: Color.fromRGBO(25, 25, 112, 0.87)
,fontWeight: FontWeight.w700
)
style: GoogleFonts.inter(
fontSize: 32,
color: Color.fromRGBO(25, 25, 112, 0.87),
fontWeight: FontWeight.w700,
),
),
Text(
'Service Center',
style: GoogleFonts.inter(
fontSize: 24,color: Color.fromRGBO(25, 25, 112, 0.87)
,fontWeight: FontWeight.w400
)
style: GoogleFonts.inter(
fontSize: 24,
color: Color.fromRGBO(25, 25, 112, 0.87),
fontWeight: FontWeight.w400,
),
),
SizedBox(height: 20),
Text(
'Service Boy List',
style: GoogleFonts.inter(
fontSize: 16,color: Color.fromRGBO(33, 33, 33, 1)
,fontWeight: FontWeight.w500
)
style: GoogleFonts.inter(
fontSize: 16,
color: Color.fromRGBO(33, 33, 33, 1),
fontWeight: FontWeight.w500,
),
),
SizedBox(height: 10),
Expanded(
child: provider.serviceBoys.isEmpty
child: provider.isLoading
? Center(child: CircularProgressIndicator())
: provider.serviceBoys.isEmpty
? Center(child: Text("No service boys found"))
: ListView.builder(
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
padding: EdgeInsets.symmetric(
horizontal: 16, vertical: 8),
itemCount: provider.serviceBoys.length,
itemBuilder: (context, index) {
final boy = provider.serviceBoys[index];
return Card(
color: Colors.white,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12)),
elevation: 2,
child: ListTile(
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
contentPadding: EdgeInsets.symmetric(
horizontal: 16, vertical: 8),
title: Text(
boy.name,
style: GoogleFonts.inter(
fontSize: 18,color: Color.fromRGBO(33, 33, 33, 0.78)
,fontWeight: FontWeight.w600
)
style: GoogleFonts.inter(
fontSize: 18,
color: Color.fromRGBO(33, 33, 33, 0.78),
fontWeight: FontWeight.w600,
),
),
subtitle: Text(
boy.phone,
style: GoogleFonts.inter(
fontSize: 16,color: Color.fromRGBO(33, 33, 33, 0.78)
,fontWeight: FontWeight.w400
)
style: GoogleFonts.inter(
fontSize: 16,
color: Color.fromRGBO(33, 33, 33, 0.78),
fontWeight: FontWeight.w400,
),
),
trailing: Row(
mainAxisSize: MainAxisSize.min,
@@ -83,7 +113,9 @@ class ServiceBoyScreen extends StatelessWidget {
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => EditServiceBoyScreen(serviceBoy: boy),
builder: (_) =>
EditServiceBoyScreen(
serviceBoy: boy),
),
);
},
@@ -92,7 +124,7 @@ class ServiceBoyScreen extends StatelessWidget {
_buildIconButton(
icon: Icons.delete,
onPressed: () {
_showDeleteDialog(context, '');
_showDeleteDialog(context, boy.id);
},
),
],
@@ -109,7 +141,11 @@ class ServiceBoyScreen extends StatelessWidget {
shape: CircleBorder(),
backgroundColor: Colors.white,
elevation: 4,
child: Icon(Icons.add, color: Color(0xFF1F1762),size: 25,),
child: Icon(
Icons.add,
color: Color(0xFF1F1762),
size: 25,
),
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (_) => AddServiceBoyScreen()),
@@ -120,7 +156,8 @@ class ServiceBoyScreen extends StatelessWidget {
);
}
Widget _buildIconButton({required IconData icon, required VoidCallback onPressed}) {
Widget _buildIconButton(
{required IconData icon, required VoidCallback onPressed}) {
return Container(
height: 40,
width: 40,
@@ -141,63 +178,72 @@ class ServiceBoyScreen extends StatelessWidget {
}
void _showDeleteDialog(BuildContext context, String id) {
final shopId = getShopId(context);
showModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
isScrollControlled: true,
builder: (_) => Container(
padding: EdgeInsets.all(24),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.vertical(top: Radius.circular(24)),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset('assets/images/delete_serviceboy.png'),
SizedBox(height: 16),
Text(
'Delete Service boy?',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.black87,
builder: (BuildContext bottomSheetContext) {
return Container(
padding: EdgeInsets.all(24),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.vertical(top: Radius.circular(24)),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset('assets/images/delete_serviceboy.png'),
SizedBox(height: 16),
Text(
'Delete Service boy?',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.black87,
),
),
),
SizedBox(height: 8),
Text(
'Are you sure you want to delete this service boy? You wont be able to undo this.',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 14,
color: Colors.black54,
SizedBox(height: 8),
Text(
'Are you sure you want to delete this service boy? You wont be able to undo this.',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 14,
color: Colors.black54,
),
),
),
SizedBox(height: 24),
SizedBox(
width: double.infinity,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.red[700],
padding: EdgeInsets.symmetric(vertical: 14),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
SizedBox(height: 24),
SizedBox(
width: double.infinity,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.red[700],
padding: EdgeInsets.symmetric(vertical: 14),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
onPressed: () async {
if (shopId != null) {
await Provider.of<ServiceBoyProvider>(
bottomSheetContext,
listen: false,
).deleteServiceBoy(id, shopId);
}
Navigator.pop(bottomSheetContext); // Correct context
},
child: Text(
'Confirm',
style: TextStyle(fontSize: 16, color: Colors.white),
),
),
onPressed: () {
// Provider.of<ServiceBoyProvider>(context, listen: false).deleteServiceBoy(id);
Navigator.pop(context);
},
child: Text(
'Confirm',
style: TextStyle(fontSize: 16, color: Colors.white),
),
),
),
SizedBox(height: 12),
],
),
),
SizedBox(height: 12),
],
),
);
},
);
}