import 'package:flutter/cupertino.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/app_util.dart'; import 'package:huixiang/view_widget/request_permission.dart'; import 'package:permission_handler/permission_handler.dart'; // import 'package:qrscan/qrscan.dart' as scanner; class Scan { static toScan(context, id, tenantCode, storeName, ApiService apiService) async { if (await Permission.camera.isPermanentlyDenied) { showCupertinoDialog( context: context, builder: (context) { return RequestPermission( "assets/image/icon_camera_permission_tips.webp", S.of(context).ninxiangjiquanxianweikaiqi, S.of(context).weilekaipaizhaoxuanzhetouxiang, S.of(context).kaiqiquanxian, (result) async { if (result) { await openAppSettings(); } }, heightRatioWithWidth: 0.82, ); }); } else if (await Permission.camera.isGranted) { var result = await Navigator.of(context).pushNamed('/router/qr_scan'); // String result = await scanner.scan(); if (result != null && result != "") { Uri uri = Uri.parse(result as String); String? table = uri.queryParameters["tableId"]; if (table?.isNotEmpty ?? false) { int? tableId = int.tryParse(table!); String storeId = id ?? ""; miniLogin(apiService, tenantCode, storeId, (token) { Navigator.of(context).pushNamed( '/router/store_order', arguments: { "id": id, "tenant": tenantCode, "storeName": storeName, "tableId": tableId, "miniToken": token, }, ); }); } } } else { await Permission.camera.request(); } } }