Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion Project2/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,41 @@ class MyApp extends StatelessWidget {
],
child: MaterialApp.router(
title: 'Smart WIC Cart',
theme: ThemeData(useMaterial3: true, colorSchemeSeed: Colors.teal),
theme: ThemeData(
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(
seedColor: const Color(0xFFD1001C),
primary: const Color(0xFFD1001C),
secondary: const Color(0xFFD1001C),
surface: Colors.white,
),
scaffoldBackgroundColor: Colors.white,
appBarTheme: const AppBarTheme(
backgroundColor: Color(0xFFD1001C),
foregroundColor: Colors.white,
elevation: 2,
),
cardTheme: CardThemeData(
color: Colors.white,
elevation: 2,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
side: BorderSide(color: Colors.grey.shade200, width: 1),
),
),
filledButtonTheme: FilledButtonThemeData(
style: FilledButton.styleFrom(
backgroundColor: const Color(0xFFD1001C),
foregroundColor: Colors.white,
disabledBackgroundColor: Colors.grey.shade300,
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
),
),
floatingActionButtonTheme: const FloatingActionButtonThemeData(
backgroundColor: Color(0xFFD1001C),
foregroundColor: Colors.white,
),
),
routerConfig: router,
),
);
Expand Down
19 changes: 8 additions & 11 deletions Project2/lib/screens/balances_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class BalancesScreen extends StatelessWidget {
return Scaffold(
appBar: AppBar(
title: const Text('WIC Benefits'),
centerTitle: true,
actions: [
// Sign out button
IconButton(
Expand Down Expand Up @@ -145,10 +144,7 @@ class BalancesScreen extends StatelessWidget {
class _BalanceCard extends StatelessWidget {
const _BalanceCard({required this.category, required this.data});

/// The canonical category name (uppercase).
final String category;

/// Balance data map with 'allowed' and 'used' keys from [AppState.balances].
final Map<String, dynamic> data;

/// Calculates the color for the progress bar based on usage percentage.
Expand All @@ -160,11 +156,11 @@ class _BalanceCard extends StatelessWidget {
///
/// For unlimited categories (allowed is null), always returns green.
Color _getProgressColor(int? allowed, int used) {
if (allowed == null) return Colors.green;
if (allowed == null) return const Color(0xFFD1001C);
final pct = used / allowed;
if (pct < 0.6) return Colors.green;
if (pct < 0.85) return Colors.orange;
return Colors.red;
if (pct < 0.6) return const Color(0xFFD1001C);
if (pct < 0.85) return Colors.orange.shade600;
return Colors.red.shade700;
}

@override
Expand Down Expand Up @@ -192,6 +188,7 @@ class _BalanceCard extends StatelessWidget {
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Color(0xFFD1001C),
),
),
),
Expand All @@ -202,14 +199,14 @@ class _BalanceCard extends StatelessWidget {
vertical: 4,
),
decoration: BoxDecoration(
color: Colors.green.shade100,
color: const Color(0xFFD1001C).withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(12),
),
child: Text(
child: const Text(
'Unlimited',
style: TextStyle(
fontSize: 12,
color: Colors.green.shade700,
color: Color(0xFFD1001C),
fontWeight: FontWeight.bold,
),
),
Expand Down
52 changes: 35 additions & 17 deletions Project2/lib/screens/basket_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class BasketScreen extends StatelessWidget {
return Scaffold(
appBar: AppBar(
title: const Text('My Basket'),
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
actions: [
IconButton(
icon: const Icon(Icons.logout),
Expand All @@ -56,7 +55,15 @@ class BasketScreen extends StatelessWidget {
Container(
width: double.infinity,
padding: const EdgeInsets.all(16),
color: Colors.blue.shade50,
decoration: BoxDecoration(
color: const Color(0xFFD1001C).withValues(alpha: 0.1),
border: Border(
bottom: BorderSide(
color: const Color(0xFFD1001C).withValues(alpha: 0.2),
width: 1,
),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expand All @@ -65,14 +72,25 @@ class BasketScreen extends StatelessWidget {
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Color(0xFFD1001C),
),
),
Text(
'$totalItems',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.blue.shade700,
Container(
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 8,
),
decoration: BoxDecoration(
color: const Color(0xFFD1001C),
borderRadius: BorderRadius.circular(20),
),
child: Text(
'$totalItems',
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
),
],
Expand All @@ -84,7 +102,7 @@ class BasketScreen extends StatelessWidget {
itemCount: basket.length,
itemBuilder: (context, index) {
final item = basket[index];
return _BasketItemTile(item: item);
return _BasketItem(item: item);
},
),
),
Expand Down Expand Up @@ -118,7 +136,7 @@ class BasketScreen extends StatelessWidget {
style: TextStyle(fontSize: 14, color: Colors.grey.shade500),
),
const SizedBox(height: 24),
ElevatedButton.icon(
FilledButton.icon(
onPressed: () => context.go('/scan'),
icon: const Icon(Icons.qr_code_scanner),
label: const Text('Start Scanning'),
Expand All @@ -139,8 +157,8 @@ class BasketScreen extends StatelessWidget {
/// Provides increment/decrement buttons that call [AppState.incrementItem]
/// and [AppState.decrementItem] respectively. Buttons are styled with
/// visual feedback and disabled states based on category limits.
class _BasketItemTile extends StatelessWidget {
const _BasketItemTile({required this.item});
class _BasketItem extends StatelessWidget {
const _BasketItem({required this.item});

/// The basket item data map containing 'upc', 'name', 'category', and 'qty'.
final Map<String, dynamic> item;
Expand All @@ -158,12 +176,12 @@ class _BasketItemTile extends StatelessWidget {
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
child: ListTile(
leading: CircleAvatar(
backgroundColor: Colors.blue.shade100,
backgroundColor: const Color(0xFFD1001C).withValues(alpha: 0.1),
child: Text(
qty.toString(),
style: TextStyle(
style: const TextStyle(
fontWeight: FontWeight.bold,
color: Colors.blue.shade700,
color: Color(0xFFD1001C),
),
),
),
Expand All @@ -175,15 +193,15 @@ class _BasketItemTile extends StatelessWidget {
// Decrement button
IconButton(
icon: const Icon(Icons.remove_circle_outline),
color: Colors.red.shade400,
color: const Color(0xFFD1001C),
onPressed: () => appState.decrementItem(upc),
tooltip: 'Remove one',
),
// Increment button
IconButton(
icon: Icon(
Icons.add_circle_outline,
color: canAdd ? Colors.green.shade400 : Colors.grey.shade300,
color: canAdd ? const Color(0xFFD1001C) : Colors.grey.shade300,
),
onPressed: canAdd ? () => appState.incrementItem(upc) : null,
tooltip: canAdd ? 'Add one' : 'Category limit reached',
Expand Down
Loading