Token management, Factory reset, UX/UI Improvements
This commit is contained in:
+21
-19
@@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:liteauthconfig/models/appconfig.dart';
|
||||
import 'package:liteauthconfig/dialogs/esptouchdialog.dart';
|
||||
import 'package:liteauthconfig/l10n/app_localizations.dart';
|
||||
import 'package:multicast_dns/multicast_dns.dart';
|
||||
import 'package:network_info_plus/network_info_plus.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
@@ -44,7 +43,7 @@ class _RegisterPageState extends State<RegisterPage> {
|
||||
var appLocal = AppLocalizations.of(context)!;
|
||||
var appTheme = Theme.of(context);
|
||||
|
||||
if (await Permission.location.isDenied) {
|
||||
if ((Platform.isAndroid || Platform.isIOS) && await Permission.location.isDenied) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog.adaptive(
|
||||
@@ -70,7 +69,7 @@ class _RegisterPageState extends State<RegisterPage> {
|
||||
],
|
||||
),
|
||||
);
|
||||
} else if (await Permission.location.isGranted) {
|
||||
} else if (!(Platform.isAndroid || Platform.isIOS) || await Permission.location.isGranted) {
|
||||
fetchNetworkInfo();
|
||||
}
|
||||
}
|
||||
@@ -95,12 +94,29 @@ class _RegisterPageState extends State<RegisterPage> {
|
||||
}
|
||||
|
||||
void submit() async {
|
||||
var appLocal = AppLocalizations.of(context)!;
|
||||
var name = nameController.text.isEmpty ? ssidController.text : nameController.text;
|
||||
|
||||
if (ssidController.text.isEmpty) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(
|
||||
appLocal.cannotBeEmpty("SSID")
|
||||
),));
|
||||
return;
|
||||
}
|
||||
|
||||
if (bssidController.text.isEmpty) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(
|
||||
appLocal.cannotBeEmpty("BSSID")
|
||||
),));
|
||||
return;
|
||||
}
|
||||
|
||||
if (widget.setup) {
|
||||
await showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => ESPTouchDialog(
|
||||
name: nameController.text,
|
||||
name: name,
|
||||
ssid: ssidController.text,
|
||||
bssid: bssidController.text,
|
||||
password: passwordController.text,
|
||||
@@ -109,26 +125,12 @@ class _RegisterPageState extends State<RegisterPage> {
|
||||
);
|
||||
} else {
|
||||
final dev = Device(
|
||||
name: nameController.text,
|
||||
name: name,
|
||||
routerSsid: ssidController.text,
|
||||
routerBssid: bssidController.text,
|
||||
networkPassword: passwordController.text,
|
||||
);
|
||||
|
||||
final MDnsClient client = MDnsClient();
|
||||
await client.start();
|
||||
|
||||
// TODO: Change to dynamic mDNS name
|
||||
String name = "liteauth.local";
|
||||
|
||||
await for (final PtrResourceRecord ptr
|
||||
in client.lookup<PtrResourceRecord>(
|
||||
ResourceRecordQuery.serverPointer(name),
|
||||
)) {
|
||||
await for (final SrvResourceRecord srv in client.lookup(ResourceRecordQuery.service(ptr.domainName))) {
|
||||
// TODO: Actually implement record lookup
|
||||
}
|
||||
}
|
||||
AppConfig().devices.add(dev);
|
||||
}
|
||||
if (context.mounted) {
|
||||
|
||||
Reference in New Issue
Block a user