feat: reformat some pages
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../l10n/app_localizations.dart';
|
||||
import '../l10n/app_localizations_helpers.dart';
|
||||
import '../models/remote_command.dart';
|
||||
import '../utils/navigation.dart';
|
||||
import '../viewmodels/admin_pin_view_model.dart';
|
||||
@@ -42,7 +43,10 @@ class AdminScreenView extends StatelessWidget {
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () => Navigator.pop(ctx, true),
|
||||
style: FilledButton.styleFrom(backgroundColor: Colors.red),
|
||||
style: FilledButton.styleFrom(
|
||||
backgroundColor: Theme.of(ctx).colorScheme.error,
|
||||
foregroundColor: Theme.of(ctx).colorScheme.onError,
|
||||
),
|
||||
child: Text(l10n.disconnect),
|
||||
),
|
||||
],
|
||||
@@ -58,6 +62,8 @@ class AdminScreenView extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final remoteSync = context.watch<RemoteSyncViewModel>();
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final locale = Localizations.localeOf(context).toLanguageTag();
|
||||
|
||||
return PopScope(
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
@@ -115,11 +121,16 @@ class AdminScreenView extends StatelessWidget {
|
||||
if (remoteSync.isConfigured) ...[
|
||||
_AdminTile(
|
||||
icon: Icons.cloud_done_outlined,
|
||||
iconColor: scheme.primary,
|
||||
title: l10n.connected,
|
||||
subtitle: l10n.deviceLinked,
|
||||
subtitle: remoteSync.venueName != null
|
||||
? l10n.deviceLinkedToVenue(remoteSync.venueName!)
|
||||
: l10n.deviceLinked,
|
||||
trailing: TextButton(
|
||||
onPressed: () => _confirmUnlink(context),
|
||||
style: TextButton.styleFrom(foregroundColor: Colors.red),
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: scheme.error,
|
||||
),
|
||||
child: Text(l10n.disconnect),
|
||||
),
|
||||
onTap: null,
|
||||
@@ -129,6 +140,7 @@ class AdminScreenView extends StatelessWidget {
|
||||
icon: remoteSync.wasRevoked
|
||||
? Icons.cloud_off_rounded
|
||||
: Icons.cloud_outlined,
|
||||
iconColor: remoteSync.wasRevoked ? scheme.error : null,
|
||||
title: l10n.notConnected,
|
||||
subtitle: remoteSync.wasRevoked
|
||||
? l10n.deviceAccessRevoked
|
||||
@@ -149,10 +161,7 @@ class AdminScreenView extends StatelessWidget {
|
||||
? l10n.syncing
|
||||
: remoteSync.lastSyncAt != null
|
||||
? l10n.lastSync(
|
||||
remoteSync.lastSyncAt!
|
||||
.toLocal()
|
||||
.toString()
|
||||
.substring(0, 19),
|
||||
l10n.relativeTime(remoteSync.lastSyncAt!, locale),
|
||||
)
|
||||
: l10n.notSyncedYet,
|
||||
trailing: remoteSync.isSyncing
|
||||
@@ -169,25 +178,29 @@ class AdminScreenView extends StatelessWidget {
|
||||
if (remoteSync.activity.isNotEmpty)
|
||||
_AdminSection(
|
||||
title: l10n.remoteActivityHistory,
|
||||
children: remoteSync.activity.map((entry) {
|
||||
return ListTile(
|
||||
dense: true,
|
||||
leading: Icon(switch (entry.result) {
|
||||
CommandResult.completed => Icons.check_circle_outline,
|
||||
CommandResult.conflict => Icons.warning_amber_outlined,
|
||||
CommandResult.failed ||
|
||||
CommandResult.expired => Icons.error_outline,
|
||||
}, size: 20),
|
||||
title: Text(
|
||||
'${entry.commandType} (${entry.commandId.substring(0, 8)}...)',
|
||||
style: const TextStyle(fontSize: 13),
|
||||
children: [
|
||||
for (final entry in remoteSync.activity)
|
||||
_AdminTile(
|
||||
icon: switch (entry.result) {
|
||||
CommandResult.completed => Icons.check_circle_outline,
|
||||
CommandResult.conflict =>
|
||||
Icons.warning_amber_outlined,
|
||||
CommandResult.failed ||
|
||||
CommandResult.expired => Icons.error_outline,
|
||||
},
|
||||
iconColor: switch (entry.result) {
|
||||
CommandResult.completed => scheme.primary,
|
||||
CommandResult.conflict => scheme.tertiary,
|
||||
CommandResult.failed ||
|
||||
CommandResult.expired => scheme.error,
|
||||
},
|
||||
title: l10n.remoteCommandLabel(entry.commandType),
|
||||
subtitle:
|
||||
'${l10n.commandResultLabel(entry.result)} · '
|
||||
'${l10n.relativeTime(entry.processedAt, locale)}',
|
||||
onTap: null,
|
||||
),
|
||||
subtitle: Text(
|
||||
'${entry.processedAt.toLocal()} - ${entry.result.name}',
|
||||
style: const TextStyle(fontSize: 11),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
@@ -241,6 +254,7 @@ class _AdminSection extends StatelessWidget {
|
||||
|
||||
class _AdminTile extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final Color? iconColor;
|
||||
final String title;
|
||||
final String? subtitle;
|
||||
final Widget? trailing;
|
||||
@@ -248,6 +262,7 @@ class _AdminTile extends StatelessWidget {
|
||||
|
||||
const _AdminTile({
|
||||
required this.icon,
|
||||
this.iconColor,
|
||||
required this.title,
|
||||
this.subtitle,
|
||||
this.trailing,
|
||||
@@ -269,7 +284,7 @@ class _AdminTile extends StatelessWidget {
|
||||
Icon(
|
||||
icon,
|
||||
size: 22,
|
||||
color: scheme.onSurface.withValues(alpha: 0.7),
|
||||
color: iconColor ?? scheme.onSurface.withValues(alpha: 0.7),
|
||||
),
|
||||
const SizedBox(width: 14),
|
||||
Expanded(
|
||||
|
||||
Reference in New Issue
Block a user