إصلاح أخطاء شاشة الكباتن من تحديث الذكاء الاصطناعي

This commit is contained in:
Hamza-Ayed
2026-07-26 13:44:07 +03:00
parent 330dfc6dba
commit e269cb9b70
21 changed files with 72156 additions and 71654 deletions
@@ -8,13 +8,13 @@ class ServerMonitorPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final controller = Get.put(ServerMonitorController());
final themeColor = const Color(0xFF6366F1);
final cs = Theme.of(context).colorScheme;
return Scaffold(
backgroundColor: const Color(0xFF0A0E27),
backgroundColor: cs.surface,
body: RefreshIndicator(
onRefresh: controller.fetchServerData,
color: themeColor,
color: cs.primary,
backgroundColor: const Color(0xFF1A1F3A),
child: CustomScrollView(
physics: const BouncingScrollPhysics(),
@@ -24,23 +24,23 @@ class ServerMonitorPage extends StatelessWidget {
expandedHeight: 100,
floating: true,
pinned: true,
backgroundColor: const Color(0xFF0A0E27),
backgroundColor: cs.surface,
elevation: 0,
flexibleSpace: FlexibleSpaceBar(
titlePadding: const EdgeInsets.only(bottom: 16),
title: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.dns_rounded,
color: Colors.white, size: 20),
Icon(Icons.dns_rounded,
color: cs.onSurface, size: 20),
const SizedBox(width: 8),
const Text(
Text(
'Server Monitor',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18,
color: Colors.white,
fontFamily: 'Segoe UI', // أو أي خط تفضله
color: cs.onSurface,
fontFamily: 'Segoe UI',
),
),
],
@@ -52,15 +52,15 @@ class ServerMonitorPage extends StatelessWidget {
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
themeColor.withOpacity(0.3),
const Color(0xFF0A0E27),
cs.primary.withValues(alpha: 0.3),
cs.surface,
],
),
),
),
),
actions: [
_buildRefreshButton(controller),
_buildRefreshButton(controller, cs),
],
),
@@ -85,7 +85,7 @@ class ServerMonitorPage extends StatelessWidget {
child: ConstrainedBox(
constraints: const BoxConstraints(
maxWidth:
1000), // لمنع التمدد الزائد في الشاشات الكبيرة
1000),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -125,7 +125,7 @@ class ServerMonitorPage extends StatelessWidget {
child: _TopProcessesCard(
data: data,
height:
600), // ارتفاع ثابت في وضع الكمبيوتر
600),
),
],
);
@@ -139,7 +139,7 @@ class ServerMonitorPage extends StatelessWidget {
_StorageNetworkCard(data: data),
const SizedBox(height: 16),
_TopProcessesCard(
data: data), // ارتفاع ديناميكي
data: data),
],
);
}
@@ -159,22 +159,22 @@ class ServerMonitorPage extends StatelessWidget {
);
}
Widget _buildRefreshButton(ServerMonitorController controller) {
Widget _buildRefreshButton(ServerMonitorController controller, ColorScheme cs) {
return Obx(() => Container(
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.1),
color: cs.onSurface.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(12),
),
child: IconButton(
icon: controller.isLoading.value
? const SizedBox(
? SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(
strokeWidth: 2, color: Colors.white),
strokeWidth: 2, color: cs.onSurface),
)
: const Icon(Icons.refresh_rounded, color: Colors.white),
: Icon(Icons.refresh_rounded, color: cs.onSurface),
onPressed: controller.fetchServerData,
),
));
@@ -219,18 +219,19 @@ class _HeaderInfo extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
return Container(
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.05),
color: cs.onSurface.withValues(alpha: 0.05),
borderRadius: BorderRadius.circular(50),
border: Border.all(color: Colors.white.withOpacity(0.1)),
border: Border.all(color: cs.onSurface.withValues(alpha: 0.1)),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.timer_outlined,
size: 16, color: Colors.greenAccent.withOpacity(0.8)),
size: 16, color: Colors.greenAccent.withValues(alpha: 0.8)),
const SizedBox(width: 8),
Text(
"Uptime: ${data.uptime.formatted}",
@@ -245,7 +246,7 @@ class _HeaderInfo extends StatelessWidget {
color: Colors.white24,
margin: const EdgeInsets.symmetric(horizontal: 12)),
Icon(Icons.update,
size: 16, color: Colors.blueAccent.withOpacity(0.8)),
size: 16, color: Colors.blueAccent.withValues(alpha: 0.8)),
const SizedBox(width: 8),
Text(
"Last Update: ${data.timestamp.split(' ')[1]}",
@@ -276,18 +277,19 @@ class _MetricCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
return Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [color.withOpacity(0.9), color.withOpacity(0.6)],
colors: [color.withValues(alpha: 0.9), color.withValues(alpha: 0.6)],
),
borderRadius: BorderRadius.circular(24),
boxShadow: [
BoxShadow(
color: color.withOpacity(0.3),
color: color.withValues(alpha: 0.3),
blurRadius: 12,
offset: const Offset(0, 8),
),
@@ -302,15 +304,15 @@ class _MetricCard extends StatelessWidget {
Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.2),
color: cs.onSurface.withValues(alpha: 0.2),
borderRadius: BorderRadius.circular(12),
),
child: Icon(icon, color: Colors.white, size: 24),
child: Icon(icon, color: cs.onSurface, size: 24),
),
Text(
value,
style: const TextStyle(
color: Colors.white,
style: TextStyle(
color: cs.onSurface,
fontSize: 28,
fontWeight: FontWeight.bold),
),
@@ -321,8 +323,8 @@ class _MetricCard extends StatelessWidget {
style: const TextStyle(color: Colors.white70, fontSize: 14)),
const SizedBox(height: 4),
Text(subtitle,
style: const TextStyle(
color: Colors.white,
style: TextStyle(
color: cs.onSurface,
fontSize: 16,
fontWeight: FontWeight.w600)),
const SizedBox(height: 12),
@@ -332,7 +334,7 @@ class _MetricCard extends StatelessWidget {
value: percent / 100,
minHeight: 6,
backgroundColor: Colors.black12,
valueColor: const AlwaysStoppedAnimation(Colors.white),
valueColor: AlwaysStoppedAnimation(cs.onSurface),
),
),
],
@@ -347,6 +349,7 @@ class _ServicesCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
return _BaseCard(
title: "حالة الخدمات",
icon: Icons.security,
@@ -362,8 +365,8 @@ class _ServicesCard extends StatelessWidget {
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: isActive
? Colors.green.withOpacity(0.3)
: Colors.red.withOpacity(0.3),
? const Color(0xFF10B981).withValues(alpha: 0.3)
: cs.error.withValues(alpha: 0.3),
),
),
child: Row(
@@ -377,8 +380,8 @@ class _ServicesCard extends StatelessWidget {
Expanded(
child: Text(
e.key.toUpperCase(),
style: const TextStyle(
color: Colors.white, fontWeight: FontWeight.w600),
style: TextStyle(
color: cs.onSurface, fontWeight: FontWeight.w600),
),
),
Container(
@@ -386,8 +389,8 @@ class _ServicesCard extends StatelessWidget {
const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: isActive
? Colors.green.withOpacity(0.1)
: Colors.red.withOpacity(0.1),
? const Color(0xFF10B981).withValues(alpha: 0.1)
: cs.error.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(6),
),
child: Text(
@@ -414,6 +417,7 @@ class _StorageNetworkCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
return _BaseCard(
title: "التخزين والشبكة",
icon: Icons.cloud_queue_rounded,
@@ -421,19 +425,19 @@ class _StorageNetworkCard extends StatelessWidget {
child: Column(
children: [
_buildRowItem(Icons.pie_chart_outline, "Storage",
"${data.disk.percent}%", "${data.disk.usedGb} GB Used"),
"${data.disk.percent}%", "${data.disk.usedGb} GB Used", cs),
const Divider(color: Colors.white10, height: 24),
_buildRowItem(Icons.download_rounded, "Download",
"${data.network.receivedMb} MB", "In"),
"${data.network.receivedMb} MB", "In", cs),
const SizedBox(height: 16),
_buildRowItem(Icons.upload_rounded, "Upload",
"${data.network.sentMb} MB", "Out"),
"${data.network.sentMb} MB", "Out", cs),
],
),
);
}
Widget _buildRowItem(IconData icon, String label, String value, String sub) {
Widget _buildRowItem(IconData icon, String label, String value, String sub, ColorScheme cs) {
return Row(
children: [
Icon(icon, color: Colors.white54, size: 20),
@@ -445,13 +449,13 @@ class _StorageNetworkCard extends StatelessWidget {
style: const TextStyle(color: Colors.white60, fontSize: 12)),
Text(sub,
style: TextStyle(
color: Colors.white.withOpacity(0.4), fontSize: 10)),
color: cs.onSurface.withValues(alpha: 0.4), fontSize: 10)),
],
),
const Spacer(),
Text(value,
style: const TextStyle(
color: Colors.white,
style: TextStyle(
color: cs.onSurface,
fontWeight: FontWeight.bold,
fontSize: 16)),
],
@@ -466,12 +470,13 @@ class _TopProcessesCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
return Container(
height: height, // إذا كان null سيأخذ الارتفاع بناءً على المحتوى
height: height,
decoration: BoxDecoration(
color: const Color(0xFF1A1F3A),
borderRadius: BorderRadius.circular(24),
border: Border.all(color: Colors.white.withOpacity(0.05)),
border: Border.all(color: cs.onSurface.withValues(alpha: 0.05)),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -483,31 +488,30 @@ class _TopProcessesCard extends StatelessWidget {
Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: Colors.orange.withOpacity(0.1),
color: Colors.orange.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(8)),
child: const Icon(Icons.analytics_rounded,
color: Colors.orange, size: 18),
),
const SizedBox(width: 12),
const Text("Top Processes",
Text("Top Processes",
style: TextStyle(
color: Colors.white,
color: cs.onSurface,
fontSize: 16,
fontWeight: FontWeight.bold)),
],
),
),
const Divider(height: 1, color: Colors.white10),
// نستخدم ListView.builder داخل Expanded إذا كان هناك ارتفاع محدد، وإلا Column للموبايل
height != null
? Expanded(child: _buildList())
: _buildList(shrinkWrap: true),
? Expanded(child: _buildList(cs: cs))
: _buildList(shrinkWrap: true, cs: cs),
],
),
);
}
Widget _buildList({bool shrinkWrap = false}) {
Widget _buildList({bool shrinkWrap = false, required ColorScheme cs}) {
return ListView.separated(
padding: const EdgeInsets.all(16),
physics: shrinkWrap
@@ -521,7 +525,7 @@ class _TopProcessesCard extends StatelessWidget {
return Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.03),
color: cs.onSurface.withValues(alpha: 0.03),
borderRadius: BorderRadius.circular(12),
),
child: Row(
@@ -535,8 +539,8 @@ class _TopProcessesCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(process.name,
style: const TextStyle(
color: Colors.white, fontWeight: FontWeight.w500),
style: TextStyle(
color: cs.onSurface, fontWeight: FontWeight.w500),
overflow: TextOverflow.ellipsis),
],
),
@@ -545,7 +549,7 @@ class _TopProcessesCard extends StatelessWidget {
padding:
const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
decoration: BoxDecoration(
color: Colors.orange.withOpacity(0.1),
color: Colors.orange.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(20),
),
child: Text(
@@ -579,13 +583,14 @@ class _BaseCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
return Container(
width: double.infinity,
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: const Color(0xFF1A1F3A),
borderRadius: BorderRadius.circular(24),
border: Border.all(color: Colors.white.withOpacity(0.05)),
border: Border.all(color: cs.onSurface.withValues(alpha: 0.05)),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -595,14 +600,14 @@ class _BaseCard extends StatelessWidget {
Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: iconColor.withOpacity(0.1),
color: iconColor.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(8)),
child: Icon(icon, color: iconColor, size: 18),
),
const SizedBox(width: 12),
Text(title,
style: const TextStyle(
color: Colors.white,
style: TextStyle(
color: cs.onSurface,
fontSize: 16,
fontWeight: FontWeight.bold)),
],
@@ -620,14 +625,15 @@ class _LoadingState extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const CircularProgressIndicator(color: Color(0xFF6366F1)),
CircularProgressIndicator(color: cs.primary),
const SizedBox(height: 16),
Text("Connecting to server...",
style: TextStyle(color: Colors.white.withOpacity(0.5))),
style: TextStyle(color: cs.onSurface.withValues(alpha: 0.5))),
],
),
);
@@ -640,6 +646,7 @@ class _ErrorState extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
return Center(
child: Padding(
padding: const EdgeInsets.all(20.0),
@@ -651,12 +658,12 @@ class _ErrorState extends StatelessWidget {
const SizedBox(height: 16),
Text(controller.errorMessage.value,
textAlign: TextAlign.center,
style: const TextStyle(color: Colors.white)),
style: TextStyle(color: cs.onSurface)),
const SizedBox(height: 24),
ElevatedButton(
onPressed: controller.fetchServerData,
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF6366F1),
backgroundColor: cs.primary,
shape: const StadiumBorder(),
),
child: const Text("Try Again"),