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:flutter/services.dart';
|
||||||
import 'package:nfc_manager/platform_tags.dart';
|
import 'package:nfc_manager/platform_tags.dart';
|
||||||
import 'services/storage.dart' as storage;
|
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 'classes/named_route_args.dart';
|
||||||
import 'package:location/location.dart';
|
import 'package:location/location.dart';
|
||||||
import 'common_widgets/custom_icon_button.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';
|
import 'package:lite_rolling_switch/lite_rolling_switch.dart';
|
||||||
//AutoUpdateApk aua = new AutoUpdateApk(getApplicationContext(), UPDATE_URL);
|
//AutoUpdateApk aua = new AutoUpdateApk(getApplicationContext(), UPDATE_URL);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
//import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||||
//import 'package:timezone/data/latest_all.dart' as tz;
|
//import 'package:timezone/data/latest_all.dart' as tz;
|
||||||
//import 'package:timezone/timezone.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{
|
class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
||||||
String appDomain = "iotechnic.eu";
|
String appDomain = "iotechnic.eu";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool isSupported = true;
|
||||||
|
|
||||||
bool _showNFClogo = false;
|
bool _showNFClogo = false;
|
||||||
bool _reportButtonDisabled = true;
|
bool _reportButtonDisabled = true;
|
||||||
final bool _nfcOk = false;
|
final bool _nfcOk = false;
|
||||||
|
|
@ -64,13 +70,20 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
||||||
WorkStateModel workState=WorkStateModel();
|
WorkStateModel workState=WorkStateModel();
|
||||||
late EmployeeArguments ea;
|
late EmployeeArguments ea;
|
||||||
EmployeePageArguments employeePageArgs = EmployeePageArguments();
|
EmployeePageArguments employeePageArgs = EmployeePageArguments();
|
||||||
device_info.DeviceInfo di=device_info.DeviceInfo();
|
//device_info.DeviceInfo di=device_info.DeviceInfo();
|
||||||
//late FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;
|
//late FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;
|
||||||
var deviceData = <String, dynamic>{};
|
//var deviceData = <String, dynamic>{};
|
||||||
|
|
||||||
|
//IMEI
|
||||||
|
String? deviceUUID1;
|
||||||
|
String? deviceUUID2;
|
||||||
|
String? deviceBrand="Mobile";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Future ?apiKey ;
|
Future ?apiKey ;
|
||||||
bool apiKeyValid=false;
|
bool apiKeyValid=false;
|
||||||
Map<String, dynamic> _deviceData = <String, dynamic>{};
|
// Map<String, dynamic> _deviceData = <String, dynamic>{};
|
||||||
// Location
|
// Location
|
||||||
final Location location = Location();
|
final Location location = Location();
|
||||||
bool _loading = false;
|
bool _loading = false;
|
||||||
|
|
@ -171,6 +184,16 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
||||||
]);
|
]);
|
||||||
super.dispose();
|
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
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
|
@ -180,26 +203,16 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
||||||
DeviceOrientation.portraitUp,
|
DeviceOrientation.portraitUp,
|
||||||
DeviceOrientation.portraitDown,
|
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 =
|
getDeviceUUID().then((value)
|
||||||
InitializationSettings(
|
//di.initPlatformState().then((value)
|
||||||
android: initializationSettingsAndroid);
|
|
||||||
flutterLocalNotificationsPlugin =
|
|
||||||
FlutterLocalNotificationsPlugin();
|
|
||||||
flutterLocalNotificationsPlugin.initialize(
|
|
||||||
initializationSettings,
|
|
||||||
);*/
|
|
||||||
|
|
||||||
|
|
||||||
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();
|
//checkApiKey();
|
||||||
//saveApiKey();
|
//saveApiKey();
|
||||||
storage.SecureStorage sc= storage.SecureStorage();
|
storage.SecureStorage sc= storage.SecureStorage();
|
||||||
|
|
@ -211,7 +224,8 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
||||||
if (value==false)
|
if (value==false)
|
||||||
{
|
{
|
||||||
Navigator.pushNamed(context, '/register', arguments: DeviceArguments(
|
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");
|
Future<String> userApiKey=sc.readSecureData("API");
|
||||||
userApiKey.then((apiKey) => checkApiKeyValidity(apiKey).then((apiKeyState) {
|
userApiKey.then((apiKey) => checkApiKeyValidity(apiKey).then((apiKeyState) {
|
||||||
|
|
@ -304,7 +318,7 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
_initOK=true;
|
_initOK=true;
|
||||||
_deviceData = deviceData;
|
// _deviceData = deviceData;
|
||||||
|
|
||||||
});
|
});
|
||||||
//getWorkState(apiKey as String);
|
//getWorkState(apiKey as String);
|
||||||
|
|
@ -410,8 +424,8 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
||||||
|
|
||||||
String indexRequest = '{'
|
String indexRequest = '{'
|
||||||
'"cmd":"ACCESSNOGEOQR",'
|
'"cmd":"ACCESSNOGEOQR",'
|
||||||
'"CID1":"${deviceData['id']}",'
|
'"CID1":"$deviceUUID1",' //$"{deviceData['id']}",'
|
||||||
'"CID2":"${deviceData['device']} ${deviceData['brand']}",'
|
'"CID2":"$deviceUUID2 $deviceBrand",' //"${deviceData['device']} ${deviceData['brand']}",'
|
||||||
'"address":"$_currentAddress",'
|
'"address":"$_currentAddress",'
|
||||||
'"qrCode":"$qrCode",'
|
'"qrCode":"$qrCode",'
|
||||||
'"LAT":"${_currentLocation.latitude}",'
|
'"LAT":"${_currentLocation.latitude}",'
|
||||||
|
|
@ -491,8 +505,10 @@ class _MainPageState extends State<MainPage> with TickerProviderStateMixin{
|
||||||
|
|
||||||
String indexRequest = '{'
|
String indexRequest = '{'
|
||||||
'"cmd":"ACCESSNOGEO",'
|
'"cmd":"ACCESSNOGEO",'
|
||||||
'"CID1":"${deviceData['id']}",'
|
// '"CID1":"${deviceData['id']}",'
|
||||||
'"CID2":"${deviceData['device']} ${deviceData['brand']}",'
|
// '"CID2":"${deviceData['device']} ${deviceData['brand']}",'
|
||||||
|
'"CID1":"$deviceUUID1",'
|
||||||
|
'"CID2":"$deviceUUID2 $deviceBrand",'
|
||||||
'"address":"$_currentAddress",'
|
'"address":"$_currentAddress",'
|
||||||
'"rfid":"$rfid",'
|
'"rfid":"$rfid",'
|
||||||
'"LAT":"${_currentLocation.latitude}",'
|
'"LAT":"${_currentLocation.latitude}",'
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import 'services/storage.dart' as storage;
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'classes/named_route_args.dart';
|
import 'classes/named_route_args.dart';
|
||||||
//import 'dart:developer';
|
//import 'dart:developer';
|
||||||
|
import 'package:uuid/uuid.dart';
|
||||||
|
|
||||||
class RegisterPage extends StatefulWidget {
|
class RegisterPage extends StatefulWidget {
|
||||||
const RegisterPage({Key? key}) : super(key: key);
|
const RegisterPage({Key? key}) : super(key: key);
|
||||||
|
|
@ -17,10 +18,12 @@ class RegisterPage extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
State<RegisterPage> createState() => _RegisterPageState();
|
State<RegisterPage> createState() => _RegisterPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
String appDomain = "iotechnic.eu";
|
String appDomain = "iotechnic.eu";
|
||||||
class _RegisterPageState extends State<RegisterPage> {
|
class _RegisterPageState extends State<RegisterPage> {
|
||||||
final usernameTxtController = TextEditingController();
|
final usernameTxtController = TextEditingController();
|
||||||
final passwordTxtController = TextEditingController();
|
final passwordTxtController = TextEditingController();
|
||||||
|
var uuid = Uuid();
|
||||||
//Map<String, dynamic> _deviceData = <String, dynamic>{};
|
//Map<String, dynamic> _deviceData = <String, dynamic>{};
|
||||||
// Eszköz regisztráció
|
// Eszköz regisztráció
|
||||||
Future deviceRegistration(String userName, String password) async {
|
Future deviceRegistration(String userName, String password) async {
|
||||||
|
|
@ -29,13 +32,22 @@ class _RegisterPageState extends State<RegisterPage> {
|
||||||
/* _deviceData=
|
/* _deviceData=
|
||||||
ModalRoute.of(context)!.settings.arguments as Map<String,dynamic>;*/
|
ModalRoute.of(context)!.settings.arguments as Map<String,dynamic>;*/
|
||||||
final args=ModalRoute.of(context)!.settings.arguments as DeviceArguments;
|
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 url = "http://$appDomain/apiRegisterDevice";
|
||||||
var report = {
|
/* var report = {
|
||||||
'deviceId': args.Id,
|
'deviceId': args.Id,
|
||||||
'username': userName,
|
'username': userName,
|
||||||
'password': password,
|
'password': password,
|
||||||
'deviceType': '${args.Name} ${args.Brand}'
|
'deviceType': '${args.Name} ${args.Brand}'
|
||||||
|
};*/
|
||||||
|
var report = {
|
||||||
|
'deviceId': deviceUUID1,
|
||||||
|
'username': userName,
|
||||||
|
'password': password,
|
||||||
|
'deviceType': '$deviceUUID2 Mobile'
|
||||||
};
|
};
|
||||||
//log('data: $report');
|
//log('data: $report');
|
||||||
final response = await http.post(
|
final response = await http.post(
|
||||||
|
|
@ -73,6 +85,8 @@ class _RegisterPageState extends State<RegisterPage> {
|
||||||
else {
|
else {
|
||||||
EasyLoading.showSuccess(resp['message']);
|
EasyLoading.showSuccess(resp['message']);
|
||||||
sc.writeSecureData("API", resp['apiKey']);
|
sc.writeSecureData("API", resp['apiKey']);
|
||||||
|
sc.writeSecureData("UUID1", deviceUUID1);
|
||||||
|
sc.writeSecureData("UUID2", deviceUUID2);
|
||||||
Future.delayed(const Duration(seconds: 3), () {
|
Future.delayed(const Duration(seconds: 3), () {
|
||||||
// Navigator.pop(context); //pop dialog
|
// Navigator.pop(context); //pop dialog
|
||||||
EasyLoading.dismiss();
|
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
|
# 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
|
# 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.
|
# 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:
|
environment:
|
||||||
sdk: '>=3.2.0 <4.0.0'
|
sdk: '>=3.2.0 <4.0.0'
|
||||||
|
|
@ -30,7 +30,7 @@ environment:
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
device_info_plus: ^9.1.1
|
#device_info_plus: ^9.1.1
|
||||||
flutter_secure_storage: ^9.0.0
|
flutter_secure_storage: ^9.0.0
|
||||||
http: ^0.13.0
|
http: ^0.13.0
|
||||||
flutter_easyloading: ^3.0.3
|
flutter_easyloading: ^3.0.3
|
||||||
|
|
@ -54,6 +54,8 @@ dependencies:
|
||||||
package_info_plus: ^5.0.1
|
package_info_plus: ^5.0.1
|
||||||
qr_flutter: ^4.1.0
|
qr_flutter: ^4.1.0
|
||||||
lite_rolling_switch: ^1.0.1
|
lite_rolling_switch: ^1.0.1
|
||||||
|
permission_handler: ^11.3.1
|
||||||
|
uuid: ^4.4.2
|
||||||
#flutter_local_notifications: ^17.1.2
|
#flutter_local_notifications: ^17.1.2
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue