Troca de desing

This commit is contained in:
Carlos Correia
2026-05-18 15:04:07 +01:00
parent 9b4c2f7e04
commit 9999011cfd
9 changed files with 3000 additions and 2138 deletions

View File

@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart'; import 'package:image_picker/image_picker.dart';
import 'package:supabase_flutter/supabase_flutter.dart'; import 'package:supabase_flutter/supabase_flutter.dart';
import '../constants/item_categories.dart'; import '../constants/item_categories.dart';
import '../theme/app_theme.dart';
class AddItemScreen extends StatefulWidget { class AddItemScreen extends StatefulWidget {
const AddItemScreen({super.key}); const AddItemScreen({super.key});
@@ -12,143 +13,94 @@ class AddItemScreen extends StatefulWidget {
} }
class _AddItemScreenState extends State<AddItemScreen> { class _AddItemScreenState extends State<AddItemScreen> {
final TextEditingController _nameController = TextEditingController(); final _nameController = TextEditingController();
final TextEditingController _descriptionController = TextEditingController(); final _descController = TextEditingController();
final _imagePicker = ImagePicker();
XFile? _pickedImage;
ItemCategory? _selectedCategory; ItemCategory? _selectedCategory;
Subcategory? _selectedSubcategory; Subcategory? _selectedSubcategory;
final Set<String> _selectedTags = {}; final Set<String> _selectedTags = {};
XFile? _selectedImage;
bool _isLoading = false; bool _isLoading = false;
Future<void> _pickImage(ImageSource source) async {
final picker = ImagePicker();
final image = await picker.pickImage(
source: source,
maxWidth: 1024,
imageQuality: 80,
);
if (image != null) {
setState(() => _selectedImage = image);
}
}
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 @override
void dispose() { void dispose() {
_nameController.dispose(); _nameController.dispose();
_descriptionController.dispose(); _descController.dispose();
super.dispose(); super.dispose();
} }
void _onCategoryChanged(ItemCategory? category) { Future<void> _pickImage() async {
setState(() { try {
_selectedCategory = category; final image = await _imagePicker.pickImage(
_selectedSubcategory = null; source: ImageSource.gallery,
_selectedTags.clear(); maxWidth: 1080,
maxHeight: 1080,
if (category != null && category.subcategories.isNotEmpty) { imageQuality: 80,
_selectedSubcategory = category.subcategories.first; );
_autoAssignTags(category.id, category.subcategories.first.id); if (image != null) {
setState(() => _pickedImage = image);
}
} catch (e) {
if (mounted) AppSnack.error(context, 'Erro ao selecionar foto: $e');
} }
});
} }
void _onSubcategoryChanged(Subcategory? subcategory) { Future<void> _takePhoto() async {
setState(() { try {
_selectedSubcategory = subcategory; final image = await _imagePicker.pickImage(
_selectedTags.clear(); source: ImageSource.camera,
maxWidth: 1080,
if (_selectedCategory != null && subcategory != null) { maxHeight: 1080,
_autoAssignTags(_selectedCategory!.id, subcategory.id); imageQuality: 80,
);
if (image != null) {
setState(() => _pickedImage = image);
}
} catch (e) {
if (mounted) AppSnack.error(context, 'Erro ao abrir câmara: $e');
} }
});
} }
void _autoAssignTags(String categoryId, String subcategoryId) { void _toggleSubcategoryTags(
final autoTags = getAutoContextTags(categoryId, subcategoryId); Subcategory? oldSub,
setState(() { Subcategory? newSub,
_selectedTags.addAll(autoTags); ) {
}); if (oldSub != null && _selectedCategory != null) {
for (final t in getAutoContextTags(_selectedCategory!.id, oldSub.id)) {
_selectedTags.remove(t);
} }
void _toggleTag(String tagId) {
setState(() {
if (_selectedTags.contains(tagId)) {
_selectedTags.remove(tagId);
} else if (_selectedTags.length < 10) {
_selectedTags.add(tagId);
} }
}); if (newSub != null && _selectedCategory != null) {
_selectedTags.addAll(
getAutoContextTags(_selectedCategory!.id, newSub.id),
);
}
} }
Future<void> _saveItem() async { Future<void> _saveItem() async {
if (_nameController.text.trim().isEmpty) { if (_nameController.text.trim().isEmpty) {
_showErrorSnackBar('Por favor, insira o nome do item'); AppSnack.error(context, 'Indique um nome');
return; return;
} }
if (_selectedCategory == null) { if (_selectedCategory == null) {
_showErrorSnackBar('Por favor, selecione uma categoria'); AppSnack.error(context, 'Selecione uma categoria');
return; return;
} }
setState(() => _isLoading = true); setState(() => _isLoading = true);
try { try {
final user = Supabase.instance.client.auth.currentUser; final user = Supabase.instance.client.auth.currentUser;
if (user == null) { if (user == null) {
_showErrorSnackBar('Usuário não autenticado'); AppSnack.error(context, 'Utilizador não autenticado');
return; return;
} }
// Ensure user profile row exists in public.users (FK requirement)
await Supabase.instance.client.from('users').upsert({ await Supabase.instance.client.from('users').upsert({
'id': user.id, 'id': user.id,
'nome': 'nome': user.userMetadata?['username'] ??
user.userMetadata?['username'] ??
user.email?.split('@').first ?? user.email?.split('@').first ??
'Usuário', 'Utilizador',
}, onConflict: 'id'); }, onConflict: 'id');
final inserted = await Supabase.instance.client final inserted = await Supabase.instance.client
@@ -164,11 +116,10 @@ class _AddItemScreenState extends State<AddItemScreen> {
}) })
.select() .select()
.single(); .single();
// Upload image if selected
if (_selectedImage != null) {
final itemId = inserted['id']; final itemId = inserted['id'];
final file = File(_selectedImage!.path);
if (_pickedImage != null) {
final file = File(_pickedImage!.path);
final fileName = final fileName =
'item_${itemId}_${DateTime.now().millisecondsSinceEpoch}.jpg'; 'item_${itemId}_${DateTime.now().millisecondsSinceEpoch}.jpg';
await Supabase.instance.client.storage await Supabase.instance.client.storage
@@ -183,333 +134,348 @@ class _AddItemScreenState extends State<AddItemScreen> {
}); });
} }
_showSuccessSnackBar('Item adicionado com sucesso!'); if (mounted) {
if (mounted) Navigator.pop(context); AppSnack.success(context, 'Item adicionado!');
Navigator.pop(context);
}
} catch (e) { } catch (e) {
_showErrorSnackBar('Erro ao salvar item: $e'); if (mounted) AppSnack.error(context, 'Erro ao guardar: $e');
} finally { } finally {
setState(() => _isLoading = false); if (mounted) setState(() => _isLoading = false);
} }
} }
void _showErrorSnackBar(String message) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(message), backgroundColor: Colors.red),
);
}
void _showSuccessSnackBar(String message) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(message), backgroundColor: Colors.green),
);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
backgroundColor: const Color(0xFFFFE5CC), backgroundColor: AppColors.background,
appBar: AppBar( appBar: AppBar(
backgroundColor: const Color(0xFF0066CC), backgroundColor: AppColors.background,
elevation: 0, elevation: 0,
title: const Text( iconTheme: const IconThemeData(color: AppColors.textPrimary),
'Adicionar Item', title: const Text('Adicionar Item', style: AppText.h3),
style: TextStyle(color: Colors.white, fontSize: 20),
),
centerTitle: true,
), ),
body: SingleChildScrollView( body: SingleChildScrollView(
padding: const EdgeInsets.all(20), padding: const EdgeInsets.fromLTRB(20, 8, 20, 32),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
// Image picker _buildImagePicker(),
Center( const SizedBox(height: 24),
child: GestureDetector( const Text('Nome', style: AppText.label),
onTap: _showImageSourcePicker, const SizedBox(height: 8),
child: Container( _textField(
width: 140, controller: _nameController,
height: 140, hint: 'ex: Camisa azul',
icon: Icons.label_outline_rounded,
),
const SizedBox(height: 20),
const Text('Descrição (opcional)', style: AppText.label),
const SizedBox(height: 8),
_textField(
controller: _descController,
hint: 'detalhes do item',
icon: Icons.notes_rounded,
maxLines: 3,
),
const SizedBox(height: 24),
const Text('Categoria', style: AppText.label),
const SizedBox(height: 12),
_buildCategoryGrid(),
if (_selectedCategory != null &&
_selectedCategory!.subcategories.isNotEmpty) ...[
const SizedBox(height: 24),
const Text('Subcategoria', style: AppText.label),
const SizedBox(height: 8),
Wrap(
spacing: 8,
runSpacing: 8,
children: _selectedCategory!.subcategories.map((sub) {
final selected = _selectedSubcategory?.id == sub.id;
return AppChip(
label: sub.name,
selected: selected,
color: _selectedCategory!.color,
onTap: () {
setState(() {
final oldSub = _selectedSubcategory;
_selectedSubcategory = selected ? null : sub;
_toggleSubcategoryTags(
oldSub,
_selectedSubcategory,
);
});
},
);
}).toList(),
),
if (_selectedSubcategory != null) ...[
const SizedBox(height: 6),
Text(
_selectedSubcategory!.description,
style: AppText.caption.copyWith(
fontStyle: FontStyle.italic,
),
),
],
],
const SizedBox(height: 24),
const Text('Tags de Contexto', style: AppText.label),
const SizedBox(height: 8),
Wrap(
spacing: 8,
runSpacing: 8,
children: contextTags.map((tag) {
final selected = _selectedTags.contains(tag.id);
return AppChip(
label: tag.name,
selected: selected,
onTap: () {
setState(() {
if (selected) {
_selectedTags.remove(tag.id);
} else {
_selectedTags.add(tag.id);
}
});
},
);
}).toList(),
),
const SizedBox(height: 32),
AppButton(
label: 'Guardar Item',
icon: Icons.check_rounded,
loading: _isLoading,
onPressed: _saveItem,
),
],
),
),
);
}
Widget _buildImagePicker() {
return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: AppColors.surface,
borderRadius: BorderRadius.circular(AppRadius.lg),
border: Border.all(color: AppColors.border),
),
clipBehavior: Clip.antiAlias,
child: Column(
children: [
AspectRatio(
aspectRatio: 16 / 11,
child: _pickedImage != null
? Stack(
fit: StackFit.expand,
children: [
Image.file(File(_pickedImage!.path), fit: BoxFit.cover),
Positioned(
top: 8,
right: 8,
child: Material(
color: Colors.black.withValues(alpha: 0.55),
shape: const CircleBorder(),
child: InkWell(
customBorder: const CircleBorder(),
onTap: () => setState(() => _pickedImage = null),
child: const Padding(
padding: EdgeInsets.all(8),
child: Icon(
Icons.close_rounded,
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.circular(16), size: 18,
border: Border.all(color: const Color(0xFFE0E0E0)),
), ),
child: _selectedImage != null
? ClipRRect(
borderRadius: BorderRadius.circular(16),
child: Image.file(
File(_selectedImage!.path),
fit: BoxFit.cover,
), ),
),
),
),
],
) )
: const Column( : Container(
color: AppColors.surfaceAlt,
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Icon( Icon(
Icons.add_a_photo_outlined, Icons.image_outlined,
size: 40, size: 48,
color: Color(0xFF0066CC), color: AppColors.textTertiary,
), ),
SizedBox(height: 8), const SizedBox(height: 8),
Text( Text(
'Adicionar foto', 'Adicione uma foto',
style: TextStyle( style: AppText.caption,
color: Color(0xFF666666),
fontSize: 12,
),
), ),
], ],
), ),
), ),
), ),
), Row(
const SizedBox(height: 20),
// Name field
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: const Color(0xFFE0E0E0)),
),
child: TextField(
controller: _nameController,
decoration: const InputDecoration(
labelText: 'Nome do item',
hintText: 'Ex: Camiseta Azul',
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(
horizontal: 16,
vertical: 16,
),
),
),
),
const SizedBox(height: 16),
// Description field
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: const Color(0xFFE0E0E0)),
),
child: TextField(
controller: _descriptionController,
maxLines: 3,
decoration: const InputDecoration(
labelText: 'Descrição (opcional)',
hintText: 'Detalhes sobre o item',
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(
horizontal: 16,
vertical: 16,
),
),
),
),
const SizedBox(height: 24),
// Category selection
const Text(
'Categoria',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Color(0xFF333333),
),
),
const SizedBox(height: 8),
Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(horizontal: 12),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: const Color(0xFFE0E0E0)),
),
child: DropdownButtonHideUnderline(
child: DropdownButton<ItemCategory>(
value: _selectedCategory,
hint: const Text('Selecione uma categoria'),
isExpanded: true,
items: itemCategories.map((category) {
return DropdownMenuItem<ItemCategory>(
value: category,
child: Row(
children: [ children: [
Text( Expanded(
category.icon, child: _imageBtn(
style: const TextStyle(fontSize: 24), icon: Icons.photo_camera_rounded,
label: 'Câmara',
onTap: _takePhoto,
),
),
Container(width: 1, height: 44, color: AppColors.border),
Expanded(
child: _imageBtn(
icon: Icons.photo_library_rounded,
label: 'Galeria',
onTap: _pickImage,
),
),
],
), ),
const SizedBox(width: 12),
Text(category.name),
], ],
), ),
); );
}).toList(), }
onChanged: _onCategoryChanged,
),
),
),
const SizedBox(height: 16), Widget _imageBtn({
required IconData icon,
// Subcategory selection required String label,
if (_selectedCategory != null && required VoidCallback onTap,
_selectedCategory!.subcategories.isNotEmpty) ...[ }) {
const Text( return Material(
'Subcategoria', color: Colors.transparent,
style: TextStyle( child: InkWell(
fontSize: 16, onTap: onTap,
fontWeight: FontWeight.bold, child: Padding(
color: Color(0xFF333333), padding: const EdgeInsets.symmetric(vertical: 12),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(icon, size: 18, color: AppColors.primary),
const SizedBox(width: 8),
Text(
label,
style: const TextStyle(
color: AppColors.primary,
fontWeight: FontWeight.w600,
), ),
), ),
const SizedBox(height: 8), ],
SizedBox(
height: 60,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: _selectedCategory!.subcategories.length,
itemBuilder: (context, index) {
final subcategory = _selectedCategory!.subcategories[index];
final isSelected = _selectedSubcategory == subcategory;
return Padding(
padding: const EdgeInsets.only(right: 8),
child: GestureDetector(
onTap: () => _onSubcategoryChanged(subcategory),
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 8,
), ),
),
),
);
}
Widget _textField({
required TextEditingController controller,
required String hint,
required IconData icon,
int maxLines = 1,
}) {
return Container(
decoration: AppDecorations.outlined(),
child: TextField(
controller: controller,
maxLines: maxLines,
style: AppText.body,
decoration: InputDecoration(
prefixIcon: maxLines == 1
? Icon(icon, color: AppColors.textSecondary)
: Padding(
padding: const EdgeInsets.only(left: 12, top: 14),
child: Icon(icon, color: AppColors.textSecondary),
),
prefixIconConstraints: maxLines == 1
? null
: const BoxConstraints(minWidth: 40, minHeight: 40),
hintText: hint,
hintStyle: TextStyle(color: AppColors.textTertiary),
border: InputBorder.none,
contentPadding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 14,
),
),
),
);
}
Widget _buildCategoryGrid() {
return GridView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: itemCategories.length,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
childAspectRatio: 1,
),
itemBuilder: (_, i) {
final c = itemCategories[i];
final selected = _selectedCategory?.id == c.id;
return AnimatedContainer(
duration: const Duration(milliseconds: 180),
decoration: BoxDecoration( decoration: BoxDecoration(
color: isSelected color: selected ? c.color : AppColors.surface,
? const Color(0xFF0066CC) borderRadius: BorderRadius.circular(AppRadius.lg),
: Colors.white,
borderRadius: BorderRadius.circular(20),
border: Border.all( border: Border.all(
color: isSelected color: selected ? c.color : AppColors.border,
? const Color(0xFF0066CC) width: 1.5,
: const Color(0xFFE0E0E0),
), ),
boxShadow: selected
? [
BoxShadow(
color: c.color.withValues(alpha: 0.3),
blurRadius: 12,
offset: const Offset(0, 6),
)
]
: null,
), ),
child: Center( child: Material(
child: Text( color: Colors.transparent,
subcategory.name, child: InkWell(
borderRadius: BorderRadius.circular(AppRadius.lg),
onTap: () {
setState(() {
if (_selectedCategory?.id != c.id) {
_selectedCategory = c;
_selectedSubcategory = null;
}
});
},
child: Padding(
padding: const EdgeInsets.all(8),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
c.icon,
size: 28,
color: selected ? Colors.white : c.color,
),
const SizedBox(height: 6),
Text(
c.name,
textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
color: isSelected fontSize: 12,
fontWeight: FontWeight.w600,
color: selected
? Colors.white ? Colors.white
: const Color(0xFF333333), : AppColors.textPrimary,
fontWeight: FontWeight.w500,
), ),
), ),
],
),
), ),
), ),
), ),
); );
}, },
),
),
const SizedBox(height: 8),
if (_selectedSubcategory != null)
Text(
_selectedSubcategory!.examples,
style: const TextStyle(
fontSize: 12,
color: Color(0xFF666666),
fontStyle: FontStyle.italic,
),
),
],
const SizedBox(height: 24),
// Context tags
const Text(
'Tags de Contexto',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Color(0xFF333333),
),
),
const SizedBox(height: 8),
Wrap(
spacing: 8,
runSpacing: 8,
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).withValues(alpha: 0.2),
checkmarkColor: const Color(0xFF0066CC),
backgroundColor: Colors.white,
labelStyle: TextStyle(
color: isSelected
? const Color(0xFF0066CC)
: const Color(0xFF333333),
),
);
}).toList(),
),
const SizedBox(height: 8),
Text(
'Tags selecionadas: ${_selectedTags.length}/10',
style: const TextStyle(fontSize: 12, color: Color(0xFF666666)),
),
const SizedBox(height: 32),
// Save button
SizedBox(
width: double.infinity,
height: 56,
child: ElevatedButton(
onPressed: _isLoading ? null : _saveItem,
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF0066CC),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
elevation: 0,
),
child: _isLoading
? const SizedBox(
height: 20,
width: 20,
child: CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(
Colors.white,
),
),
)
: const Text(
'Salvar Item',
style: TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.w600,
),
),
),
),
],
),
),
); );
} }
} }

