mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-10 19:19:17 +03:30
Fix qr code in of adding labels in add cycles.dart
This commit is contained in:
@@ -1,11 +1,15 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
|
|
||||||
import '../config/urls.dart';
|
import '../config/urls.dart';
|
||||||
import '../config/user.dart';
|
import '../config/user.dart';
|
||||||
import '../models/cycles_models.dart';
|
import '../models/cycles_models.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
|
import '../pages/TestPages/test_filter_screen.dart';
|
||||||
|
|
||||||
class CyclesProvider extends ChangeNotifier {
|
class CyclesProvider extends ChangeNotifier {
|
||||||
List<String> labelVals = [];
|
List<String> labelVals = [];
|
||||||
List<TextEditingController> labelValues = [];
|
List<TextEditingController> labelValues = [];
|
||||||
@@ -41,6 +45,55 @@ class CyclesProvider extends ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isCorrectLabel = false;
|
||||||
|
|
||||||
|
changeLabelValByScan(String value, int index) async {
|
||||||
|
labelVals.forEach((label) {
|
||||||
|
if (label == value) {
|
||||||
|
labelValues[index].text = label;
|
||||||
|
isCorrectLabel = true;
|
||||||
|
}
|
||||||
|
print("label value : $label");
|
||||||
|
});
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
void scanLabel(isEnabled, context, index) async {
|
||||||
|
await scan().then(
|
||||||
|
(String result) async {
|
||||||
|
if (result == 'cancel') {
|
||||||
|
if (index != 0) await removeLabelVal();
|
||||||
|
print('cancel');
|
||||||
|
} else if (result == 'error') {
|
||||||
|
print('error');
|
||||||
|
} else if (result == 'access') {
|
||||||
|
print('access');
|
||||||
|
} else {
|
||||||
|
await changeLabelValByScan(result, index);
|
||||||
|
isEnabled = false;
|
||||||
|
print("currect label : ${isCorrectLabel}");
|
||||||
|
if (isCorrectLabel) {
|
||||||
|
Fluttertoast.showToast(
|
||||||
|
msg: "Label added.",
|
||||||
|
toastLength: Toast.LENGTH_SHORT,
|
||||||
|
gravity: ToastGravity.BOTTOM,
|
||||||
|
);
|
||||||
|
scanLabel(isEnabled, context, index += 1);
|
||||||
|
await addLabelVal();
|
||||||
|
isCorrectLabel = false;
|
||||||
|
} else {
|
||||||
|
Fluttertoast.showToast(
|
||||||
|
msg: "No label exists,try again!",
|
||||||
|
toastLength: Toast.LENGTH_SHORT,
|
||||||
|
gravity: ToastGravity.BOTTOM,
|
||||||
|
);
|
||||||
|
scanLabel(isEnabled, context, index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
String searchBoxValue = '';
|
String searchBoxValue = '';
|
||||||
bool filterOn = false;
|
bool filterOn = false;
|
||||||
List<CycleResultObject>? items;
|
List<CycleResultObject>? items;
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import 'package:cssd/utils/scan.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import '../../../providers/cycles.dart';
|
import '../../../providers/cycles.dart';
|
||||||
|
|
||||||
class AddLabelBox extends StatelessWidget {
|
class AddLabelBox extends StatelessWidget {
|
||||||
@@ -155,22 +153,9 @@ class AddLabelBox extends StatelessWidget {
|
|||||||
Spacer(),
|
Spacer(),
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
scan().then(
|
Provider.of<CyclesProvider>(context,
|
||||||
(String result) {
|
listen: false)
|
||||||
if (result == 'cancel') {
|
.scanLabel(true, context, index);
|
||||||
print('cancel');
|
|
||||||
} else if (result == 'error') {
|
|
||||||
print('error');
|
|
||||||
} else if (result == 'access') {
|
|
||||||
print('access');
|
|
||||||
} else {
|
|
||||||
print(result);
|
|
||||||
Provider.of<CyclesProvider>(context,
|
|
||||||
listen: false)
|
|
||||||
.changeLabelVal(result, index);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.all(8),
|
padding: EdgeInsets.all(8),
|
||||||
|
|||||||
Reference in New Issue
Block a user