Improve Login and Settings
This commit is contained in:
@@ -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,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -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,22 +160,46 @@ 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(
|
||||
Icons.settings_input_antenna,
|
||||
color: Theme.of(context).colorScheme.onPrimaryContainer,
|
||||
),
|
||||
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,
|
||||
),
|
||||
),
|
||||
title: Text(device.callsign ?? 'Unknown'),
|
||||
subtitle: Column(
|
||||
|
||||
@@ -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',
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -11,7 +11,7 @@ class MoreView extends StatelessWidget {
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('More'),
|
||||
title: const Text('Settings'),
|
||||
),
|
||||
body: ListView(
|
||||
children: [
|
||||
|
||||
Reference in New Issue
Block a user