Resolve all lints and deprecation warnings

This commit is contained in:
2026-01-09 10:04:51 -06:00
parent 512577b092
commit a799e9cf59
56 changed files with 2819 additions and 3159 deletions

View File

@@ -5,10 +5,9 @@ import '../../theme/app_theme.dart';
import '../../models/user_profile.dart';
import '../../providers/user_provider.dart';
import '../../services/notification_service.dart';
import '../../widgets/pad_settings_dialog.dart'; // We can reuse the logic, but maybe embed it directly or just link it.
// Actually, let's rebuild the UI here properly as a screen instead of a dialog,
// or for now, since we already have the dialog logic working well, let's just
// have this screen trigger the dialog or embed the same widgets.
// or for now, since we already have the dialog logic working well, let's just
// have this screen trigger the dialog or embed the same widgets.
// However, the user asked to "make a new setting page", so a full screen is better.
// I'll copy the logic from the dialog into this screen for a seamless experience.
@@ -16,16 +15,18 @@ class SuppliesSettingsScreen extends ConsumerStatefulWidget {
const SuppliesSettingsScreen({super.key});
@override
ConsumerState<SuppliesSettingsScreen> createState() => _SuppliesSettingsScreenState();
ConsumerState<SuppliesSettingsScreen> createState() =>
_SuppliesSettingsScreenState();
}
class _SuppliesSettingsScreenState extends ConsumerState<SuppliesSettingsScreen> {
class _SuppliesSettingsScreenState
extends ConsumerState<SuppliesSettingsScreen> {
bool _isTrackingEnabled = false;
int _typicalFlow = 2;
int _typicalFlow = 2;
bool _isAutoInventoryEnabled = true;
bool _showPadTimerMinutes = true;
bool _showPadTimerSeconds = false;
// Inventory
List<SupplyItem> _supplies = [];
int _lowInventoryThreshold = 5;
@@ -41,7 +42,7 @@ class _SuppliesSettingsScreenState extends ConsumerState<SuppliesSettingsScreen>
_lowInventoryThreshold = user.lowInventoryThreshold;
_showPadTimerMinutes = user.showPadTimerMinutes;
_showPadTimerSeconds = user.showPadTimerSeconds;
// Load supplies
if (user.padSupplies != null) {
_supplies = List.from(user.padSupplies!);
@@ -65,19 +66,21 @@ class _SuppliesSettingsScreenState extends ConsumerState<SuppliesSettingsScreen>
padInventoryCount: totalCount,
lowInventoryThreshold: _lowInventoryThreshold,
);
await ref.read(userProfileProvider.notifier).updateProfile(updatedProfile);
await ref
.read(userProfileProvider.notifier)
.updateProfile(updatedProfile);
// Check for Low Supply Alert
if (updatedProfile.notifyLowSupply &&
if (updatedProfile.notifyLowSupply &&
totalCount <= updatedProfile.lowInventoryThreshold) {
NotificationService().showLocalNotification(
id: 2001,
title: 'Low Pad Supply',
body: 'Your inventory is low ($totalCount left). Time to restock!',
);
NotificationService().showLocalNotification(
id: 2001,
title: 'Low Pad Supply',
body: 'Your inventory is low ($totalCount left). Time to restock!',
);
}
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Preferences saved')),
@@ -121,7 +124,7 @@ class _SuppliesSettingsScreenState extends ConsumerState<SuppliesSettingsScreen>
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Toggle
// Toggle
Row(
children: [
Expanded(
@@ -137,14 +140,14 @@ class _SuppliesSettingsScreenState extends ConsumerState<SuppliesSettingsScreen>
Switch(
value: _isTrackingEnabled,
onChanged: (val) => setState(() => _isTrackingEnabled = val),
activeColor: AppColors.menstrualPhase,
activeThumbColor: AppColors.menstrualPhase,
),
],
),
if (_isTrackingEnabled) ...[
const Divider(height: 32),
// Inventory Section
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
@@ -161,7 +164,8 @@ class _SuppliesSettingsScreenState extends ConsumerState<SuppliesSettingsScreen>
onPressed: () => _addOrEditSupply(),
icon: const Icon(Icons.add),
label: const Text('Add Item'),
style: TextButton.styleFrom(foregroundColor: AppColors.menstrualPhase),
style: TextButton.styleFrom(
foregroundColor: AppColors.menstrualPhase),
),
],
),
@@ -170,7 +174,7 @@ class _SuppliesSettingsScreenState extends ConsumerState<SuppliesSettingsScreen>
Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.grey.withOpacity(0.1),
color: Colors.grey.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(12),
),
child: Center(
@@ -193,10 +197,12 @@ class _SuppliesSettingsScreenState extends ConsumerState<SuppliesSettingsScreen>
tileColor: Theme.of(context).cardTheme.color,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
side: BorderSide(color: Colors.black.withOpacity(0.05)),
side: BorderSide(
color: Colors.black.withValues(alpha: 0.05)),
),
leading: CircleAvatar(
backgroundColor: AppColors.menstrualPhase.withOpacity(0.1),
backgroundColor:
AppColors.menstrualPhase.withValues(alpha: 0.1),
child: Text(
item.count.toString(),
style: GoogleFonts.outfit(
@@ -205,10 +211,14 @@ class _SuppliesSettingsScreenState extends ConsumerState<SuppliesSettingsScreen>
),
),
),
title: Text(item.brand, style: GoogleFonts.outfit(fontWeight: FontWeight.w600)),
subtitle: Text(item.type.label, style: GoogleFonts.outfit(fontSize: 12)),
title: Text(item.brand,
style:
GoogleFonts.outfit(fontWeight: FontWeight.w600)),
subtitle: Text(item.type.label,
style: GoogleFonts.outfit(fontSize: 12)),
trailing: IconButton(
icon: const Icon(Icons.delete_outline, color: Colors.red),
icon:
const Icon(Icons.delete_outline, color: Colors.red),
onPressed: () {
setState(() {
_supplies.removeAt(index);
@@ -221,7 +231,7 @@ class _SuppliesSettingsScreenState extends ConsumerState<SuppliesSettingsScreen>
),
const Divider(height: 32),
// Typical Flow
Text(
'Typical Flow Intensity',
@@ -234,7 +244,9 @@ class _SuppliesSettingsScreenState extends ConsumerState<SuppliesSettingsScreen>
const SizedBox(height: 8),
Row(
children: [
Text('Light', style: GoogleFonts.outfit(fontSize: 12, color: AppColors.warmGray)),
Text('Light',
style: GoogleFonts.outfit(
fontSize: 12, color: AppColors.warmGray)),
Expanded(
child: Slider(
value: _typicalFlow.toDouble(),
@@ -242,42 +254,45 @@ class _SuppliesSettingsScreenState extends ConsumerState<SuppliesSettingsScreen>
max: 5,
divisions: 4,
activeColor: AppColors.menstrualPhase,
onChanged: (val) => setState(() => _typicalFlow = val.round()),
onChanged: (val) =>
setState(() => _typicalFlow = val.round()),
),
),
Text('Heavy', style: GoogleFonts.outfit(fontSize: 12, color: AppColors.warmGray)),
Text('Heavy',
style: GoogleFonts.outfit(
fontSize: 12, color: AppColors.warmGray)),
],
),
Center(
child: Text(
'$_typicalFlow/5',
style: GoogleFonts.outfit(
fontWeight: FontWeight.bold,
color: AppColors.menstrualPhase
)
),
child: Text('$_typicalFlow/5',
style: GoogleFonts.outfit(
fontWeight: FontWeight.bold,
color: AppColors.menstrualPhase)),
),
const SizedBox(height: 24),
// Auto Deduct Toggle
SwitchListTile(
contentPadding: EdgeInsets.zero,
title: Text(
'Auto-deduct on Log',
style: GoogleFonts.outfit(fontWeight: FontWeight.w500, color: AppColors.charcoal),
),
subtitle: Text(
'Reduce count when you log a pad',
style: GoogleFonts.outfit(fontSize: 12, color: AppColors.warmGray),
),
value: _isAutoInventoryEnabled,
onChanged: (val) => setState(() => _isAutoInventoryEnabled = val),
activeColor: AppColors.menstrualPhase,
contentPadding: EdgeInsets.zero,
title: Text(
'Auto-deduct on Log',
style: GoogleFonts.outfit(
fontWeight: FontWeight.w500, color: AppColors.charcoal),
),
subtitle: Text(
'Reduce count when you log a pad',
style: GoogleFonts.outfit(
fontSize: 12, color: AppColors.warmGray),
),
value: _isAutoInventoryEnabled,
onChanged: (val) =>
setState(() => _isAutoInventoryEnabled = val),
activeThumbColor: AppColors.menstrualPhase,
),
const Divider(height: 32),
Text(
'Timer Display Settings',
style: GoogleFonts.outfit(
@@ -289,35 +304,39 @@ class _SuppliesSettingsScreenState extends ConsumerState<SuppliesSettingsScreen>
const SizedBox(height: 8),
SwitchListTile(
contentPadding: EdgeInsets.zero,
title: Text(
'Show Minutes',
style: GoogleFonts.outfit(fontWeight: FontWeight.w500, color: AppColors.charcoal),
),
value: _showPadTimerMinutes,
onChanged: (val) {
setState(() {
_showPadTimerMinutes = val;
if (!val) {
_showPadTimerSeconds = false;
}
});
},
activeColor: AppColors.menstrualPhase,
contentPadding: EdgeInsets.zero,
title: Text(
'Show Minutes',
style: GoogleFonts.outfit(
fontWeight: FontWeight.w500, color: AppColors.charcoal),
),
value: _showPadTimerMinutes,
onChanged: (val) {
setState(() {
_showPadTimerMinutes = val;
if (!val) {
_showPadTimerSeconds = false;
}
});
},
activeThumbColor: AppColors.menstrualPhase,
),
SwitchListTile(
contentPadding: EdgeInsets.zero,
title: Text(
'Show Seconds',
style: GoogleFonts.outfit(
fontWeight: FontWeight.w500,
color: _showPadTimerMinutes ? AppColors.charcoal : AppColors.warmGray
),
),
value: _showPadTimerSeconds,
onChanged: _showPadTimerMinutes ? (val) => setState(() => _showPadTimerSeconds = val) : null,
activeColor: AppColors.menstrualPhase,
contentPadding: EdgeInsets.zero,
title: Text(
'Show Seconds',
style: GoogleFonts.outfit(
fontWeight: FontWeight.w500,
color: _showPadTimerMinutes
? AppColors.charcoal
: AppColors.warmGray),
),
value: _showPadTimerSeconds,
onChanged: _showPadTimerMinutes
? (val) => setState(() => _showPadTimerSeconds = val)
: null,
activeThumbColor: AppColors.menstrualPhase,
),
],
],
@@ -345,11 +364,12 @@ class _SupplyDialogState extends State<_SupplyDialog> {
@override
void initState() {
super.initState();
_brandController = TextEditingController(text: widget.initialItem?.brand ?? '');
_brandController =
TextEditingController(text: widget.initialItem?.brand ?? '');
_type = widget.initialItem?.type ?? PadType.regular;
_count = widget.initialItem?.count ?? 0;
}
@override
void dispose() {
_brandController.dispose();
@@ -371,11 +391,13 @@ class _SupplyDialogState extends State<_SupplyDialog> {
),
const SizedBox(height: 16),
DropdownButtonFormField<PadType>(
value: _type,
items: PadType.values.map((t) => DropdownMenuItem(
value: t,
child: Text(t.label),
)).toList(),
initialValue: _type,
items: PadType.values
.map((t) => DropdownMenuItem(
value: t,
child: Text(t.label),
))
.toList(),
onChanged: (val) => setState(() => _type = val!),
decoration: const InputDecoration(labelText: 'Type'),
),
@@ -383,14 +405,18 @@ class _SupplyDialogState extends State<_SupplyDialog> {
TextField(
keyboardType: TextInputType.number,
decoration: const InputDecoration(labelText: 'Quantity'),
controller: TextEditingController(text: _count.toString()), // Hacky for demo, binding needed properly
controller: TextEditingController(
text: _count
.toString()), // Hacky for demo, binding needed properly
onChanged: (val) => _count = int.tryParse(val) ?? 0,
),
],
),
),
actions: [
TextButton(onPressed: () => Navigator.pop(context), child: const Text('Cancel')),
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('Cancel')),
ElevatedButton(
onPressed: () {
if (_brandController.text.isEmpty) return;