games_app/prediqo_mobile/lib/features/admin/presentation/options_screen.dart
2026-10-25 20:49:23 +02:00

151 lines
5.2 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
import '../../../core/theme/app_theme.dart';
import '../../../l10n/app_strings.dart';
import '../../../shared/widgets/pred_card.dart';
import '../../../shared/widgets/tloto_gradient_app_bar.dart';
import '../../auth/bloc/auth_bloc.dart';
class OptionsScreen extends StatelessWidget {
const OptionsScreen({super.key});
@override
Widget build(BuildContext context) {
final s = context.strings;
final isAdmin = context.read<AuthBloc>().state.isAdmin;
final isDark = Theme.of(context).brightness == Brightness.dark;
final bottomInset = MediaQuery.paddingOf(context).bottom;
final muted = isDark ? AppColors.textMuted : const Color(0xFF94A3B8);
return AnnotatedRegion<SystemUiOverlayStyle>(
value: TlotoGradientAppBar.overlayStyle,
child: Scaffold(
key: const Key('options_screen'),
body: Column(
children: [
TlotoGradientAppBar(title: s.settings),
Expanded(
child: ListView(
physics: const BouncingScrollPhysics(),
padding: EdgeInsets.fromLTRB(20, 16, 20, 24 + bottomInset),
children: [
if (isAdmin) ...[
Text(
s.adminOnly,
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.w700,
),
),
const SizedBox(height: 12),
_OptionTile(
icon: Icons.hub_rounded,
title: s.networkStatus,
subtitle: s.networkWarning,
onTap: () => context.push('/admin/network'),
),
const SizedBox(height: 10),
_OptionTile(
icon: Icons.people_rounded,
title: s.users,
subtitle: s.usersManageSubtitle,
onTap: () => context.push('/admin/users'),
),
const SizedBox(height: 10),
_OptionTile(
icon: Icons.settings_applications_rounded,
title: s.settings,
subtitle: s.systemSettingsSubtitle,
onTap: () => context.push('/options/settings'),
),
] else
Padding(
padding: const EdgeInsets.symmetric(vertical: 48),
child: Column(
children: [
Icon(
Icons.admin_panel_settings_outlined,
size: 48,
color: muted,
),
const SizedBox(height: 12),
Text(
s.noAdminOptions,
style: TextStyle(color: muted),
textAlign: TextAlign.center,
),
],
),
),
],
),
),
],
),
),
);
}
}
class _OptionTile extends StatelessWidget {
const _OptionTile({
required this.icon,
required this.title,
required this.subtitle,
required this.onTap,
});
final IconData icon;
final String title;
final String subtitle;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
final isDark = Theme.of(context).brightness == Brightness.dark;
final color = Theme.of(context).colorScheme.primary;
final secondary = isDark ? AppColors.textSecondary : const Color(0xFF475569);
final chevron = isDark ? AppColors.textMuted : const Color(0xFF94A3B8);
return PredCard(
onTap: onTap,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
child: Row(
children: [
Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: color.withValues(alpha: isDark ? 0.15 : 0.12),
borderRadius: BorderRadius.circular(12),
),
child: Icon(icon, color: color, size: 24),
),
const SizedBox(width: 16),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: Theme.of(context).textTheme.titleSmall?.copyWith(
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 2),
Text(
subtitle,
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: secondary,
),
),
],
),
),
Icon(Icons.chevron_right_rounded, color: chevron),
],
),
);
}
}