2025-09-19 16:40:05 +03:30
|
|
|
import 'package:flutter/material.dart';
|
2025-09-22 11:00:18 +03:30
|
|
|
import 'package:go_router/go_router.dart';
|
2025-09-19 16:40:05 +03:30
|
|
|
import 'package:hesabix_ui/l10n/app_localizations.dart';
|
|
|
|
|
|
2025-09-22 11:00:18 +03:30
|
|
|
class SystemSettingsPage extends StatefulWidget {
|
2025-09-19 16:40:05 +03:30
|
|
|
const SystemSettingsPage({super.key});
|
|
|
|
|
|
2025-09-22 11:00:18 +03:30
|
|
|
@override
|
|
|
|
|
State<SystemSettingsPage> createState() => _SystemSettingsPageState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
|
|
|
|
late final List<SettingsItem> _settingsItems;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
_settingsItems = [
|
|
|
|
|
SettingsItem(
|
|
|
|
|
title: 'storageManagement',
|
|
|
|
|
description: 'storageManagementDescription',
|
|
|
|
|
icon: Icons.cloud_upload_outlined,
|
|
|
|
|
color: const Color(0xFF2196F3),
|
|
|
|
|
route: '/user/profile/system-settings/storage',
|
|
|
|
|
),
|
|
|
|
|
SettingsItem(
|
|
|
|
|
title: 'systemConfiguration',
|
|
|
|
|
description: 'systemConfigurationDescription',
|
|
|
|
|
icon: Icons.settings_outlined,
|
|
|
|
|
color: const Color(0xFF4CAF50),
|
|
|
|
|
route: '/user/profile/system-settings/configuration',
|
|
|
|
|
),
|
|
|
|
|
SettingsItem(
|
|
|
|
|
title: 'userManagement',
|
|
|
|
|
description: 'userManagementDescription',
|
|
|
|
|
icon: Icons.people_outlined,
|
|
|
|
|
color: const Color(0xFFFF9800),
|
|
|
|
|
route: '/user/profile/system-settings/users',
|
|
|
|
|
),
|
|
|
|
|
SettingsItem(
|
|
|
|
|
title: 'systemLogs',
|
|
|
|
|
description: 'systemLogsDescription',
|
|
|
|
|
icon: Icons.analytics_outlined,
|
|
|
|
|
color: const Color(0xFF9C27B0),
|
|
|
|
|
route: '/user/profile/system-settings/logs',
|
|
|
|
|
),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-19 16:40:05 +03:30
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final theme = Theme.of(context);
|
|
|
|
|
final colorScheme = theme.colorScheme;
|
2025-09-22 11:00:18 +03:30
|
|
|
final t = AppLocalizations.of(context);
|
2025-09-19 16:40:05 +03:30
|
|
|
|
|
|
|
|
return Scaffold(
|
2025-09-22 11:00:18 +03:30
|
|
|
backgroundColor: colorScheme.surface,
|
2025-09-19 16:40:05 +03:30
|
|
|
appBar: AppBar(
|
2025-09-22 11:00:18 +03:30
|
|
|
title: Text(
|
|
|
|
|
t.systemSettingsWelcome,
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
fontSize: 20,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
backgroundColor: Colors.transparent,
|
2025-09-19 16:40:05 +03:30
|
|
|
elevation: 0,
|
2025-09-22 11:00:18 +03:30
|
|
|
centerTitle: true,
|
|
|
|
|
actions: [
|
|
|
|
|
IconButton(
|
|
|
|
|
onPressed: () => _showHelpDialog(context),
|
|
|
|
|
icon: const Icon(Icons.help_outline),
|
|
|
|
|
tooltip: t.systemSettingsWelcome,
|
|
|
|
|
),
|
|
|
|
|
],
|
2025-09-19 16:40:05 +03:30
|
|
|
),
|
2025-09-22 11:00:18 +03:30
|
|
|
body: SingleChildScrollView(
|
|
|
|
|
padding: const EdgeInsets.all(20),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
_buildWelcomeSection(theme, colorScheme, t),
|
|
|
|
|
const SizedBox(height: 24),
|
|
|
|
|
_buildSettingsList(theme, colorScheme, t),
|
|
|
|
|
const SizedBox(height: 20),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildWelcomeSection(ThemeData theme, ColorScheme colorScheme, AppLocalizations t) {
|
|
|
|
|
return Container(
|
|
|
|
|
padding: const EdgeInsets.all(20),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
gradient: LinearGradient(
|
|
|
|
|
begin: Alignment.topLeft,
|
|
|
|
|
end: Alignment.bottomRight,
|
|
|
|
|
colors: [
|
|
|
|
|
colorScheme.primary.withOpacity(0.1),
|
|
|
|
|
colorScheme.primaryContainer.withOpacity(0.3),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
borderRadius: BorderRadius.circular(16),
|
|
|
|
|
border: Border.all(
|
|
|
|
|
color: colorScheme.primary.withOpacity(0.2),
|
|
|
|
|
width: 1,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
padding: const EdgeInsets.all(12),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
gradient: LinearGradient(
|
|
|
|
|
begin: Alignment.topLeft,
|
|
|
|
|
end: Alignment.bottomRight,
|
|
|
|
|
colors: [
|
|
|
|
|
colorScheme.primary,
|
|
|
|
|
colorScheme.primary.withOpacity(0.8),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
boxShadow: [
|
|
|
|
|
BoxShadow(
|
|
|
|
|
color: colorScheme.primary.withOpacity(0.3),
|
|
|
|
|
blurRadius: 8,
|
|
|
|
|
offset: const Offset(0, 2),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
child: const Icon(
|
|
|
|
|
Icons.admin_panel_settings_outlined,
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
size: 20,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 16),
|
|
|
|
|
Expanded(
|
2025-09-19 16:40:05 +03:30
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
2025-09-22 11:00:18 +03:30
|
|
|
Text(
|
|
|
|
|
t.systemAdministration,
|
|
|
|
|
style: theme.textTheme.titleLarge?.copyWith(
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
color: colorScheme.onSurface,
|
|
|
|
|
fontSize: 18,
|
2025-09-19 16:40:05 +03:30
|
|
|
),
|
|
|
|
|
),
|
2025-09-22 11:00:18 +03:30
|
|
|
const SizedBox(height: 6),
|
|
|
|
|
Text(
|
|
|
|
|
t.systemSettingsDescription,
|
|
|
|
|
style: theme.textTheme.bodyMedium?.copyWith(
|
|
|
|
|
color: colorScheme.onSurface.withOpacity(0.7),
|
|
|
|
|
fontSize: 14,
|
2025-09-19 16:40:05 +03:30
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
2025-09-22 11:00:18 +03:30
|
|
|
Container(
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: colorScheme.primary.withOpacity(0.1),
|
|
|
|
|
borderRadius: BorderRadius.circular(20),
|
|
|
|
|
),
|
|
|
|
|
child: Text(
|
|
|
|
|
'${_settingsItems.length}',
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: colorScheme.primary,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
2025-09-19 16:40:05 +03:30
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-22 11:00:18 +03:30
|
|
|
Widget _buildSettingsList(ThemeData theme, ColorScheme colorScheme, AppLocalizations t) {
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
t.availableSettings,
|
|
|
|
|
style: theme.textTheme.titleLarge?.copyWith(
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
color: colorScheme.onSurface,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const Spacer(),
|
|
|
|
|
Container(
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: colorScheme.primary.withOpacity(0.1),
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
),
|
|
|
|
|
child: Text(
|
|
|
|
|
'${_settingsItems.length} ${t.availableSettings.toLowerCase()}',
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: colorScheme.primary,
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
|
LayoutBuilder(
|
|
|
|
|
builder: (context, constraints) {
|
|
|
|
|
int crossAxisCount = 3;
|
|
|
|
|
if (constraints.maxWidth < 600) {
|
|
|
|
|
crossAxisCount = 2;
|
|
|
|
|
} else if (constraints.maxWidth > 1200) {
|
|
|
|
|
crossAxisCount = 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return GridView.builder(
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
|
crossAxisCount: crossAxisCount,
|
|
|
|
|
crossAxisSpacing: 12,
|
|
|
|
|
mainAxisSpacing: 12,
|
|
|
|
|
childAspectRatio: 1.0,
|
|
|
|
|
),
|
|
|
|
|
itemCount: _settingsItems.length,
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
return _buildSettingsCard(_settingsItems[index], theme, colorScheme, t);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
2025-09-19 16:40:05 +03:30
|
|
|
|
2025-09-22 11:00:18 +03:30
|
|
|
Widget _buildSettingsCard(SettingsItem item, ThemeData theme, ColorScheme colorScheme, AppLocalizations t) {
|
2025-09-19 16:40:05 +03:30
|
|
|
return Card(
|
2025-09-22 11:00:18 +03:30
|
|
|
elevation: 1,
|
2025-09-19 16:40:05 +03:30
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
2025-09-22 11:00:18 +03:30
|
|
|
side: BorderSide(
|
|
|
|
|
color: colorScheme.outline.withOpacity(0.2),
|
|
|
|
|
width: 1,
|
|
|
|
|
),
|
2025-09-19 16:40:05 +03:30
|
|
|
),
|
2025-09-22 11:00:18 +03:30
|
|
|
child: Material(
|
|
|
|
|
color: Colors.transparent,
|
|
|
|
|
child: InkWell(
|
|
|
|
|
onTap: () => context.go(item.route!),
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
hoverColor: item.color.withOpacity(0.05),
|
|
|
|
|
splashColor: item.color.withOpacity(0.1),
|
|
|
|
|
child: AnimatedContainer(
|
|
|
|
|
duration: const Duration(milliseconds: 200),
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
AnimatedContainer(
|
|
|
|
|
duration: const Duration(milliseconds: 200),
|
|
|
|
|
padding: const EdgeInsets.all(12),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: item.color.withOpacity(0.1),
|
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
|
boxShadow: [
|
|
|
|
|
BoxShadow(
|
|
|
|
|
color: item.color.withOpacity(0.1),
|
|
|
|
|
blurRadius: 4,
|
|
|
|
|
offset: const Offset(0, 2),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
child: Icon(
|
|
|
|
|
item.icon,
|
|
|
|
|
color: item.color,
|
|
|
|
|
size: 24,
|
|
|
|
|
),
|
2025-09-19 16:40:05 +03:30
|
|
|
),
|
2025-09-22 11:00:18 +03:30
|
|
|
const SizedBox(height: 12),
|
|
|
|
|
Text(
|
|
|
|
|
_getLocalizedText(t, item.title),
|
|
|
|
|
style: theme.textTheme.titleSmall?.copyWith(
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
color: colorScheme.onSurface,
|
|
|
|
|
fontSize: 13,
|
|
|
|
|
),
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
maxLines: 1,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 6),
|
|
|
|
|
Text(
|
|
|
|
|
_getLocalizedText(t, item.description),
|
2025-09-19 16:40:05 +03:30
|
|
|
style: theme.textTheme.bodySmall?.copyWith(
|
2025-09-22 11:00:18 +03:30
|
|
|
color: colorScheme.onSurface.withOpacity(0.6),
|
|
|
|
|
fontSize: 11,
|
2025-09-19 16:40:05 +03:30
|
|
|
),
|
2025-09-22 11:00:18 +03:30
|
|
|
textAlign: TextAlign.center,
|
2025-09-19 16:40:05 +03:30
|
|
|
maxLines: 2,
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
),
|
2025-09-22 11:00:18 +03:30
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
AnimatedContainer(
|
|
|
|
|
duration: const Duration(milliseconds: 200),
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: item.color.withOpacity(0.1),
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
),
|
|
|
|
|
child: Icon(
|
2025-09-19 16:40:05 +03:30
|
|
|
Icons.arrow_forward_ios,
|
2025-09-22 11:00:18 +03:30
|
|
|
size: 12,
|
|
|
|
|
color: item.color,
|
2025-09-19 16:40:05 +03:30
|
|
|
),
|
2025-09-22 11:00:18 +03:30
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
2025-09-19 16:40:05 +03:30
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
2025-09-22 11:00:18 +03:30
|
|
|
|
|
|
|
|
String _getLocalizedText(AppLocalizations t, String key) {
|
|
|
|
|
switch (key) {
|
|
|
|
|
case 'storageManagement':
|
|
|
|
|
return t.storageManagement;
|
|
|
|
|
case 'storageManagementDescription':
|
|
|
|
|
return t.storageManagementDescription;
|
|
|
|
|
case 'systemConfiguration':
|
|
|
|
|
return t.systemConfiguration;
|
|
|
|
|
case 'systemConfigurationDescription':
|
|
|
|
|
return t.systemConfigurationDescription;
|
|
|
|
|
case 'userManagement':
|
|
|
|
|
return t.userManagement;
|
|
|
|
|
case 'userManagementDescription':
|
|
|
|
|
return t.userManagementDescription;
|
|
|
|
|
case 'systemLogs':
|
|
|
|
|
return t.systemLogs;
|
|
|
|
|
case 'systemLogsDescription':
|
|
|
|
|
return t.systemLogsDescription;
|
|
|
|
|
default:
|
|
|
|
|
return key;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _showHelpDialog(BuildContext context) {
|
|
|
|
|
final t = AppLocalizations.of(context);
|
|
|
|
|
showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (context) => AlertDialog(
|
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
borderRadius: BorderRadius.circular(16),
|
|
|
|
|
),
|
|
|
|
|
title: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Icon(
|
|
|
|
|
Icons.help_outline,
|
|
|
|
|
color: Theme.of(context).colorScheme.primary,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 8),
|
|
|
|
|
Text(t.systemSettingsWelcome),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
content: Text(
|
|
|
|
|
t.systemSettingsDescription,
|
|
|
|
|
),
|
|
|
|
|
actions: [
|
|
|
|
|
TextButton(
|
|
|
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
|
|
|
child: Text(t.ok),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
2025-09-19 16:40:05 +03:30
|
|
|
}
|
2025-09-22 11:00:18 +03:30
|
|
|
|
|
|
|
|
class SettingsItem {
|
|
|
|
|
final String title;
|
|
|
|
|
final String description;
|
|
|
|
|
final IconData icon;
|
|
|
|
|
final Color color;
|
|
|
|
|
final String? route;
|
|
|
|
|
|
|
|
|
|
SettingsItem({
|
|
|
|
|
required this.title,
|
|
|
|
|
required this.description,
|
|
|
|
|
required this.icon,
|
|
|
|
|
required this.color,
|
|
|
|
|
this.route,
|
|
|
|
|
});
|
|
|
|
|
}
|