Skip to content

Commit

Permalink
fix for onboarding issue #300
Browse files Browse the repository at this point in the history
  • Loading branch information
murali-shris committed Dec 21, 2021
1 parent 8211b4a commit 94f89f7
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 23 deletions.
3 changes: 3 additions & 0 deletions at_onboarding_flutter/CHANGELOG.md
@@ -1,3 +1,6 @@
## 3.1.2
- Fixed at_client dependency issue
- Fixed lint errors
## 3.1.1
- Update a dependency to the latest release.

Expand Down
16 changes: 9 additions & 7 deletions at_onboarding_flutter/lib/screens/pair_atsign.dart
Expand Up @@ -406,19 +406,20 @@ class _PairAtsignWidgetState extends State<PairAtsignWidget> {
try {
_isServerCheck = false;
_isContinue = true;
// ignore: always_specify_types
var fileContents, aesKey, atsign;
setState(() {
loading = true;
});

// ignore: always_specify_types
var path = await _desktopKeyPicker();

if (path == null) {
return;
}

File selectedFile = File(path);
var length = selectedFile.lengthSync();
int length = selectedFile.lengthSync();
if (length < 10) {
_showAlertDialog(_incorrectKeyFile);
return;
Expand Down Expand Up @@ -465,25 +466,26 @@ class _PairAtsignWidgetState extends State<PairAtsignWidget> {

Future<dynamic> _desktopKeyPicker() async {
try {
// ignore: omit_local_variable_types
final XTypeGroup typeGroup = XTypeGroup(
XTypeGroup typeGroup = XTypeGroup(
label: 'images',
// ignore: always_specify_types
extensions: ['atKeys'],
);
final List<XFile> files =
List<XFile> files =
// ignore: always_specify_types
await openFiles(acceptedTypeGroups: [typeGroup]);
if (files.isEmpty) {
return null;
}
// ignore: omit_local_variable_types
final XFile file = files[0];
XFile file = files[0];
return file.path;
} catch (e) {
print('Error in desktopImagePicker $e');
return null;
}
}

// ignore: always_declare_return_types, always_specify_types
_showAlertDialog(var errorMessage,
{bool? isPkam, String? title, bool? getClose, Function? onClose}) {
showDialog(
Expand Down
2 changes: 1 addition & 1 deletion at_onboarding_flutter/lib/services/onboarding_service.dart
Expand Up @@ -213,7 +213,7 @@ class OnboardingService {

Future<void> _sync(String? atSign) async {
// ignore: deprecated_member_use
if (_atClientPreference.syncStrategy == SyncStrategy.ONDEMAND) {
if (_atClientPreference.syncStrategy == SyncStrategy.onDemand) {
_getClientServiceForAtsign(atSign)!.atClientManager.syncService.sync();
}
}
Expand Down
24 changes: 12 additions & 12 deletions at_onboarding_flutter/lib/widgets/custom_dialog.dart
@@ -1,7 +1,6 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:typed_data';

import 'package:at_client_mobile/at_client_mobile.dart';
import 'package:at_onboarding_flutter/screens/atsign_list_screen.dart';
Expand Down Expand Up @@ -1248,11 +1247,13 @@ class _CustomDialogState extends State<CustomDialog> {
void _uploadQRFileForDesktop(
BuildContext context, dynamic processAESKey) async {
try {
// ignore: always_specify_types
var fileContents, aesKey, atsign;
setState(() {
loading = true;
});

// ignore: always_specify_types
var path = await _desktopKeyPicker();
print(path);
if (path == null) {
Expand All @@ -1264,20 +1265,20 @@ class _CustomDialogState extends State<CustomDialog> {

File selectedFile = File(path);

var length = selectedFile.lengthSync();
int length = selectedFile.lengthSync();
if (length < 10) {
showErrorDialog(context, 'Incorrect QR file');
return;
}

var image = img.decodePng(selectedFile.readAsBytesSync())!;
img.Image image = img.decodePng(selectedFile.readAsBytesSync())!;

LuminanceSource source = RGBLuminanceSource(image.width, image.height,
image.getBytes(format: img.Format.abgr).buffer.asInt32List());
var bitmap = BinaryBitmap(HybridBinarizer(source));
BinaryBitmap bitmap = BinaryBitmap(HybridBinarizer(source));

var reader = QRCodeReader();
var result = reader.decode(bitmap);
QRCodeReader reader = QRCodeReader();
Result result = reader.decode(bitmap);
List<String> params = result.text.replaceAll('"', '').split(':');
atsign = params[0];
aesKey = params[1];
Expand All @@ -1304,18 +1305,17 @@ class _CustomDialogState extends State<CustomDialog> {

Future<dynamic> _desktopKeyPicker() async {
try {
// ignore: omit_local_variable_types
final XTypeGroup typeGroup = XTypeGroup(
XTypeGroup typeGroup = XTypeGroup(
label: 'images',
// ignore: always_specify_types
extensions: ['png'],
);
final List<XFile> files =
await openFiles(acceptedTypeGroups: [typeGroup]);
// ignore: always_specify_types
List<XFile> files = await openFiles(acceptedTypeGroups: [typeGroup]);
if (files.isEmpty) {
return null;
}
// ignore: omit_local_variable_types
final XFile file = files[0];
XFile file = files[0];
return file.path;
} catch (e) {
print('Error in desktopImagePicker $e');
Expand Down
6 changes: 3 additions & 3 deletions at_onboarding_flutter/pubspec.yaml
Expand Up @@ -2,7 +2,7 @@ name: at_onboarding_flutter
description: A Flutter plugin project for onboarding any @‎sign in @‎platform
apps with ease. Provides a QRscanner option and an upload key file option to
authenticate.
version: 3.1.1
version: 3.1.2
homepage: https://atsign.dev
repository: https://github.com/atsign-foundation/at_widgets/tree/trunk/at_onboarding_flutter
issue_tracker: https://github.com/atsign-foundation/at_widgets/issues
Expand Down Expand Up @@ -35,8 +35,8 @@ dependencies:
file_selector_linux: ^0.0.2+1

at_backupkey_flutter: ^3.1.1
at_client: ^3.0.6
at_client_mobile: ^3.1.2
at_client: ^3.0.7
at_client_mobile: ^3.1.3
at_commons: ^3.0.2
at_server_status: ^1.0.3
at_utils: ^3.0.2
Expand Down

0 comments on commit 94f89f7

Please sign in to comment.