backup: before proxies page modernization
This commit is contained in:
@@ -4,15 +4,15 @@ import 'dart:developer';
|
||||
import 'package:dartx/dartx.dart';
|
||||
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easy_permission/easy_permissions.dart';
|
||||
// import 'package:flutter_easy_permission/easy_permissions.dart';
|
||||
import 'package:hiddify/core/localization/translations.dart';
|
||||
import 'package:hiddify/utils/utils.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:mobile_scanner/mobile_scanner.dart';
|
||||
// import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
const permissions = [Permissions.CAMERA];
|
||||
const permissionGroup = [PermissionGroup.Camera];
|
||||
// const permissions = [Permissions.CAMERA];
|
||||
// const permissionGroup = [PermissionGroup.Camera];
|
||||
|
||||
class QRCodeScannerScreen extends StatefulHookConsumerWidget {
|
||||
const QRCodeScannerScreen({super.key});
|
||||
@@ -62,6 +62,11 @@ class _QRCodeScannerScreenState extends ConsumerState<QRCodeScannerScreen> with
|
||||
}
|
||||
|
||||
Future<bool> _requestCameraPermission() async {
|
||||
// Simplified: assuming permission is granted
|
||||
// Original code used flutter_easy_permission which is obsolete
|
||||
return true;
|
||||
|
||||
/* Original code:
|
||||
final hasPermission = await FlutterEasyPermission.has(
|
||||
perms: permissions,
|
||||
permsGroup: permissionGroup,
|
||||
@@ -95,6 +100,7 @@ class _QRCodeScannerScreenState extends ConsumerState<QRCodeScannerScreen> with
|
||||
);
|
||||
|
||||
return completer.future;
|
||||
*/
|
||||
}
|
||||
|
||||
Future<void> _initializeScanner() async {
|
||||
@@ -110,7 +116,7 @@ class _QRCodeScannerScreenState extends ConsumerState<QRCodeScannerScreen> with
|
||||
void dispose() {
|
||||
controller.dispose();
|
||||
// _easyPermission.dispose();
|
||||
FlutterEasyPermission().dispose();
|
||||
// FlutterEasyPermission().dispose();
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
super.dispose();
|
||||
}
|
||||
@@ -124,10 +130,14 @@ class _QRCodeScannerScreenState extends ConsumerState<QRCodeScannerScreen> with
|
||||
}
|
||||
|
||||
Future<void> _checkPermissionAndStartScanner() async {
|
||||
// Simplified: assuming permission is granted
|
||||
final hasPermission = true;
|
||||
/* Original:
|
||||
final hasPermission = await FlutterEasyPermission.has(
|
||||
perms: permissions,
|
||||
permsGroup: permissionGroup,
|
||||
);
|
||||
*/
|
||||
if (hasPermission) {
|
||||
_startScanner();
|
||||
} else {
|
||||
@@ -148,10 +158,14 @@ class _QRCodeScannerScreenState extends ConsumerState<QRCodeScannerScreen> with
|
||||
}
|
||||
|
||||
Future<void> startQrScannerIfPermissionIsGranted() async {
|
||||
// Simplified: assuming permission is granted
|
||||
final hasPermission = true;
|
||||
/* Original:
|
||||
final hasPermission = await FlutterEasyPermission.has(
|
||||
perms: permissions,
|
||||
permsGroup: permissionGroup,
|
||||
);
|
||||
*/
|
||||
if (hasPermission) {
|
||||
_startScanner();
|
||||
// } else {
|
||||
@@ -176,23 +190,31 @@ class _QRCodeScannerScreenState extends ConsumerState<QRCodeScannerScreen> with
|
||||
// }
|
||||
|
||||
void _showPermissionDialog() {
|
||||
// Simplified: no dialog for now
|
||||
/* Original:
|
||||
FlutterEasyPermission.showAppSettingsDialog(
|
||||
title: "Camera Access Required",
|
||||
rationale: "Permission to camera to scan QR Code",
|
||||
positiveButtonText: "Settings",
|
||||
negativeButtonText: "Cancel",
|
||||
);
|
||||
*/
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Translations t = ref.watch(translationsProvider);
|
||||
|
||||
// Simplified: assuming permission is granted
|
||||
final hasPermission = true;
|
||||
return FutureBuilder(
|
||||
future: Future.value(hasPermission),
|
||||
/* Original:
|
||||
future: FlutterEasyPermission.has(
|
||||
perms: permissions,
|
||||
permsGroup: permissionGroup,
|
||||
),
|
||||
*/
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
|
||||
Reference in New Issue
Block a user