411 lines
16 KiB
Dart
411 lines
16 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:intaleq_maps/intaleq_maps.dart';
|
|
import '../models/military_operations_models.dart';
|
|
import '../services/military_grid_utils.dart';
|
|
import '../services/minefield_engine.dart';
|
|
|
|
/// Dedicated Tactical Minefield Threat & Breaching HUD Sheet
|
|
class TacticalMinefieldSheet extends StatefulWidget {
|
|
final LatLng? startPoint;
|
|
final LatLng? endPoint;
|
|
final VoidCallback onPickStart;
|
|
final VoidCallback onPickEnd;
|
|
final VoidCallback onSwap;
|
|
final VoidCallback onClose;
|
|
final Function(MinefieldZoneResult) onZoneCalculated;
|
|
|
|
const TacticalMinefieldSheet({
|
|
super.key,
|
|
required this.startPoint,
|
|
required this.endPoint,
|
|
required this.onPickStart,
|
|
required this.onPickEnd,
|
|
required this.onSwap,
|
|
required this.onClose,
|
|
required this.onZoneCalculated,
|
|
});
|
|
|
|
@override
|
|
State<TacticalMinefieldSheet> createState() => _TacticalMinefieldSheetState();
|
|
}
|
|
|
|
class _TacticalMinefieldSheetState extends State<TacticalMinefieldSheet> {
|
|
MinefieldType _type = MinefieldType.antiTank;
|
|
double _widthMeters = 200.0;
|
|
MinefieldZoneResult? _result;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_recalculate();
|
|
}
|
|
|
|
@override
|
|
void didUpdateWidget(covariant TacticalMinefieldSheet oldWidget) {
|
|
super.didUpdateWidget(oldWidget);
|
|
if (widget.startPoint != oldWidget.startPoint ||
|
|
widget.endPoint != oldWidget.endPoint) {
|
|
_recalculate();
|
|
}
|
|
}
|
|
|
|
void _recalculate() {
|
|
if (widget.startPoint == null || widget.endPoint == null) {
|
|
setState(() => _result = null);
|
|
return;
|
|
}
|
|
|
|
final res = MinefieldEngine.calculateMinefieldZone(
|
|
startPoint: widget.startPoint!,
|
|
endPoint: widget.endPoint!,
|
|
type: _type,
|
|
widthMeters: _widthMeters,
|
|
);
|
|
|
|
setState(() => _result = res);
|
|
widget.onZoneCalculated(res);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
decoration: const BoxDecoration(
|
|
color: Color(0xFF090E1A),
|
|
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
|
border: Border(top: BorderSide(color: Color(0xFFF59E0B), width: 1.5)),
|
|
boxShadow: [
|
|
BoxShadow(color: Colors.black87, blurRadius: 24, spreadRadius: 4),
|
|
],
|
|
),
|
|
child: SafeArea(
|
|
top: false,
|
|
child: SingleChildScrollView(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
// ── Header ───────────────────────────────────────────
|
|
Row(
|
|
children: [
|
|
Container(
|
|
padding: const EdgeInsets.all(8),
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFFF59E0B).withAlpha(40),
|
|
borderRadius: BorderRadius.circular(10),
|
|
border: Border.all(color: const Color(0xFFF59E0B)),
|
|
),
|
|
child: const Icon(Icons.warning_amber, color: Color(0xFFFBBF24), size: 20),
|
|
),
|
|
const SizedBox(width: 10),
|
|
const Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'حقول الألغام وممرات العبور الآمنة (Minefield & Breaching)',
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
Text(
|
|
'تحديد نطاق الخطر، حساب الكثافة وتخطيط ثغرات العبور التكتيكية',
|
|
style: TextStyle(color: Color(0xFF94A3B8), fontSize: 10),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
IconButton(
|
|
icon: const Icon(Icons.close, color: Colors.white70, size: 20),
|
|
onPressed: widget.onClose,
|
|
),
|
|
],
|
|
),
|
|
|
|
const SizedBox(height: 14),
|
|
|
|
// ── Minefield Type Selector ───────────────────────────
|
|
Row(
|
|
children: [
|
|
_buildTypeTab(
|
|
type: MinefieldType.antiTank,
|
|
title: 'ضد الدروع (AT)',
|
|
subtitle: 'حقول موانع الآليات',
|
|
),
|
|
const SizedBox(width: 8),
|
|
_buildTypeTab(
|
|
type: MinefieldType.antiPersonnel,
|
|
title: 'ضد الأفراد (AP)',
|
|
subtitle: 'كثافة ألغام عالية',
|
|
),
|
|
const SizedBox(width: 8),
|
|
_buildTypeTab(
|
|
type: MinefieldType.mixedBarrier,
|
|
title: 'مانع مركب',
|
|
subtitle: 'مختلط مدرعات ومترجلين',
|
|
),
|
|
],
|
|
),
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
// ── Positions Picker Card ─────────────────────────────
|
|
Container(
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFF0F172A),
|
|
borderRadius: BorderRadius.circular(12),
|
|
border: Border.all(color: Colors.white12),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: InkWell(
|
|
onTap: widget.onPickStart,
|
|
borderRadius: BorderRadius.circular(8),
|
|
child: Container(
|
|
padding: const EdgeInsets.all(8),
|
|
decoration: BoxDecoration(
|
|
color: widget.startPoint != null
|
|
? const Color(0x33F59E0B)
|
|
: Colors.white.withAlpha(10),
|
|
borderRadius: BorderRadius.circular(8),
|
|
border: Border.all(
|
|
color: widget.startPoint != null
|
|
? const Color(0xFFF59E0B)
|
|
: Colors.white24,
|
|
),
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
const Text('بداية الحقل (A):', style: TextStyle(color: Color(0xFF94A3B8), fontSize: 10)),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
widget.startPoint != null
|
|
? MilitaryGridUtils.latLngToMgrs(
|
|
widget.startPoint!.latitude,
|
|
widget.startPoint!.longitude,
|
|
)
|
|
: 'حدد النقطة الأولى...',
|
|
style: TextStyle(
|
|
color: widget.startPoint != null ? Colors.white : Colors.white54,
|
|
fontSize: 11,
|
|
fontFamily: 'monospace',
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
IconButton(
|
|
icon: const Icon(Icons.swap_horiz, color: Color(0xFFF59E0B), size: 20),
|
|
onPressed: widget.onSwap,
|
|
),
|
|
Expanded(
|
|
child: InkWell(
|
|
onTap: widget.onPickEnd,
|
|
borderRadius: BorderRadius.circular(8),
|
|
child: Container(
|
|
padding: const EdgeInsets.all(8),
|
|
decoration: BoxDecoration(
|
|
color: widget.endPoint != null
|
|
? const Color(0x33EF4444)
|
|
: Colors.white.withAlpha(10),
|
|
borderRadius: BorderRadius.circular(8),
|
|
border: Border.all(
|
|
color: widget.endPoint != null
|
|
? const Color(0xFFEF4444)
|
|
: Colors.white24,
|
|
),
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
const Text('نهاية الحقل (B):', style: TextStyle(color: Color(0xFF94A3B8), fontSize: 10)),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
widget.endPoint != null
|
|
? MilitaryGridUtils.latLngToMgrs(
|
|
widget.endPoint!.latitude,
|
|
widget.endPoint!.longitude,
|
|
)
|
|
: 'حدد النقطة الثانية...',
|
|
style: TextStyle(
|
|
color: widget.endPoint != null ? Colors.white : Colors.white54,
|
|
fontSize: 11,
|
|
fontFamily: 'monospace',
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
|
|
const SizedBox(height: 12),
|
|
|
|
// ── Width Slider ──────────────────────────────────────
|
|
Row(
|
|
children: [
|
|
const Icon(Icons.straighten, color: Color(0xFF38BDF8), size: 16),
|
|
const SizedBox(width: 6),
|
|
Text(
|
|
'عمق الحقل التكتيكي: ${_widthMeters.toInt()} متر',
|
|
style: const TextStyle(color: Colors.white, fontSize: 11, fontWeight: FontWeight.bold),
|
|
),
|
|
],
|
|
),
|
|
Slider(
|
|
value: _widthMeters,
|
|
min: 50,
|
|
max: 600,
|
|
divisions: 11,
|
|
activeColor: const Color(0xFFF59E0B),
|
|
inactiveColor: const Color(0xFF1E293B),
|
|
onChanged: (v) {
|
|
setState(() => _widthMeters = v);
|
|
_recalculate();
|
|
},
|
|
),
|
|
|
|
// ── Minefield Analysis Card ───────────────────────────
|
|
if (_result != null) ...[
|
|
Row(
|
|
children: [
|
|
_buildMetricCard(
|
|
title: 'طول الجبهة / الامتداد',
|
|
value: '${_result!.lengthMeters.toInt()}م',
|
|
subvalue: '${(_result!.lengthMeters / 1000).toStringAsFixed(2)} كم',
|
|
color: const Color(0xFF38BDF8),
|
|
),
|
|
const SizedBox(width: 8),
|
|
_buildMetricCard(
|
|
title: 'العدد التقديري للألغام',
|
|
value: '≈ ${_result!.estimatedMinesCount.toInt()} لغم',
|
|
subvalue: 'كثافة نظامية',
|
|
color: const Color(0xFFEF4444),
|
|
),
|
|
],
|
|
),
|
|
|
|
const SizedBox(height: 10),
|
|
|
|
// Breaching Corridor Info
|
|
Container(
|
|
padding: const EdgeInsets.all(16),
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFF10B981).withAlpha(30),
|
|
borderRadius: BorderRadius.circular(8),
|
|
border: Border.all(color: const Color(0xFF10B981)),
|
|
),
|
|
child: const Row(
|
|
children: [
|
|
Icon(Icons.alt_route, color: Color(0xFF10B981), size: 18),
|
|
SizedBox(width: 8),
|
|
Expanded(
|
|
child: Text(
|
|
'تم تخطيط ممر الثغرة الآمن (Breaching Lane) بعرض 16م لمرور الأرتال والمدرعات',
|
|
style: TextStyle(
|
|
color: Color(0xFF10B981),
|
|
fontSize: 11,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildTypeTab({
|
|
required MinefieldType type,
|
|
required String title,
|
|
required String subtitle,
|
|
}) {
|
|
final isSelected = _type == type;
|
|
return Expanded(
|
|
child: InkWell(
|
|
onTap: () {
|
|
setState(() => _type = type);
|
|
_recalculate();
|
|
},
|
|
borderRadius: BorderRadius.circular(10),
|
|
child: Container(
|
|
padding: const EdgeInsets.all(16),
|
|
decoration: BoxDecoration(
|
|
color: isSelected ? const Color(0xFFF59E0B).withAlpha(40) : const Color(0xFF0F172A),
|
|
borderRadius: BorderRadius.circular(10),
|
|
border: Border.all(
|
|
color: isSelected ? const Color(0xFFF59E0B) : Colors.white12,
|
|
),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
Text(
|
|
title,
|
|
style: TextStyle(
|
|
color: isSelected ? Colors.white : const Color(0xFF94A3B8),
|
|
fontSize: 10.5,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
const SizedBox(height: 2),
|
|
Text(
|
|
subtitle,
|
|
style: TextStyle(
|
|
color: isSelected ? const Color(0xFFFBBF24) : Colors.white38,
|
|
fontSize: 8.5,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildMetricCard({
|
|
required String title,
|
|
required String value,
|
|
required String subvalue,
|
|
required Color color,
|
|
}) {
|
|
return Expanded(
|
|
child: Container(
|
|
padding: const EdgeInsets.all(10),
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFF0F172A),
|
|
borderRadius: BorderRadius.circular(10),
|
|
border: Border.all(color: Colors.white12),
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(title, style: const TextStyle(color: Color(0xFF94A3B8), fontSize: 9.5)),
|
|
const SizedBox(height: 3),
|
|
Text(value, style: TextStyle(color: color, fontSize: 13.5, fontWeight: FontWeight.bold)),
|
|
Text(subvalue, style: const TextStyle(color: Colors.white54, fontSize: 9.5)),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|