98 lines
3.7 KiB
Dart
98 lines
3.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../models/serviceboy_model.dart';
|
|
import '../provider/serviceboy_provider.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
|
|
class AssignServiceBoyDialog extends StatelessWidget {
|
|
final List<ServiceBoy> serviceBoys;
|
|
|
|
const AssignServiceBoyDialog({super.key, required this.serviceBoys});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ChangeNotifierProvider(
|
|
create: (_) => ServiceBoyProvider(),
|
|
child: Consumer<ServiceBoyProvider>(
|
|
builder: (context, assignProvider, _) {
|
|
return AlertDialog(
|
|
backgroundColor: Colors.white,
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
|
title: const Text("Select Service Boy", style: TextStyle(fontWeight: FontWeight.bold)),
|
|
content: SizedBox(
|
|
height: 200,
|
|
width: double.maxFinite,
|
|
child: ListView.builder(
|
|
itemCount: serviceBoys.length,
|
|
itemBuilder: (context, index) {
|
|
final boy = serviceBoys[index];
|
|
final isSelected = assignProvider.selectedBoy == boy;
|
|
|
|
return GestureDetector(
|
|
onTap: () => assignProvider.selectBoy(boy),
|
|
child: Container(
|
|
padding: const EdgeInsets.all(12),
|
|
margin: const EdgeInsets.symmetric(vertical: 4),
|
|
decoration: BoxDecoration(
|
|
color: isSelected ? Color.fromRGBO(0, 80, 170, 1) : Colors.transparent,
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
boy.name,
|
|
style: TextStyle(
|
|
color: isSelected ? Colors.white : Colors.black,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
Text(
|
|
"Phone: ${boy.phone}",
|
|
style: TextStyle(
|
|
color: isSelected ? Colors.white70 : Colors.grey[700],
|
|
fontSize: 13,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
child: Text("CANCEL",style: GoogleFonts.poppins(
|
|
fontSize: 14,color: Color.fromRGBO(25, 25, 112, 1)
|
|
,fontWeight: FontWeight.w400
|
|
),),
|
|
onPressed: () {
|
|
Navigator.of(context).pop(); // return null
|
|
},
|
|
),
|
|
ElevatedButton(
|
|
onPressed: assignProvider.selectedBoy != null
|
|
? () {
|
|
Navigator.of(context).pop(assignProvider.selectedBoy);
|
|
}
|
|
: null,
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Color(0xFF1B1464),
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)),
|
|
),
|
|
child: Text("Assign",style: GoogleFonts.inter(
|
|
fontSize: 12,color: Colors.white
|
|
,fontWeight: FontWeight.w500
|
|
),),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|