View File

@@ -1,11 +1,11 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:supabase_flutter/supabase_flutter.dart'; import 'package:supabase_flutter/supabase_flutter.dart';
import 'perfil_screen.dart'; import '../constants/item_categories.dart';
import '../theme/app_theme.dart';
import 'add_item_screen.dart'; import 'add_item_screen.dart';
import 'item_screen.dart'; import 'item_screen.dart';
import 'perfil_screen.dart';
import 'week_screen.dart'; import 'week_screen.dart';
import 'ai_chat_screen.dart';
import '../constants/item_categories.dart';
class HomeScreen extends StatefulWidget { class HomeScreen extends StatefulWidget {
const HomeScreen({super.key}); const HomeScreen({super.key});
@@ -15,55 +15,105 @@ class HomeScreen extends StatefulWidget {
} }
class _HomeScreenState extends State<HomeScreen> { class _HomeScreenState extends State<HomeScreen> {
int _selectedIndex = 0; int _index = 0;
final List<Widget> _screens = [ static const _tabs = [
const _HomeContent(), _HomeContent(),
const _ItemsScreen(), ItemScreen(),
const _WeekScreen(), WeekScreen(),
const _AiScreen(), PerfilScreen(),
const _ProfileScreen(),
]; ];
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
backgroundColor: const Color(0xFFFFE5CC), backgroundColor: AppColors.background,
body: _screens[_selectedIndex], body: IndexedStack(index: _index, children: _tabs),
bottomNavigationBar: BottomNavigationBar( bottomNavigationBar: _buildBottomNav(),
currentIndex: _selectedIndex, );
onTap: (index) => setState(() => _selectedIndex = index), }
selectedItemColor: const Color(0xFF0066CC),
unselectedItemColor: const Color(0xFF666666), Widget _buildBottomNav() {
backgroundColor: Colors.white, return Container(
type: BottomNavigationBarType.fixed, decoration: BoxDecoration(
items: const [ color: AppColors.surface,
BottomNavigationBarItem( boxShadow: [
icon: Icon(Icons.home), BoxShadow(
label: 'Início', color: Colors.black.withValues(alpha: 0.06),
), blurRadius: 20,
BottomNavigationBarItem( offset: const Offset(0, -4),
icon: Icon(Icons.inventory_2_outlined),
label: 'Itens',
),
BottomNavigationBarItem(
icon: Icon(Icons.calendar_today_outlined),
label: 'Semana',
),
BottomNavigationBarItem(
icon: Icon(Icons.auto_awesome_outlined),
label: 'IA',
),
BottomNavigationBarItem(
icon: Icon(Icons.person_outline),
label: 'Perfil',
), ),
], ],
), ),
child: SafeArea(
top: false,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
_navItem(0, Icons.home_rounded, 'Início'),
_navItem(1, Icons.inventory_2_rounded, 'Itens'),
_navItem(2, Icons.calendar_month_rounded, 'Semana'),
_navItem(3, Icons.person_rounded, 'Perfil'),
],
),
),
),
);
}
Widget _navItem(int idx, IconData icon, String label) {
final selected = _index == idx;
return Expanded(
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.circular(AppRadius.lg),
onTap: () => setState(() => _index = idx),
child: AnimatedContainer(
duration: const Duration(milliseconds: 220),
curve: Curves.easeOut,
padding: const EdgeInsets.symmetric(vertical: 8),
decoration: BoxDecoration(
color: selected
? AppColors.primary.withValues(alpha: 0.08)
: Colors.transparent,
borderRadius: BorderRadius.circular(AppRadius.lg),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
icon,
size: 24,
color:
selected ? AppColors.primary : AppColors.textSecondary,
),
const SizedBox(height: 3),
Text(
label,
style: TextStyle(
fontSize: 11,
fontWeight:
selected ? FontWeight.w700 : FontWeight.w500,
color: selected
? AppColors.primary
: AppColors.textSecondary,
),
),
],
),
),
),
),
); );
} }
} }
// ============================================================
// Home tab content
// ============================================================
class _HomeContent extends StatefulWidget { class _HomeContent extends StatefulWidget {
const _HomeContent(); const _HomeContent();
@@ -73,6 +123,7 @@ class _HomeContent extends StatefulWidget {
class _HomeContentState extends State<_HomeContent> { class _HomeContentState extends State<_HomeContent> {
int _itemCount = 0; int _itemCount = 0;
String _userName = '';
List<Map<String, dynamic>> _todayItems = []; List<Map<String, dynamic>> _todayItems = [];
List<Map<String, dynamic>> _recentItems = []; List<Map<String, dynamic>> _recentItems = [];
bool _isLoading = true; bool _isLoading = true;
@@ -104,21 +155,27 @@ class _HomeContentState extends State<_HomeContent> {
final user = Supabase.instance.client.auth.currentUser; final user = Supabase.instance.client.auth.currentUser;
if (user == null) return; if (user == null) return;
// total item count
final all = await Supabase.instance.client final all = await Supabase.instance.client
.from('items') .from('items')
.select('id') .select('id')
.eq('user_id', user.id); .eq('user_id', user.id);
// recent 5 items
final recent = await Supabase.instance.client final recent = await Supabase.instance.client
.from('items') .from('items')
.select('*, item_images(image_url)') .select('*, item_images(image_url)')
.eq('user_id', user.id) .eq('user_id', user.id)
.order('id', ascending: false) .order('id', ascending: false)
.limit(5); .limit(8);
Map<String, dynamic>? userRow;
try {
userRow = await Supabase.instance.client
.from('users')
.select('nome')
.eq('id', user.id)
.maybeSingle();
} catch (_) {}
// today's plan
final today = DateTime.now(); final today = DateTime.now();
final plan = await Supabase.instance.client final plan = await Supabase.instance.client
.from('plans') .from('plans')
@@ -138,356 +195,450 @@ class _HomeContentState extends State<_HomeContent> {
.toList(); .toList();
} }
if (!mounted) return;
setState(() { setState(() {
_itemCount = all.length; _itemCount = all.length;
_userName = userRow?['nome'] ??
user.email?.split('@').first ??
'Utilizador';
_recentItems = List<Map<String, dynamic>>.from(recent); _recentItems = List<Map<String, dynamic>>.from(recent);
_todayItems = todayItems; _todayItems = todayItems;
_isLoading = false; _isLoading = false;
}); });
} catch (e) { } catch (e) {
debugPrint('Error loading home: $e'); debugPrint('Error loading home: $e');
setState(() => _isLoading = false); if (mounted) setState(() => _isLoading = false);
} }
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SafeArea( return Scaffold(
child: Stack( backgroundColor: AppColors.background,
children: [ body: SafeArea(
Column( bottom: false,
children: [
// App Bar
Container(
color: const Color(0xFF0066CC),
padding: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 16,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'DayMaker',
style: TextStyle(
color: Colors.white,
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 4),
Text(
'$_itemCount itens',
style: const TextStyle(
color: Colors.white70,
fontSize: 14,
),
),
],
),
IconButton(
icon: const Icon(
Icons.notifications_outlined,
color: Colors.white,
),
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Notificações'),
backgroundColor: Color(0xFF0066CC),
),
);
},
),
],
),
),
Expanded(
child: RefreshIndicator( child: RefreshIndicator(
onRefresh: _loadData, onRefresh: _loadData,
child: SingleChildScrollView( color: AppColors.primary,
child: ListView(
physics: const AlwaysScrollableScrollPhysics(), physics: const AlwaysScrollableScrollPhysics(),
padding: const EdgeInsets.fromLTRB(20, 20, 20, 100),
children: [
_buildGreeting(),
const SizedBox(height: 20),
_buildHeroCard(),
const SizedBox(height: 24),
_buildSectionHeader('Hoje'),
const SizedBox(height: 12),
_buildTodaySection(),
const SizedBox(height: 24),
_buildSectionHeader('Itens recentes'),
const SizedBox(height: 12),
_buildRecentItems(),
const SizedBox(height: 24),
_buildAddCta(),
],
),
),
),
);
}
Widget _buildGreeting() {
final hour = DateTime.now().hour;
final saudacao = hour < 12
? 'Bom dia'
: hour < 19
? 'Boa tarde'
: 'Boa noite';
return Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
saudacao,
style: AppText.bodySecondary,
),
const SizedBox(height: 2),
Text(
_userName.isEmpty ? 'Olá!' : _userName,
style: AppText.h2,
),
],
),
),
Container(
width: 44,
height: 44,
decoration: BoxDecoration(
color: AppColors.surface,
shape: BoxShape.circle,
boxShadow: AppShadows.soft,
),
child: const Icon(
Icons.notifications_none_rounded,
color: AppColors.textPrimary,
),
),
],
);
}
Widget _buildHeroCard() {
final today = DateTime.now();
final dayName = _weekdayLong[today.weekday - 1];
return Container(
decoration: BoxDecoration(
gradient: AppColors.brandGradient,
borderRadius: BorderRadius.circular(AppRadius.xl),
boxShadow: AppShadows.brand,
),
padding: const EdgeInsets.all(20), padding: const EdgeInsets.all(20),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
_buildTodaySection(), Row(
const SizedBox(height: 24), children: [
const Text( const Icon(
'Itens Recentes', Icons.calendar_today_rounded,
style: TextStyle( color: Colors.white,
fontSize: 18, size: 18,
fontWeight: FontWeight.bold,
color: Color(0xFF333333),
),
),
const SizedBox(height: 12),
_buildRecentItems(),
],
),
), ),
const SizedBox(width: 8),
Text(
'$dayName, ${today.day}/${today.month}',
style: const TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
), ),
), ),
], ],
), ),
const SizedBox(height: 14),
// Floating Action Button Row(
Positioned( children: [
bottom: 80, _heroStat(
right: 20, value: '${_todayItems.length}',
child: FloatingActionButton( label: 'Hoje',
onPressed: () { icon: Icons.today_rounded,
Navigator.of(context)
.push(
MaterialPageRoute(builder: (_) => const AddItemScreen()),
)
.then((_) => _loadData());
},
backgroundColor: const Color(0xFF0066CC),
child: const Icon(Icons.add, color: Colors.white),
), ),
const SizedBox(width: 12),
_heroStat(
value: '$_itemCount',
label: 'No inventário',
icon: Icons.inventory_2_rounded,
),
],
), ),
], ],
), ),
); );
} }
Widget _heroStat({
required String value,
required String label,
required IconData icon,
}) {
return Expanded(
child: Container(
padding: const EdgeInsets.all(14),
decoration: BoxDecoration(
color: Colors.white.withValues(alpha: 0.18),
borderRadius: BorderRadius.circular(AppRadius.md),
border: Border.all(color: Colors.white.withValues(alpha: 0.25)),
),
child: Row(
children: [
Icon(icon, color: Colors.white, size: 22),
const SizedBox(width: 10),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
value,
style: const TextStyle(
color: Colors.white,
fontSize: 22,
fontWeight: FontWeight.bold,
height: 1,
),
),
const SizedBox(height: 2),
Text(
label,
style: TextStyle(
color: Colors.white.withValues(alpha: 0.85),
fontSize: 12,
),
),
],
),
],
),
),
);
}
Widget _buildSectionHeader(String title) {
return Text(title, style: AppText.h3);
}
Widget _buildTodaySection() { Widget _buildTodaySection() {
final today = DateTime.now(); if (_isLoading) {
final dayName = _weekdayLong[today.weekday - 1]; return _skeletonRow();
}
if (_todayItems.isEmpty) {
return Container( return Container(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(18),
decoration: AppDecorations.card(),
child: Row(
children: [
Container(
width: 44,
height: 44,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: AppColors.primary.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(16), borderRadius: BorderRadius.circular(AppRadius.md),
), ),
child: const Icon(
Icons.event_available_rounded,
color: AppColors.primary,
),
),
const SizedBox(width: 12),
const Expanded(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text( Text(
'Hoje - $dayName', 'Nada planeado para hoje',
style: const TextStyle( style: AppText.body,
fontSize: 18,
fontWeight: FontWeight.bold,
color: Color(0xFF0066CC),
),
), ),
SizedBox(height: 2),
Text( Text(
'${today.day}/${today.month}', 'Vá à aba Semana para organizar',
style: const TextStyle(fontSize: 14, color: Color(0xFF666666)), style: AppText.caption,
), ),
], ],
), ),
const SizedBox(height: 6),
Text(
'${_todayItems.length} ${_todayItems.length == 1 ? "item planejado" : "itens planejados"}',
style: const TextStyle(fontSize: 14, color: Color(0xFF666666)),
),
const SizedBox(height: 12),
if (_isLoading)
const Padding(
padding: EdgeInsets.symmetric(vertical: 16),
child: Center(child: CircularProgressIndicator()),
)
else if (_todayItems.isEmpty)
Container(
padding: const EdgeInsets.symmetric(vertical: 20),
alignment: Alignment.center,
child: const Text(
'Nada planejado para hoje',
style: TextStyle(color: Color(0xFF999999)),
),
)
else
SizedBox(
height: 90,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: _todayItems.length,
itemBuilder: (_, i) => _buildTodayChip(_todayItems[i]),
),
), ),
], ],
), ),
); );
} }
Widget _buildTodayChip(Map<String, dynamic> item) {
final images = item['item_images'] as List?;
final imageUrl = (images != null && images.isNotEmpty)
? images.first['image_url']
: null;
final category = itemCategories.firstWhere(
(c) => c.id == item['categoria'],
orElse: () => itemCategories.last,
);
return Container(
width: 80,
margin: const EdgeInsets.only(right: 10),
child: Column(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(10),
child: imageUrl != null
? Image.network(
imageUrl,
width: 60,
height: 60,
fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) =>
_placeholder(category.icon),
)
: _placeholder(category.icon),
),
const SizedBox(height: 4),
Text(
item['nome'] ?? '',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(fontSize: 11, color: Color(0xFF333333)),
),
],
),
);
}
Widget _placeholder(String icon) {
return Container(
width: 60,
height: 60,
color: const Color(0xFF0066CC).withValues(alpha: 0.1),
alignment: Alignment.center,
child: Text(icon, style: const TextStyle(fontSize: 26)),
);
}
Widget _buildRecentItems() {
if (_isLoading) {
return const SizedBox(
height: 100,
child: Center(child: CircularProgressIndicator()),
);
}
if (_recentItems.isEmpty) {
return Container(
height: 100,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
),
child: const Center(
child: Text(
'Sem itens ainda',
style: TextStyle(color: Color(0xFF999999)),
),
),
);
}
return SizedBox( return SizedBox(
height: 130, height: 130,
child: ListView.builder( child: ListView.builder(
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
itemCount: _recentItems.length, itemCount: _todayItems.length,
itemBuilder: (_, i) { itemBuilder: (_, i) => _itemCard(_todayItems[i], compact: true),
final item = _recentItems[i]; ),
final images = item['item_images'] as List?;
final imageUrl = (images != null && images.isNotEmpty)
? images.first['image_url']
: null;
final category = itemCategories.firstWhere(
(c) => c.id == item['categoria'],
orElse: () => itemCategories.last,
); );
}
Widget _buildRecentItems() {
if (_isLoading) return _skeletonRow();
if (_recentItems.isEmpty) {
return Container( return Container(
width: 110, padding: const EdgeInsets.all(18),
margin: const EdgeInsets.only(right: 10), decoration: AppDecorations.card(),
padding: const EdgeInsets.all(8), child: Row(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
ClipRRect( Container(
borderRadius: BorderRadius.circular(8), width: 44,
child: imageUrl != null height: 44,
? Image.network( decoration: BoxDecoration(
imageUrl, color: AppColors.accent.withValues(alpha: 0.15),
width: double.infinity, borderRadius: BorderRadius.circular(AppRadius.md),
height: 70, ),
fit: BoxFit.cover, child: const Icon(
errorBuilder: (context, error, stackTrace) => Icons.add_box_rounded,
_placeholder(category.icon), color: AppColors.accent,
) ),
: Container( ),
width: double.infinity, const SizedBox(width: 12),
height: 70, const Expanded(
color: const Color(0xFF0066CC).withValues(alpha: 0.1),
alignment: Alignment.center,
child: Text( child: Text(
category.icon, 'Adicione o seu primeiro item',
style: const TextStyle(fontSize: 30), style: AppText.body,
),
),
),
const SizedBox(height: 6),
Text(
item['nome'] ?? '',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 12,
),
),
Text(
category.name,
style: const TextStyle(
fontSize: 10,
color: Color(0xFF666666),
), ),
), ),
], ],
), ),
); );
}
return SizedBox(
height: 160,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: _recentItems.length,
itemBuilder: (_, i) => _itemCard(_recentItems[i]),
),
);
}
Widget _itemCard(Map<String, dynamic> item, {bool compact = false}) {
final images = item['item_images'] as List?;
final imageUrl = (images != null && images.isNotEmpty)
? images.first['image_url'] as String?
: null;
final cat = categoryById(item['categoria'] as String?);
final size = compact ? 110.0 : 130.0;
return Container(
width: size,
margin: const EdgeInsets.only(right: 12),
decoration: AppDecorations.card(),
clipBehavior: Clip.antiAlias,
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: () {},
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Stack(
children: [
Container(
width: double.infinity,
height: compact ? 72 : 90,
color: cat.color.withValues(alpha: 0.15),
child: imageUrl != null
? Image.network(
imageUrl,
fit: BoxFit.cover,
errorBuilder: (_, __, ___) => Center(
child: Icon(
cat.icon,
color: cat.color,
size: 32,
),
),
)
: Center(
child: Icon(
cat.icon,
color: cat.color,
size: 32,
),
),
),
],
),
Padding(
padding: const EdgeInsets.fromLTRB(10, 8, 10, 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
item['nome'] ?? '',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontSize: 13,
fontWeight: FontWeight.w600,
color: AppColors.textPrimary,
),
),
const SizedBox(height: 2),
Text(
cat.name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 11,
color: cat.color,
fontWeight: FontWeight.w600,
),
),
],
),
),
],
),
),
),
);
}
Widget _skeletonRow() {
return SizedBox(
height: 130,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: 3,
itemBuilder: (_, __) => Container(
width: 110,
margin: const EdgeInsets.only(right: 12),
decoration: BoxDecoration(
color: AppColors.surfaceAlt,
borderRadius: BorderRadius.circular(AppRadius.lg),
),
),
),
);
}
Widget _buildAddCta() {
return Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.circular(AppRadius.lg),
onTap: () {
Navigator.of(context)
.push(
MaterialPageRoute(builder: (_) => const AddItemScreen()),
)
.then((_) => _loadData());
}, },
child: Container(
padding: const EdgeInsets.all(18),
decoration: BoxDecoration(
color: AppColors.surface,
borderRadius: BorderRadius.circular(AppRadius.lg),
border: Border.all(
color: AppColors.primary.withValues(alpha: 0.3),
style: BorderStyle.solid,
width: 1.5,
),
),
child: Row(
children: [
Container(
width: 44,
height: 44,
decoration: BoxDecoration(
gradient: AppColors.brandGradient,
borderRadius: BorderRadius.circular(AppRadius.md),
),
child:
const Icon(Icons.add_rounded, color: Colors.white, size: 24),
),
const SizedBox(width: 14),
const Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Adicionar item', style: AppText.h3),
SizedBox(height: 2),
Text(
'Foto, categoria e tags em segundos',
style: AppText.caption,
),
],
),
),
const Icon(
Icons.arrow_forward_ios_rounded,
size: 16,
color: AppColors.textTertiary,
),
],
),
),
), ),
); );
} }
} }
class _ItemsScreen extends StatelessWidget {
const _ItemsScreen();
@override
Widget build(BuildContext context) => const ItemScreen();
}
class _WeekScreen extends StatelessWidget {
const _WeekScreen();
@override
Widget build(BuildContext context) => const WeekScreen();
}
class _AiScreen extends StatelessWidget {
const _AiScreen();
@override
Widget build(BuildContext context) => const AiChatScreen();
}
class _ProfileScreen extends StatelessWidget {
const _ProfileScreen();
@override
Widget build(BuildContext context) => const PerfilScreen();
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,9 @@
import 'package:flutter/material.dart';
import 'package:supabase_flutter/supabase_flutter.dart';
import 'package:image_picker/image_picker.dart';
import 'dart:io'; import 'dart:io';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:supabase_flutter/supabase_flutter.dart';
import '../login/login_screen.dart'; import '../login/login_screen.dart';
import '../theme/app_theme.dart';
class PerfilScreen extends StatefulWidget { class PerfilScreen extends StatefulWidget {
const PerfilScreen({super.key}); const PerfilScreen({super.key});
@@ -17,6 +18,8 @@ class _PerfilScreenState extends State<PerfilScreen> {
String _nome = ''; String _nome = '';
String _email = ''; String _email = '';
bool _isLoading = true; bool _isLoading = true;
int _itemCount = 0;
int _plansCount = 0;
@override @override
void initState() { void initState() {
@@ -27,299 +30,357 @@ class _PerfilScreenState extends State<PerfilScreen> {
Future<void> _loadUserData() async { Future<void> _loadUserData() async {
try { try {
final user = Supabase.instance.client.auth.currentUser; final user = Supabase.instance.client.auth.currentUser;
if (user != null) { if (user == null) return;
setState(() { setState(() => _email = user.email ?? '');
_email = user.email ?? '';
});
// Fetch user data from users table
final response = await Supabase.instance.client final response = await Supabase.instance.client
.from('users') .from('users')
.select() .select()
.eq('id', user.id) .eq('id', user.id)
.single(); .maybeSingle();
final items = await Supabase.instance.client
.from('items')
.select('id')
.eq('user_id', user.id);
final plans = await Supabase.instance.client
.from('plans')
.select('id')
.eq('user_id', user.id);
if (!mounted) return;
setState(() { setState(() {
_nome = response['nome'] ?? ''; _nome = response?['nome'] ?? '';
_avatarUrl = response['avatar_url']; _avatarUrl = response?['avatar_url'];
_itemCount = (items as List).length;
_plansCount = (plans as List).length;
}); });
}
} catch (e) { } catch (e) {
debugPrint('Error loading user data: $e'); debugPrint('Error loading user data: $e');
} finally { } finally {
setState(() => _isLoading = false); if (mounted) setState(() => _isLoading = false);
} }
} }
Future<void> _pickImage() async { Future<void> _pickImage() async {
try { try {
final XFile? image = await _imagePicker.pickImage( final image = await _imagePicker.pickImage(
source: ImageSource.gallery, source: ImageSource.gallery,
maxWidth: 512, maxWidth: 512,
maxHeight: 512, maxHeight: 512,
imageQuality: 75, imageQuality: 75,
); );
if (image != null) await _uploadImage(image);
if (image != null) {
await _uploadImage(image);
}
} catch (e) { } catch (e) {
_showErrorSnackBar('Erro ao selecionar imagem: $e'); if (mounted) AppSnack.error(context, 'Erro: $e');
} }
} }
Future<void> _uploadImage(XFile image) async { Future<void> _uploadImage(XFile image) async {
final user = Supabase.instance.client.auth.currentUser; final user = Supabase.instance.client.auth.currentUser;
if (user == null) { if (user == null) {
_showErrorSnackBar('Usuário não autenticado'); AppSnack.error(context, 'Utilizador não autenticado');
return; return;
} }
setState(() => _isLoading = true); setState(() => _isLoading = true);
try { try {
final file = File(image.path); final file = File(image.path);
final fileName = final fileName =
'${user.id}_${DateTime.now().millisecondsSinceEpoch}.jpg'; '${user.id}_${DateTime.now().millisecondsSinceEpoch}.jpg';
// Upload to Supabase Storage
await Supabase.instance.client.storage await Supabase.instance.client.storage
.from('avatars') .from('avatars')
.upload(fileName, file); .upload(fileName, file);
// Get public URL
final imageUrl = Supabase.instance.client.storage final imageUrl = Supabase.instance.client.storage
.from('avatars') .from('avatars')
.getPublicUrl(fileName); .getPublicUrl(fileName);
// Update user's avatar_url in database
await Supabase.instance.client await Supabase.instance.client
.from('users') .from('users')
.update({'avatar_url': imageUrl}) .update({'avatar_url': imageUrl})
.eq('id', user.id); .eq('id', user.id);
if (!mounted) return;
setState(() { setState(() => _avatarUrl = imageUrl);
_avatarUrl = imageUrl; AppSnack.success(context, 'Foto atualizada!');
});
_showSuccessSnackBar('Foto atualizada com sucesso!');
} catch (e) { } catch (e) {
_showErrorSnackBar('Erro ao fazer upload: $e'); if (mounted) AppSnack.error(context, 'Erro: $e');
} finally { } finally {
setState(() => _isLoading = false); if (mounted) setState(() => _isLoading = false);
} }
} }
Future<void> _confirmLogout() async {
final ok = await showDialog<bool>(
context: context,
builder: (ctx) => AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppRadius.lg),
),
title: const Text('Sair da conta?'),
content: const Text('Vai ter de fazer login novamente.'),
actions: [
TextButton(
onPressed: () => Navigator.pop(ctx, false),
child: const Text('Cancelar'),
),
TextButton(
onPressed: () => Navigator.pop(ctx, true),
style: TextButton.styleFrom(foregroundColor: AppColors.error),
child: const Text('Sair'),
),
],
),
);
if (ok == true) _logout();
}
Future<void> _logout() async { Future<void> _logout() async {
try { try {
await Supabase.instance.client.auth.signOut(); await Supabase.instance.client.auth.signOut();
if (mounted) { if (mounted) {
Navigator.of(context).pushAndRemoveUntil( Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (_) => const LoginScreen()), MaterialPageRoute(builder: (_) => const LoginScreen()),
(route) => false, (_) => false,
); );
} }
} catch (e) { } catch (e) {
_showErrorSnackBar('Erro ao sair: $e'); if (mounted) AppSnack.error(context, 'Erro ao sair: $e');
} }
} }
void _showErrorSnackBar(String message) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(message), backgroundColor: Colors.red),
);
}
void _showSuccessSnackBar(String message) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(message), backgroundColor: Colors.green),
);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
backgroundColor: const Color(0xFFFFE5CC), backgroundColor: AppColors.background,
appBar: AppBar( body: SafeArea(
backgroundColor: const Color(0xFF0066CC), bottom: false,
elevation: 0, child: _isLoading
title: const Text(
'Perfil',
style: TextStyle(color: Colors.white, fontSize: 20),
),
centerTitle: true,
),
body: _isLoading
? const Center(child: CircularProgressIndicator()) ? const Center(child: CircularProgressIndicator())
: SingleChildScrollView( : SingleChildScrollView(
padding: const EdgeInsets.all(20), padding: const EdgeInsets.fromLTRB(20, 12, 20, 100),
child: Column( child: Column(
children: [ children: [
const SizedBox(height: 20), _buildHeader(),
const SizedBox(height: 24),
_buildAvatar(),
const SizedBox(height: 16),
Text(
_nome.isNotEmpty ? _nome : 'Utilizador',
style: AppText.h2,
),
const SizedBox(height: 4),
Text(_email, style: AppText.bodySecondary),
const SizedBox(height: 24),
_buildStatsRow(),
const SizedBox(height: 24),
_buildInfoCard(),
const SizedBox(height: 24),
AppButton(
label: 'Sair da Conta',
icon: Icons.logout_rounded,
danger: true,
onPressed: _confirmLogout,
),
],
),
),
),
);
}
// Avatar section Widget _buildHeader() {
GestureDetector( return const Padding(
onTap: _pickImage, padding: EdgeInsets.symmetric(vertical: 4),
child: Stack( child: Align(
alignment: Alignment.centerLeft,
child: Text('Perfil', style: AppText.h2),
),
);
}
Widget _buildAvatar() {
return Stack(
children: [ children: [
Container( Container(
width: 120, width: 120,
height: 120, height: 120,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, gradient: AppColors.brandGradient,
shape: BoxShape.circle, shape: BoxShape.circle,
border: Border.all( boxShadow: AppShadows.brand,
color: const Color(0xFF0066CC),
width: 3,
),
), ),
padding: const EdgeInsets.all(4),
child: ClipOval(
child: _avatarUrl != null child: _avatarUrl != null
? ClipOval( ? Image.network(
child: Image.network(
_avatarUrl!, _avatarUrl!,
fit: BoxFit.cover, fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) { errorBuilder: (_, __, ___) => Container(
return const Icon( color: AppColors.surface,
Icons.person, child: const Icon(
Icons.person_rounded,
size: 60, size: 60,
color: Color(0xFFCCCCCC), color: AppColors.textTertiary,
); ),
},
), ),
) )
: const Icon( : Container(
Icons.person, color: AppColors.surface,
child: const Icon(
Icons.person_rounded,
size: 60, size: 60,
color: Color(0xFFCCCCCC), color: AppColors.textTertiary,
),
),
), ),
), ),
Positioned( Positioned(
bottom: 0, bottom: 0,
right: 0, right: 0,
child: Material(
color: AppColors.surface,
shape: const CircleBorder(),
elevation: 2,
child: InkWell(
customBorder: const CircleBorder(),
onTap: _pickImage,
child: Container( child: Container(
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
decoration: const BoxDecoration( decoration: BoxDecoration(
color: Color(0xFF0066CC), gradient: AppColors.brandGradient,
shape: BoxShape.circle, shape: BoxShape.circle,
border: Border.all(color: AppColors.surface, width: 3),
), ),
child: const Icon( child: const Icon(
Icons.camera_alt, Icons.camera_alt_rounded,
color: Colors.white, color: Colors.white,
size: 20, size: 16,
),
),
), ),
), ),
), ),
], ],
), );
), }
const SizedBox(height: 20), Widget _buildStatsRow() {
return Row(
children: [
_statCard(
icon: Icons.inventory_2_rounded,
color: AppColors.primary,
value: '$_itemCount',
label: 'Itens',
),
const SizedBox(width: 12),
_statCard(
icon: Icons.calendar_month_rounded,
color: AppColors.accent,
value: '$_plansCount',
label: 'Dias planeados',
),
],
);
}
// Name section Widget _statCard({
Container( required IconData icon,
width: double.infinity, required Color color,
required String value,
required String label,
}) {
return Expanded(
child: Container(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
decoration: BoxDecoration( decoration: AppDecorations.card(),
color: Colors.white,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: const Color(0xFFE0E0E0)),
),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
const Text(
'Nome',
style: TextStyle(
fontSize: 14,
color: Color(0xFF666666),
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 8),
Text(
_nome.isNotEmpty ? _nome : 'Não definido',
style: const TextStyle(
fontSize: 18,
color: Color(0xFF333333),
fontWeight: FontWeight.bold,
),
),
],
),
),
const SizedBox(height: 16),
// Email section
Container( Container(
width: double.infinity, width: 36,
padding: const EdgeInsets.all(16), height: 36,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: color.withValues(alpha: 0.12),
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(AppRadius.sm),
border: Border.all(color: const Color(0xFFE0E0E0)),
), ),
child: Column( child: Icon(icon, color: color, size: 20),
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'Email',
style: TextStyle(
fontSize: 14,
color: Color(0xFF666666),
fontWeight: FontWeight.w500,
), ),
), const SizedBox(height: 10),
const SizedBox(height: 8),
Text( Text(
_email, value,
style: const TextStyle( style: const TextStyle(
fontSize: 18, fontSize: 22,
color: Color(0xFF333333),
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: AppColors.textPrimary,
), ),
), ),
], Text(label, style: AppText.caption),
),
),
const SizedBox(height: 32),
// Logout button
SizedBox(
width: double.infinity,
height: 56,
child: ElevatedButton(
onPressed: _logout,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.red,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
elevation: 0,
),
child: const Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.logout, color: Colors.white),
SizedBox(width: 8),
Text(
'Sair da Conta',
style: TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.w600,
),
),
],
),
),
),
const SizedBox(height: 20),
], ],
), ),
), ),
); );
} }
Widget _buildInfoCard() {
return Container(
decoration: AppDecorations.card(),
clipBehavior: Clip.antiAlias,
child: Column(
children: [
_infoRow(
icon: Icons.person_outline_rounded,
label: 'Nome',
value: _nome.isNotEmpty ? _nome : 'Não definido',
),
const Divider(height: 1, thickness: 1, color: AppColors.divider),
_infoRow(
icon: Icons.alternate_email_rounded,
label: 'Email',
value: _email,
),
],
),
);
}
Widget _infoRow({
required IconData icon,
required String label,
required String value,
}) {
return Padding(
padding: const EdgeInsets.all(16),
child: Row(
children: [
Container(
width: 40,
height: 40,
decoration: BoxDecoration(
color: AppColors.primary.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(AppRadius.md),
),
child: Icon(icon, color: AppColors.primary, size: 20),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(label, style: AppText.caption),
const SizedBox(height: 2),
Text(
value,
style: const TextStyle(
fontWeight: FontWeight.w600,
color: AppColors.textPrimary,
fontSize: 15,
),
),
],
),
),
],
),
);
}
} }

View File

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:supabase_flutter/supabase_flutter.dart'; import 'package:supabase_flutter/supabase_flutter.dart';
import '../constants/item_categories.dart'; import '../constants/item_categories.dart';
import '../theme/app_theme.dart';
class WeekScreen extends StatefulWidget { class WeekScreen extends StatefulWidget {
const WeekScreen({super.key}); const WeekScreen({super.key});
@@ -14,17 +15,8 @@ class _WeekScreenState extends State<WeekScreen> {
List<Map<String, dynamic>> _dayItems = []; List<Map<String, dynamic>> _dayItems = [];
bool _isLoading = false; bool _isLoading = false;
static const _weekdayNames = [ static const _weekdayShort = ['Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb', 'Dom'];
'Seg', static const _weekdayLong = [
'Ter',
'Qua',
'Qui',
'Sex',
'Sáb',
'Dom',
];
static const _weekdayNamesLong = [
'Segunda', 'Segunda',
'Terça', 'Terça',
'Quarta', 'Quarta',
@@ -42,11 +34,8 @@ class _WeekScreenState extends State<WeekScreen> {
DateTime get _startOfWeek { DateTime get _startOfWeek {
final now = DateTime.now(); final now = DateTime.now();
return DateTime( return DateTime(now.year, now.month, now.day)
now.year, .subtract(Duration(days: now.weekday - 1));
now.month,
now.day,
).subtract(Duration(days: now.weekday - 1));
} }
String _dateKey(DateTime d) => String _dateKey(DateTime d) =>
@@ -57,16 +46,13 @@ class _WeekScreenState extends State<WeekScreen> {
Future<int> _getOrCreatePlanId(DateTime day) async { Future<int> _getOrCreatePlanId(DateTime day) async {
final user = Supabase.instance.client.auth.currentUser!; final user = Supabase.instance.client.auth.currentUser!;
final dateStr = _dateKey(day); final dateStr = _dateKey(day);
final existing = await Supabase.instance.client final existing = await Supabase.instance.client
.from('plans') .from('plans')
.select('id') .select('id')
.eq('user_id', user.id) .eq('user_id', user.id)
.eq('data', dateStr) .eq('data', dateStr)
.maybeSingle(); .maybeSingle();
if (existing != null) return existing['id'] as int; if (existing != null) return existing['id'] as int;
final created = await Supabase.instance.client final created = await Supabase.instance.client
.from('plans') .from('plans')
.insert({'user_id': user.id, 'data': dateStr}) .insert({'user_id': user.id, 'data': dateStr})
@@ -80,7 +66,6 @@ class _WeekScreenState extends State<WeekScreen> {
try { try {
final user = Supabase.instance.client.auth.currentUser; final user = Supabase.instance.client.auth.currentUser;
if (user == null) return; if (user == null) return;
final dateStr = _dateKey(_selectedDay); final dateStr = _dateKey(_selectedDay);
final plan = await Supabase.instance.client final plan = await Supabase.instance.client
.from('plans') .from('plans')
@@ -88,15 +73,14 @@ class _WeekScreenState extends State<WeekScreen> {
.eq('user_id', user.id) .eq('user_id', user.id)
.eq('data', dateStr) .eq('data', dateStr)
.maybeSingle(); .maybeSingle();
if (plan == null) { if (plan == null) {
if (!mounted) return;
setState(() { setState(() {
_dayItems = []; _dayItems = [];
_isLoading = false; _isLoading = false;
}); });
return; return;
} }
final planItems = plan['plan_items'] as List? ?? []; final planItems = plan['plan_items'] as List? ?? [];
final items = planItems final items = planItems
.where((pi) => pi['items'] != null) .where((pi) => pi['items'] != null)
@@ -104,55 +88,46 @@ class _WeekScreenState extends State<WeekScreen> {
(pi) => Map<String, dynamic>.from(pi['items']), (pi) => Map<String, dynamic>.from(pi['items']),
) )
.toList(); .toList();
if (!mounted) return;
setState(() { setState(() {
_dayItems = items; _dayItems = items;
_isLoading = false; _isLoading = false;
}); });
} catch (e) { } catch (e) {
debugPrint('Error loading day items: $e'); debugPrint('Error loading day: $e');
setState(() => _isLoading = false); if (mounted) setState(() => _isLoading = false);
} }
} }
Future<void> _addItemsToDay() async { Future<void> _addItemsToDay() async {
final user = Supabase.instance.client.auth.currentUser; final user = Supabase.instance.client.auth.currentUser;
if (user == null) return; if (user == null) return;
final allItems = await Supabase.instance.client final allItems = await Supabase.instance.client
.from('items') .from('items')
.select('*, item_images(image_url)') .select('*, item_images(image_url)')
.eq('user_id', user.id); .eq('user_id', user.id);
final available = List<Map<String, dynamic>>.from(allItems); final available = List<Map<String, dynamic>>.from(allItems);
final existingIds = _dayItems.map((i) => i['id']).toSet(); final existingIds = _dayItems.map((i) => i['id']).toSet();
final toShow = available final toShow =
.where((i) => !existingIds.contains(i['id'])) available.where((i) => !existingIds.contains(i['id'])).toList();
.toList();
if (!mounted) return; if (!mounted) return;
final selected = await showModalBottomSheet<List<int>>( final selected = await showModalBottomSheet<List<int>>(
context: context, context: context,
isScrollControlled: true, isScrollControlled: true,
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
builder: (ctx) => _ItemPickerSheet(items: toShow), builder: (_) => _ItemPickerSheet(items: toShow),
); );
if (selected == null || selected.isEmpty) return; if (selected == null || selected.isEmpty) return;
try { try {
final planId = await _getOrCreatePlanId(_selectedDay); final planId = await _getOrCreatePlanId(_selectedDay);
final rows = selected final rows =
.map((id) => {'plan_id': planId, 'item_id': id}) selected.map((id) => {'plan_id': planId, 'item_id': id}).toList();
.toList();
await Supabase.instance.client.from('plan_items').insert(rows); await Supabase.instance.client.from('plan_items').insert(rows);
_loadDayItems(); _loadDayItems();
} catch (e) { } catch (e) {
if (mounted) { if (mounted) AppSnack.error(context, 'Erro: $e');
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Erro: $e'), backgroundColor: Colors.red),
);
}
} }
} }
@@ -166,75 +141,110 @@ class _WeekScreenState extends State<WeekScreen> {
.eq('item_id', item['id']); .eq('item_id', item['id']);
_loadDayItems(); _loadDayItems();
} catch (e) { } catch (e) {
if (mounted) { if (mounted) AppSnack.error(context, 'Erro: $e');
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Erro: $e'), backgroundColor: Colors.red),
);
}
} }
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final start = _startOfWeek; final days = List.generate(7, (i) => _startOfWeek.add(Duration(days: i)));
final days = List.generate(7, (i) => start.add(Duration(days: i)));
return Scaffold( return Scaffold(
backgroundColor: const Color(0xFFFFE5CC), backgroundColor: AppColors.background,
appBar: AppBar( body: SafeArea(
backgroundColor: const Color(0xFF0066CC), bottom: false,
elevation: 0, child: Column(
title: const Text(
'Minha Semana',
style: TextStyle(color: Colors.white, fontSize: 20),
),
centerTitle: true,
),
body: Column(
children: [ children: [
// Week selector _buildHeader(),
Container( _buildDaysRow(days),
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 8), const SizedBox(height: 12),
_buildDayTitle(),
const SizedBox(height: 8),
Expanded(
child: _isLoading
? const Center(child: CircularProgressIndicator())
: _dayItems.isEmpty
? _buildEmpty()
: ListView.builder(
padding: const EdgeInsets.fromLTRB(
20, 0, 20, 120,
),
itemCount: _dayItems.length,
itemBuilder: (_, i) =>
_buildItemTile(_dayItems[i]),
),
),
],
),
),
floatingActionButton: _buildFab(),
);
}
Widget _buildHeader() {
return const Padding(
padding: EdgeInsets.fromLTRB(20, 12, 20, 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Minha Semana', style: AppText.h2),
SizedBox(height: 2),
Text(
'Planeie o que precisa para cada dia',
style: AppText.caption,
),
],
),
);
}
Widget _buildDaysRow(List<DateTime> days) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Row( child: Row(
children: days.map((day) { children: days.map((day) {
final isSelected = final isSelected = day.year == _selectedDay.year &&
day.year == _selectedDay.year &&
day.month == _selectedDay.month && day.month == _selectedDay.month &&
day.day == _selectedDay.day; day.day == _selectedDay.day;
final isToday = final today = DateTime.now();
day.year == DateTime.now().year && final isToday = day.year == today.year &&
day.month == DateTime.now().month && day.month == today.month &&
day.day == DateTime.now().day; day.day == today.day;
return Expanded( return Expanded(
child: GestureDetector( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 3),
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.circular(AppRadius.md),
onTap: () { onTap: () {
setState(() => _selectedDay = day); setState(() => _selectedDay = day);
_loadDayItems(); _loadDayItems();
}, },
child: Container( child: AnimatedContainer(
margin: const EdgeInsets.symmetric(horizontal: 3), duration: const Duration(milliseconds: 200),
padding: const EdgeInsets.symmetric(vertical: 10), padding: const EdgeInsets.symmetric(vertical: 12),
decoration: BoxDecoration( decoration: BoxDecoration(
color: isSelected gradient: isSelected ? AppColors.brandGradient : null,
? const Color(0xFF0066CC) color: isSelected ? null : AppColors.surface,
: Colors.white, borderRadius: BorderRadius.circular(AppRadius.md),
borderRadius: BorderRadius.circular(12),
border: Border.all( border: Border.all(
color: isToday color: isToday && !isSelected
? const Color(0xFF0066CC) ? AppColors.primary
: Colors.transparent, : AppColors.border,
width: 2, width: isToday ? 1.5 : 1,
), ),
boxShadow: isSelected ? AppShadows.brand : null,
), ),
child: Column( child: Column(
children: [ children: [
Text( Text(
_weekdayNames[day.weekday - 1], _weekdayShort[day.weekday - 1],
style: TextStyle( style: TextStyle(
fontSize: 12, fontSize: 11,
fontWeight: FontWeight.w600,
color: isSelected color: isSelected
? Colors.white ? Colors.white
: const Color(0xFF666666), : AppColors.textSecondary,
), ),
), ),
const SizedBox(height: 4), const SizedBox(height: 4),
@@ -245,146 +255,211 @@ class _WeekScreenState extends State<WeekScreen> {
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: isSelected color: isSelected
? Colors.white ? Colors.white
: const Color(0xFF333333), : AppColors.textPrimary,
), ),
), ),
], ],
), ),
), ),
), ),
),
),
); );
}).toList(), }).toList(),
), ),
), );
// Day title }
Padding(
padding: const EdgeInsets.fromLTRB(20, 8, 20, 12), Widget _buildDayTitle() {
return Padding(
padding: const EdgeInsets.fromLTRB(20, 8, 20, 8),
child: Row( child: Row(
children: [ children: [
Text( Text(
'${_weekdayNamesLong[_selectedDay.weekday - 1]}, ' '${_weekdayLong[_selectedDay.weekday - 1]}, '
'${_selectedDay.day}/${_selectedDay.month}', '${_selectedDay.day}/${_selectedDay.month}',
style: const TextStyle( style: AppText.h3,
fontSize: 18,
fontWeight: FontWeight.bold,
color: Color(0xFF333333),
),
), ),
const Spacer(), const Spacer(),
Text( Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
decoration: BoxDecoration(
color: AppColors.primary.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(AppRadius.pill),
),
child: Text(
'${_dayItems.length} ${_dayItems.length == 1 ? "item" : "itens"}', '${_dayItems.length} ${_dayItems.length == 1 ? "item" : "itens"}',
style: const TextStyle( style: const TextStyle(
color: Color(0xFF666666), color: AppColors.primary,
fontSize: 13, fontWeight: FontWeight.w600,
fontSize: 12,
),
), ),
), ),
], ],
), ),
), );
// Items list }
Expanded(
child: _isLoading Widget _buildEmpty() {
? const Center(child: CircularProgressIndicator()) return Center(
: _dayItems.isEmpty
? Center(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Icon( Container(
Icons.calendar_today_outlined, width: 80,
size: 56, height: 80,
color: Colors.grey[400], decoration: BoxDecoration(
color: AppColors.primary.withValues(alpha: 0.1),
shape: BoxShape.circle,
), ),
const SizedBox(height: 12), child: const Icon(
const Text( Icons.event_available_rounded,
'Nenhum item para este dia', color: AppColors.primary,
style: TextStyle( size: 36,
color: Color(0xFF666666),
fontSize: 16,
), ),
), ),
const SizedBox(height: 16),
const Text('Nada planeado', style: AppText.h3),
const SizedBox(height: 4), const SizedBox(height: 4),
const Text( Text(
'Toque em + para adicionar', 'Toque em + para adicionar itens',
style: TextStyle( style: AppText.caption,
color: Color(0xFF999999),
fontSize: 13,
),
), ),
], ],
), ),
)
: ListView.builder(
padding: const EdgeInsets.symmetric(horizontal: 16),
itemCount: _dayItems.length,
itemBuilder: (_, i) => _buildItemTile(_dayItems[i]),
),
),
],
),
floatingActionButton: FloatingActionButton(
backgroundColor: const Color(0xFF0066CC),
onPressed: _addItemsToDay,
child: const Icon(Icons.add, color: Colors.white),
),
); );
} }
Widget _buildItemTile(Map<String, dynamic> item) { Widget _buildItemTile(Map<String, dynamic> item) {
final images = item['item_images'] as List?; final images = item['item_images'] as List?;
final imageUrl = (images != null && images.isNotEmpty) final imageUrl = (images != null && images.isNotEmpty)
? images.first['image_url'] ? images.first['image_url'] as String?
: null; : null;
final category = itemCategories.firstWhere( final cat = categoryById(item['categoria'] as String?);
(c) => c.id == item['categoria'], return Dismissible(
orElse: () => itemCategories.last, key: ValueKey(item['id']),
); direction: DismissDirection.endToStart,
background: Container(
return Card(
margin: const EdgeInsets.only(bottom: 10), margin: const EdgeInsets.only(bottom: 10),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)), padding: const EdgeInsets.symmetric(horizontal: 24),
child: ListTile( alignment: Alignment.centerRight,
contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4), decoration: BoxDecoration(
leading: ClipRRect( color: AppColors.error,
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(AppRadius.lg),
),
child: const Icon(Icons.delete_outline, color: Colors.white),
),
onDismissed: (_) => _removeItem(item),
child: Container(
margin: const EdgeInsets.only(bottom: 10),
decoration: AppDecorations.card(),
clipBehavior: Clip.antiAlias,
child: Padding(
padding: const EdgeInsets.all(10),
child: Row(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(AppRadius.md),
child: Container(
width: 56,
height: 56,
color: cat.color.withValues(alpha: 0.15),
child: imageUrl != null child: imageUrl != null
? Image.network( ? Image.network(
imageUrl, imageUrl,
width: 56,
height: 56,
fit: BoxFit.cover, fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) => errorBuilder: (_, __, ___) =>
_icon(category.icon), Icon(cat.icon, color: cat.color, size: 24),
) )
: _icon(category.icon), : Icon(cat.icon, color: cat.color, size: 24),
), ),
title: Text(
item['nome'] ?? 'Sem nome',
style: const TextStyle(fontWeight: FontWeight.bold),
), ),
subtitle: Text(category.name), const SizedBox(width: 12),
trailing: IconButton( Expanded(
icon: const Icon(Icons.close, color: Colors.red), child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
item['nome'] ?? '',
style: const TextStyle(
fontWeight: FontWeight.w600,
fontSize: 15,
color: AppColors.textPrimary,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 4),
Row(
children: [
Icon(cat.icon, size: 12, color: cat.color),
const SizedBox(width: 4),
Text(
cat.name,
style: TextStyle(
fontSize: 12,
color: cat.color,
fontWeight: FontWeight.w600,
),
),
],
),
],
),
),
IconButton(
icon: const Icon(
Icons.close_rounded,
color: AppColors.textTertiary,
),
onPressed: () => _removeItem(item), onPressed: () => _removeItem(item),
), ),
],
),
),
), ),
); );
} }
Widget _icon(String icon) { Widget _buildFab() {
return Container( return Container(
width: 56, decoration: BoxDecoration(
height: 56, gradient: AppColors.brandGradient,
color: const Color(0xFF0066CC).withValues(alpha: 0.1), borderRadius: BorderRadius.circular(AppRadius.lg),
alignment: Alignment.center, boxShadow: AppShadows.brand,
child: Text(icon, style: const TextStyle(fontSize: 26)), ),
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.circular(AppRadius.lg),
onTap: _addItemsToDay,
child: const Padding(
padding: EdgeInsets.symmetric(horizontal: 18, vertical: 14),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.add_rounded, color: Colors.white),
SizedBox(width: 6),
Text(
'Adicionar',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
),
),
],
),
),
),
),
); );
} }
} }
// ============================================= // ============================================================
// Bottom sheet para escolher itens // Item picker bottom sheet
// ============================================= // ============================================================
class _ItemPickerSheet extends StatefulWidget { class _ItemPickerSheet extends StatefulWidget {
final List<Map<String, dynamic>> items; final List<Map<String, dynamic>> items;
const _ItemPickerSheet({required this.items}); const _ItemPickerSheet({required this.items});
@@ -401,9 +476,10 @@ class _ItemPickerSheetState extends State<_ItemPickerSheet> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final filtered = widget.items final filtered = widget.items
.where( .where(
(i) => (i['nome'] ?? '').toString().toLowerCase().contains( (i) => (i['nome'] ?? '')
_query.toLowerCase(), .toString()
), .toLowerCase()
.contains(_query.toLowerCase()),
) )
.toList(); .toList();
@@ -414,132 +490,74 @@ class _ItemPickerSheetState extends State<_ItemPickerSheet> {
expand: false, expand: false,
builder: (_, scrollController) => Container( builder: (_, scrollController) => Container(
decoration: const BoxDecoration( decoration: const BoxDecoration(
color: Color(0xFFFFE5CC), color: AppColors.background,
borderRadius: BorderRadius.vertical(top: Radius.circular(20)), borderRadius: BorderRadius.vertical(top: Radius.circular(24)),
), ),
child: Column( child: Column(
children: [ children: [
Container( Container(
margin: const EdgeInsets.symmetric(vertical: 8), margin: const EdgeInsets.symmetric(vertical: 10),
width: 40, width: 42,
height: 4, height: 4,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.grey[400], color: AppColors.border,
borderRadius: BorderRadius.circular(2), borderRadius: BorderRadius.circular(2),
), ),
), ),
const Padding( const Padding(
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 4), padding: EdgeInsets.symmetric(horizontal: 20, vertical: 4),
child: Text( child: Align(
'Adicionar itens ao dia', alignment: Alignment.centerLeft,
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), child: Text('Adicionar itens ao dia', style: AppText.h3),
), ),
), ),
Padding( Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), padding: const EdgeInsets.fromLTRB(20, 12, 20, 8),
child: Container( child: Container(
decoration: BoxDecoration( decoration: AppDecorations.outlined(radius: AppRadius.pill),
color: Colors.white,
borderRadius: BorderRadius.circular(14),
),
child: TextField( child: TextField(
onChanged: (v) => setState(() => _query = v), onChanged: (v) => setState(() => _query = v),
decoration: const InputDecoration( decoration: const InputDecoration(
prefixIcon: Icon(Icons.search), prefixIcon: Icon(
Icons.search_rounded,
color: AppColors.textSecondary,
),
hintText: 'Pesquisar...', hintText: 'Pesquisar...',
border: InputBorder.none, border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(vertical: 12), contentPadding: EdgeInsets.symmetric(vertical: 14),
), ),
), ),
), ),
), ),
Expanded( Expanded(
child: filtered.isEmpty child: filtered.isEmpty
? const Center(child: Text('Nenhum item disponível')) ? Center(
: ListView.builder( child: Text(
controller: scrollController, 'Sem itens disponíveis',
itemCount: filtered.length, style: AppText.caption,
itemBuilder: (_, i) {
final item = filtered[i];
final id = item['id'] as int;
final selected = _selected.contains(id);
final images = item['item_images'] as List?;
final imageUrl = (images != null && images.isNotEmpty)
? images.first['image_url']
: null;
final category = itemCategories.firstWhere(
(c) => c.id == item['categoria'],
orElse: () => itemCategories.last,
);
return CheckboxListTile(
value: selected,
activeColor: const Color(0xFF0066CC),
onChanged: (v) {
setState(() {
if (v == true) {
_selected.add(id);
} else {
_selected.remove(id);
}
});
},
title: Text(item['nome'] ?? ''),
subtitle: Text(category.name),
secondary: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: imageUrl != null
? Image.network(
imageUrl,
width: 48,
height: 48,
fit: BoxFit.cover,
errorBuilder:
(context, error, stackTrace) =>
Container(
width: 48,
height: 48,
color: const Color(
0xFF0066CC,
).withValues(alpha: 0.1),
alignment: Alignment.center,
child: Text(category.icon),
), ),
) )
: Container( : ListView.builder(
width: 48, controller: scrollController,
height: 48, padding: const EdgeInsets.fromLTRB(20, 4, 20, 12),
color: const Color( itemCount: filtered.length,
0xFF0066CC, itemBuilder: (_, i) =>
).withValues(alpha: 0.1), _buildPickerTile(filtered[i]),
alignment: Alignment.center,
child: Text(category.icon),
),
),
);
},
), ),
), ),
SafeArea( SafeArea(
top: false,
child: Padding( child: Padding(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(20),
child: SizedBox( child: AppButton(
width: double.infinity, label: _selected.isEmpty
height: 50, ? 'Selecione itens'
child: ElevatedButton( : 'Adicionar (${_selected.length})',
icon: Icons.check_rounded,
onPressed: _selected.isEmpty onPressed: _selected.isEmpty
? null ? null
: () => Navigator.pop(context, _selected.toList()), : () =>
style: ElevatedButton.styleFrom( Navigator.pop(context, _selected.toList()),
backgroundColor: const Color(0xFF0066CC),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
),
child: Text(
'Adicionar (${_selected.length})',
style: const TextStyle(color: Colors.white, fontSize: 16),
),
),
), ),
), ),
), ),
@@ -548,4 +566,113 @@ class _ItemPickerSheetState extends State<_ItemPickerSheet> {
), ),
); );
} }
Widget _buildPickerTile(Map<String, dynamic> item) {
final id = item['id'] as int;
final selected = _selected.contains(id);
final images = item['item_images'] as List?;
final imageUrl = (images != null && images.isNotEmpty)
? images.first['image_url'] as String?
: null;
final cat = categoryById(item['categoria'] as String?);
return Container(
margin: const EdgeInsets.only(bottom: 8),
decoration: BoxDecoration(
color: AppColors.surface,
borderRadius: BorderRadius.circular(AppRadius.md),
border: Border.all(
color: selected ? AppColors.primary : AppColors.border,
width: selected ? 1.5 : 1,
),
),
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.circular(AppRadius.md),
onTap: () {
setState(() {
if (selected) {
_selected.remove(id);
} else {
_selected.add(id);
}
});
},
child: Padding(
padding: const EdgeInsets.all(10),
child: Row(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(AppRadius.sm),
child: Container(
width: 48,
height: 48,
color: cat.color.withValues(alpha: 0.15),
child: imageUrl != null
? Image.network(
imageUrl,
fit: BoxFit.cover,
errorBuilder: (_, __, ___) =>
Icon(cat.icon, color: cat.color, size: 22),
)
: Icon(cat.icon, color: cat.color, size: 22),
),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
item['nome'] ?? '',
style: const TextStyle(
fontWeight: FontWeight.w600,
color: AppColors.textPrimary,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 2),
Text(
cat.name,
style: TextStyle(
fontSize: 12,
color: cat.color,
fontWeight: FontWeight.w600,
),
),
],
),
),
AnimatedContainer(
duration: const Duration(milliseconds: 180),
width: 24,
height: 24,
decoration: BoxDecoration(
color: selected
? AppColors.primary
: Colors.transparent,
shape: BoxShape.circle,
border: Border.all(
color: selected
? AppColors.primary
: AppColors.border,
width: 2,
),
),
child: selected
? const Icon(
Icons.check_rounded,
color: Colors.white,
size: 16,
)
: null,
),
],
),
),
),
),
);
}
} }

View File

@@ -1,14 +1,18 @@
import 'package:flutter/material.dart';
class ItemCategory { class ItemCategory {
final String id; final String id;
final String name; final String name;
final String icon; final IconData icon;
final Color color;
final String description; final String description;
final List<Subcategory> subcategories; final List<Subcategory> subcategories;
ItemCategory({ const ItemCategory({
required this.id, required this.id,
required this.name, required this.name,
required this.icon, required this.icon,
required this.color,
required this.description, required this.description,
required this.subcategories, required this.subcategories,
}); });
@@ -17,9 +21,13 @@ class ItemCategory {
class Subcategory { class Subcategory {
final String id; final String id;
final String name; final String name;
final String examples; final String description;
Subcategory({required this.id, required this.name, required this.examples}); const Subcategory({
required this.id,
required this.name,
required this.description,
});
} }
class ContextTag { class ContextTag {
@@ -28,7 +36,7 @@ class ContextTag {
final String description; final String description;
final String examples; final String examples;
ContextTag({ const ContextTag({
required this.id, required this.id,
required this.name, required this.name,
required this.description, required this.description,
@@ -36,174 +44,188 @@ class ContextTag {
}); });
} }
// Categorias principais // Lista de categorias principais
final List<ItemCategory> itemCategories = [ final List<ItemCategory> itemCategories = [
ItemCategory( ItemCategory(
id: 'clothing', id: 'clothing',
name: 'Roupa', name: 'Roupa',
icon: '👕', icon: Icons.checkroom_rounded,
color: const Color(0xFFEC4899),
description: 'Peças de vestuário', description: 'Peças de vestuário',
subcategories: [ subcategories: [
Subcategory(
id: 'casual',
name: 'Casual',
examples: 't-shirts, calças de ganga, hoodies',
),
Subcategory( Subcategory(
id: 'formal', id: 'formal',
name: 'Formal', name: 'Formal',
examples: 'fatos, camisas, vestidos de cerimónia', description: 'fato, camisa, blazer, vestido',
),
Subcategory(
id: 'casual',
name: 'Casual',
description: 't-shirt, jeans, hoodie',
), ),
Subcategory( Subcategory(
id: 'sportswear', id: 'sportswear',
name: 'Sportswear', name: 'Sportswear',
examples: 'leggings, tops de treino, shorts', description: 'leggings, calções, top desportivo',
), ),
Subcategory( Subcategory(
id: 'outerwear', id: 'outerwear',
name: 'Outerwear', name: 'Outerwear',
examples: 'casacos, impermeáveis, parkas', description: 'casaco, blusão, sobretudo',
), ),
Subcategory( Subcategory(
id: 'underwear', id: 'underwear',
name: 'Underwear', name: 'Underwear',
examples: 'roupa interior, meias', description: 'cuecas, meias, sutiãs',
), ),
Subcategory( Subcategory(
id: 'sleepwear', id: 'sleepwear',
name: 'Sleepwear', name: 'Sleepwear',
examples: 'pijamas, roupões', description: 'pijamas, roupões',
), ),
], ],
), ),
ItemCategory( ItemCategory(
id: 'electronics', id: 'electronics',
name: 'Eletrónica', name: 'Eletrónica',
icon: '💻', icon: Icons.devices_other_rounded,
color: const Color(0xFF8B5CF6),
description: 'Dispositivos e acessórios tecnológicos', description: 'Dispositivos e acessórios tecnológicos',
subcategories: [ subcategories: [
Subcategory( Subcategory(
id: 'computers', id: 'computers',
name: 'Computers', name: 'Computadores',
examples: 'portáteis, tablets', description: 'portátil, tablet',
), ),
Subcategory( Subcategory(
id: 'phones', id: 'phones',
name: 'Phones', name: 'Telemóveis',
examples: 'smartphones, earphones', description: 'smartphone, smartwatch',
), ),
Subcategory( Subcategory(
id: 'cameras', id: 'audio',
name: 'Cameras', name: 'Áudio',
examples: 'máquinas fotográficas, action cams', description: 'auscultadores, colunas',
), ),
Subcategory( Subcategory(
id: 'cables', id: 'cables',
name: 'Cables', name: 'Cabos e Carregadores',
examples: 'carregadores, cabos USB, adaptadores', description: 'USB, power bank',
),
Subcategory(
id: 'cameras',
name: 'Câmaras',
description: 'fotográfica, GoPro, drone',
), ),
Subcategory( Subcategory(
id: 'gaming', id: 'gaming',
name: 'Gaming', name: 'Gaming',
examples: 'consolas, comandos, jogos', description: 'consola, comandos',
),
Subcategory(
id: 'audio',
name: 'Audio',
examples: 'headphones, colunas bluetooth',
), ),
], ],
), ),
ItemCategory( ItemCategory(
id: 'footwear', id: 'footwear',
name: 'Calçado', name: 'Calçado',
icon: '👟', icon: Icons.hiking_rounded,
color: const Color(0xFFF59E0B),
description: 'Sapatos, botas, sandálias', description: 'Sapatos, botas, sandálias',
subcategories: [ subcategories: [
Subcategory(
id: 'casual',
name: 'Casual',
examples: 'sapatilhas, loafers',
),
Subcategory( Subcategory(
id: 'formal', id: 'formal',
name: 'Formal', name: 'Formal',
examples: 'sapatos de salto, mocassins', description: 'sapatos de vestir',
),
Subcategory(
id: 'casual',
name: 'Casual',
description: 'sapatilhas do dia-a-dia',
), ),
Subcategory( Subcategory(
id: 'sport', id: 'sport',
name: 'Sport', name: 'Desporto',
examples: 'ténis de corrida, chuteiras', description: 'ténis de corrida, futebol',
), ),
Subcategory( Subcategory(
id: 'outdoor', id: 'outdoor',
name: 'Outdoor', name: 'Outdoor',
examples: 'botas de caminhada, sandálias', description: 'botas de montanha',
),
Subcategory(
id: 'sandals',
name: 'Sandálias',
description: 'chinelos, sandálias',
), ),
], ],
), ),
ItemCategory( ItemCategory(
id: 'accessories', id: 'accessories',
name: 'Acessórios', name: 'Acessórios',
icon: '🎒', icon: Icons.work_outline_rounded,
color: const Color(0xFF10B981),
description: 'Bolsas, relógios, óculos, bijuteria', description: 'Bolsas, relógios, óculos, bijuteria',
subcategories: [ subcategories: [
Subcategory( Subcategory(
id: 'bags', id: 'bags',
name: 'Bags', name: 'Malas e Bolsas',
examples: 'mochilas, malas, bolsas', description: 'mochila, mala, carteira',
), ),
Subcategory( Subcategory(
id: 'watches', id: 'watches',
name: 'Watches', name: 'Relógios',
examples: 'relógios analógicos e digitais', description: 'relógios analógicos e digitais',
),
Subcategory(
id: 'eyewear',
name: 'Eyewear',
examples: 'óculos de sol, óculos de grau',
), ),
Subcategory( Subcategory(
id: 'jewelry', id: 'jewelry',
name: 'Jewelry', name: 'Joias e Bijuteria',
examples: 'colares, pulseiras, brincos', description: 'colares, anéis, brincos',
),
Subcategory(
id: 'eyewear',
name: 'Óculos',
description: 'óculos de sol, graduados',
),
Subcategory(
id: 'hats',
name: 'Chapéus',
description: 'bonés, chapéus, gorros',
), ),
Subcategory(id: 'hats', name: 'Hats', examples: 'bonés, chapéus, gorros'),
Subcategory(id: 'belts', name: 'Belts', examples: 'cintos'),
], ],
), ),
ItemCategory( ItemCategory(
id: 'documents', id: 'documents',
name: 'Documentos', name: 'Documentos',
icon: '📄', icon: Icons.description_rounded,
color: const Color(0xFFEF4444),
description: 'Passaporte, cartões, papéis importantes', description: 'Passaporte, cartões, papéis importantes',
subcategories: [ subcategories: [
Subcategory( Subcategory(
id: 'identity', id: 'identity',
name: 'Identity', name: 'Identidade',
examples: 'passaporte, BI, carta de condução', description: 'cartão de cidadão, carta de condução',
),
Subcategory(
id: 'health',
name: 'Health',
examples: 'cartão de saúde, receitas',
), ),
Subcategory( Subcategory(
id: 'travel', id: 'travel',
name: 'Travel', name: 'Viagem',
examples: 'bilhetes, reservas, seguros', description: 'passaporte, visto',
), ),
Subcategory( Subcategory(
id: 'financial', id: 'cards',
name: 'Financial', name: 'Cartões',
examples: 'cartões de crédito/débito', description: 'crédito, débito, fidelização',
),
Subcategory(
id: 'health',
name: 'Saúde',
description: 'cartão de saúde, receitas',
), ),
], ],
), ),
ItemCategory( ItemCategory(
id: 'other', id: 'other',
name: 'Outros', name: 'Outros',
icon: '📦', icon: Icons.inventory_2_rounded,
color: const Color(0xFF64748B),
description: 'Tudo o resto', description: 'Tudo o resto',
subcategories: [], subcategories: [],
), ),
@@ -291,3 +313,12 @@ List<String> getAutoContextTags(String categoryId, String subcategoryId) {
return autoTags[key] ?? []; return autoTags[key] ?? [];
} }
/// Helper to fetch a category by id, falling back to "Outros".
ItemCategory categoryById(String? id) {
if (id == null) return itemCategories.last;
return itemCategories.firstWhere(
(c) => c.id == id,
orElse: () => itemCategories.last,
);
}

View File

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:supabase_flutter/supabase_flutter.dart'; import 'package:supabase_flutter/supabase_flutter.dart';
import '../Screens/home_screen.dart'; import '../Screens/home_screen.dart';
import '../theme/app_theme.dart';
class LoginScreen extends StatefulWidget { class LoginScreen extends StatefulWidget {
const LoginScreen({super.key}); const LoginScreen({super.key});
@@ -9,364 +10,15 @@ class LoginScreen extends StatefulWidget {
State<LoginScreen> createState() => _LoginScreenState(); State<LoginScreen> createState() => _LoginScreenState();
} }
class _LoginScreenState extends State<LoginScreen> { class _LoginScreenState extends State<LoginScreen>
bool isLoginSelected = true; with SingleTickerProviderStateMixin {
bool _isLogin = true;
bool _isLoading = false; bool _isLoading = false;
final TextEditingController _usernameController = TextEditingController(); bool _obscurePassword = true;
final TextEditingController _emailController = TextEditingController();
final TextEditingController _passwordController = TextEditingController();
@override final _usernameController = TextEditingController();
Widget build(BuildContext context) { final _emailController = TextEditingController();
return Scaffold( final _passwordController = TextEditingController();
backgroundColor: const Color(0xFFFFE5CC), // Light orange background
appBar: AppBar(
backgroundColor: const Color(0xFF0066CC), // Blue app bar
elevation: 0,
toolbarHeight: 0, // Remove default app bar height
),
body: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(height: 40),
// Logo
Image.asset(
'assets/logoDayMaker.png',
width: 220,
height: 220,
fit: BoxFit.contain,
),
const SizedBox(height: 24),
// App title and subtitle
const Text(
'DayMaker',
style: TextStyle(
fontSize: 32,
fontWeight: FontWeight.bold,
color: Color(0xFF0066CC),
),
),
const SizedBox(height: 8),
const Text(
'Organize sua rotina com inteligência',
style: TextStyle(fontSize: 16, color: Color(0xFF666666)),
textAlign: TextAlign.center,
),
const SizedBox(height: 40),
// Toggle buttons for Login/Create Account
Row(
children: [
Expanded(
child: GestureDetector(
onTap: () => setState(() => isLoginSelected = true),
child: Container(
padding: const EdgeInsets.symmetric(vertical: 12),
decoration: BoxDecoration(
color: isLoginSelected
? const Color(0xFF0066CC)
: Colors.transparent,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(20),
bottomLeft: Radius.circular(20),
),
border: Border.all(
color: const Color(0xFF0066CC),
width: 2,
),
),
child: Text(
'Entrar',
textAlign: TextAlign.center,
style: TextStyle(
color: isLoginSelected
? Colors.white
: const Color(0xFF0066CC),
fontWeight: FontWeight.w600,
fontSize: 16,
),
),
),
),
),
Expanded(
child: GestureDetector(
onTap: () => setState(() => isLoginSelected = false),
child: Container(
padding: const EdgeInsets.symmetric(vertical: 12),
decoration: BoxDecoration(
color: !isLoginSelected
? const Color(0xFF0066CC)
: Colors.transparent,
borderRadius: const BorderRadius.only(
topRight: Radius.circular(20),
bottomRight: Radius.circular(20),
),
border: Border.all(
color: const Color(0xFF0066CC),
width: 2,
),
),
child: Text(
'Criar Conta',
textAlign: TextAlign.center,
style: TextStyle(
color: !isLoginSelected
? Colors.white
: const Color(0xFF0066CC),
fontWeight: FontWeight.w600,
fontSize: 16,
),
),
),
),
),
],
),
const SizedBox(height: 32),
// Email field
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(24),
border: Border.all(color: const Color(0xFFE0E0E0)),
),
child: TextField(
controller: _emailController,
keyboardType: TextInputType.emailAddress,
decoration: const InputDecoration(
prefixIcon: Icon(Icons.email, color: Color(0xFF666666)),
hintText: 'Digite seu email',
hintStyle: TextStyle(color: Color(0xFF999999)),
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(
horizontal: 16,
vertical: 16,
),
),
),
),
const SizedBox(height: 16),
// Username field (only shown when Criar Conta is selected)
if (!isLoginSelected)
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(24),
border: Border.all(color: const Color(0xFFE0E0E0)),
),
child: TextField(
controller: _usernameController,
decoration: const InputDecoration(
prefixIcon: Icon(Icons.person, color: Color(0xFF666666)),
hintText: 'Digite seu nome',
hintStyle: TextStyle(color: Color(0xFF999999)),
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(
horizontal: 16,
vertical: 16,
),
),
),
),
if (!isLoginSelected) const SizedBox(height: 16),
// Password field
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(24),
border: Border.all(color: const Color(0xFFE0E0E0)),
),
child: TextField(
controller: _passwordController,
obscureText: true,
decoration: const InputDecoration(
prefixIcon: Icon(Icons.lock, color: Color(0xFF666666)),
hintText: 'Digite sua senha',
hintStyle: TextStyle(color: Color(0xFF999999)),
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(
horizontal: 16,
vertical: 16,
),
),
),
),
const SizedBox(height: 32),
// Login/Create Account button
SizedBox(
width: double.infinity,
height: 56,
child: ElevatedButton(
onPressed: _isLoading
? null
: () async {
if (isLoginSelected) {
await _handleLogin();
} else {
await _handleSignUp();
}
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF0066CC),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(42),
),
elevation: 0,
),
child: _isLoading
? const SizedBox(
height: 20,
width: 20,
child: CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(
Colors.white,
),
),
)
: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
isLoginSelected ? 'Entrar' : 'Criar Conta',
style: const TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.w600,
),
),
const SizedBox(width: 8),
const Icon(
Icons.arrow_forward,
color: Colors.white,
size: 20,
),
],
),
),
),
const Spacer(),
// Version text
const Text(
'Versão 1.0.0',
style: TextStyle(color: Color(0xFF666666), fontSize: 14),
),
const SizedBox(height: 16),
],
),
),
),
);
}
Future<void> _handleLogin() async {
final email = _emailController.text.trim();
final password = _passwordController.text.trim();
if (email.isEmpty || password.isEmpty) {
_showErrorSnackBar('Por favor, preencha todos os campos');
return;
}
setState(() => _isLoading = true);
try {
final response = await Supabase.instance.client.auth.signInWithPassword(
email: email,
password: password,
);
if (response.user != null) {
if (mounted) {
Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (_) => const HomeScreen()),
);
}
}
} on AuthException catch (e) {
_showErrorSnackBar('Erro de login: ${e.message}');
} catch (e) {
_showErrorSnackBar('Erro ao fazer login: $e');
} finally {
if (mounted) {
setState(() => _isLoading = false);
}
}
}
Future<void> _handleSignUp() async {
final email = _emailController.text.trim();
final username = _usernameController.text.trim();
final password = _passwordController.text.trim();
if (email.isEmpty || username.isEmpty || password.isEmpty) {
_showErrorSnackBar('Por favor, preencha todos os campos');
return;
}
setState(() => _isLoading = true);
try {
final response = await Supabase.instance.client.auth.signUp(
email: email,
password: password,
data: {'username': username},
);
if (response.user != null) {
// Save user data to users table
await Supabase.instance.client.from('users').insert({
'id': response.user!.id,
'nome': username,
'email': email,
});
_showSuccessSnackBar('Conta criada com sucesso!');
setState(() => isLoginSelected = true);
}
} on AuthException catch (e) {
_showErrorSnackBar('Erro ao criar conta: ${e.message}');
} catch (e) {
_showErrorSnackBar('Erro ao criar conta: $e');
} finally {
if (mounted) {
setState(() => _isLoading = false);
}
}
}
void _showErrorSnackBar(String message) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(message), backgroundColor: Colors.red),
);
}
void _showSuccessSnackBar(String message) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(message), backgroundColor: Colors.green),
);
}
@override @override
void dispose() { void dispose() {
@@ -375,4 +27,277 @@ class _LoginScreenState extends State<LoginScreen> {
_passwordController.dispose(); _passwordController.dispose();
super.dispose(); super.dispose();
} }
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.background,
body: SafeArea(
child: SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: MediaQuery.of(context).size.height -
MediaQuery.of(context).padding.top -
MediaQuery.of(context).padding.bottom,
),
child: IntrinsicHeight(
child: Column(
children: [
const SizedBox(height: 40),
_buildBrandHeader(),
const SizedBox(height: 32),
_buildModeToggle(),
const SizedBox(height: 28),
_buildForm(),
const SizedBox(height: 24),
_buildSubmitButton(),
const Spacer(),
Padding(
padding: const EdgeInsets.only(top: 24, bottom: 8),
child: Text(
'Versão 1.0.0',
style: AppText.caption,
),
),
],
),
),
),
),
),
);
}
Widget _buildBrandHeader() {
return Column(
children: [
Container(
width: 84,
height: 84,
decoration: BoxDecoration(
gradient: AppColors.brandGradient,
borderRadius: BorderRadius.circular(24),
boxShadow: AppShadows.brand,
),
child: const Icon(
Icons.auto_awesome_rounded,
color: Colors.white,
size: 42,
),
),
const SizedBox(height: 18),
const Text('DayMaker', style: AppText.h1),
const SizedBox(height: 6),
Text(
'Organize a sua rotina com inteligência',
style: AppText.bodySecondary,
textAlign: TextAlign.center,
),
],
);
}
Widget _buildModeToggle() {
return Container(
decoration: BoxDecoration(
color: AppColors.surfaceAlt,
borderRadius: BorderRadius.circular(AppRadius.pill),
),
padding: const EdgeInsets.all(4),
child: Row(
children: [
_toggleButton('Entrar', _isLogin, () {
setState(() => _isLogin = true);
}),
_toggleButton('Criar Conta', !_isLogin, () {
setState(() => _isLogin = false);
}),
],
),
);
}
Widget _toggleButton(String label, bool selected, VoidCallback onTap) {
return Expanded(
child: AnimatedContainer(
duration: const Duration(milliseconds: 200),
curve: Curves.easeOut,
decoration: BoxDecoration(
color: selected ? AppColors.surface : Colors.transparent,
borderRadius: BorderRadius.circular(AppRadius.pill),
boxShadow: selected ? AppShadows.soft : null,
),
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.circular(AppRadius.pill),
onTap: onTap,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 12),
child: Center(
child: Text(
label,
style: TextStyle(
fontWeight: FontWeight.w600,
color: selected
? AppColors.primary
: AppColors.textSecondary,
),
),
),
),
),
),
),
);
}
Widget _buildForm() {
return Column(
children: [
_inputField(
controller: _emailController,
icon: Icons.email_outlined,
hint: 'Insira o seu email',
keyboard: TextInputType.emailAddress,
),
AnimatedSize(
duration: const Duration(milliseconds: 250),
curve: Curves.easeOut,
child: !_isLogin
? Padding(
padding: const EdgeInsets.only(top: 12),
child: _inputField(
controller: _usernameController,
icon: Icons.person_outline,
hint: 'Insira o seu nome',
),
)
: const SizedBox.shrink(),
),
const SizedBox(height: 12),
_inputField(
controller: _passwordController,
icon: Icons.lock_outline_rounded,
hint: 'Insira a sua palavra-passe',
obscure: _obscurePassword,
trailing: IconButton(
onPressed: () =>
setState(() => _obscurePassword = !_obscurePassword),
icon: Icon(
_obscurePassword
? Icons.visibility_off_outlined
: Icons.visibility_outlined,
color: AppColors.textSecondary,
),
),
),
],
);
}
Widget _inputField({
required TextEditingController controller,
required IconData icon,
required String hint,
TextInputType? keyboard,
bool obscure = false,
Widget? trailing,
}) {
return Container(
decoration: AppDecorations.outlined(),
child: TextField(
controller: controller,
keyboardType: keyboard,
obscureText: obscure,
style: AppText.body,
decoration: InputDecoration(
prefixIcon: Icon(icon, color: AppColors.textSecondary),
suffixIcon: trailing,
hintText: hint,
hintStyle: TextStyle(color: AppColors.textTertiary),
border: InputBorder.none,
contentPadding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 16,
),
),
),
);
}
Widget _buildSubmitButton() {
return AppButton(
label: _isLogin ? 'Entrar' : 'Criar Conta',
icon: Icons.arrow_forward_rounded,
loading: _isLoading,
onPressed: () => _isLogin ? _handleLogin() : _handleSignUp(),
);
}
Future<void> _handleLogin() async {
final email = _emailController.text.trim();
final password = _passwordController.text.trim();
if (email.isEmpty || password.isEmpty) {
AppSnack.error(context, 'Por favor, preencha todos os campos');
return;
}
setState(() => _isLoading = true);
try {
final response =
await Supabase.instance.client.auth.signInWithPassword(
email: email,
password: password,
);
if (response.user != null && mounted) {
Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (_) => const HomeScreen()),
);
}
} on AuthException catch (e) {
if (mounted) AppSnack.error(context, 'Erro de login: ${e.message}');
} catch (e) {
if (mounted) AppSnack.error(context, 'Erro: $e');
} finally {
if (mounted) setState(() => _isLoading = false);
}
}
Future<void> _handleSignUp() async {
final email = _emailController.text.trim();
final username = _usernameController.text.trim();
final password = _passwordController.text.trim();
if (email.isEmpty || username.isEmpty || password.isEmpty) {
AppSnack.error(context, 'Por favor, preencha todos os campos');
return;
}
setState(() => _isLoading = true);
try {
final response = await Supabase.instance.client.auth.signUp(
email: email,
password: password,
data: {'username': username},
);
if (response.user != null) {
await Supabase.instance.client.from('users').insert({
'id': response.user!.id,
'nome': username,
'email': email,
});
if (mounted) {
AppSnack.success(context, 'Conta criada com sucesso!');
setState(() => _isLogin = true);
}
}
} on AuthException catch (e) {
if (mounted) {
AppSnack.error(context, 'Erro ao criar conta: ${e.message}');
}
} catch (e) {
if (mounted) AppSnack.error(context, 'Erro: $e');
} finally {
if (mounted) setState(() => _isLoading = false);
}
}
} }

