Improve Login and Settings

This commit is contained in:
2026-02-01 22:42:00 +01:00
parent 9dc86419e4
commit 9fd0c210ae
11 changed files with 140 additions and 8 deletions

View File

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';
import '../services/authentication_manager.dart';
import '../services/brandmeister_client.dart';
@@ -133,11 +134,39 @@ class _AuthViewState extends State<AuthView> {
const SizedBox(height: 24),
TextButton.icon(
onPressed: () {
// Open BrandMeister website
final url = Uri.parse('https://brandmeister.network/?page=profile-api');
launchUrl(url, mode: LaunchMode.externalApplication);
},
icon: const Icon(Icons.open_in_new),
label: const Text('Get API Token from BrandMeister'),
),
const SizedBox(height: 32),
Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surfaceContainerHighest,
borderRadius: BorderRadius.circular(12),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(
Icons.lock_outline,
size: 20,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
const SizedBox(width: 12),
Expanded(
child: Text(
'Your API token is stored securely in encrypted storage on your device. It is never shared with anyone and is only used to authenticate with the BrandMeister network.',
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
),
],
),
),
],
),
),

View File

@@ -143,6 +143,7 @@ class _DevicesViewState extends State<DevicesView> {
const Divider(),
..._devices.map((device) => _DeviceRow(
device: device,
baseRadioId: _devices.isNotEmpty ? _devices.first.id : null,
onTap: () {
Navigator.push(
context,
@@ -159,19 +160,43 @@ class _DevicesViewState extends State<DevicesView> {
class _DeviceRow extends StatelessWidget {
final Device device;
final int? baseRadioId;
final VoidCallback onTap;
const _DeviceRow({
required this.device,
required this.onTap,
this.baseRadioId,
});
String? get _deviceExtension {
if (baseRadioId == null) return null;
final baseStr = baseRadioId.toString();
final idStr = device.id.toString();
// Check if device ID starts with the base radio ID
if (idStr.startsWith(baseStr)) {
final extension = idStr.substring(baseStr.length);
return extension.isNotEmpty ? extension : '0';
}
return null;
}
@override
Widget build(BuildContext context) {
final extension = _deviceExtension;
final showExtension = extension != null && extension != '0';
return ListTile(
leading: CircleAvatar(
backgroundColor: Theme.of(context).colorScheme.primaryContainer,
child: Icon(
child: showExtension
? Text(
extension,
style: TextStyle(
fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.onPrimaryContainer,
),
)
: Icon(
Icons.settings_input_antenna,
color: Theme.of(context).colorScheme.onPrimaryContainer,
),

View File

@@ -37,8 +37,8 @@ class _MainViewState extends State<MainView> {
label: 'Last Activity',
),
BottomNavigationBarItem(
icon: Icon(Icons.more_horiz),
label: 'More',
icon: Icon(Icons.settings),
label: 'Settings',
),
],
),

View File

@@ -11,7 +11,7 @@ class MoreView extends StatelessWidget {
return Scaffold(
appBar: AppBar(
title: const Text('More'),
title: const Text('Settings'),
),
body: ListView(
children: [

View File

@@ -7,9 +7,13 @@
#include "generated_plugin_registrant.h"
#include <flutter_secure_storage_linux/flutter_secure_storage_linux_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin");
flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar);
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
}

View File

@@ -4,6 +4,7 @@
list(APPEND FLUTTER_PLUGIN_LIST
flutter_secure_storage_linux
url_launcher_linux
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST

View File

@@ -6,7 +6,9 @@ import FlutterMacOS
import Foundation
import flutter_secure_storage_macos
import url_launcher_macos
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
}

View File

@@ -509,6 +509,70 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.4.0"
url_launcher:
dependency: "direct main"
description:
name: url_launcher
sha256: f6a7e5c4835bb4e3026a04793a4199ca2d14c739ec378fdfe23fc8075d0439f8
url: "https://pub.dev"
source: hosted
version: "6.3.2"
url_launcher_android:
dependency: transitive
description:
name: url_launcher_android
sha256: "767344bf3063897b5cf0db830e94f904528e6dd50a6dfaf839f0abf509009611"
url: "https://pub.dev"
source: hosted
version: "6.3.28"
url_launcher_ios:
dependency: transitive
description:
name: url_launcher_ios
sha256: cfde38aa257dae62ffe79c87fab20165dfdf6988c1d31b58ebf59b9106062aad
url: "https://pub.dev"
source: hosted
version: "6.3.6"
url_launcher_linux:
dependency: transitive
description:
name: url_launcher_linux
sha256: d5e14138b3bc193a0f63c10a53c94b91d399df0512b1f29b94a043db7482384a
url: "https://pub.dev"
source: hosted
version: "3.2.2"
url_launcher_macos:
dependency: transitive
description:
name: url_launcher_macos
sha256: "368adf46f71ad3c21b8f06614adb38346f193f3a59ba8fe9a2fd74133070ba18"
url: "https://pub.dev"
source: hosted
version: "3.2.5"
url_launcher_platform_interface:
dependency: transitive
description:
name: url_launcher_platform_interface
sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029"
url: "https://pub.dev"
source: hosted
version: "2.3.2"
url_launcher_web:
dependency: transitive
description:
name: url_launcher_web
sha256: d0412fcf4c6b31ecfdb7762359b7206ffba3bbffd396c6d9f9c4616ece476c1f
url: "https://pub.dev"
source: hosted
version: "2.4.2"
url_launcher_windows:
dependency: transitive
description:
name: url_launcher_windows
sha256: "712c70ab1b99744ff066053cbe3e80c73332b38d46e5e945c98689b2e66fc15f"
url: "https://pub.dev"
source: hosted
version: "3.1.5"
vector_math:
dependency: transitive
description:

View File

@@ -47,6 +47,9 @@ dependencies:
# WebSocket client for real-time updates
web_socket_channel: ^3.0.1
# URL launcher for opening external links
url_launcher: ^6.2.0
dev_dependencies:
flutter_test:
sdk: flutter

View File

@@ -7,8 +7,11 @@
#include "generated_plugin_registrant.h"
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
#include <url_launcher_windows/url_launcher_windows.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
UrlLauncherWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
}

View File

@@ -4,6 +4,7 @@
list(APPEND FLUTTER_PLUGIN_LIST
flutter_secure_storage_windows
url_launcher_windows
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST