-
Notifications
You must be signed in to change notification settings - Fork 286
Description
// Digital Wardrobe — Flutter (single-file starter)
ElevatedButton(onPressed: _save, child: Text('Save Item'))
],
),
),
);
}
void showImageSourceSheet() {
showModalBottomSheet(
context: context,
builder: () => SafeArea(
child: Wrap(
children: [
ListTile(leading: Icon(Icons.camera_alt), title: Text('Camera'), onTap: () { Navigator.pop(context); _pickImage(ImageSource.camera); }),
ListTile(leading: Icon(Icons.photo), title: Text('Gallery'), onTap: () { Navigator.pop(context); _pickImage(ImageSource.gallery); }),
],
),
),
);
}
}
class ItemDetailScreen extends StatelessWidget {
final ClothingItem item;
const ItemDetailScreen({required this.item});
@OverRide
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(item.name), actions: [
IconButton(
icon: Icon(Icons.delete),
onPressed: () async {
final confirmed = await showDialog(
context: context,
builder: (_) => AlertDialog(
title: Text('Delete'),
content: Text('Delete this item?'),
actions: [TextButton(onPressed: () => Navigator.pop(context, false), child: Text('No')), TextButton(onPressed: () => Navigator.pop(context, true), child: Text('Yes'))],
),
);
if (confirmed == true) {
await item.delete();
// delete image file
final f = File(item.imagePath);
if (await f.exists()) await f.delete();
Navigator.of(context).pop();
}
},
)
]),
body: Column(
children: [
Expanded(child: Image.file(File(item.imagePath), width: double.infinity, fit: BoxFit.cover)),
Padding(
padding: EdgeInsets.all(16),
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Text(item.name, style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold)),
SizedBox(height: 8),
Text('Category: ${item.category}'),
SizedBox(height: 8),
Text('Added: ${item.addedAt.toLocal()}'),
]),
)
],
),
);
}
}