11import 'dart:async' ;
2+
23import 'package:flutter/material.dart' ;
34import 'package:flutter_riverpod/flutter_riverpod.dart' ;
45import 'package:intl/intl.dart' ;
56import 'package:syncfusion_flutter_charts/charts.dart' ;
67import 'package:sysadmin/core/utils/color_extension.dart' ;
7- import 'package:sysadmin/providers/system_resources_provider.dart' ;
88import 'package:sysadmin/providers/process_monitor_provider.dart' ;
9+ import 'package:sysadmin/providers/system_resources_provider.dart' ;
910
1011class SystemResourceDetailsScreen extends ConsumerStatefulWidget {
1112 const SystemResourceDetailsScreen ({super .key});
@@ -150,7 +151,7 @@ class _SystemResourceDetailsScreenState extends ConsumerState<SystemResourceDeta
150151 value:
151152 '${systemResources .swapUsage .toStringAsFixed (1 )}% (${(systemResources .usedSwap / 1024 ).toStringAsFixed (1 )}GB / ${(systemResources .totalSwap / 1024 ).toStringAsFixed (1 )}GB)' ,
152153 chartData: _swapHistory,
153- color: Colors .orange ,
154+ color: Colors .purpleAccent ,
154155 processes: processes.swapProcesses,
155156 resourceType: 'Swap' ,
156157 theme: theme,
@@ -203,22 +204,20 @@ class _SystemResourceDetailsScreenState extends ConsumerState<SystemResourceDeta
203204 ),
204205 ],
205206 ),
206- const SizedBox (height: 16 ),
207+ const SizedBox (height: 32 ),
207208
208209 // Live Chart
209210 SizedBox (
210211 height: 150 ,
211212 child: _buildLiveChart (chartData, color, resourceType),
212213 ),
213214
214- const SizedBox (height: 16 ),
215- Divider (color: theme.dividerColor),
216- const SizedBox (height: 8 ),
215+ const SizedBox (height: 32 ),
217216
218217 // Top Processes Title
219218 Text (
220219 'Top 5 Processes by $resourceType ' ,
221- style: theme.textTheme.titleSmall ,
220+ style: theme.textTheme.labelLarge ,
222221 ),
223222 const SizedBox (height: 8 ),
224223
@@ -231,7 +230,7 @@ class _SystemResourceDetailsScreenState extends ConsumerState<SystemResourceDeta
231230
232231 Widget _buildLiveChart (List <ResourceDataPoint > data, Color color, String resourceType) {
233232 final now = DateTime .now ();
234- final firstTime = now.subtract (const Duration (seconds: 60 ));
233+ final firstTime = now.subtract (const Duration (seconds: 15 ));
235234
236235 return SfCartesianChart (
237236 key: ValueKey ('${resourceType }_chart_${DateTime .now ().millisecondsSinceEpoch }' ),
@@ -241,9 +240,9 @@ class _SystemResourceDetailsScreenState extends ConsumerState<SystemResourceDeta
241240 majorGridLines: const MajorGridLines (width: 0 ),
242241 axisLine: const AxisLine (width: 0.5 ),
243242 labelStyle: const TextStyle (fontSize: 9 ),
244- dateFormat: DateFormat .Hms (),
243+ dateFormat: DateFormat .ms (),
245244 intervalType: DateTimeIntervalType .seconds,
246- interval: 15 ,
245+ interval: 5 ,
247246 minimum: firstTime,
248247 maximum: now,
249248 ),
@@ -313,7 +312,7 @@ class _SystemResourceDetailsScreenState extends ConsumerState<SystemResourceDeta
313312 const SizedBox (height: 8 ),
314313 Text (
315314 'Loading process data...' ,
316- style: TextStyle (color: theme.colorScheme.onSurface.withOpacity (0.7 )),
315+ style: TextStyle (color: theme.colorScheme.onSurface.useOpacity (0.7 )),
317316 ),
318317 ],
319318 ),
@@ -370,7 +369,7 @@ class _SystemResourceDetailsScreenState extends ConsumerState<SystemResourceDeta
370369 ),
371370 ],
372371 );
373- }). toList () ,
372+ }),
374373 ],
375374 );
376375 }
@@ -383,7 +382,7 @@ class _SystemResourceDetailsScreenState extends ConsumerState<SystemResourceDeta
383382 style: TextStyle (
384383 fontWeight: FontWeight .bold,
385384 fontSize: 13 ,
386- color: theme.colorScheme.onSurface.withOpacity (0.8 ),
385+ color: theme.colorScheme.onSurface.useOpacity (0.8 ),
387386 ),
388387 ),
389388 );
@@ -392,12 +391,12 @@ class _SystemResourceDetailsScreenState extends ConsumerState<SystemResourceDeta
392391 Color _getColorBasedOnUsage (double value, String type) {
393392 if (type == 'CPU' ) {
394393 if (value > 80 ) return Colors .red;
395- if (value > 50 ) return Colors .orange ;
394+ if (value > 50 ) return Theme . of (context).primaryColor ;
396395 return Colors .green;
397396 } else {
398397 // For memory usage
399398 if (value > 1000 ) return Colors .red;
400- if (value > 500 ) return Colors .orange ;
399+ if (value > 500 ) return Theme . of (context).primaryColor ;
401400 return Colors .green;
402401 }
403402 }
0 commit comments