Files
intaleq/intaleq_rider/lib/controller/home/device_tier.dart
T
Hamza-AyedandClaude Opus 5 0aab85c732 refactor: إعادة تسمية التطبيقات الأربعة siro_* → intaleq_*
المجلدات وأسماء حزم dart واستيراداتها:
  siro_rider → intaleq_rider    siro_driver  → intaleq_driver
  siro_admin → intaleq_admin    siro_service → intaleq_service

شمل ذلك `name:` في كل pubspec وكل `package:siro_*` في الاستيرادات
(115 ملفاً في rider وحده)، وإشارات أسماء المجلدات في docs/ وتعليق في
backend/Admin/notifications/broadcast.php. لم تبقَ إشارة واحدة (تحقّقت).

+ ضُمّت حزم get و get_storage داخل intaleq_driver/packages/ وحُوّلت
مساراتها الثلاثة من `../../Intaleq/packages/*` إلى `./packages/*`. كانت
تُحل عرضاً إلى مجلد App/Intaleq القديم المجاور — تبعية خارج المستودع
تنكسر بأول نقل. لم يبقَ في أي تطبيق تبعية مسار خارج الشجرة.

⚠️ لم تُمسّ بعد: هويات المتاجر (applicationId · PRODUCT_BUNDLE_IDENTIFIER ·
shorebird app_id) ولا الألوان ولا النصوص المرئية ولا النطاقات — كل منها
كوميت منفصل، والهويات تحتاج قرار المالك.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 16:10:58 +03:00

87 lines
2.5 KiB
Dart

import 'dart:io';
import 'package:device_info_plus/device_info_plus.dart';
import '../../main.dart';
// مفاتيح التخزين (بسيطة)
const _kDeviceTierKey = 'deviceTier'; // 'low' | 'mid' | 'high'
const _kDeviceTierCheckedAtKey = 'deviceTierTime'; // millisSinceEpoch
Future<String> detectAndCacheDeviceTier({bool force = false}) async {
// لا تعيد الفحص إذا عملناه خلال آخر 24 ساعة
if (!force) {
final last = box.read(_kDeviceTierCheckedAtKey);
if (last is int) {
final dt = DateTime.fromMillisecondsSinceEpoch(last);
if (DateTime.now().difference(dt) < const Duration(hours: 24)) {
final cached = box.read(_kDeviceTierKey);
if (cached is String && cached.isNotEmpty)
return cached; // low/mid/high
}
}
}
final info = DeviceInfoPlugin();
int score = 0;
if (Platform.isAndroid) {
final a = await info.androidInfo;
final int sdk = a.version.sdkInt ?? 0;
final int cores = Platform.numberOfProcessors;
final int abisCount = a.supportedAbis.length;
final bool isEmu = !(a.isPhysicalDevice ?? true);
// SDK (أقدم = أضعف)
if (sdk <= 26)
score += 3; // 8.0 وأقدم
else if (sdk <= 29)
score += 2; // 9-10
else if (sdk <= 30) score += 1; // 11
// الأنوية
if (cores <= 4)
score += 3;
else if (cores <= 6)
score += 2;
else if (cores <= 8) score += 1;
// ABI count (القليل غالباً أضعف)
if (abisCount <= 1)
score += 2;
else if (abisCount == 2) score += 1;
// محاكي
if (isEmu) score += 2;
} else {
// iOS/منصات أخرى: تقدير سريع بالأنوية فقط
final int cores = Platform.numberOfProcessors;
if (cores <= 4)
score += 3;
else if (cores <= 6)
score += 2;
else if (cores <= 8) score += 1;
}
// تحويل السكور إلى تصنيف
final String tier = (score >= 6)
? 'low'
: (score >= 3)
? 'mid'
: 'high';
box.write(_kDeviceTierKey, tier);
box.write(_kDeviceTierCheckedAtKey, DateTime.now().millisecondsSinceEpoch);
return tier;
}
// للقراءة السريعة وقت ما تحتاج:
String getCachedDeviceTier() {
final t = box.read(_kDeviceTierKey);
if (t is String && t.isNotEmpty) return t;
return 'mid';
}
bool isLowEnd() => getCachedDeviceTier() == 'low';
bool isMidEnd() => getCachedDeviceTier() == 'mid';
bool isHighEnd() => getCachedDeviceTier() == 'high';