Compare commits
3 Commits
b7d847f169
...
5c818643db
| Author | SHA1 | Date |
|---|---|---|
|
|
5c818643db | |
|
|
af41592029 | |
|
|
8ea1190b4c |
|
|
@ -8,7 +8,7 @@ import 'dart:convert';
|
|||
import 'package:flutter/services.dart';
|
||||
import 'package:nfc_manager/platform_tags.dart';
|
||||
import 'services/storage.dart' as storage;
|
||||
import 'services/device_info.dart' as device_info;
|
||||
//import 'services/device_info.dart' as device_info;
|
||||
import 'classes/named_route_args.dart';
|
||||
import 'package:location/location.dart';
|
||||
import 'common_widgets/custom_icon_button.dart';
|
||||
|
|
@ -24,6 +24,8 @@ import 'package:qr_flutter/qr_flutter.dart';
|
|||
import 'package:lite_rolling_switch/lite_rolling_switch.dart';
|
||||
//AutoUpdateApk aua = new AutoUpdateApk(getApplicationContext(), UPDATE_URL);
|
||||
|
||||
|
||||
|
||||
//import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
//import 'package:timezone/data/latest_all.dart' as tz;
|
||||
//import 'package:timezone/timezone.dart' as tz;
|
||||
|
|
@ -38,6 +40,10 @@ class MainPage extends StatefulWidget {
|
|||
class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
||||
String appDomain = "iotechnic.eu";
|
||||
|
||||
|
||||
|
||||
bool isSupported = true;
|
||||
|
||||
bool _showNFClogo = false;
|
||||
bool _reportButtonDisabled = true;
|
||||
final bool _nfcOk = false;
|
||||
|
|
@ -64,13 +70,20 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
|||
WorkStateModel workState=WorkStateModel();
|
||||
late EmployeeArguments ea;
|
||||
EmployeePageArguments employeePageArgs = EmployeePageArguments();
|
||||
device_info.DeviceInfo di=device_info.DeviceInfo();
|
||||
//device_info.DeviceInfo di=device_info.DeviceInfo();
|
||||
//late FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;
|
||||
var deviceData = <String, dynamic>{};
|
||||
//var deviceData = <String, dynamic>{};
|
||||
|
||||
//IMEI
|
||||
String? deviceUUID1;
|
||||
String? deviceUUID2;
|
||||
String? deviceBrand="Mobile";
|
||||
|
||||
|
||||
|
||||
Future ?apiKey ;
|
||||
bool apiKeyValid=false;
|
||||
Map<String, dynamic> _deviceData = <String, dynamic>{};
|
||||
// Map<String, dynamic> _deviceData = <String, dynamic>{};
|
||||
// Location
|
||||
final Location location = Location();
|
||||
bool _loading = false;
|
||||
|
|
@ -171,6 +184,16 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
|||
]);
|
||||
super.dispose();
|
||||
}
|
||||
Future<bool> getDeviceUUID() async{
|
||||
storage.SecureStorage sc= storage.SecureStorage();
|
||||
deviceUUID1= await sc.readSecureData('UUID1');
|
||||
deviceUUID2= await sc.readSecureData('UUID2');
|
||||
if (deviceUUID1!.startsWith("No data found!") || deviceUUID2!.startsWith("No data found!")) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
|
@ -180,26 +203,16 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
|||
DeviceOrientation.portraitUp,
|
||||
DeviceOrientation.portraitDown,
|
||||
]);
|
||||
//tz.initializeTimeZones();
|
||||
//Initialization Settings for Android
|
||||
/* const AndroidInitializationSettings initializationSettingsAndroid =
|
||||
AndroidInitializationSettings('@mipmap/ic_launcher');
|
||||
//InitializationSettings for initializing settings for both platforms (Android & iOS)
|
||||
|
||||
const InitializationSettings initializationSettings =
|
||||
InitializationSettings(
|
||||
android: initializationSettingsAndroid);
|
||||
flutterLocalNotificationsPlugin =
|
||||
FlutterLocalNotificationsPlugin();
|
||||
flutterLocalNotificationsPlugin.initialize(
|
||||
initializationSettings,
|
||||
);*/
|
||||
|
||||
|
||||
di.initPlatformState().then((value)
|
||||
getDeviceUUID().then((value)
|
||||
//di.initPlatformState().then((value)
|
||||
{
|
||||
deviceData = value;
|
||||
|
||||
// deviceData = value;
|
||||
if (value==false) {
|
||||
Navigator.pushNamed(context, '/register', arguments: DeviceArguments(
|
||||
//deviceData['id'], deviceData['device'], deviceData['brand'])).then((value)
|
||||
"", "", ""));
|
||||
}
|
||||
//checkApiKey();
|
||||
//saveApiKey();
|
||||
storage.SecureStorage sc= storage.SecureStorage();
|
||||
|
|
@ -211,7 +224,8 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
|||
if (value==false)
|
||||
{
|
||||
Navigator.pushNamed(context, '/register', arguments: DeviceArguments(
|
||||
deviceData['id'], deviceData['device'], deviceData['brand'])).then((value)
|
||||
//deviceData['id'], deviceData['device'], deviceData['brand'])).then((value)
|
||||
deviceUUID1!, deviceUUID2!, deviceBrand!)).then((value)
|
||||
{
|
||||
Future<String> userApiKey=sc.readSecureData("API");
|
||||
userApiKey.then((apiKey) => checkApiKeyValidity(apiKey).then((apiKeyState) {
|
||||
|
|
@ -304,7 +318,7 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
|||
if (!mounted) return;
|
||||
setState(() {
|
||||
_initOK=true;
|
||||
_deviceData = deviceData;
|
||||
// _deviceData = deviceData;
|
||||
|
||||
});
|
||||
//getWorkState(apiKey as String);
|
||||
|
|
@ -410,8 +424,8 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
|||
|
||||
String indexRequest = '{'
|
||||
'"cmd":"ACCESSNOGEOQR",'
|
||||
'"CID1":"${deviceData['id']}",'
|
||||
'"CID2":"${deviceData['device']} ${deviceData['brand']}",'
|
||||
'"CID1":"$deviceUUID1",' //$"{deviceData['id']}",'
|
||||
'"CID2":"$deviceUUID2 $deviceBrand",' //"${deviceData['device']} ${deviceData['brand']}",'
|
||||
'"address":"$_currentAddress",'
|
||||
'"qrCode":"$qrCode",'
|
||||
'"LAT":"${_currentLocation.latitude}",'
|
||||
|
|
@ -491,8 +505,10 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
|||
|
||||
String indexRequest = '{'
|
||||
'"cmd":"ACCESSNOGEO",'
|
||||
'"CID1":"${deviceData['id']}",'
|
||||
'"CID2":"${deviceData['device']} ${deviceData['brand']}",'
|
||||
// '"CID1":"${deviceData['id']}",'
|
||||
// '"CID2":"${deviceData['device']} ${deviceData['brand']}",'
|
||||
'"CID1":"$deviceUUID1",'
|
||||
'"CID2":"$deviceUUID2 $deviceBrand",'
|
||||
'"address":"$_currentAddress",'
|
||||
'"rfid":"$rfid",'
|
||||
'"LAT":"${_currentLocation.latitude}",'
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import 'services/storage.dart' as storage;
|
|||
import 'dart:convert';
|
||||
import 'classes/named_route_args.dart';
|
||||
//import 'dart:developer';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
class RegisterPage extends StatefulWidget {
|
||||
const RegisterPage({Key? key}) : super(key: key);
|
||||
|
|
@ -17,10 +18,12 @@ class RegisterPage extends StatefulWidget {
|
|||
@override
|
||||
State<RegisterPage> createState() => _RegisterPageState();
|
||||
}
|
||||
|
||||
String appDomain = "iotechnic.eu";
|
||||
class _RegisterPageState extends State<RegisterPage> {
|
||||
final usernameTxtController = TextEditingController();
|
||||
final passwordTxtController = TextEditingController();
|
||||
var uuid = Uuid();
|
||||
//Map<String, dynamic> _deviceData = <String, dynamic>{};
|
||||
// Eszköz regisztráció
|
||||
Future deviceRegistration(String userName, String password) async {
|
||||
|
|
@ -29,13 +32,22 @@ class _RegisterPageState extends State<RegisterPage> {
|
|||
/* _deviceData=
|
||||
ModalRoute.of(context)!.settings.arguments as Map<String,dynamic>;*/
|
||||
final args=ModalRoute.of(context)!.settings.arguments as DeviceArguments;
|
||||
String deviceUUID1= uuid.v1(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a'
|
||||
String deviceUUID2= uuid.v4(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a'
|
||||
|
||||
|
||||
var url = "http://$appDomain/apiRegisterDevice";
|
||||
var report = {
|
||||
/* var report = {
|
||||
'deviceId': args.Id,
|
||||
'username': userName,
|
||||
'password': password,
|
||||
'deviceType': '${args.Name} ${args.Brand}'
|
||||
};*/
|
||||
var report = {
|
||||
'deviceId': deviceUUID1,
|
||||
'username': userName,
|
||||
'password': password,
|
||||
'deviceType': '$deviceUUID2 Mobile'
|
||||
};
|
||||
//log('data: $report');
|
||||
final response = await http.post(
|
||||
|
|
@ -73,6 +85,8 @@ class _RegisterPageState extends State<RegisterPage> {
|
|||
else {
|
||||
EasyLoading.showSuccess(resp['message']);
|
||||
sc.writeSecureData("API", resp['apiKey']);
|
||||
sc.writeSecureData("UUID1", deviceUUID1);
|
||||
sc.writeSecureData("UUID2", deviceUUID2);
|
||||
Future.delayed(const Duration(seconds: 3), () {
|
||||
// Navigator.pop(context); //pop dialog
|
||||
EasyLoading.dismiss();
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
# In Windows, build-name is used as the major, minor, and patch parts
|
||||
# of the product and file versions while build-number is used as the build suffix.
|
||||
version: 1.0.2+1
|
||||
version: 1.0.3+1
|
||||
|
||||
environment:
|
||||
sdk: '>=3.2.0 <4.0.0'
|
||||
|
|
@ -30,7 +30,7 @@ environment:
|
|||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
device_info_plus: ^9.1.1
|
||||
#device_info_plus: ^9.1.1
|
||||
flutter_secure_storage: ^9.0.0
|
||||
http: ^0.13.0
|
||||
flutter_easyloading: ^3.0.3
|
||||
|
|
@ -54,6 +54,8 @@ dependencies:
|
|||
package_info_plus: ^5.0.1
|
||||
qr_flutter: ^4.1.0
|
||||
lite_rolling_switch: ^1.0.1
|
||||
permission_handler: ^11.3.1
|
||||
uuid: ^4.4.2
|
||||
#flutter_local_notifications: ^17.1.2
|
||||
|
||||
dev_dependencies:
|
||||
|
|
|
|||
Loading…
Reference in New Issue