im so tired man

This commit is contained in:
Wowieee4
2026-05-28 11:27:06 +07:00
parent 66da2473e1
commit 6272ece15d
86 changed files with 1759 additions and 4090 deletions
@@ -0,0 +1,3 @@
Activity log application layer.
This layer is reserved for Cubit/BLoC orchestration between the activity log UI and domain contracts.
@@ -0,0 +1,3 @@
Activity log data layer.
This layer is reserved for remote/local data sources and repository implementations.
@@ -0,0 +1,3 @@
Activity log domain layer.
This layer is reserved for entities, repository contracts, and use cases.
@@ -0,0 +1,3 @@
AI benchmark application layer.
This layer is reserved for benchmark Cubit/BLoC orchestration.
@@ -0,0 +1,3 @@
AI benchmark data layer.
This layer is reserved for benchmark result persistence and export adapters.
@@ -0,0 +1,3 @@
AI benchmark domain layer.
This layer is reserved for benchmark entities and use cases.
@@ -0,0 +1,3 @@
Auth application layer.
This layer is reserved for auth Cubit/BLoC orchestration between auth UI and auth domain contracts.
@@ -151,163 +151,182 @@ class _AuthFrame extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFFEAF4FF),
body: Stack(
children: [
const Positioned.fill(
child: DecoratedBox(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [Color(0xFFD9EEFF), Color(0xFFF7FAFC)],
),
),
),
),
Positioned(
top: -90,
right: -60,
child: TweenAnimationBuilder<double>(
tween: Tween(begin: 0.85, end: 1),
duration: const Duration(milliseconds: 900),
curve: Curves.easeOutCubic,
builder: (_, value, child) => Transform.scale(
scale: value,
child: child,
),
child: Container(
width: 260,
height: 260,
decoration: BoxDecoration(
color: const Color(0xFF2563EB).withValues(alpha: 0.14),
shape: BoxShape.circle,
),
),
),
),
Center(
child: SingleChildScrollView(
padding: const EdgeInsets.all(24),
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 430),
child: TweenAnimationBuilder<double>(
tween: Tween(begin: 18, end: 0),
duration: const Duration(milliseconds: 520),
curve: Curves.easeOutCubic,
builder: (_, offset, child) => Opacity(
opacity: (1 - offset / 18).clamp(0.0, 1.0),
child: Transform.translate(
offset: Offset(0, offset),
child: child,
body: LayoutBuilder(
builder: (context, constraints) {
final compact =
constraints.maxWidth < 480 || constraints.maxHeight < 720;
return Stack(
children: [
const Positioned.fill(
child: DecoratedBox(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [Color(0xFFD9EEFF), Color(0xFFF7FAFC)],
),
),
child: RepaintBoundary(
child: Container(
decoration: BoxDecoration(
color: Colors.white.withValues(alpha: 0.96),
borderRadius: BorderRadius.circular(30),
border: Border.all(
color: Colors.white.withValues(alpha: 0.8)),
boxShadow: [
BoxShadow(
color:
const Color(0xFF1E3A8A).withValues(alpha: 0.14),
blurRadius: 40,
offset: const Offset(0, 20),
),
],
),
),
Positioned(
top: compact ? -70 : -90,
right: compact ? -70 : -60,
child: Container(
width: compact ? 180 : 260,
height: compact ? 180 : 260,
decoration: BoxDecoration(
color: const Color(0xFF2563EB).withValues(alpha: 0.12),
shape: BoxShape.circle,
),
),
),
Center(
child: SingleChildScrollView(
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior.onDrag,
padding: EdgeInsets.fromLTRB(
compact ? 14 : 24,
compact ? 12 : 24,
compact ? 14 : 24,
20 + MediaQuery.of(context).viewInsets.bottom,
),
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: compact ? 380 : 430),
child: TweenAnimationBuilder<double>(
tween: Tween(begin: 18, end: 0),
duration: const Duration(milliseconds: 520),
curve: Curves.easeOutCubic,
builder: (_, offset, child) => Opacity(
opacity: (1 - offset / 18).clamp(0.0, 1.0),
child: Transform.translate(
offset: Offset(0, offset),
child: child,
),
),
child: Padding(
padding: const EdgeInsets.fromLTRB(24, 26, 24, 24),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Row(
child: RepaintBoundary(
child: Container(
decoration: BoxDecoration(
color: Colors.white.withValues(alpha: 0.96),
borderRadius:
BorderRadius.circular(compact ? 22 : 30),
border: Border.all(
color: Colors.white.withValues(alpha: 0.8)),
boxShadow: [
BoxShadow(
color: const Color(0xFF1E3A8A)
.withValues(alpha: 0.14),
blurRadius: compact ? 24 : 40,
offset: const Offset(0, 18),
),
],
),
child: Padding(
padding: EdgeInsets.fromLTRB(
compact ? 18 : 24,
compact ? 18 : 26,
compact ? 18 : 24,
compact ? 18 : 24,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Container(
width: 56,
height: 56,
decoration: BoxDecoration(
gradient: const LinearGradient(
colors: [
Color(0xFF2563EB),
Color(0xFF0891B2)
Row(
children: [
Container(
width: compact ? 44 : 56,
height: compact ? 44 : 56,
decoration: BoxDecoration(
gradient: const LinearGradient(
colors: [
Color(0xFF2563EB),
Color(0xFF0891B2)
],
),
borderRadius: BorderRadius.circular(16),
),
child: Icon(Icons.navigation_rounded,
color: Colors.white,
size: compact ? 26 : 30),
),
const SizedBox(width: 12),
const Expanded(
child: Text(
'WalkGuide',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w900,
color: Color(0xFF0F172A),
),
),
),
],
),
SizedBox(height: compact ? 14 : 16),
if (!compact)
Container(
padding: const EdgeInsets.symmetric(
horizontal: 10, vertical: 6),
decoration: BoxDecoration(
color: const Color(0xFFEFF6FF),
borderRadius: BorderRadius.circular(999),
),
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.shield_outlined,
size: 14, color: Color(0xFF1D4ED8)),
SizedBox(width: 6),
Text(
'Secure Assistive Navigation',
style: TextStyle(
color: Color(0xFF1D4ED8),
fontSize: 11,
fontWeight: FontWeight.w800,
),
),
],
),
borderRadius: BorderRadius.circular(18),
),
child: const Icon(Icons.navigation_rounded,
color: Colors.white, size: 30),
if (!compact) const SizedBox(height: 18),
Text(
title,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: Theme.of(context)
.textTheme
.headlineMedium
?.copyWith(
fontSize: compact ? 26 : null,
fontWeight: FontWeight.w900,
color: const Color(0xFF0F172A),
),
),
const SizedBox(width: 12),
const Expanded(
child: Text(
'WalkGuide',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w900,
color: Color(0xFF0F172A),
),
const SizedBox(height: 6),
Text(
subtitle,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: Color(0xFF64748B),
height: 1.35,
),
),
SizedBox(height: compact ? 18 : 26),
child,
],
),
const SizedBox(height: 16),
Container(
padding: const EdgeInsets.symmetric(
horizontal: 10, vertical: 6),
decoration: BoxDecoration(
color: const Color(0xFFEFF6FF),
borderRadius: BorderRadius.circular(999),
),
child: const Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.shield_outlined,
size: 14, color: Color(0xFF1D4ED8)),
SizedBox(width: 6),
Text(
'Secure Assistive Navigation',
style: TextStyle(
color: Color(0xFF1D4ED8),
fontSize: 11,
fontWeight: FontWeight.w800,
),
),
],
),
),
const SizedBox(height: 18),
Text(
title,
style: Theme.of(context)
.textTheme
.headlineMedium
?.copyWith(
fontWeight: FontWeight.w900,
color: const Color(0xFF0F172A),
),
),
const SizedBox(height: 6),
Text(
subtitle,
style: const TextStyle(
color: Color(0xFF64748B),
height: 1.35,
),
),
const SizedBox(height: 26),
child,
],
),
),
),
),
),
),
),
),
),
],
],
);
},
),
);
}
@@ -299,133 +299,151 @@ class _AuthFrame extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFFEAF4FF),
body: Stack(
children: [
const Positioned.fill(
child: DecoratedBox(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [Color(0xFFD9EEFF), Color(0xFFF7FAFC)],
),
),
),
),
Positioned(
top: -90,
right: -60,
child: TweenAnimationBuilder<double>(
tween: Tween(begin: 0.85, end: 1),
duration: const Duration(milliseconds: 900),
curve: Curves.easeOutCubic,
builder: (_, value, child) => Transform.scale(
scale: value,
child: child,
),
child: Container(
width: 260,
height: 260,
decoration: BoxDecoration(
color: const Color(0xFF2563EB).withValues(alpha: 0.14),
shape: BoxShape.circle,
),
),
),
),
Center(
child: SingleChildScrollView(
padding: const EdgeInsets.all(24),
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 430),
child: TweenAnimationBuilder<double>(
tween: Tween(begin: 18, end: 0),
duration: const Duration(milliseconds: 520),
curve: Curves.easeOutCubic,
builder: (_, offset, child) => Opacity(
opacity: (1 - offset / 18).clamp(0.0, 1.0),
child: Transform.translate(
offset: Offset(0, offset),
child: child,
body: LayoutBuilder(
builder: (context, constraints) {
final compact =
constraints.maxWidth < 480 || constraints.maxHeight < 720;
return Stack(
children: [
const Positioned.fill(
child: DecoratedBox(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [Color(0xFFD9EEFF), Color(0xFFF7FAFC)],
),
),
child: RepaintBoundary(
child: Container(
decoration: BoxDecoration(
color: Colors.white.withValues(alpha: 0.96),
borderRadius: BorderRadius.circular(30),
border: Border.all(
color: Colors.white.withValues(alpha: 0.8)),
boxShadow: [
BoxShadow(
color:
const Color(0xFF1E3A8A).withValues(alpha: 0.14),
blurRadius: 40,
offset: const Offset(0, 20),
),
],
),
),
Positioned(
top: compact ? -70 : -90,
right: compact ? -70 : -60,
child: Container(
width: compact ? 180 : 260,
height: compact ? 180 : 260,
decoration: BoxDecoration(
color: const Color(0xFF2563EB).withValues(alpha: 0.12),
shape: BoxShape.circle,
),
),
),
Center(
child: SingleChildScrollView(
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior.onDrag,
padding: EdgeInsets.fromLTRB(
compact ? 14 : 24,
compact ? 12 : 24,
compact ? 14 : 24,
20 + MediaQuery.of(context).viewInsets.bottom,
),
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: compact ? 380 : 430),
child: TweenAnimationBuilder<double>(
tween: Tween(begin: 18, end: 0),
duration: const Duration(milliseconds: 520),
curve: Curves.easeOutCubic,
builder: (_, offset, child) => Opacity(
opacity: (1 - offset / 18).clamp(0.0, 1.0),
child: Transform.translate(
offset: Offset(0, offset),
child: child,
),
),
child: Padding(
padding: const EdgeInsets.fromLTRB(24, 26, 24, 24),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Row(
child: RepaintBoundary(
child: Container(
decoration: BoxDecoration(
color: Colors.white.withValues(alpha: 0.96),
borderRadius:
BorderRadius.circular(compact ? 22 : 30),
border: Border.all(
color: Colors.white.withValues(alpha: 0.8)),
boxShadow: [
BoxShadow(
color: const Color(0xFF1E3A8A)
.withValues(alpha: 0.14),
blurRadius: compact ? 24 : 40,
offset: const Offset(0, 18),
),
],
),
child: Padding(
padding: EdgeInsets.fromLTRB(
compact ? 18 : 24,
compact ? 18 : 26,
compact ? 18 : 24,
compact ? 18 : 24,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Container(
width: 56,
height: 56,
decoration: BoxDecoration(
color: const Color(0xFF1D4ED8),
borderRadius: BorderRadius.circular(18),
),
child: const Icon(Icons.navigation_rounded,
color: Colors.white, size: 30),
),
const SizedBox(width: 12),
const Expanded(
child: Text(
'WalkGuide',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w900,
color: Color(0xFF0F172A),
Row(
children: [
Container(
width: compact ? 44 : 56,
height: compact ? 44 : 56,
decoration: BoxDecoration(
color: const Color(0xFF1D4ED8),
borderRadius: BorderRadius.circular(16),
),
child: Icon(Icons.navigation_rounded,
color: Colors.white,
size: compact ? 26 : 30),
),
const SizedBox(width: 12),
const Expanded(
child: Text(
'WalkGuide',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w900,
color: Color(0xFF0F172A),
),
),
),
],
),
SizedBox(height: compact ? 14 : 22),
Text(
title,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: Theme.of(context)
.textTheme
.headlineMedium
?.copyWith(
fontSize: compact ? 26 : null,
fontWeight: FontWeight.w900,
color: const Color(0xFF0F172A),
),
),
const SizedBox(height: 6),
Text(
subtitle,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
color: Color(0xFF64748B),
height: 1.35,
),
),
SizedBox(height: compact ? 18 : 26),
child,
],
),
const SizedBox(height: 22),
Text(
title,
style: Theme.of(context)
.textTheme
.headlineMedium
?.copyWith(
fontWeight: FontWeight.w900,
color: const Color(0xFF0F172A),
),
),
const SizedBox(height: 6),
Text(
subtitle,
style: const TextStyle(
color: Color(0xFF64748B),
height: 1.35,
),
),
const SizedBox(height: 26),
child,
],
),
),
),
),
),
),
),
),
),
],
],
);
},
),
);
}
@@ -0,0 +1,3 @@
Call application layer.
This layer owns call state orchestration. The current route keeps a compatibility screen while call side effects are delegated to core services.
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import '../../app/injection_container.dart';
import '../../core/errors/friendly_error.dart';
import '../../core/services/call_service.dart';
import '../../core/services/haptic_service.dart';
import '../../core/services/tts_service.dart';
@@ -63,65 +64,71 @@ class _CallScreenState extends State<CallScreen>
unawaited(_finishRemoteEnded());
});
try {
final invite = await callService.startPairedCall();
if (!mounted) return;
if (invite == null) {
final invite = await runFriendly<Map<String, dynamic>>(
() => callService.startPairedCall(),
onError: _failCall,
fallback: 'Panggilan gagal. Server tidak merespons.',
);
if (!mounted) return;
if (invite == null) {
if (_phase != _CallPhase.failed) {
_failCall('Panggilan gagal. Pastikan sudah pairing dan server aktif.');
return;
}
_otherId = _asInt(invite['receiverId']);
_activeChannel = invite['channelName']?.toString();
setState(() => _phase = _CallPhase.calling);
sl<TtsService>().speak(
'Panggilan dikirim ke ${widget.targetLabel}. Menunggu jawaban.',
);
_startAcceptedPolling();
_ringTimeout?.cancel();
_ringTimeout = Timer(const Duration(seconds: 45), () {
if (!mounted || _phase == _CallPhase.connected) return;
_failCall('Panggilan tidak dijawab.');
});
} catch (_) {
if (!mounted) return;
_failCall('Panggilan gagal. Server tidak merespons.');
return;
}
_otherId = _asInt(invite['receiverId']);
_activeChannel = invite['channelName']?.toString();
setState(() => _phase = _CallPhase.calling);
sl<TtsService>().speak(
'Panggilan dikirim ke ${widget.targetLabel}. Menunggu jawaban.',
);
_startAcceptedPolling();
_ringTimeout?.cancel();
_ringTimeout = Timer(const Duration(seconds: 45), () {
if (!mounted || _phase == _CallPhase.connected) return;
_failCall('Panggilan tidak dijawab.');
});
}
void _startAcceptedPolling() {
_acceptedPoll?.cancel();
_acceptedPoll = Timer.periodic(const Duration(seconds: 2), (_) async {
if (!mounted || _activeChannel == null) return;
try {
final state = await sl<CallService>()
final state = await runFriendly<Map<String, dynamic>>(
() => sl<CallService>()
.getCallState(_activeChannel)
.timeout(const Duration(seconds: 3));
final status = state?['status']?.toString();
if (status == 'ENDED') {
await _finishRemoteEnded();
return;
}
if (status == 'ACCEPTED') {
_markRemoteConnected();
return;
}
final accepted = await sl<CallService>()
.getAcceptedCall()
.timeout(const Duration(seconds: 3));
if (accepted?['type']?.toString() != 'CALL_ACCEPTED') return;
final channel = accepted?['channelName']?.toString();
if (_activeChannel != null &&
channel != null &&
channel.isNotEmpty &&
channel != _activeChannel) {
return;
}
_markRemoteConnected();
} catch (_) {
// Keep ringing; a short network hiccup should not cancel the call UI.
.timeout(const Duration(seconds: 3)),
onError: (_) {},
fallback: 'Polling panggilan gagal.',
);
if (state == null) return;
final status = state['status']?.toString();
if (status == 'ENDED') {
await _finishRemoteEnded();
return;
}
if (status == 'ACCEPTED') {
_markRemoteConnected();
return;
}
final accepted = await runFriendly<Map<String, dynamic>>(
() => sl<CallService>()
.getAcceptedCall()
.timeout(const Duration(seconds: 3)),
onError: (_) {},
fallback: 'Polling panggilan diterima gagal.',
);
if (accepted?['type']?.toString() != 'CALL_ACCEPTED') return;
final channel = accepted?['channelName']?.toString();
if (_activeChannel != null &&
channel != null &&
channel.isNotEmpty &&
channel != _activeChannel) {
return;
}
_markRemoteConnected();
});
}
@@ -319,7 +326,12 @@ class _IncomingCallScreenState extends State<IncomingCallScreen> {
setState(() => _responding = true);
sl<TtsService>().speak('Menerima panggilan.');
final joined = await _joinIncomingChannel();
final joined = await runFriendly<bool>(
() => _joinIncomingChannel(),
onError: (_) {},
fallback: 'Panggilan gagal tersambung.',
) ??
false;
if (!mounted) return;
if (!joined || _joinedChannel == null || widget.callerId == null) {
setState(() {
@@ -350,14 +362,16 @@ class _IncomingCallScreenState extends State<IncomingCallScreen> {
_statePoll?.cancel();
_statePoll = Timer.periodic(const Duration(seconds: 2), (_) async {
if (!mounted || _joinedChannel == null) return;
try {
final state = await sl<CallService>()
final state = await runFriendly<Map<String, dynamic>>(
() => sl<CallService>()
.getCallState(_joinedChannel)
.timeout(const Duration(seconds: 3));
if (state?['status']?.toString() == 'ENDED') {
await _finishIncomingRemoteEnded();
}
} catch (_) {}
.timeout(const Duration(seconds: 3)),
onError: (_) {},
fallback: 'Polling panggilan masuk gagal.',
);
if (state?['status']?.toString() == 'ENDED') {
await _finishIncomingRemoteEnded();
}
});
}
@@ -0,0 +1,3 @@
Call data layer.
This layer is reserved for call remote data sources and repository implementations over `/shared/call/**`.
@@ -0,0 +1,3 @@
Call domain layer.
This layer is reserved for call session entities, repository contracts, and call use cases.
@@ -0,0 +1,3 @@
Guardian dashboard application layer.
This layer is reserved for dashboard, map, SOS, notification, AI config, shortcut, and geofence Cubits.
@@ -0,0 +1,3 @@
Guardian dashboard data layer.
This layer is reserved for `/guardian/**` data sources and repository implementations.
@@ -0,0 +1,3 @@
Guardian dashboard domain layer.
This layer is reserved for Guardian dashboard entities, repository contracts, and use cases.
@@ -0,0 +1,3 @@
Home application layer.
This layer is reserved for role-specific home state orchestration.
@@ -0,0 +1,3 @@
Home data layer.
This layer is reserved for home/dashboard data adapters.
@@ -0,0 +1,3 @@
Home domain layer.
This layer is reserved for home/dashboard domain entities and use cases.
@@ -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;
@@ -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;
}
}
@@ -0,0 +1,3 @@
Manual application layer.
This layer is reserved for manual/TTS instruction state orchestration.
@@ -0,0 +1,3 @@
Manual data layer.
This layer is reserved for local command and shortcut documentation data sources.
@@ -0,0 +1,3 @@
Manual domain layer.
This layer is reserved for manual section entities and instruction use cases.
@@ -0,0 +1,3 @@
Manual presentation layer.
This layer is reserved for manual pages and widgets.
@@ -0,0 +1,3 @@
Navigation mode application layer.
This layer is reserved for navigation Cubit/BLoC orchestration.
@@ -0,0 +1,3 @@
Navigation mode data layer.
This layer is reserved for location, OSM, and OSRM data adapters.
@@ -0,0 +1,3 @@
Navigation mode domain layer.
This layer is reserved for route, waypoint, and navigation use cases.
@@ -61,35 +61,40 @@ class _NavState extends Cubit<int> {
StreamSubscription<Position>? _posStream;
void _set(_NavPhase p, String status) {
if (isClosed) return;
phase = p;
statusText = status;
_notify();
}
void _notify() => emit(state + 1);
void _notify() {
if (isClosed) return;
emit(state + 1);
}
// ── locate ──────────────────────────────────────────────────────────────
Future<bool> locate() async {
_set(_NavPhase.locating, 'Mencari lokasi GPS…');
final located = await guarded<bool>(
() async {
LocationPermission perm = await Geolocator.checkPermission();
if (perm == LocationPermission.denied) {
perm = await Geolocator.requestPermission();
}
if (perm == LocationPermission.deniedForever) {
_set(_NavPhase.error, 'Izin lokasi diblokir permanen.');
return false;
}
final pos = await Geolocator.getCurrentPosition(
desiredAccuracy: LocationAccuracy.high,
).timeout(const Duration(seconds: 12));
currentPosition = LatLng(pos.latitude, pos.longitude);
_set(_NavPhase.idle, 'Lokasi ditemukan. Cari tujuan atau ketuk peta.');
_reportToBackend(pos);
return true;
LocationPermission perm = await Geolocator.checkPermission();
if (perm == LocationPermission.denied) {
perm = await Geolocator.requestPermission();
}
if (perm == LocationPermission.deniedForever) {
_set(_NavPhase.error, 'Izin lokasi diblokir permanen.');
return false;
}
final pos = await Geolocator.getCurrentPosition(
desiredAccuracy: LocationAccuracy.high,
).timeout(const Duration(seconds: 12));
currentPosition = LatLng(pos.latitude, pos.longitude);
_set(_NavPhase.idle, 'Lokasi ditemukan. Cari tujuan atau ketuk peta.');
_reportToBackend(pos);
return true;
},
onTimeout: () => _set(_NavPhase.error, 'GPS timeout. Pastikan GPS aktif.'),
onTimeout: () =>
_set(_NavPhase.error, 'GPS timeout. Pastikan GPS aktif.'),
onError: (_) => _set(_NavPhase.error,
'Lokasi belum bisa dibaca. Pastikan GPS dan izin lokasi aktif.'),
);
@@ -113,33 +118,37 @@ class _NavState extends Cubit<int> {
Future<List<_Place>> searchPlaces(String query) async {
if (query.trim().isEmpty) return const [];
return await guarded<List<_Place>>(
() async {
final res = await Dio().get(
'https://nominatim.openstreetmap.org/search',
queryParameters: {
'q': query,
'format': 'jsonv2',
'limit': 6,
'addressdetails': 0,
if (currentPosition != null) 'viewbox': _viewbox(currentPosition!),
if (currentPosition != null) 'bounded': 0,
},
options: Options(
headers: {'User-Agent': 'WalkGuide/1.0 (walkguide@campus.ac.id)'},
receiveTimeout: const Duration(seconds: 8),
),
);
final list = res.data as List;
return list.map((e) {
final lat = double.tryParse(e['lat'].toString()) ?? 0;
final lng = double.tryParse(e['lon'].toString()) ?? 0;
return _Place(
displayName: e['display_name'].toString(),
position: LatLng(lat, lng),
);
}).toList();
},
) ?? const [];
() async {
final res = await Dio().get(
'https://nominatim.openstreetmap.org/search',
queryParameters: {
'q': query,
'format': 'jsonv2',
'limit': 6,
'addressdetails': 0,
if (currentPosition != null)
'viewbox': _viewbox(currentPosition!),
if (currentPosition != null) 'bounded': 0,
},
options: Options(
headers: {
'User-Agent': 'WalkGuide/1.0 (walkguide@campus.ac.id)'
},
receiveTimeout: const Duration(seconds: 8),
),
);
final list = res.data as List;
return list.map((e) {
final lat = double.tryParse(e['lat'].toString()) ?? 0;
final lng = double.tryParse(e['lon'].toString()) ?? 0;
return _Place(
displayName: e['display_name'].toString(),
position: LatLng(lat, lng),
);
}).toList();
},
) ??
const [];
}
String _viewbox(LatLng c) =>
@@ -148,23 +157,25 @@ class _NavState extends Cubit<int> {
// ── reverse geocode ──────────────────────────────────────────────────────
Future<String> reverseGeocode(LatLng pos) async {
return await guarded<String>(
() async {
final res = await Dio().get(
'https://nominatim.openstreetmap.org/reverse',
queryParameters: {
'lat': pos.latitude,
'lon': pos.longitude,
'format': 'jsonv2',
},
options: Options(
headers: {'User-Agent': 'WalkGuide/1.0 (walkguide@campus.ac.id)'},
receiveTimeout: const Duration(seconds: 6),
),
);
return res.data['display_name']?.toString() ??
'${pos.latitude.toStringAsFixed(5)}, ${pos.longitude.toStringAsFixed(5)}';
},
) ??
() async {
final res = await Dio().get(
'https://nominatim.openstreetmap.org/reverse',
queryParameters: {
'lat': pos.latitude,
'lon': pos.longitude,
'format': 'jsonv2',
},
options: Options(
headers: {
'User-Agent': 'WalkGuide/1.0 (walkguide@campus.ac.id)'
},
receiveTimeout: const Duration(seconds: 6),
),
);
return res.data['display_name']?.toString() ??
'${pos.latitude.toStringAsFixed(5)}, ${pos.longitude.toStringAsFixed(5)}';
},
) ??
'${pos.latitude.toStringAsFixed(5)}, ${pos.longitude.toStringAsFixed(5)}';
}
@@ -180,47 +191,47 @@ class _NavState extends Cubit<int> {
final origin = currentPosition!;
await guarded<void>(
() async {
final url = 'http://router.project-osrm.org/route/v1/foot/'
'${origin.longitude},${origin.latitude};'
'${dest.position.longitude},${dest.position.latitude}'
'?steps=true&geometries=geojson&overview=full&annotations=false';
final url = 'http://router.project-osrm.org/route/v1/foot/'
'${origin.longitude},${origin.latitude};'
'${dest.position.longitude},${dest.position.latitude}'
'?steps=true&geometries=geojson&overview=full&annotations=false';
final res = await Dio().get(
url,
options: Options(receiveTimeout: const Duration(seconds: 12)),
);
final res = await Dio().get(
url,
options: Options(receiveTimeout: const Duration(seconds: 12)),
);
final route = res.data['routes'][0];
final geom = route['geometry']['coordinates'] as List;
routePoints = geom.map((c) {
final lst = c as List;
return LatLng((lst[1] as num).toDouble(), (lst[0] as num).toDouble());
}).toList();
final route = res.data['routes'][0];
final geom = route['geometry']['coordinates'] as List;
routePoints = geom.map((c) {
final lst = c as List;
return LatLng((lst[1] as num).toDouble(), (lst[0] as num).toDouble());
}).toList();
// parse steps
final legs = route['legs'] as List;
final rawSteps = <_Step>[];
for (final leg in legs) {
for (final step in leg['steps'] as List) {
final maneuver = step['maneuver'] as Map;
final instruction = _buildInstruction(maneuver, step);
final dist = (step['distance'] as num?)?.toDouble() ?? 0;
final loc = maneuver['location'] as List;
rawSteps.add(_Step(
instruction: instruction,
distanceM: dist,
point:
LatLng((loc[1] as num).toDouble(), (loc[0] as num).toDouble()),
));
// parse steps
final legs = route['legs'] as List;
final rawSteps = <_Step>[];
for (final leg in legs) {
for (final step in leg['steps'] as List) {
final maneuver = step['maneuver'] as Map;
final instruction = _buildInstruction(maneuver, step);
final dist = (step['distance'] as num?)?.toDouble() ?? 0;
final loc = maneuver['location'] as List;
rawSteps.add(_Step(
instruction: instruction,
distanceM: dist,
point: LatLng(
(loc[1] as num).toDouble(), (loc[0] as num).toDouble()),
));
}
}
}
steps = rawSteps;
currentStepIndex = 0;
steps = rawSteps;
currentStepIndex = 0;
_set(_NavPhase.navigating,
steps.isNotEmpty ? steps[0].instruction : 'Ikuti rute biru.');
_notify();
_startTracking();
_set(_NavPhase.navigating,
steps.isNotEmpty ? steps[0].instruction : 'Ikuti rute biru.');
_notify();
_startTracking();
},
onError: (_) => _set(_NavPhase.error,
'Gagal mendapat rute. Periksa koneksi lalu coba lagi.'),
@@ -289,6 +300,7 @@ class _NavState extends Cubit<int> {
distanceFilter: 5,
),
).listen((pos) {
if (isClosed) return;
currentPosition = LatLng(pos.latitude, pos.longitude);
_reportToBackend(pos);
_updateStep();
@@ -298,6 +310,7 @@ class _NavState extends Cubit<int> {
void _updateStep() {
if (steps.isEmpty || phase != _NavPhase.navigating) return;
if (currentPosition == null) return;
if (currentStepIndex >= steps.length - 1) return;
final current = steps[currentStepIndex];
@@ -317,6 +330,7 @@ class _NavState extends Cubit<int> {
}
void stopNavigation() {
if (isClosed) return;
_posStream?.cancel();
_posStream = null;
destination = null;
@@ -0,0 +1,3 @@
Pairing application layer.
This layer is reserved for pairing Cubit/BLoC orchestration.
@@ -0,0 +1,3 @@
Pairing data layer.
This layer is reserved for `/shared/pairing/**` data sources and repository implementations.
@@ -0,0 +1,3 @@
Pairing domain layer.
This layer is reserved for pairing entities, repository contracts, and use cases.
@@ -0,0 +1,3 @@
Server connect application layer.
This layer is reserved for connection testing and save-server-url state orchestration.
@@ -0,0 +1,3 @@
Server connect data layer.
This layer is reserved for ping data sources and local server URL persistence adapters.
@@ -0,0 +1,3 @@
Server connect domain layer.
This layer is reserved for server info entities and connection use cases.
@@ -0,0 +1,3 @@
Server connect presentation layer.
This layer is reserved for first-run connection pages and widgets.
@@ -37,6 +37,7 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
await runFriendlyAction(
() async {
final clean = AppConstants.normalizeServerUrl(_url.text);
await sl<ApiClient>().init(clean);
final res = await Dio(BaseOptions(
connectTimeout: AppConstants.pingTimeout,
receiveTimeout: AppConstants.pingTimeout,
@@ -47,7 +48,8 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
: 'Server merespons, tetapi format ping tidak valid.';
},
onError: (message) => _message = message,
fallback: 'Tidak bisa terhubung. Periksa URL dan jaringan.',
fallback:
'Tidak bisa terhubung. Untuk HP via USB, jalankan adb reverse tcp:8080 tcp:8080 lalu pakai http://127.0.0.1:8080.',
);
if (mounted) setState(() => _loading = false);
}
@@ -60,6 +62,8 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
}
void _useUsbUrl() => setState(() => _url.text = 'http://127.0.0.1:8080');
void _useAndroidEmulatorUrl() =>
setState(() => _url.text = 'http://10.0.2.2:8080');
@override
Widget build(BuildContext context) {
@@ -96,12 +100,23 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
SafeArea(
child: LayoutBuilder(
builder: (context, constraints) {
final compact = constraints.maxWidth < 390;
final compact =
constraints.maxWidth < 480 || constraints.maxHeight < 720;
final horizontalPadding =
constraints.maxWidth < 480 ? 12.0 : 20.0;
return SingleChildScrollView(
padding: EdgeInsets.fromLTRB(20, compact ? 20 : 36, 20, 24),
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior.onDrag,
padding: EdgeInsets.fromLTRB(
horizontalPadding,
compact ? 10 : 32,
horizontalPadding,
20 + MediaQuery.of(context).viewInsets.bottom,
),
child: Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 460),
constraints:
BoxConstraints(maxWidth: compact ? 380 : 520),
child: TweenAnimationBuilder<double>(
tween: Tween(begin: 18, end: 0),
duration: const Duration(milliseconds: 520),
@@ -114,7 +129,8 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
child: Container(
decoration: BoxDecoration(
color: Colors.white.withValues(alpha: 0.96),
borderRadius: BorderRadius.circular(28),
borderRadius:
BorderRadius.circular(compact ? 22 : 28),
border: Border.all(
color: Colors.white.withValues(alpha: 0.7)),
boxShadow: [
@@ -126,13 +142,18 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
],
),
child: ClipRRect(
borderRadius: BorderRadius.circular(28),
borderRadius:
BorderRadius.circular(compact ? 22 : 28),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Container(
padding:
const EdgeInsets.fromLTRB(22, 22, 22, 20),
padding: EdgeInsets.fromLTRB(
compact ? 14 : 22,
compact ? 14 : 22,
compact ? 14 : 22,
compact ? 14 : 20,
),
decoration: const BoxDecoration(
color: Color(0xFF071226),
),
@@ -143,37 +164,38 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
Row(
children: [
Container(
width: 48,
height: 48,
width: compact ? 38 : 48,
height: compact ? 38 : 48,
decoration: BoxDecoration(
color: const Color(0xFF2563EB),
borderRadius:
BorderRadius.circular(16),
),
child: const Icon(
Icons.navigation_rounded,
color: Colors.white,
size: 28),
child: Icon(
Icons.navigation_rounded,
color: Colors.white,
size: compact ? 24 : 28,
),
),
const SizedBox(width: 12),
const Expanded(
Expanded(
child: Text(
'WalkGuide Link',
'WalkGuide',
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontSize: compact ? 16 : 20,
fontWeight: FontWeight.w900,
),
),
),
],
),
const SizedBox(height: 18),
const Text(
SizedBox(height: compact ? 14 : 18),
Text(
'Connect to Server',
style: TextStyle(
color: Colors.white,
fontSize: 30,
fontSize: compact ? 22 : 30,
fontWeight: FontWeight.w900,
height: 1,
),
@@ -191,7 +213,7 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
),
),
Padding(
padding: const EdgeInsets.all(22),
padding: EdgeInsets.all(compact ? 14 : 22),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.stretch,
@@ -217,13 +239,18 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
label: 'USB: 127.0.0.1',
onTap: _useUsbUrl,
),
_HintChip(
icon: Icons.phone_android_outlined,
label: 'Emulator: 10.0.2.2',
onTap: _useAndroidEmulatorUrl,
),
const _HintChip(
icon: Icons.wifi_tethering_outlined,
label: 'Wi-Fi: IP laptop',
),
],
),
const SizedBox(height: 16),
SizedBox(height: compact ? 12 : 16),
OutlinedButton.icon(
onPressed: _loading ? null : _test,
icon: _loading
@@ -251,15 +278,17 @@ class _ServerConnectScreenState extends State<ServerConnectScreen> {
label: const Text('Continue'),
),
],
const SizedBox(height: 18),
const Center(
child: Text(
'v1.0.0 | Spring Boot + Flutter',
style: TextStyle(
fontSize: 11,
color: Color(0xFF94A3B8)),
if (!compact) ...[
const SizedBox(height: 18),
const Center(
child: Text(
'v1.0.0 | Spring Boot + Flutter',
style: TextStyle(
fontSize: 11,
color: Color(0xFF94A3B8)),
),
),
),
],
],
),
),
@@ -0,0 +1,3 @@
Settings application layer.
This layer is reserved for settings Cubit/BLoC orchestration.
@@ -0,0 +1,3 @@
Settings data layer.
This layer is reserved for `/user/settings` and local settings data adapters.
@@ -0,0 +1,3 @@
Settings domain layer.
This layer is reserved for settings entities, repository contracts, and update use cases.
@@ -125,6 +125,7 @@ class _UserSettingsScreenState extends State<UserSettingsScreen> {
setState(() => _saving = true);
// Apply TTS locally dulu
await sl<TtsService>().setLanguage(_ttsLanguage);
context.read<AppCubit>().setLocaleCode(_ttsLanguage);
if (_hapticEnabled) {
await sl<HapticService>().success();
}
@@ -243,9 +243,18 @@ class _SosScreenState extends State<SosScreen>
bloc: _sosCubit,
builder: (context, sosState) {
final sending = sosState.phase == SosPhase.sending;
final size = MediaQuery.sizeOf(context);
final compact = size.height < 620;
final landscapeTight = size.width > size.height && size.height < 520;
final pagePadding = compact ? 12.0 : 16.0;
final sectionGap = landscapeTight
? 8.0
: compact
? 12.0
: 24.0;
return SafeArea(
child: Padding(
padding: const EdgeInsets.all(16),
padding: EdgeInsets.all(pagePadding),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
@@ -278,14 +287,14 @@ class _SosScreenState extends State<SosScreen>
],
),
const SizedBox(height: 24),
SizedBox(height: sectionGap),
// Active SOS banner
if (_hasActiveSos)
_ActiveSosBanner(
event: _events.first, onRefresh: _loadHistory),
const SizedBox(height: 24),
SizedBox(height: sectionGap),
// SOS Button
Center(
@@ -312,6 +321,8 @@ class _SosScreenState extends State<SosScreen>
? 'SOS aktif — Guardian sudah mendapat notifikasi'
: 'Tekan tombol untuk kirim SOS darurat ke Guardian',
textAlign: TextAlign.center,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: _hasActiveSos
? const Color(0xFFDC2626)
@@ -321,22 +332,25 @@ class _SosScreenState extends State<SosScreen>
),
),
const SizedBox(height: 28),
SizedBox(height: sectionGap),
// History section
const Text(
'Riwayat SOS',
style: TextStyle(fontWeight: FontWeight.w800, fontSize: 16),
),
const SizedBox(height: 10),
Expanded(
if (!landscapeTight) ...[
const Text(
'Riwayat SOS',
style: TextStyle(fontWeight: FontWeight.w800, fontSize: 16),
),
const SizedBox(height: 10),
Expanded(
child: _SosHistory(
loading: _historyLoading,
error: _historyError,
events: _events,
onRefresh: _loadHistory,
)),
loading: _historyLoading,
error: _historyError,
events: _events,
onRefresh: _loadHistory,
),
),
] else
const Spacer(),
],
),
),
@@ -361,8 +375,16 @@ class _SosButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
final screen = MediaQuery.sizeOf(context);
final compact = screen.height < 620;
final landscapeTight = screen.width > screen.height && screen.height < 520;
final dimension = landscapeTight
? 132.0
: compact
? 154.0
: 200.0;
return SizedBox.square(
dimension: 200,
dimension: dimension,
child: FilledButton(
style: FilledButton.styleFrom(
shape: const CircleBorder(),
@@ -377,14 +399,14 @@ class _SosButton extends StatelessWidget {
children: [
Icon(
active ? Icons.emergency : Icons.emergency_outlined,
size: 48,
size: dimension < 150 ? 34 : 48,
color: Colors.white,
),
const SizedBox(height: 6),
SizedBox(height: dimension < 150 ? 3 : 6),
Text(
'SOS',
style: const TextStyle(
fontSize: 38,
style: TextStyle(
fontSize: dimension < 150 ? 28 : 38,
fontWeight: FontWeight.w900,
color: Colors.white,
letterSpacing: 2,
@@ -402,8 +424,16 @@ class _SendingIndicator extends StatelessWidget {
@override
Widget build(BuildContext context) {
final screen = MediaQuery.sizeOf(context);
final compact = screen.height < 620;
final landscapeTight = screen.width > screen.height && screen.height < 520;
final dimension = landscapeTight
? 132.0
: compact
? 154.0
: 200.0;
return SizedBox.square(
dimension: 200,
dimension: dimension,
child: DecoratedBox(
decoration: BoxDecoration(
color: const Color(0xFFDC2626).withValues(alpha: 0.15),
@@ -144,6 +144,7 @@ class _WalkGuideScreenState extends State<WalkGuideScreen>
() async {
final cameras = await availableCameras();
if (cameras.isEmpty) return;
await sl<YoloDetector>().init();
final backCamera = cameras.firstWhere(
(camera) => camera.lensDirection == CameraLensDirection.back,
orElse: () => cameras.first,
@@ -808,6 +809,7 @@ class _Page extends StatelessWidget {
@override
Widget build(BuildContext context) {
final compact = MediaQuery.sizeOf(context).height < 520;
return SafeArea(
child: DecoratedBox(
decoration: const BoxDecoration(
@@ -818,15 +820,20 @@ class _Page extends StatelessWidget {
),
),
child: Padding(
padding: const EdgeInsets.fromLTRB(16, 14, 16, 16),
padding: EdgeInsets.fromLTRB(
compact ? 12 : 16,
compact ? 8 : 14,
compact ? 12 : 16,
compact ? 10 : 16,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Container(
width: 46,
height: 46,
width: compact ? 38 : 46,
height: compact ? 38 : 46,
decoration: BoxDecoration(
color: const Color(0xFF2563EB),
borderRadius: BorderRadius.circular(14),
@@ -839,21 +846,24 @@ class _Page extends StatelessWidget {
),
],
),
child: const Icon(Icons.navigation_rounded,
color: Colors.white, size: 26),
child: Icon(Icons.navigation_rounded,
color: Colors.white, size: compact ? 22 : 26),
),
const SizedBox(width: 12),
SizedBox(width: compact ? 10 : 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context)
.textTheme
.headlineSmall
?.copyWith(
fontWeight: FontWeight.w900,
color: const Color(0xFF0F172A),
fontSize: compact ? 22 : null,
)),
if (subtitle != null)
Text(subtitle!,
@@ -866,7 +876,7 @@ class _Page extends StatelessWidget {
...?actions,
],
),
const SizedBox(height: 16),
SizedBox(height: compact ? 8 : 16),
Expanded(child: child),
],
),