Camara e chat IA

This commit is contained in:
2026-05-17 17:05:01 +01:00
parent e8fa39c594
commit 5158d140ca
9 changed files with 196 additions and 121 deletions

View File

@@ -22,10 +22,10 @@ class _AddItemScreenState extends State<AddItemScreen> {
bool _isLoading = false;
Future<void> _pickImage() async {
Future<void> _pickImage(ImageSource source) async {
final picker = ImagePicker();
final image = await picker.pickImage(
source: ImageSource.gallery,
source: source,
maxWidth: 1024,
imageQuality: 80,
);
@@ -34,6 +34,46 @@ class _AddItemScreenState extends State<AddItemScreen> {
}
}
Future<void> _showImageSourcePicker() async {
final source = await showModalBottomSheet<ImageSource>(
context: context,
backgroundColor: Colors.white,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
),
builder: (context) => SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 12),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
leading: const Icon(
Icons.photo_camera,
color: Color(0xFF0066CC),
),
title: const Text('Tirar foto'),
onTap: () => Navigator.pop(context, ImageSource.camera),
),
ListTile(
leading: const Icon(
Icons.photo_library,
color: Color(0xFF0066CC),
),
title: const Text('Escolher da galeria'),
onTap: () => Navigator.pop(context, ImageSource.gallery),
),
],
),
),
),
);
if (source != null) {
await _pickImage(source);
}
}
@override
void dispose() {
_nameController.dispose();
@@ -185,7 +225,7 @@ class _AddItemScreenState extends State<AddItemScreen> {
// Image picker
Center(
child: GestureDetector(
onTap: _pickImage,
onTap: _showImageSourcePicker,
child: Container(
width: 140,
height: 140,
@@ -297,7 +337,7 @@ class _AddItemScreenState extends State<AddItemScreen> {
value: _selectedCategory,
hint: const Text('Selecione uma categoria'),
isExpanded: true,
items: ITEM_CATEGORIES.map((category) {
items: itemCategories.map((category) {
return DropdownMenuItem<ItemCategory>(
value: category,
child: Row(
@@ -407,13 +447,13 @@ class _AddItemScreenState extends State<AddItemScreen> {
Wrap(
spacing: 8,
runSpacing: 8,
children: CONTEXT_TAGS.map((tag) {
children: contextTags.map((tag) {
final isSelected = _selectedTags.contains(tag.id);
return FilterChip(
label: Text(tag.name),
selected: isSelected,
onSelected: (selected) => _toggleTag(tag.id),
selectedColor: const Color(0xFF0066CC).withOpacity(0.2),
selectedColor: const Color(0xFF0066CC).withValues(alpha: 0.2),
checkmarkColor: const Color(0xFF0066CC),
backgroundColor: Colors.white,
labelStyle: TextStyle(