Initial commit for Intaleq Driver

This commit is contained in:
Hamza-Ayed
2025-09-01 19:04:50 +03:00
parent 889c67a691
commit 8c7f3e3a75
46 changed files with 4300 additions and 6192 deletions

View File

@@ -1,9 +1,11 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/foundation.dart'
show kIsWeb, defaultTargetPlatform, TargetPlatform;
import 'controller/functions/device_analyzer.dart';
// --- CompatibilityDetailCard Widget (Updated to use 'max_score') ---
// --- CompatibilityDetailCard Widget (كما هو) ---
class CompatibilityDetailCard extends StatelessWidget {
final Map<String, dynamic> detail;
const CompatibilityDetailCard({super.key, required this.detail});
@@ -16,17 +18,14 @@ class CompatibilityDetailCard extends StatelessWidget {
IconData _getIconForLabel(String label) {
if (label.contains('رام')) return Icons.memory;
if (label.contains('معالج') || label.contains('CPU')) {
if (label.contains('معالج') || label.contains('CPU'))
return Icons.developer_board;
}
if (label.contains('تخزين') || label.contains('كتابة')) {
if (label.contains('تخزين') || label.contains('كتابة'))
return Icons.sd_storage_outlined;
}
if (label.contains('أندرويد')) return Icons.android;
if (label.contains('خدمات')) return Icons.g_mobiledata;
if (label.contains('حساسات') || label.contains('Gyroscope')) {
if (label.contains('حساسات') || label.contains('Gyroscope'))
return Icons.sensors;
}
return Icons.smartphone;
}
@@ -35,7 +34,6 @@ class CompatibilityDetailCard extends StatelessWidget {
final bool status = detail['status'] ?? false;
final String label = detail['label'] ?? "";
final int achievedScore = detail['achieved_score'] ?? 0;
// Corrected to use 'max_score' from the analyzer
final int maxScore = detail['max_score'] ?? 1;
final Color color = _getStatusColor(status, achievedScore, maxScore);
final double progress =
@@ -49,10 +47,9 @@ class CompatibilityDetailCard extends StatelessWidget {
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.08),
blurRadius: 15,
offset: const Offset(0, 5),
)
color: Colors.grey.withOpacity(0.08),
blurRadius: 15,
offset: const Offset(0, 5))
],
),
child: Column(
@@ -64,20 +61,15 @@ class CompatibilityDetailCard extends StatelessWidget {
color: Colors.grey.shade600, size: 20),
const SizedBox(width: 8),
Expanded(
child: Text(
label,
child: Text(label,
style: TextStyle(
fontSize: 15,
color: Colors.grey.shade800,
fontWeight: FontWeight.w600)),
),
Text("$achievedScore/$maxScore نقطة",
style: TextStyle(
fontSize: 15,
color: Colors.grey.shade800,
fontWeight: FontWeight.w600),
),
),
// Corrected to display points out of max_score
Text(
"$achievedScore/$maxScore نقطة",
style: TextStyle(
color: color, fontWeight: FontWeight.bold, fontSize: 14),
),
color: color, fontWeight: FontWeight.bold, fontSize: 14)),
],
),
const SizedBox(height: 12),
@@ -94,7 +86,7 @@ class CompatibilityDetailCard extends StatelessWidget {
}
}
// --- Main Page Widget ---
// --- Main Page Widget (Android-only) ---
class DeviceCompatibilityPage extends StatefulWidget {
const DeviceCompatibilityPage({super.key});
@override
@@ -107,23 +99,28 @@ class _DeviceCompatibilityPageState extends State<DeviceCompatibilityPage> {
List<Map<String, dynamic>> details = [];
bool isLoading = true;
bool get _isAndroid =>
!kIsWeb && defaultTargetPlatform == TargetPlatform.android;
@override
void initState() {
super.initState();
_initializePage();
if (_isAndroid) {
_initializePage();
} else {
// منصّة غير أندرويد: لا تعمل أي تحليلات
setState(() => isLoading = false);
}
}
Future<void> _initializePage() async {
// await BatteryNotifier.checkBatteryAndNotify();
final result = await DeviceAnalyzer().analyzeDevice();
if (mounted) {
setState(() {
score = result['score'];
details = List<Map<String, dynamic>>.from(result['details']);
isLoading = false;
});
}
if (!mounted) return;
setState(() {
score = result['score'];
details = List<Map<String, dynamic>>.from(result['details']);
isLoading = false;
});
}
Color _getColorForScore(int value) {
@@ -141,6 +138,41 @@ class _DeviceCompatibilityPageState extends State<DeviceCompatibilityPage> {
@override
Widget build(BuildContext context) {
// حظر الصفحة على غير أندرويد
if (!_isAndroid) {
return Scaffold(
backgroundColor: const Color(0xFFF7F8FC),
appBar: AppBar(
title: const Text("توافق الجهاز",
style: TextStyle(
color: Colors.black87, fontWeight: FontWeight.bold)),
centerTitle: true,
backgroundColor: Colors.transparent,
elevation: 0,
iconTheme: const IconThemeData(color: Colors.black87),
),
body: Center(
child: Padding(
padding: const EdgeInsets.all(24),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.phone_iphone, size: 56, color: Colors.grey),
const SizedBox(height: 12),
const Text("هذه الصفحة متاحة لأجهزة أندرويد فقط",
style: TextStyle(fontSize: 16)),
const SizedBox(height: 8),
ElevatedButton(
onPressed: () => Get.back(),
child: const Text("رجوع"),
),
],
),
),
),
);
}
return Scaffold(
backgroundColor: const Color(0xFFF7F8FC),
appBar: AppBar(
@@ -188,57 +220,48 @@ class _DeviceCompatibilityPageState extends State<DeviceCompatibilityPage> {
);
}
/// ## Corrected Score Header Widget
/// This widget now uses a `Stack` to correctly place the text over the `PieChart`.
/// الهيدر
Widget _buildScoreHeader() {
return Container(
margin: const EdgeInsets.symmetric(horizontal: 16),
height: 220, // Give the container a fixed height
height: 220,
child: Stack(
alignment: Alignment.center,
children: [
// Layer 1: The Pie Chart
PieChart(
PieChartData(
sectionsSpace: 4,
// This creates the "hole" in the middle.
centerSpaceRadius: 80,
startDegreeOffset: -90,
sections: [
PieChartSectionData(
color: _getColorForScore(score),
value: score.toDouble(),
title: '',
radius: 25,
),
color: _getColorForScore(score),
value: score.toDouble(),
title: '',
radius: 25),
PieChartSectionData(
color: Colors.grey.shade200,
value: (100 - score).toDouble().clamp(0, 100),
title: '',
radius: 25,
),
color: Colors.grey.shade200,
value: (100 - score).toDouble().clamp(0, 100),
title: '',
radius: 25),
],
),
),
// Layer 2: The text and message, centered on top of the chart
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"$score%",
style: TextStyle(
fontSize: 52,
fontWeight: FontWeight.bold,
color: _getColorForScore(score)),
),
Text("$score%",
style: TextStyle(
fontSize: 52,
fontWeight: FontWeight.bold,
color: _getColorForScore(score))),
const SizedBox(height: 4),
Text(
_getScoreMessage(score),
style: TextStyle(
color: Colors.grey.shade700,
fontSize: 16,
fontWeight: FontWeight.w500),
),
Text(_getScoreMessage(score),
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.grey.shade700,
fontSize: 16,
fontWeight: FontWeight.w500)),
],
),
],