feat: alphabet list, change Layout etc
This commit is contained in:
@@ -39,6 +39,7 @@ class _ProductFormViewState extends State<ProductFormView> {
|
||||
Product? _existingProduct;
|
||||
String? _imagePath;
|
||||
bool _hasImage = false;
|
||||
bool _infiniteStock = false;
|
||||
bool _isLoading = true;
|
||||
bool _isSaving = false;
|
||||
|
||||
@@ -79,6 +80,7 @@ class _ProductFormViewState extends State<ProductFormView> {
|
||||
_priceController.text = (product.priceInCents / 100).toStringAsFixed(2);
|
||||
_stockController.text = product.stockQuantity.toString();
|
||||
_lowStockController.text = product.lowStockThreshold.toString();
|
||||
_infiniteStock = product.infiniteStock;
|
||||
_imagePath = product.imagePath;
|
||||
_hasImage = product.imagePath != null && product.imagePath!.isNotEmpty;
|
||||
|
||||
@@ -189,6 +191,7 @@ class _ProductFormViewState extends State<ProductFormView> {
|
||||
priceInCents: priceInCents,
|
||||
stockQuantity: stockQuantity,
|
||||
lowStockThreshold: lowStockThreshold,
|
||||
infiniteStock: _infiniteStock,
|
||||
imagePath: _imagePath,
|
||||
);
|
||||
|
||||
@@ -200,6 +203,7 @@ class _ProductFormViewState extends State<ProductFormView> {
|
||||
priceInCents: priceInCents,
|
||||
stockQuantity: stockQuantity,
|
||||
lowStockThreshold: lowStockThreshold,
|
||||
infiniteStock: _infiniteStock,
|
||||
imagePath: _imagePath,
|
||||
);
|
||||
}
|
||||
@@ -429,46 +433,64 @@ class _ProductFormViewState extends State<ProductFormView> {
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: _stockController,
|
||||
decoration: InputDecoration(
|
||||
labelText: l10n.stock,
|
||||
border: OutlineInputBorder(),
|
||||
SwitchListTile(
|
||||
value: _infiniteStock,
|
||||
onChanged: (value) {
|
||||
setState(() => _infiniteStock = value);
|
||||
},
|
||||
title: Text(l10n.infiniteStock),
|
||||
subtitle: Text(l10n.infiniteStockDescription),
|
||||
secondary: const Icon(Icons.all_inclusive_rounded),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
side: BorderSide(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
validator: (value) {
|
||||
final number = int.tryParse(value ?? '');
|
||||
|
||||
if (number == null || number < 0) {
|
||||
return l10n.enterValidStock;
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: _lowStockController,
|
||||
decoration: InputDecoration(
|
||||
labelText: l10n.lowStockThreshold,
|
||||
border: OutlineInputBorder(),
|
||||
if (!_infiniteStock) ...[
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: _stockController,
|
||||
decoration: InputDecoration(
|
||||
labelText: l10n.stock,
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.next,
|
||||
validator: (value) {
|
||||
final number = int.tryParse(value ?? '');
|
||||
|
||||
if (number == null || number < 0) {
|
||||
return l10n.enterValidStock;
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.done,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
validator: (value) {
|
||||
final number = int.tryParse(value ?? '');
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: _lowStockController,
|
||||
decoration: InputDecoration(
|
||||
labelText: l10n.lowStockThreshold,
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
keyboardType: TextInputType.number,
|
||||
textInputAction: TextInputAction.done,
|
||||
onFieldSubmitted: (_) {
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
validator: (value) {
|
||||
final number = int.tryParse(value ?? '');
|
||||
|
||||
if (number == null || number < 0) {
|
||||
return l10n.enterValidThreshold;
|
||||
}
|
||||
if (number == null || number < 0) {
|
||||
return l10n.enterValidThreshold;
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
),
|
||||
return null;
|
||||
},
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 24),
|
||||
FilledButton.icon(
|
||||
onPressed: _isSaving ? null : _save,
|
||||
|
||||
Reference in New Issue
Block a user