369
lib/theme/app_theme.dart Normal file
View File

@@ -0,0 +1,369 @@
import 'package:flutter/material.dart';
/// Design tokens for DayMaker — a single source of truth for the new look.
class AppColors {
// Brand
static const Color primary = Color(0xFF2563EB); // refined modern blue
static const Color primaryDark = Color(0xFF1D4ED8);
static const Color primaryLight = Color(0xFF60A5FA);
static const Color accent = Color(0xFFFB923C); // warm orange accent (legacy peach reborn)
// Neutrals
static const Color background = Color(0xFFF7F8FB);
static const Color surface = Colors.white;
static const Color surfaceAlt = Color(0xFFF1F5F9);
static const Color border = Color(0xFFE2E8F0);
static const Color divider = Color(0xFFEDF2F7);
// Text
static const Color textPrimary = Color(0xFF0F172A);
static const Color textSecondary = Color(0xFF64748B);
static const Color textTertiary = Color(0xFF94A3B8);
static const Color textOnPrimary = Colors.white;
// Status
static const Color success = Color(0xFF10B981);
static const Color error = Color(0xFFEF4444);
static const Color warning = Color(0xFFF59E0B);
// Gradients
static const LinearGradient brandGradient = LinearGradient(
colors: [Color(0xFF2563EB), Color(0xFF60A5FA)],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
);
static const LinearGradient warmGradient = LinearGradient(
colors: [Color(0xFFFB923C), Color(0xFFF472B6)],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
);
}
class AppRadius {
static const double sm = 8;
static const double md = 12;
static const double lg = 16;
static const double xl = 20;
static const double pill = 999;
}
class AppSpacing {
static const double xs = 4;
static const double sm = 8;
static const double md = 12;
static const double lg = 16;
static const double xl = 20;
static const double xxl = 24;
static const double huge = 32;
}
class AppShadows {
static List<BoxShadow> soft = [
BoxShadow(
color: Colors.black.withValues(alpha: 0.04),
blurRadius: 12,
offset: const Offset(0, 4),
),
];
static List<BoxShadow> medium = [
BoxShadow(
color: Colors.black.withValues(alpha: 0.06),
blurRadius: 20,
offset: const Offset(0, 8),
),
];
static List<BoxShadow> brand = [
BoxShadow(
color: AppColors.primary.withValues(alpha: 0.25),
blurRadius: 16,
offset: const Offset(0, 8),
),
];
}
class AppText {
static const TextStyle h1 = TextStyle(
fontSize: 28,
fontWeight: FontWeight.bold,
color: AppColors.textPrimary,
height: 1.2,
);
static const TextStyle h2 = TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
color: AppColors.textPrimary,
height: 1.25,
);
static const TextStyle h3 = TextStyle(
fontSize: 18,
fontWeight: FontWeight.w700,
color: AppColors.textPrimary,
height: 1.3,
);
static const TextStyle body = TextStyle(
fontSize: 15,
color: AppColors.textPrimary,
height: 1.4,
);
static const TextStyle bodySecondary = TextStyle(
fontSize: 14,
color: AppColors.textSecondary,
height: 1.4,
);
static const TextStyle caption = TextStyle(
fontSize: 12,
color: AppColors.textTertiary,
height: 1.3,
);
static const TextStyle button = TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Colors.white,
letterSpacing: 0.2,
);
static const TextStyle label = TextStyle(
fontSize: 13,
fontWeight: FontWeight.w600,
color: AppColors.textSecondary,
letterSpacing: 0.3,
);
}
/// Shared decorations for cards and surfaces.
class AppDecorations {
static BoxDecoration card({Color? color, double radius = AppRadius.lg}) =>
BoxDecoration(
color: color ?? AppColors.surface,
borderRadius: BorderRadius.circular(radius),
boxShadow: AppShadows.soft,
);
static BoxDecoration outlined({double radius = AppRadius.lg}) =>
BoxDecoration(
color: AppColors.surface,
borderRadius: BorderRadius.circular(radius),
border: Border.all(color: AppColors.border),
);
static BoxDecoration filled({Color? color, double radius = AppRadius.md}) =>
BoxDecoration(
color: color ?? AppColors.surfaceAlt,
borderRadius: BorderRadius.circular(radius),
);
}
/// Reusable widgets.
class AppButton extends StatelessWidget {
final String label;
final IconData? icon;
final VoidCallback? onPressed;
final bool loading;
final bool secondary;
final bool danger;
final double height;
const AppButton({
super.key,
required this.label,
this.icon,
this.onPressed,
this.loading = false,
this.secondary = false,
this.danger = false,
this.height = 54,
});
@override
Widget build(BuildContext context) {
final disabled = onPressed == null || loading;
final bg = danger
? AppColors.error
: secondary
? AppColors.surface
: AppColors.primary;
final fg = secondary ? AppColors.primary : Colors.white;
return SizedBox(
width: double.infinity,
height: height,
child: AnimatedOpacity(
opacity: disabled && !loading ? 0.5 : 1,
duration: const Duration(milliseconds: 150),
child: Material(
color: bg,
borderRadius: BorderRadius.circular(AppRadius.lg),
elevation: secondary ? 0 : 0,
child: InkWell(
onTap: disabled ? null : onPressed,
borderRadius: BorderRadius.circular(AppRadius.lg),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(AppRadius.lg),
border: secondary
? Border.all(color: AppColors.primary, width: 1.5)
: null,
boxShadow: secondary || danger ? null : AppShadows.brand,
),
alignment: Alignment.center,
child: loading
? SizedBox(
height: 22,
width: 22,
child: CircularProgressIndicator(
strokeWidth: 2.4,
valueColor: AlwaysStoppedAnimation<Color>(fg),
),
)
: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (icon != null) ...[
Icon(icon, color: fg, size: 20),
const SizedBox(width: 8),
],
Text(
label,
style: AppText.button.copyWith(color: fg),
),
],
),
),
),
),
),
);
}
}
/// Pill-style chip for filters/tags. Animated selection.
class AppChip extends StatelessWidget {
final String label;
final IconData? icon;
final bool selected;
final VoidCallback? onTap;
final Color? color;
const AppChip({
super.key,
required this.label,
this.icon,
this.selected = false,
this.onTap,
this.color,
});
@override
Widget build(BuildContext context) {
final accent = color ?? AppColors.primary;
return AnimatedContainer(
duration: const Duration(milliseconds: 180),
curve: Curves.easeOut,
decoration: BoxDecoration(
color: selected ? accent : AppColors.surface,
borderRadius: BorderRadius.circular(AppRadius.pill),
border: Border.all(
color: selected ? accent : AppColors.border,
width: 1.2,
),
boxShadow: selected
? [
BoxShadow(
color: accent.withValues(alpha: 0.25),
blurRadius: 10,
offset: const Offset(0, 4),
)
]
: null,
),
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.circular(AppRadius.pill),
onTap: onTap,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 14,
vertical: 8,
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (icon != null) ...[
Icon(
icon,
size: 16,
color: selected ? Colors.white : accent,
),
const SizedBox(width: 6),
],
Text(
label,
style: TextStyle(
fontSize: 13.5,
fontWeight: FontWeight.w600,
color: selected ? Colors.white : AppColors.textPrimary,
),
),
],
),
),
),
),
);
}
}
/// Helpers for snackbars
class AppSnack {
static void error(BuildContext context, String message) {
ScaffoldMessenger.of(context)
..hideCurrentSnackBar()
..showSnackBar(
SnackBar(
content: Row(
children: [
const Icon(Icons.error_outline, color: Colors.white),
const SizedBox(width: 10),
Expanded(child: Text(message)),
],
),
backgroundColor: AppColors.error,
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppRadius.md),
),
),
);
}
static void success(BuildContext context, String message) {
ScaffoldMessenger.of(context)
..hideCurrentSnackBar()
..showSnackBar(
SnackBar(
content: Row(
children: [
const Icon(Icons.check_circle_outline, color: Colors.white),
const SizedBox(width: 10),
Expanded(child: Text(message)),
],
),
backgroundColor: AppColors.success,
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(AppRadius.md),
),
),
);
}
}

View File

@@ -61,10 +61,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: characters name: characters
sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.4.1" version: "1.4.0"
clock: clock:
dependency: transitive dependency: transitive
description: description:
@@ -404,18 +404,18 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: matcher name: matcher
sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861 sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.12.19" version: "0.12.17"
material_color_utilities: material_color_utilities:
dependency: transitive dependency: transitive
description: description:
name: material_color_utilities name: material_color_utilities
sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b" sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.13.0" version: "0.11.1"
meta: meta:
dependency: transitive dependency: transitive
description: description:
@@ -713,10 +713,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
sha256: "8161c84903fd860b26bfdefb7963b3f0b68fee7adea0f59ef805ecca346f0c7a" sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.7.10" version: "0.7.7"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description: