import 'package:quality_plan_maker/utils/exports.
dart';
class SelectedProcessesListWidget extends StatelessWidget {
const SelectedProcessesListWidget({[Link]});
@override
Widget build(BuildContext context) {
final colorTheme = [Link](context).colorScheme;
final textTheme = [Link](context).textTheme;
return Consumer<OperationStateProvider>(
builder: (context, provider, child) {
return Column(
children: [
Row(
children: [
Container(
padding: [Link](8),
decoration: BoxDecoration(
color: [Link],
borderRadius: [Link](8),
),
child: Icon(
Icons.precision_manufacturing_rounded,
color: [Link],
size: 20,
),
),
SizedBox(width: 12),
Expanded(
child: Text(
'Selected Processes',
style: [Link]!.copyWith(
fontWeight: [Link],
color: [Link],
),
),
),
Container(
padding: [Link](horizontal: 12, vertical: 4),
decoration: BoxDecoration(
color: [Link],
borderRadius: [Link](16),
),
child: Text(
'${[Link]}',
style: [Link]!.copyWith(
color: [Link],
fontWeight: [Link],
),
),
),
],
),
SizedBox(height: 20),
// List or Empty State
Expanded(
child: [Link]
? _buildEmptyState(colorTheme, textTheme)
: _buildProcessList(provider, colorTheme, textTheme),
),
],
);
},
);
}
Widget _buildEmptyState(ColorScheme colorScheme, TextTheme textTheme) {
return Center(
child: Column(
mainAxisAlignment: [Link],
children: [
Container(
padding: [Link](24),
decoration: BoxDecoration(
color: [Link](alpha:0.3),
shape: [Link],
),
child: Icon(
Icons.inventory_2_outlined,
size: 48,
color: [Link],
),
),
SizedBox(height: 24),
Text(
'No Processes Selected',
style: [Link]!.copyWith(
fontWeight: FontWeight.w600,
color: [Link],
),
),
SizedBox(height: 8),
Text(
'Select operations and machines above\nto start building your quality
plan',
style: [Link]!.copyWith(
color: [Link],
),
textAlign: [Link],
),
],
),
);
}
Widget _buildProcessList(
OperationStateProvider provider,
ColorScheme colorScheme,
TextTheme textTheme,
) {
return Scrollbar(
controller: [Link],
thumbVisibility: true,
trackVisibility: true,
radius: const [Link](4.0),
child: [Link](
padding: [Link](bottom: 16),
itemCount: [Link],
itemBuilder: (context, index) {
final selectedData = [Link][index];
return Container(
margin: [Link](bottom: 16),
decoration: BoxDecoration(
color: [Link],
borderRadius: [Link](16),
border: [Link](
color: [Link](alpha: 0.2),
width: 1,
),
boxShadow: [
BoxShadow(
color: [Link](alpha:0.05),
blurRadius: 10,
offset: Offset(0, 2),
),
],
),
child: Column(
children: [
// Process Header
Container(
padding: [Link](20),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
[Link](alpha:0.1),
[Link](alpha:0.05),
],
),
borderRadius: [Link](
topLeft: [Link](16),
topRight: [Link](16),
),
),
child: Row(
children: [
Container(
width: 40,
height: 40,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
[Link],
[Link](alpha:0.8),
],
),
shape: [Link],
boxShadow: [
BoxShadow(
color: [Link](alpha:0.3),
blurRadius: 8,
offset: Offset(0, 2),
),
],
),
child: Center(
child: Text(
'${index + 1}',
style: TextStyle(
color: [Link],
fontWeight: [Link],
fontSize: 16,
),
),
),
),
SizedBox(width: 16),
Expanded(
child: Column(
crossAxisAlignment: [Link],
children: [
Text(
[Link],
style: [Link]!.copyWith(
fontWeight: [Link],
color: [Link],
),
),
SizedBox(height: 4),
Container(
padding: [Link](
horizontal: 8,
vertical: 2,
),
decoration: BoxDecoration(
color: [Link],
borderRadius: [Link](12),
),
child: Text(
'${[Link]} - $
{[Link]}',
style: [Link]!.copyWith(
color: [Link],
fontWeight: FontWeight.w500,
),
),
),
],
),
),
IconButton(
icon: Container(
padding: [Link](8),
decoration: BoxDecoration(
color: [Link](alpha:0.1),
borderRadius: [Link](8),
),
child: Icon(
Icons.delete_outline_rounded,
color: [Link],
size: 20,
),
),
onPressed: [Link]
? null
: () => _showDeleteDialog(
context,
() => [Link](index),
),
tooltip: 'Remove Process',
),
],
),
),
// Products Section
_buildProductsSection(
selectedData,
textTheme,
provider,
index,
colorScheme,
context,
),
],
),
);
},
),
);
}
Widget _buildProductsSection(
selectedData,
TextTheme textTheme,
OperationStateProvider provider,
int processIndex,
ColorScheme colorScheme,
BuildContext context,
) {
return Container(
padding: [Link](20),
child: Column(
crossAxisAlignment: [Link],
children: [
Row(
children: [
Icon(
Icons.inventory_rounded,
color: [Link],
size: 20,
),
SizedBox(width: 8),
Text(
'Products',
style: [Link]!.copyWith(
fontWeight: [Link],
color: [Link],
),
),
SizedBox(width: 8),
Container(
padding: [Link](horizontal: 8, vertical: 2),
decoration: BoxDecoration(
color: [Link],
borderRadius: [Link](10),
),
child: Text(
'${[Link]}',
style: [Link]!.copyWith(
color: [Link],
fontWeight: FontWeight.w600,
),
),
),
],
),
SizedBox(height: 16),
// Products List
...[Link]().[Link]<Widget>((entry) {
int productIndex = [Link];
var product = [Link];
return Container(
margin: [Link](bottom: 12),
decoration: BoxDecoration(
color: [Link].shade50,
borderRadius: [Link](12),
border: [Link](
color: [Link](alpha: 0.2),
width: 1,
),
boxShadow: [
BoxShadow(
color: [Link](alpha: .02),
blurRadius: 4,
offset: Offset(0, 1),
),
],
),
child: Padding(
padding: [Link](16),
child: Column(
crossAxisAlignment: [Link],
children: [
// Product Header with Remove Button
Row(
children: [
Container(
padding: [Link](6),
decoration: BoxDecoration(
color: [Link](alpha:0.1),
borderRadius: [Link](6),
),
child: Icon(
Icons.precision_manufacturing_outlined,
size: 16,
color: [Link],
),
),
SizedBox(width: 8),
Expanded(
child: Row(
children: [
Text(
[Link],
style: [Link]!.copyWith(
fontWeight: [Link],
color: [Link],
),
),
gap12,
Expanded(
child: AppField(
hintText: "Enter spec & tolerance",
onChanged: (value) {
[Link](
processIndex,
productIndex,
value,
);
},
),
),
],
),
),
Expanded(
child: Align(
alignment: [Link],
child: IconButton(
icon: Container(
padding: [Link](4),
decoration: BoxDecoration(
color: [Link](alpha:0.1),
borderRadius: [Link](6),
),
child: Icon(
Icons.close_rounded,
color: [Link],
size: 16,
),
),
onPressed: () => _showProductDeleteDialog(
context,
[Link],
() => [Link](
processIndex,
productIndex,
),
),
tooltip: 'Remove Product',
constraints: BoxConstraints(
minWidth: 32,
minHeight: 32,
),
),
),
),
],
),
],
),
),
);
}).toList(),
],
),
);
}
void _showDeleteDialog(BuildContext context, VoidCallback onConfirm) {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: [Link](16),
),
title: Row(
children: [
Icon(Icons.warning_amber_rounded, color: [Link]),
SizedBox(width: 8),
Text('Remove Process'),
],
),
content: Text(
'Are you sure you want to remove this process? This action cannot be
undone.',
),
actions: [
TextButton(
onPressed: () => [Link](context).pop(),
child: Text('Cancel'),
),
ElevatedButton(
onPressed: () {
[Link](context).pop();
onConfirm();
},
style: [Link](
backgroundColor: [Link],
foregroundColor: [Link],
),
child: Text('Remove'),
),
],
);
},
);
}
void _showProductDeleteDialog(
BuildContext context,
String productName,
VoidCallback onConfirm,
) {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: [Link](16),
),
title: Row(
children: [
Icon(Icons.delete_outline, color: [Link]),
SizedBox(width: 8),
Text('Remove Product'),
],
),
content: Text('Remove "$productName" from this process?'),
actions: [
TextButton(
onPressed: () => [Link](context).pop(),
child: Text('Cancel'),
),
ElevatedButton(
onPressed: () {
[Link](context).pop();
onConfirm();
},
style: [Link](
backgroundColor: [Link],
foregroundColor: [Link],
),
child: Text('Remove'),
),
],
);
},
);
}
}