fix
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../providers/auth_provider.dart';
|
||||
import '../widgets/widgets.dart';
|
||||
import '../utils/validators.dart';
|
||||
import 'register_page.dart';
|
||||
|
||||
/// Login page with email and password authentication
|
||||
class LoginPage extends ConsumerStatefulWidget {
|
||||
@@ -66,11 +66,7 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
||||
}
|
||||
|
||||
void _navigateToRegister() {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const RegisterPage(),
|
||||
),
|
||||
);
|
||||
context.push('/register');
|
||||
}
|
||||
|
||||
void _handleForgotPassword() {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../providers/auth_provider.dart';
|
||||
import '../widgets/widgets.dart';
|
||||
import '../utils/validators.dart';
|
||||
@@ -90,7 +91,7 @@ class _RegisterPageState extends ConsumerState<RegisterPage> {
|
||||
}
|
||||
|
||||
void _navigateBackToLogin() {
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -142,7 +142,7 @@ final class AuthProvider extends $NotifierProvider<Auth, AuthState> {
|
||||
}
|
||||
}
|
||||
|
||||
String _$authHash() => r'73c9e7b70799eba2904eb6fc65454332d4146a33';
|
||||
String _$authHash() => r'24ad5a5313febf1a3ac2550adaf19f34098a8f7c';
|
||||
|
||||
/// Auth state notifier provider
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../domain/entities/category.dart';
|
||||
import '../providers/categories_provider.dart';
|
||||
import '../../../products/presentation/providers/products_provider.dart';
|
||||
import '../../../products/presentation/widgets/product_card.dart';
|
||||
import '../../../products/presentation/widgets/product_list_item.dart';
|
||||
@@ -10,11 +11,11 @@ enum ViewMode { grid, list }
|
||||
|
||||
/// Category detail page showing products in the category
|
||||
class CategoryDetailPage extends ConsumerStatefulWidget {
|
||||
final Category category;
|
||||
final String categoryId;
|
||||
|
||||
const CategoryDetailPage({
|
||||
super.key,
|
||||
required this.category,
|
||||
required this.categoryId,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -26,80 +27,178 @@ class _CategoryDetailPageState extends ConsumerState<CategoryDetailPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final categoriesAsync = ref.watch(categoriesProvider);
|
||||
final productsAsync = ref.watch(productsProvider);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(widget.category.name),
|
||||
actions: [
|
||||
// View mode toggle
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
_viewMode == ViewMode.grid
|
||||
? Icons.view_list_rounded
|
||||
: Icons.grid_view_rounded,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_viewMode =
|
||||
_viewMode == ViewMode.grid ? ViewMode.list : ViewMode.grid;
|
||||
});
|
||||
},
|
||||
tooltip: _viewMode == ViewMode.grid
|
||||
? 'Switch to list view'
|
||||
: 'Switch to grid view',
|
||||
),
|
||||
],
|
||||
),
|
||||
body: productsAsync.when(
|
||||
data: (products) {
|
||||
// Filter products by category
|
||||
final categoryProducts = products
|
||||
.where((product) => product.categoryId == widget.category.id)
|
||||
.toList();
|
||||
return categoriesAsync.when(
|
||||
data: (categories) {
|
||||
// Find the category by ID
|
||||
Category? category;
|
||||
try {
|
||||
category = categories.firstWhere((c) => c.id == widget.categoryId);
|
||||
} catch (e) {
|
||||
// Category not found
|
||||
category = null;
|
||||
}
|
||||
|
||||
if (categoryProducts.isEmpty) {
|
||||
return Center(
|
||||
// Handle category not found
|
||||
if (category == null) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Category Not Found'),
|
||||
),
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.inventory_2_outlined,
|
||||
Icons.error_outline,
|
||||
size: 64,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'No products in this category',
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
'Category not found',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Products will appear here once added',
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
'The category you are looking for does not exist',
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
FilledButton.icon(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
label: const Text('Go Back'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
await ref.read(productsProvider.notifier).syncProducts();
|
||||
},
|
||||
child: _viewMode == ViewMode.grid
|
||||
? _buildGridView(categoryProducts)
|
||||
: _buildListView(categoryProducts),
|
||||
),
|
||||
);
|
||||
},
|
||||
loading: () => const Center(
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(category.name),
|
||||
actions: [
|
||||
// View mode toggle
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
_viewMode == ViewMode.grid
|
||||
? Icons.view_list_rounded
|
||||
: Icons.grid_view_rounded,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_viewMode =
|
||||
_viewMode == ViewMode.grid ? ViewMode.list : ViewMode.grid;
|
||||
});
|
||||
},
|
||||
tooltip: _viewMode == ViewMode.grid
|
||||
? 'Switch to list view'
|
||||
: 'Switch to grid view',
|
||||
),
|
||||
],
|
||||
),
|
||||
body: productsAsync.when(
|
||||
data: (products) {
|
||||
// Filter products by category
|
||||
final categoryProducts = products
|
||||
.where((product) => product.categoryId == category!.id)
|
||||
.toList();
|
||||
|
||||
if (categoryProducts.isEmpty) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.inventory_2_outlined,
|
||||
size: 64,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'No products in this category',
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Products will appear here once added',
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
await ref.read(productsProvider.notifier).syncProducts();
|
||||
},
|
||||
child: _viewMode == ViewMode.grid
|
||||
? _buildGridView(categoryProducts)
|
||||
: _buildListView(categoryProducts),
|
||||
);
|
||||
},
|
||||
loading: () => const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
error: (error, stack) => Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.error_outline,
|
||||
size: 64,
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Error loading products',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
error.toString(),
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
FilledButton.icon(
|
||||
onPressed: () {
|
||||
ref.invalidate(productsProvider);
|
||||
},
|
||||
icon: const Icon(Icons.refresh),
|
||||
label: const Text('Retry'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
loading: () => Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Loading...'),
|
||||
),
|
||||
body: const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
error: (error, stack) => Center(
|
||||
),
|
||||
error: (error, stack) => Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Error'),
|
||||
),
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
@@ -110,7 +209,7 @@ class _CategoryDetailPageState extends ConsumerState<CategoryDetailPage> {
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Error loading products',
|
||||
'Error loading category',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
@@ -122,7 +221,7 @@ class _CategoryDetailPageState extends ConsumerState<CategoryDetailPage> {
|
||||
const SizedBox(height: 16),
|
||||
FilledButton.icon(
|
||||
onPressed: () {
|
||||
ref.invalidate(productsProvider);
|
||||
ref.invalidate(categoriesProvider);
|
||||
},
|
||||
icon: const Icon(Icons.refresh),
|
||||
label: const Text('Retry'),
|
||||
|
||||
@@ -6,7 +6,8 @@ import '../../../../core/providers/providers.dart';
|
||||
part 'categories_provider.g.dart';
|
||||
|
||||
/// Provider for categories list with online-first approach
|
||||
@riverpod
|
||||
/// keepAlive ensures data persists when switching tabs
|
||||
@Riverpod(keepAlive: true)
|
||||
class Categories extends _$Categories {
|
||||
@override
|
||||
Future<List<Category>> build() async {
|
||||
|
||||
@@ -9,21 +9,24 @@ part of 'categories_provider.dart';
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
/// Provider for categories list with online-first approach
|
||||
/// keepAlive ensures data persists when switching tabs
|
||||
|
||||
@ProviderFor(Categories)
|
||||
const categoriesProvider = CategoriesProvider._();
|
||||
|
||||
/// Provider for categories list with online-first approach
|
||||
/// keepAlive ensures data persists when switching tabs
|
||||
final class CategoriesProvider
|
||||
extends $AsyncNotifierProvider<Categories, List<Category>> {
|
||||
/// Provider for categories list with online-first approach
|
||||
/// keepAlive ensures data persists when switching tabs
|
||||
const CategoriesProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
retry: null,
|
||||
name: r'categoriesProvider',
|
||||
isAutoDispose: true,
|
||||
isAutoDispose: false,
|
||||
dependencies: null,
|
||||
$allTransitiveDependencies: null,
|
||||
);
|
||||
@@ -36,9 +39,10 @@ final class CategoriesProvider
|
||||
Categories create() => Categories();
|
||||
}
|
||||
|
||||
String _$categoriesHash() => r'33c33b08f8926e5bbbd112285591c74a3ff0f61c';
|
||||
String _$categoriesHash() => r'c26eb4b4a76ce796eb65b7843a390805528dec4a';
|
||||
|
||||
/// Provider for categories list with online-first approach
|
||||
/// keepAlive ensures data persists when switching tabs
|
||||
|
||||
abstract class _$Categories extends $AsyncNotifier<List<Category>> {
|
||||
FutureOr<List<Category>> build();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../../domain/entities/category.dart';
|
||||
import '../pages/category_detail_page.dart';
|
||||
|
||||
/// Category card widget
|
||||
class CategoryCard extends StatelessWidget {
|
||||
@@ -22,12 +22,7 @@ class CategoryCard extends StatelessWidget {
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
// Navigate to category detail page
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => CategoryDetailPage(category: category),
|
||||
),
|
||||
);
|
||||
context.push('/categories/${category.id}');
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../../domain/entities/product.dart';
|
||||
import '../../data/models/product_model.dart';
|
||||
import '../providers/products_provider.dart';
|
||||
@@ -139,7 +140,7 @@ class _BatchUpdatePageState extends ConsumerState<BatchUpdatePage> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: OutlinedButton(
|
||||
onPressed: _isLoading ? null : () => Navigator.pop(context),
|
||||
onPressed: _isLoading ? null : () => context.pop(),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
),
|
||||
@@ -327,7 +328,7 @@ class _BatchUpdatePageState extends ConsumerState<BatchUpdatePage> {
|
||||
ref.invalidate(productsProvider);
|
||||
|
||||
if (mounted) {
|
||||
Navigator.pop(context);
|
||||
context.pop();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
|
||||
@@ -3,33 +3,66 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import '../../domain/entities/product.dart';
|
||||
import '../providers/products_provider.dart';
|
||||
import '../../../categories/presentation/providers/categories_provider.dart';
|
||||
import '../../../../shared/widgets/price_display.dart';
|
||||
|
||||
/// Product detail page showing full product information
|
||||
class ProductDetailPage extends ConsumerWidget {
|
||||
final Product product;
|
||||
final String productId;
|
||||
|
||||
const ProductDetailPage({
|
||||
super.key,
|
||||
required this.product,
|
||||
required this.productId,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final productsAsync = ref.watch(productsProvider);
|
||||
final categoriesAsync = ref.watch(categoriesProvider);
|
||||
|
||||
// Find category name
|
||||
final categoryName = categoriesAsync.whenOrNull(
|
||||
data: (categories) {
|
||||
final category = categories.firstWhere(
|
||||
(cat) => cat.id == product.categoryId,
|
||||
orElse: () => categories.first,
|
||||
);
|
||||
return category.name;
|
||||
},
|
||||
);
|
||||
return productsAsync.when(
|
||||
data: (products) {
|
||||
// Find the product by ID
|
||||
Product? product;
|
||||
try {
|
||||
product = products.firstWhere((p) => p.id == productId);
|
||||
} catch (e) {
|
||||
// Product not found
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Product Not Found')),
|
||||
body: const Center(child: Text('Product not found')),
|
||||
);
|
||||
}
|
||||
|
||||
// Find category name
|
||||
final categoryName = categoriesAsync.whenOrNull(
|
||||
data: (categories) {
|
||||
try {
|
||||
final category = categories.firstWhere(
|
||||
(cat) => cat.id == product!.categoryId,
|
||||
);
|
||||
return category.name;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
return _buildProductDetail(context, product, categoryName);
|
||||
},
|
||||
loading: () => Scaffold(
|
||||
appBar: AppBar(title: const Text('Product Details')),
|
||||
body: const Center(child: CircularProgressIndicator()),
|
||||
),
|
||||
error: (error, stack) => Scaffold(
|
||||
appBar: AppBar(title: const Text('Error')),
|
||||
body: Center(child: Text('Error: $error')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildProductDetail(BuildContext context, Product product, String? categoryName) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Product Details'),
|
||||
@@ -48,7 +81,7 @@ class ProductDetailPage extends ConsumerWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Product Image
|
||||
_buildProductImage(context),
|
||||
_buildProductImage(context, product),
|
||||
|
||||
// Product Info Section
|
||||
Padding(
|
||||
@@ -97,19 +130,19 @@ class ProductDetailPage extends ConsumerWidget {
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Stock Information
|
||||
_buildStockSection(context),
|
||||
_buildStockSection(context, product),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Description Section
|
||||
_buildDescriptionSection(context),
|
||||
_buildDescriptionSection(context, product),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Additional Information
|
||||
_buildAdditionalInfo(context),
|
||||
_buildAdditionalInfo(context, product),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Action Buttons
|
||||
_buildActionButtons(context),
|
||||
_buildActionButtons(context, product),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -120,7 +153,7 @@ class ProductDetailPage extends ConsumerWidget {
|
||||
}
|
||||
|
||||
/// Build product image section
|
||||
Widget _buildProductImage(BuildContext context) {
|
||||
Widget _buildProductImage(BuildContext context, Product product) {
|
||||
return Hero(
|
||||
tag: 'product-${product.id}',
|
||||
child: Container(
|
||||
@@ -154,9 +187,9 @@ class ProductDetailPage extends ConsumerWidget {
|
||||
}
|
||||
|
||||
/// Build stock information section
|
||||
Widget _buildStockSection(BuildContext context) {
|
||||
final stockColor = _getStockColor(context);
|
||||
final stockStatus = _getStockStatus();
|
||||
Widget _buildStockSection(BuildContext context, Product product) {
|
||||
final stockColor = _getStockColor(context, product);
|
||||
final stockStatus = _getStockStatus(product);
|
||||
|
||||
return Card(
|
||||
child: Padding(
|
||||
@@ -245,7 +278,7 @@ class ProductDetailPage extends ConsumerWidget {
|
||||
}
|
||||
|
||||
/// Build description section
|
||||
Widget _buildDescriptionSection(BuildContext context) {
|
||||
Widget _buildDescriptionSection(BuildContext context, Product product) {
|
||||
if (product.description == null || product.description!.isEmpty) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
@@ -269,7 +302,7 @@ class ProductDetailPage extends ConsumerWidget {
|
||||
}
|
||||
|
||||
/// Build additional information section
|
||||
Widget _buildAdditionalInfo(BuildContext context) {
|
||||
Widget _buildAdditionalInfo(BuildContext context, Product product) {
|
||||
final dateFormat = DateFormat('MMM dd, yyyy');
|
||||
|
||||
return Card(
|
||||
@@ -355,7 +388,7 @@ class ProductDetailPage extends ConsumerWidget {
|
||||
}
|
||||
|
||||
/// Build action buttons
|
||||
Widget _buildActionButtons(BuildContext context) {
|
||||
Widget _buildActionButtons(BuildContext context, Product product) {
|
||||
return Column(
|
||||
children: [
|
||||
// Add to Cart Button
|
||||
@@ -400,7 +433,7 @@ class ProductDetailPage extends ConsumerWidget {
|
||||
}
|
||||
|
||||
/// Get stock color based on quantity
|
||||
Color _getStockColor(BuildContext context) {
|
||||
Color _getStockColor(BuildContext context, Product product) {
|
||||
if (product.stockQuantity == 0) {
|
||||
return Colors.red;
|
||||
} else if (product.stockQuantity < 5) {
|
||||
@@ -411,7 +444,7 @@ class ProductDetailPage extends ConsumerWidget {
|
||||
}
|
||||
|
||||
/// Get stock status text
|
||||
String _getStockStatus() {
|
||||
String _getStockStatus(Product product) {
|
||||
if (product.stockQuantity == 0) {
|
||||
return 'Out of Stock';
|
||||
} else if (product.stockQuantity < 5) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../widgets/product_grid.dart';
|
||||
import '../widgets/product_search_bar.dart';
|
||||
import '../widgets/product_list_item.dart';
|
||||
@@ -99,13 +100,9 @@ class _ProductsPageState extends ConsumerState<ProductsPage> {
|
||||
final selectedProducts = filteredProducts
|
||||
.where((p) => _selectedProductIds.contains(p.id))
|
||||
.toList();
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => BatchUpdatePage(
|
||||
selectedProducts: selectedProducts,
|
||||
),
|
||||
),
|
||||
context.push(
|
||||
'/products/batch-update',
|
||||
extra: selectedProducts,
|
||||
).then((_) {
|
||||
setState(() {
|
||||
_isSelectionMode = false;
|
||||
|
||||
@@ -6,7 +6,8 @@ import '../../../../core/providers/providers.dart';
|
||||
part 'products_provider.g.dart';
|
||||
|
||||
/// Provider for products list with online-first approach
|
||||
@riverpod
|
||||
/// keepAlive ensures data persists when switching tabs
|
||||
@Riverpod(keepAlive: true)
|
||||
class Products extends _$Products {
|
||||
@override
|
||||
Future<List<Product>> build() async {
|
||||
|
||||
@@ -9,21 +9,24 @@ part of 'products_provider.dart';
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
/// Provider for products list with online-first approach
|
||||
/// keepAlive ensures data persists when switching tabs
|
||||
|
||||
@ProviderFor(Products)
|
||||
const productsProvider = ProductsProvider._();
|
||||
|
||||
/// Provider for products list with online-first approach
|
||||
/// keepAlive ensures data persists when switching tabs
|
||||
final class ProductsProvider
|
||||
extends $AsyncNotifierProvider<Products, List<Product>> {
|
||||
/// Provider for products list with online-first approach
|
||||
/// keepAlive ensures data persists when switching tabs
|
||||
const ProductsProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
retry: null,
|
||||
name: r'productsProvider',
|
||||
isAutoDispose: true,
|
||||
isAutoDispose: false,
|
||||
dependencies: null,
|
||||
$allTransitiveDependencies: null,
|
||||
);
|
||||
@@ -36,9 +39,10 @@ final class ProductsProvider
|
||||
Products create() => Products();
|
||||
}
|
||||
|
||||
String _$productsHash() => r'0ff8c2de46bb4b1e29678cc811ec121c9fb4c8eb';
|
||||
String _$productsHash() => r'1fa5341d86a35a3b3d6666da88e0c5db757cdcdb';
|
||||
|
||||
/// Provider for products list with online-first approach
|
||||
/// keepAlive ensures data persists when switching tabs
|
||||
|
||||
abstract class _$Products extends $AsyncNotifier<List<Product>> {
|
||||
FutureOr<List<Product>> build();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../../domain/entities/product.dart';
|
||||
import '../pages/product_detail_page.dart';
|
||||
import '../../../../shared/widgets/price_display.dart';
|
||||
|
||||
/// Product card widget
|
||||
@@ -20,12 +20,7 @@ class ProductCard extends StatelessWidget {
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
// Navigate to product detail page
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ProductDetailPage(product: product),
|
||||
),
|
||||
);
|
||||
context.push('/products/${product.id}');
|
||||
},
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../../domain/entities/product.dart';
|
||||
import '../pages/product_detail_page.dart';
|
||||
import '../../../../shared/widgets/price_display.dart';
|
||||
|
||||
/// Product list item widget for list view
|
||||
@@ -23,12 +23,7 @@ class ProductListItem extends StatelessWidget {
|
||||
onTap: onTap ??
|
||||
() {
|
||||
// Navigate to product detail page
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ProductDetailPage(product: product),
|
||||
),
|
||||
);
|
||||
context.push('/products/${product.id}');
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../providers/settings_provider.dart';
|
||||
import '../../../auth/presentation/providers/auth_provider.dart';
|
||||
import '../../../../core/constants/app_constants.dart';
|
||||
@@ -105,11 +106,11 @@ class SettingsPage extends ConsumerWidget {
|
||||
content: const Text('Are you sure you want to logout?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
onPressed: () => context.pop(false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
onPressed: () => context.pop(true),
|
||||
style: FilledButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
@@ -294,7 +295,7 @@ class SettingsPage extends ConsumerWidget {
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
ref.read(settingsProvider.notifier).updateTheme(value);
|
||||
Navigator.pop(context);
|
||||
context.pop();
|
||||
}
|
||||
},
|
||||
),
|
||||
@@ -305,7 +306,7 @@ class SettingsPage extends ConsumerWidget {
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
ref.read(settingsProvider.notifier).updateTheme(value);
|
||||
Navigator.pop(context);
|
||||
context.pop();
|
||||
}
|
||||
},
|
||||
),
|
||||
@@ -316,7 +317,7 @@ class SettingsPage extends ConsumerWidget {
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
ref.read(settingsProvider.notifier).updateTheme(value);
|
||||
Navigator.pop(context);
|
||||
context.pop();
|
||||
}
|
||||
},
|
||||
),
|
||||
@@ -341,7 +342,7 @@ class SettingsPage extends ConsumerWidget {
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
ref.read(settingsProvider.notifier).updateLanguage(value);
|
||||
Navigator.pop(context);
|
||||
context.pop();
|
||||
}
|
||||
},
|
||||
),
|
||||
@@ -352,7 +353,7 @@ class SettingsPage extends ConsumerWidget {
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
ref.read(settingsProvider.notifier).updateLanguage(value);
|
||||
Navigator.pop(context);
|
||||
context.pop();
|
||||
}
|
||||
},
|
||||
),
|
||||
@@ -363,7 +364,7 @@ class SettingsPage extends ConsumerWidget {
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
ref.read(settingsProvider.notifier).updateLanguage(value);
|
||||
Navigator.pop(context);
|
||||
context.pop();
|
||||
}
|
||||
},
|
||||
),
|
||||
@@ -388,7 +389,7 @@ class SettingsPage extends ConsumerWidget {
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
// TODO: Implement currency update
|
||||
Navigator.pop(context);
|
||||
context.pop();
|
||||
}
|
||||
},
|
||||
),
|
||||
@@ -399,7 +400,7 @@ class SettingsPage extends ConsumerWidget {
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
// TODO: Implement currency update
|
||||
Navigator.pop(context);
|
||||
context.pop();
|
||||
}
|
||||
},
|
||||
),
|
||||
@@ -410,7 +411,7 @@ class SettingsPage extends ConsumerWidget {
|
||||
onChanged: (value) {
|
||||
if (value != null) {
|
||||
// TODO: Implement currency update
|
||||
Navigator.pop(context);
|
||||
context.pop();
|
||||
}
|
||||
},
|
||||
),
|
||||
@@ -437,13 +438,13 @@ class SettingsPage extends ConsumerWidget {
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
onPressed: () => context.pop(),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
// TODO: Implement store name update
|
||||
Navigator.pop(context);
|
||||
context.pop();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Store name updated')),
|
||||
);
|
||||
@@ -476,13 +477,13 @@ class SettingsPage extends ConsumerWidget {
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
onPressed: () => context.pop(),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
// TODO: Implement tax rate update
|
||||
Navigator.pop(context);
|
||||
context.pop();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Tax rate updated')),
|
||||
);
|
||||
@@ -521,7 +522,7 @@ class SettingsPage extends ConsumerWidget {
|
||||
|
||||
// Close loading dialog
|
||||
if (context.mounted) {
|
||||
Navigator.pop(context);
|
||||
context.pop();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Data synced successfully')),
|
||||
);
|
||||
@@ -538,12 +539,12 @@ class SettingsPage extends ConsumerWidget {
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
onPressed: () => context.pop(),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
context.pop();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Cache cleared')),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user