added new tragets... fixed some issues.
This commit is contained in:
+171
-113
@@ -20,22 +20,11 @@ class _SpectatorScreenState extends State<SpectatorScreen> {
|
||||
List<bool> _enabledCameras = List.generate(6, (_) => false); // Which cameras have IPs configured
|
||||
List<Map<String, dynamic>> _cameras = [];
|
||||
Color _bulletColor = Colors.blue; // default/fallback bullet color
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadCameras();
|
||||
_loadBulletColor();
|
||||
_setSystemUIMode();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _setSystemUIMode() {
|
||||
// No special system UI mode needed for portrait
|
||||
}
|
||||
|
||||
String _t(String key) {
|
||||
@@ -94,110 +83,181 @@ class _SpectatorScreenState extends State<SpectatorScreen> {
|
||||
return Colors.pink;
|
||||
case 'lime':
|
||||
return Colors.lime;
|
||||
case 'mint':
|
||||
return Colors.greenAccent;
|
||||
case 'orange':
|
||||
return Colors.orange;
|
||||
case 'red':
|
||||
return Colors.red;
|
||||
case 'violet':
|
||||
return Colors.deepPurpleAccent;
|
||||
case 'amber':
|
||||
return Colors.amber;
|
||||
case 'brown':
|
||||
return Colors.brown;
|
||||
case 'grey':
|
||||
return Colors.grey;
|
||||
default:
|
||||
return Colors.blue;
|
||||
}
|
||||
}
|
||||
|
||||
void _showCameraSelection() {
|
||||
showModalBottomSheet(
|
||||
showDialog(
|
||||
context: context,
|
||||
backgroundColor: Colors.grey[900],
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
|
||||
),
|
||||
builder: (context) => StatefulBuilder(
|
||||
builder: (context, setModalState) => SingleChildScrollView(
|
||||
builder: (context, setModalState) => Dialog(
|
||||
backgroundColor: Colors.grey[900],
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 24),
|
||||
padding: const EdgeInsets.fromLTRB(24, 20, 24, 20),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
_t('Select Cameras'),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
Text(
|
||||
_t('Select Cameras'),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
// Single row of 6 camera buttons
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: List.generate(6, (index) {
|
||||
final cameraNum = index + 1;
|
||||
final isSelected = _selectedCameras[index];
|
||||
final isEnabled = _enabledCameras[index];
|
||||
const SizedBox(height: 24),
|
||||
// Row 1: Cameras 1-3
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: List.generate(3, (index) {
|
||||
final cameraNum = index + 1;
|
||||
final isSelected = _selectedCameras[index];
|
||||
final isEnabled = _enabledCameras[index];
|
||||
|
||||
return GestureDetector(
|
||||
onTap: isEnabled
|
||||
? () {
|
||||
setModalState(() {
|
||||
return GestureDetector(
|
||||
onTap: isEnabled
|
||||
? () {
|
||||
// Update both modal and parent state simultaneously
|
||||
_selectedCameras[index] = !_selectedCameras[index];
|
||||
});
|
||||
// Also update the parent state to refresh camera grid
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
setModalState(() {});
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
}
|
||||
: null,
|
||||
child: Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
color: !isEnabled
|
||||
? Colors.grey[700]
|
||||
: (isSelected ? _bulletColor : Colors.grey[800]),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(
|
||||
: null,
|
||||
child: Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
color: !isEnabled
|
||||
? Colors.grey[600]!
|
||||
: (isSelected ? _bulletColor : Colors.grey[700]!),
|
||||
width: 2,
|
||||
? Colors.grey[700]
|
||||
: (isSelected ? _bulletColor : Colors.grey[800]),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(
|
||||
color: !isEnabled
|
||||
? Colors.grey[600]!
|
||||
: (isSelected ? _bulletColor : Colors.grey[700]!),
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'$cameraNum',
|
||||
style: TextStyle(
|
||||
color: isEnabled ? Colors.white : Colors.grey[500],
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
child: Center(
|
||||
child: Text(
|
||||
'$cameraNum',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 40,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.grey[800],
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
);
|
||||
}),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
// Row 2: Cameras 4-6
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: List.generate(3, (index) {
|
||||
final cameraNum = index + 4;
|
||||
final arrayIndex = index + 3;
|
||||
final isSelected = _selectedCameras[arrayIndex];
|
||||
final isEnabled = _enabledCameras[arrayIndex];
|
||||
|
||||
return GestureDetector(
|
||||
onTap: isEnabled
|
||||
? () {
|
||||
// Update both modal and parent state simultaneously
|
||||
_selectedCameras[arrayIndex] = !_selectedCameras[arrayIndex];
|
||||
setModalState(() {});
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
: null,
|
||||
child: Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
color: !isEnabled
|
||||
? Colors.grey[700]
|
||||
: (isSelected ? _bulletColor : Colors.grey[800]),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(
|
||||
color: !isEnabled
|
||||
? Colors.grey[600]!
|
||||
: (isSelected ? _bulletColor : Colors.grey[700]!),
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'$cameraNum',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Container(
|
||||
padding: const EdgeInsets.only(top: 16),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
top: BorderSide(color: Colors.grey[700]!, width: 1),
|
||||
),
|
||||
),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text(
|
||||
_t('Done'),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const SizedBox(height: 16),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 40,
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: _bulletColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text(
|
||||
_t('Done'),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -205,7 +265,6 @@ class _SpectatorScreenState extends State<SpectatorScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final visibleCameras = <Map<String, dynamic>>[];
|
||||
@@ -215,6 +274,7 @@ class _SpectatorScreenState extends State<SpectatorScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
// Portrait list view
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.black,
|
||||
appBar: AppBar(
|
||||
@@ -280,33 +340,31 @@ class _SpectatorScreenState extends State<SpectatorScreen> {
|
||||
stream: streamUrl,
|
||||
isLive: true,
|
||||
fit: BoxFit.cover,
|
||||
error: (context, error, stackTrace) {
|
||||
return Container(
|
||||
color: Colors.grey[700],
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.videocam_off,
|
||||
error: (context, error, stackTrace) => Container(
|
||||
color: Colors.grey[700],
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.videocam_off,
|
||||
color: Colors.white,
|
||||
size: 32,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
"${_t('Camera')} $cameraIndex",
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
size: 32,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
"${_t('Camera')} $cameraIndex",
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
// Camera number circle - top right (with bullet color)
|
||||
Positioned(
|
||||
|
||||
Reference in New Issue
Block a user