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
11 changes: 11 additions & 0 deletions Kiosk/lib/db/database_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,17 @@ class DatabaseHelper {
return maps.map((json) => Product.fromJson(json)).toList();
}

Future<List<Product>> searchProducts(String query) async {
final db = await instance.database;
final maps = await db.query(
'products',
where: 'barcode LIKE ? OR name LIKE ?',
whereArgs: ['$query%', '%$query%'],
limit: 20,
);
return maps.map((json) => Product.fromJson(json)).toList();
}

Future<void> clearProducts() async {
final db = await instance.database;
await db.delete('products');
Expand Down
6 changes: 6 additions & 0 deletions Kiosk/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@
"searchApps": "Search apps",
"noAppsFound": "No apps found",
"homeAppOpenFailed": "Can't open {package}. Opening Launcher instead.",
"noBarcodeProductsTitle": "No Barcode Products",
"noBarcodeProductsEmpty": "No no-barcode products",
"categories": "Categories",
"categoryAll": "All",
"categoryUncategorized": "Uncategorized",
"searchProducts": "Search products",
"clear": "Clear",
"save": "Save"
}
36 changes: 36 additions & 0 deletions Kiosk/lib/l10n/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,42 @@ abstract class AppLocalizations {
/// **'Can\'t open {package}. Opening Launcher instead.'**
String homeAppOpenFailed(Object package);

/// No description provided for @noBarcodeProductsTitle.
///
/// In en, this message translates to:
/// **'No Barcode Products'**
String get noBarcodeProductsTitle;

/// No description provided for @noBarcodeProductsEmpty.
///
/// In en, this message translates to:
/// **'No no-barcode products'**
String get noBarcodeProductsEmpty;

/// No description provided for @categories.
///
/// In en, this message translates to:
/// **'Categories'**
String get categories;

/// No description provided for @categoryAll.
///
/// In en, this message translates to:
/// **'All'**
String get categoryAll;

/// No description provided for @categoryUncategorized.
///
/// In en, this message translates to:
/// **'Uncategorized'**
String get categoryUncategorized;

/// No description provided for @searchProducts.
///
/// In en, this message translates to:
/// **'Search products'**
String get searchProducts;

/// No description provided for @clear.
///
/// In en, this message translates to:
Expand Down
18 changes: 18 additions & 0 deletions Kiosk/lib/l10n/app_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,24 @@ class AppLocalizationsEn extends AppLocalizations {
return 'Can\'t open $package. Opening Launcher instead.';
}

@override
String get noBarcodeProductsTitle => 'No Barcode Products';

@override
String get noBarcodeProductsEmpty => 'No no-barcode products';

@override
String get categories => 'Categories';

@override
String get categoryAll => 'All';

@override
String get categoryUncategorized => 'Uncategorized';

@override
String get searchProducts => 'Search products';

@override
String get clear => 'Clear';

Expand Down
18 changes: 18 additions & 0 deletions Kiosk/lib/l10n/app_localizations_zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,24 @@ class AppLocalizationsZh extends AppLocalizations {
return '无法打开 $package,将打开桌面启动器。';
}

@override
String get noBarcodeProductsTitle => '无条码商品';

@override
String get noBarcodeProductsEmpty => '暂无无条码商品';

@override
String get categories => '分类';

@override
String get categoryAll => '全部';

@override
String get categoryUncategorized => '未分类';

@override
String get searchProducts => '搜索商品';

@override
String get clear => '清除';

Expand Down
6 changes: 6 additions & 0 deletions Kiosk/lib/l10n/app_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@
"searchApps": "搜索应用",
"noAppsFound": "未找到应用",
"homeAppOpenFailed": "无法打开 {package},将打开桌面启动器。",
"noBarcodeProductsTitle": "无条码商品",
"noBarcodeProductsEmpty": "暂无无条码商品",
"categories": "分类",
"categoryAll": "全部",
"categoryUncategorized": "未分类",
"searchProducts": "搜索商品",
"clear": "清除",
"save": "保存"
}
36 changes: 29 additions & 7 deletions Kiosk/lib/screens/main_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import 'package:kiosk/db/database_helper.dart';
import 'package:kiosk/models/product.dart';
import 'package:kiosk/models/order.dart' as model; // Alias to avoid conflict if needed
import 'package:kiosk/screens/payment_screen.dart';
import 'package:kiosk/screens/manual_barcode_dialog.dart';
import 'package:kiosk/screens/no_barcode_products_dialog.dart';
import 'package:kiosk/screens/settings_screen.dart';
import 'package:mobile_scanner/mobile_scanner.dart';
import 'package:kiosk/l10n/app_localizations.dart';
Expand Down Expand Up @@ -260,6 +262,24 @@ class _MainScreenState extends State<MainScreen> {
);
}

Future<void> _openNoBarcodePicker() async {
final l10n = AppLocalizations.of(context)!;
final messenger = ScaffoldMessenger.of(context);
await showDialog<void>(
context: context,
builder: (context) {
return NoBarcodeProductsDialog(
onAdd: (product) {
_addToCart(product);
messenger.showSnackBar(
SnackBar(content: Text(l10n.addedProduct(product.name))),
);
},
);
},
);
}

Future<void> _handleBarcodeDetect(BarcodeCapture capture) async {
// Only process logic if not already processing
if (_isProcessing) return;
Expand Down Expand Up @@ -649,19 +669,21 @@ class _MainScreenState extends State<MainScreen> {
Row(
children: [
TextButton.icon(
onPressed: () {
// Manual barcode entry dialog
// Placeholder
onPressed: () async {
final product = await showDialog<Product>(
context: context,
builder: (context) => const ManualBarcodeDialog(),
);
if (product != null) {
_addToCart(product);
}
},
icon: const Icon(Icons.keyboard, color: Colors.grey),
label: Text(l10n.inputBarcode, style: const TextStyle(color: Colors.grey)),
),
const SizedBox(width: 16),
TextButton.icon(
onPressed: () {
// No barcode selection
// Placeholder
},
onPressed: _openNoBarcodePicker,
icon: const Icon(Icons.grid_view, color: Colors.grey),
label: Text(l10n.noBarcodeItem, style: const TextStyle(color: Colors.grey)),
),
Expand Down
Loading