im so tired man
This commit is contained in:
+13
-5
@@ -41,6 +41,7 @@ class _GuardianDashboardScreenState extends State<GuardianDashboardScreen>
|
||||
// ââ€Âۉâ€Â€ Live location (WebSocket) ââ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Â€
|
||||
LatLng? _liveLatLng;
|
||||
bool _liveConnected = false;
|
||||
DateTime? _lastRealtimeStatusReload;
|
||||
final MapController _mapController = MapController();
|
||||
|
||||
// ââ€Âۉâ€Â€ Pulse animation for live dot ââ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Âۉâ€Â€
|
||||
@@ -133,12 +134,13 @@ class _GuardianDashboardScreenState extends State<GuardianDashboardScreen>
|
||||
'User',
|
||||
userOnline: userStatus?['online'] as bool? ?? false,
|
||||
userLastSeen: userStatus?['lastSeenAt']?.toString(),
|
||||
battery: userStatus?['battery'] as int?,
|
||||
speed: userStatus?['lastSpeed'] as double?,
|
||||
obstaclesTotal: userStatus?['obstaclesToday'] as int? ??
|
||||
dashboard?['obstaclesToday'] as int? ??
|
||||
battery: (userStatus?['battery'] as num?)?.toInt(),
|
||||
speed: (userStatus?['lastSpeed'] as num?)?.toDouble(),
|
||||
obstaclesTotal: (userStatus?['obstaclesToday'] as num?)?.toInt() ??
|
||||
(dashboard?['obstaclesToday'] as num?)?.toInt() ??
|
||||
0,
|
||||
unreadNotif: dashboard?['unreadNotifCount'] as int? ?? 0,
|
||||
unreadNotif:
|
||||
(dashboard?['unreadNotifCount'] as num?)?.toInt() ?? 0,
|
||||
unreadSos: sosPending,
|
||||
lastLat: lastLoc?['lat'] != null
|
||||
? (lastLoc!['lat'] as num).toDouble()
|
||||
@@ -247,6 +249,12 @@ class _GuardianDashboardScreenState extends State<GuardianDashboardScreen>
|
||||
_liveConnected = true;
|
||||
});
|
||||
_moveMapSafely(newPos);
|
||||
final now = DateTime.now();
|
||||
if (_lastRealtimeStatusReload == null ||
|
||||
now.difference(_lastRealtimeStatusReload!).inSeconds >= 15) {
|
||||
_lastRealtimeStatusReload = now;
|
||||
unawaited(_loadAll(silent: true));
|
||||
}
|
||||
});
|
||||
ws.subscribeSos((sosData) {
|
||||
if (!mounted) return;
|
||||
|
||||
+26
-13
@@ -3,7 +3,6 @@ import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:camera/camera.dart';
|
||||
import '../../../core/secure_storage.dart';
|
||||
import '../../auth/presentation/login_screen.dart';
|
||||
import '../../../../main.dart';
|
||||
|
||||
class UserDashboardScreen extends StatefulWidget {
|
||||
const UserDashboardScreen({super.key});
|
||||
@@ -12,7 +11,8 @@ class UserDashboardScreen extends StatefulWidget {
|
||||
State<UserDashboardScreen> createState() => _UserDashboardScreenState();
|
||||
}
|
||||
|
||||
class _UserDashboardScreenState extends State<UserDashboardScreen> with TickerProviderStateMixin {
|
||||
class _UserDashboardScreenState extends State<UserDashboardScreen>
|
||||
with TickerProviderStateMixin {
|
||||
CameraController? _camCtrl;
|
||||
late AnimationController _radarCtrl;
|
||||
late Animation<double> _radarAnim;
|
||||
@@ -31,8 +31,10 @@ class _UserDashboardScreenState extends State<UserDashboardScreen> with TickerPr
|
||||
}
|
||||
|
||||
Future<void> _initCamera() async {
|
||||
final cameras = await availableCameras();
|
||||
if (cameras.isEmpty) return;
|
||||
_camCtrl = CameraController(cameras[0], ResolutionPreset.high, enableAudio: false);
|
||||
_camCtrl = CameraController(cameras[0], ResolutionPreset.medium,
|
||||
enableAudio: false);
|
||||
await _camCtrl!.initialize();
|
||||
if (mounted) setState(() {});
|
||||
}
|
||||
@@ -85,7 +87,8 @@ class _UserDashboardScreenState extends State<UserDashboardScreen> with TickerPr
|
||||
gradient: RadialGradient(
|
||||
colors: [
|
||||
Colors.transparent,
|
||||
const Color(0xFF10B981).withValues(alpha: 0.05 + _radarCtrl.value * 0.08),
|
||||
const Color(0xFF10B981)
|
||||
.withValues(alpha: 0.05 + _radarCtrl.value * 0.08),
|
||||
],
|
||||
stops: const [0.5, 1.0],
|
||||
radius: 1.4,
|
||||
@@ -127,7 +130,8 @@ class _UserDashboardScreenState extends State<UserDashboardScreen> with TickerPr
|
||||
),
|
||||
child: Row(children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withValues(alpha: 0.54),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
@@ -158,7 +162,8 @@ class _UserDashboardScreenState extends State<UserDashboardScreen> with TickerPr
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
onPressed: _logout,
|
||||
icon: const Icon(Icons.power_settings_new, color: Colors.white, size: 26),
|
||||
icon: const Icon(Icons.power_settings_new,
|
||||
color: Colors.white, size: 26),
|
||||
style: IconButton.styleFrom(
|
||||
backgroundColor: Colors.redAccent.withValues(alpha: 0.8),
|
||||
),
|
||||
@@ -204,15 +209,19 @@ class _UserDashboardScreenState extends State<UserDashboardScreen> with TickerPr
|
||||
color: const Color(0x33F59E0B),
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: const Icon(Icons.warning_amber_rounded, color: Color(0xFFF59E0B), size: 16),
|
||||
child: const Icon(Icons.warning_amber_rounded,
|
||||
color: Color(0xFFF59E0B), size: 16),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Text('Obstacle ahead',
|
||||
style: GoogleFonts.inter(
|
||||
color: Colors.white, fontSize: 13, fontWeight: FontWeight.w500)),
|
||||
color: Colors.white,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500)),
|
||||
Text('2.1m — Haptic alert sent',
|
||||
style: GoogleFonts.inter(color: Colors.white60, fontSize: 11)),
|
||||
style:
|
||||
GoogleFonts.inter(color: Colors.white60, fontSize: 11)),
|
||||
]),
|
||||
]),
|
||||
),
|
||||
@@ -234,9 +243,12 @@ class _UserDashboardScreenState extends State<UserDashboardScreen> with TickerPr
|
||||
),
|
||||
child: Column(children: [
|
||||
Row(children: [
|
||||
Expanded(child: _bigBtn(const Color(0xCC1A56DB), Icons.mic, () {})),
|
||||
Expanded(
|
||||
child: _bigBtn(const Color(0xCC1A56DB), Icons.mic, () {})),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(child: _bigBtn(const Color(0xCCDC2626), Icons.phone_in_talk, () {})),
|
||||
Expanded(
|
||||
child: _bigBtn(
|
||||
const Color(0xCCDC2626), Icons.phone_in_talk, () {})),
|
||||
]),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
@@ -290,7 +302,8 @@ class _RadarPainter extends CustomPainter {
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 1.2;
|
||||
for (final r in [48.0, 34.0, 20.0]) {
|
||||
paint.color = const Color(0xFF60EFAB).withValues(alpha: 0.15 + (50 - r) / 100);
|
||||
paint.color =
|
||||
const Color(0xFF60EFAB).withValues(alpha: 0.15 + (50 - r) / 100);
|
||||
canvas.drawCircle(center, r, paint);
|
||||
}
|
||||
paint
|
||||
@@ -301,4 +314,4 @@ class _RadarPainter extends CustomPainter {
|
||||
|
||||
@override
|
||||
bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user