From f180f6ff36f29b779d7bc1377387c72a3aa8cfad Mon Sep 17 00:00:00 2001 From: 240403 <240403@epvc.pt> Date: Thu, 12 Mar 2026 14:29:55 +0000 Subject: [PATCH] =?UTF-8?q?adi=C3=A7=C3=A3o=20e=20conexao=20das=20telas=20?= =?UTF-8?q?que=20faltavam?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/screens/bluethoot_cpnnection_screen.dart | 411 +++++++++++++++++++ lib/screens/google_map_screen.dart | 262 ++++++++++++ lib/screens/logado_screen.dart | 14 +- 3 files changed, 680 insertions(+), 7 deletions(-) diff --git a/lib/screens/bluethoot_cpnnection_screen.dart b/lib/screens/bluethoot_cpnnection_screen.dart index e69de29..19b558d 100644 --- a/lib/screens/bluethoot_cpnnection_screen.dart +++ b/lib/screens/bluethoot_cpnnection_screen.dart @@ -0,0 +1,411 @@ +import 'dart:async'; +import 'dart:io'; +import 'package:flutter/material.dart'; +import 'package:flutter_blue_plus/flutter_blue_plus.dart'; +import 'package:permission_handler/permission_handler.dart'; +import '../constants/app_colors.dart'; +import '../constants/app_strings.dart'; + +class BluetoothConnectionScreen extends StatefulWidget { + const BluetoothConnectionScreen({super.key}); + + @override + State createState() => _BluetoothConnectionScreenState(); +} + +class _BluetoothConnectionScreenState extends State { + List _scanResults = []; + bool _isScanning = false; + BluetoothDevice? _connectedDevice; + late StreamSubscription> _scanResultsSubscription; + late StreamSubscription _isScanningSubscription; + + @override + void initState() { + super.initState(); + + _scanResultsSubscription = FlutterBluePlus.scanResults.listen((results) { + if (mounted) { + setState(() { + // Filtra os dispositivos para mostrar apenas aqueles que possuem um nome identificado + _scanResults = results.where((r) => r.device.platformName.isNotEmpty).toList(); + }); + } + }); + + _isScanningSubscription = FlutterBluePlus.isScanning.listen((state) { + if (mounted) { + setState(() { + _isScanning = state; + }); + } + }); + } + + @override + void dispose() { + _scanResultsSubscription.cancel(); + _isScanningSubscription.cancel(); + super.dispose(); + } + + Future _requestPermissionsAndStartScan() async { + if (Platform.isAndroid) { + Map statuses = await [ + Permission.bluetoothScan, + Permission.bluetoothConnect, + Permission.bluetoothAdvertise, + Permission.location, + ].request(); + + bool allGranted = true; + if (statuses[Permission.bluetoothScan]?.isDenied ?? true) allGranted = false; + if (statuses[Permission.bluetoothConnect]?.isDenied ?? true) allGranted = false; + + final bool scanPermanentlyDenied = statuses[Permission.bluetoothScan]?.isPermanentlyDenied ?? false; + final bool connectPermanentlyDenied = statuses[Permission.bluetoothConnect]?.isPermanentlyDenied ?? false; + + if (scanPermanentlyDenied || connectPermanentlyDenied) { + if (mounted) { + _showSettingsDialog(); + } + return; + } + + if (allGranted) { + _startScan(); + } else { + if (mounted) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text(AppStrings.permissionsDenied), + behavior: SnackBarBehavior.floating, + ), + ); + } + } + } else { + _startScan(); + } + } + + void _showSettingsDialog() { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text("Permissões Necessárias"), + content: const Text("As permissões de Bluetooth foram negadas permanentemente. Por favor, habilite-as nas configurações do sistema para continuar."), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: const Text("CANCELAR"), + ), + TextButton( + onPressed: () { + openAppSettings(); + Navigator.pop(context); + }, + child: const Text("CONFIGURAÇÕES"), + ), + ], + ), + ); + } + + Future _startScan() async { + try { + if (await FlutterBluePlus.adapterState.first != BluetoothAdapterState.on) { + if (mounted) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text(AppStrings.turnOnBluetooth), + behavior: SnackBarBehavior.floating, + ), + ); + } + return; + } + + await FlutterBluePlus.startScan( + timeout: const Duration(seconds: 15), + ); + } catch (e) { + if (mounted) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text('${AppStrings.scanError}$e'), + behavior: SnackBarBehavior.floating, + ), + ); + } + } + } + + Future _stopScan() async { + try { + await FlutterBluePlus.stopScan(); + } catch (e) { + if (mounted) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text('${AppStrings.stopScanError}$e'), + behavior: SnackBarBehavior.floating, + ), + ); + } + } + } + + Future _connectToDevice(BluetoothDevice device) async { + try { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text('${AppStrings.connectingTo}${device.platformName.isEmpty ? AppStrings.unknownDevice : device.platformName}...'), + duration: const Duration(seconds: 2), + behavior: SnackBarBehavior.floating, + ), + ); + + await device.connect(); + if (mounted) { + setState(() { + _connectedDevice = device; + _isScanning = false; + }); + FlutterBluePlus.stopScan(); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text(AppStrings.connectedSuccess), + backgroundColor: AppColors.success, + behavior: SnackBarBehavior.floating, + ), + ); + } + } catch (e) { + if (mounted) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text('${AppStrings.connectFail}$e'), + backgroundColor: AppColors.error, + behavior: SnackBarBehavior.floating, + ), + ); + } + } + } + + Future _disconnectDevice() async { + if (_connectedDevice != null) { + await _connectedDevice!.disconnect(); + setState(() { + _connectedDevice = null; + }); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColors.background, + appBar: AppBar( + title: const Text( + AppStrings.bluetoothTitle, + style: TextStyle( + fontWeight: FontWeight.w900, + letterSpacing: 2, + color: Colors.white, + ), + ), + centerTitle: true, + backgroundColor: Colors.transparent, + elevation: 0, + leading: IconButton( + icon: const Icon(Icons.arrow_back_ios_new, color: Colors.white, size: 20), + onPressed: () => Navigator.pop(context), + ), + ), + body: Stack( + children: [ + Column( + children: [ + const SizedBox(height: 20), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 25), + child: Container( + padding: const EdgeInsets.all(25), + decoration: BoxDecoration( + color: AppColors.backgroundGrey, + borderRadius: BorderRadius.circular(30), + border: Border.all(color: Colors.white.withValues(alpha: 0.05)), + boxShadow: [ + BoxShadow( + color: Colors.black.withValues(alpha: 0.3), + blurRadius: 20, + offset: const Offset(0, 10), + ), + ], + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + _connectedDevice != null + ? AppStrings.statusConnected + : (_isScanning ? AppStrings.searching : AppStrings.statusReady), + style: TextStyle( + color: _connectedDevice != null ? Colors.greenAccent : (_isScanning ? AppColors.coral : Colors.white54), + fontSize: 10, + fontWeight: FontWeight.w900, + letterSpacing: 1, + ), + ), + const SizedBox(height: 8), + Text( + _connectedDevice != null + ? AppStrings.oneDevice + : '${_scanResults.length} ${AppStrings.foundDevices}', + style: const TextStyle( + color: Colors.white, + fontSize: 22, + fontWeight: FontWeight.w900, + ), + ), + ], + ), + if (_connectedDevice == null) + GestureDetector( + onTap: _isScanning ? _stopScan : _requestPermissionsAndStartScan, + child: Container( + padding: const EdgeInsets.all(15), + decoration: BoxDecoration( + color: _isScanning ? Colors.red.withValues(alpha: 0.1) : AppColors.coral.withValues(alpha: 0.1), + shape: BoxShape.circle, + border: Border.all( + color: _isScanning ? Colors.red.withValues(alpha: 0.5) : AppColors.coral.withValues(alpha: 0.5), + width: 2, + ), + ), + child: Icon( + _isScanning ? Icons.stop_rounded : Icons.search_rounded, + color: _isScanning ? Colors.red : AppColors.coral, + size: 28, + ), + ), + ) + else + GestureDetector( + onTap: _disconnectDevice, + child: Container( + padding: const EdgeInsets.all(15), + decoration: BoxDecoration( + color: Colors.red.withValues(alpha: 0.1), + shape: BoxShape.circle, + border: Border.all( + color: Colors.red.withValues(alpha: 0.5), + width: 2, + ), + ), + child: const Icon( + Icons.close_rounded, + color: Colors.red, + size: 28, + ), + ), + ), + ], + ), + ), + ), + const SizedBox(height: 30), + Expanded( + child: ListView.builder( + itemCount: _connectedDevice != null ? 1 : _scanResults.length, + padding: const EdgeInsets.symmetric(horizontal: 25), + physics: const BouncingScrollPhysics(), + itemBuilder: (context, index) { + final BluetoothDevice device = _connectedDevice ?? _scanResults[index].device; + final name = device.platformName.isEmpty ? AppStrings.unknownDevice : device.platformName; + + return Padding( + padding: const EdgeInsets.only(bottom: 18), + child: Container( + padding: const EdgeInsets.all(20), + decoration: BoxDecoration( + color: AppColors.backgroundGrey.withValues(alpha: 0.4), + borderRadius: BorderRadius.circular(25), + border: Border.all(color: Colors.white.withValues(alpha: 0.03)), + ), + child: Row( + children: [ + Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: AppColors.background.withValues(alpha: 0.8), + borderRadius: BorderRadius.circular(15), + ), + child: Icon( + Icons.bluetooth_audio_rounded, + color: _connectedDevice != null ? Colors.greenAccent : AppColors.coral.withValues(alpha: 0.8), + size: 24 + ), + ), + const SizedBox(width: 20), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + name, + style: const TextStyle( + color: Colors.white, + fontSize: 16, + fontWeight: FontWeight.w900 + ), + ), + const SizedBox(height: 4), + Text( + device.remoteId.toString(), + style: const TextStyle( + color: Colors.white38, + fontSize: 11, + fontWeight: FontWeight.bold + ), + ), + ], + ), + ), + if (_connectedDevice == null) + GestureDetector( + onTap: () => _connectToDevice(device), + child: const Icon(Icons.add_link_rounded, color: Colors.white24), + ) + else + const Icon(Icons.check_circle_rounded, color: Colors.greenAccent), + ], + ), + ), + ); + }, + ), + ), + ], + ), + if (_isScanning) + const Positioned( + bottom: 0, + left: 0, + right: 0, + child: LinearProgressIndicator( + backgroundColor: Colors.transparent, + valueColor: AlwaysStoppedAnimation(AppColors.coral), + minHeight: 2, + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/google_map_screen.dart b/lib/screens/google_map_screen.dart index e69de29..f2bb209 100644 --- a/lib/screens/google_map_screen.dart +++ b/lib/screens/google_map_screen.dart @@ -0,0 +1,262 @@ +import 'dart:async'; +import 'dart:math'; +import 'dart:ui' as ui; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; +import 'package:geolocator/geolocator.dart'; +import '../constants/app_colors.dart'; +import '../constants/app_strings.dart'; + +class GoogleMapScreen extends StatefulWidget { + const GoogleMapScreen({super.key}); + + @override + State createState() => _GoogleMapScreenState(); +} + +class _GoogleMapScreenState extends State { + GoogleMapController? _mapController; + StreamSubscription? _positionStreamSubscription; + Timer? _simulationTimer; + + // Controle de frequência de atualização para evitar sobrecarga e crashes + DateTime? _lastUpdate; + + final List _routePoints = []; + final Set _polylines = {}; + final Set _markers = {}; + + LatLng? _plannedStart; + LatLng? _plannedEnd; + bool _isPlanningMode = false; + bool _isRunning = false; + + double _currentSpeed = 0.0; + double _totalDistance = 0.0; + LatLng _currentPosition = const LatLng(38.7223, -9.1393); + bool _isLoading = true; + bool _isSimulating = false; + + BitmapDescriptor? _startIcon; + BitmapDescriptor? _arrowIcon; + BitmapDescriptor? _finishIcon; + + @override + void initState() { + super.initState(); + _setupIconsAndTracking(); + } + + Future _setupIconsAndTracking() async { + // Marcadores premium: tamanho ideal para visibilidade e estética + _startIcon = await _createPremiumMarker(Colors.greenAccent, Icons.play_arrow_rounded, 85); + _finishIcon = await _createPremiumMarker(AppColors.coral, Icons.flag_rounded, 85); + _arrowIcon = await _createArrowMarker(Colors.black, Colors.white, 95); + await _initTracking(); + } + + Future _createPremiumMarker(Color color, IconData icon, double size) async { + final ui.PictureRecorder recorder = ui.PictureRecorder(); + final Canvas canvas = Canvas(recorder); + final Paint shadowPaint = Paint()..color = Colors.black.withOpacity(0.4)..maskFilter = const MaskFilter.blur(BlurStyle.normal, 6); + canvas.drawCircle(Offset(size / 2, size / 2 + 3), size / 2, shadowPaint); + canvas.drawCircle(Offset(size / 2, size / 2), size / 2, Paint()..color = Colors.white); + canvas.drawCircle(Offset(size / 2, size / 2), size / 2 - 5, Paint()..color = color); + TextPainter textPainter = TextPainter(textDirection: TextDirection.ltr); + textPainter.text = TextSpan(text: String.fromCharCode(icon.codePoint), style: TextStyle(fontSize: size * 0.6, fontFamily: icon.fontFamily, color: Colors.white, fontWeight: FontWeight.bold)); + textPainter.layout(); + textPainter.paint(canvas, Offset((size - textPainter.width) / 2, (size - textPainter.height) / 2)); + final ui.Image image = await recorder.endRecording().toImage(size.toInt(), size.toInt() + 6); + final ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png); + return BitmapDescriptor.fromBytes(byteData!.buffer.asUint8List()); + } + + Future _createArrowMarker(Color color, Color borderColor, double size) async { + final ui.PictureRecorder recorder = ui.PictureRecorder(); + final Canvas canvas = Canvas(recorder); + final Path path = Path(); + path.moveTo(size / 2, 0); + path.lineTo(size * 0.9, size); + path.lineTo(size / 2, size * 0.7); + path.lineTo(size * 0.1, size); + path.close(); + canvas.drawPath(path.shift(const Offset(0, 4)), Paint()..color = Colors.black38..maskFilter = const MaskFilter.blur(BlurStyle.normal, 4)); + canvas.drawPath(path, Paint()..color = color); + canvas.drawPath(path, Paint()..color = borderColor..style = ui.PaintingStyle.stroke..strokeWidth = 7); + final ui.Image image = await recorder.endRecording().toImage(size.toInt(), size.toInt() + 6); + final ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png); + return BitmapDescriptor.fromBytes(byteData!.buffer.asUint8List()); + } + + @override + void dispose() { + _positionStreamSubscription?.cancel(); + _simulationTimer?.cancel(); + _mapController?.dispose(); + super.dispose(); + } + + Future _initTracking() async { + bool serviceEnabled = await Geolocator.isLocationServiceEnabled(); + if (!serviceEnabled) return; + LocationPermission permission = await Geolocator.checkPermission(); + if (permission == LocationPermission.denied) { + permission = await Geolocator.requestPermission(); + if (permission == LocationPermission.denied) return; + } + Position position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.bestForNavigation); + _currentPosition = LatLng(position.latitude, position.longitude); + setState(() => _isLoading = false); + _startLocationStream(); + } + + void _startLocationStream() { + _positionStreamSubscription = Geolocator.getPositionStream( + locationSettings: const LocationSettings( + accuracy: LocationAccuracy.bestForNavigation, + distanceFilter: 0 + ) + ).listen((Position position) { + if (!_isSimulating) { + final now = DateTime.now(); + if (_lastUpdate == null || now.difference(_lastUpdate!).inMilliseconds > 500) { + _lastUpdate = now; + _updatePosition(LatLng(position.latitude, position.longitude), position.speed); + } + } + }, onError: (error) { + debugPrint("${AppStrings.unknownDevice}: $error"); + }); + } + + void _updatePosition(LatLng newPoint, double speed) { + if (!mounted) return; + setState(() { + if (_routePoints.isNotEmpty) { + _totalDistance += Geolocator.distanceBetween(_currentPosition.latitude, _currentPosition.longitude, newPoint.latitude, newPoint.longitude); + } + _currentSpeed = speed >= 0 ? speed : 0; + _routePoints.add(newPoint); + _currentPosition = newPoint; + _updateMarkers(); + + if (_routePoints.length > 1) { + _polylines.removeWhere((p) => p.polylineId.value == 'route' || p.polylineId.value == 'route_glow'); + _polylines.add(Polyline( + polylineId: const PolylineId('route_glow'), + points: List.from(_routePoints), + color: Colors.cyanAccent.withOpacity(0.3), + width: 14, + zIndex: 9, + )); + _polylines.add(Polyline( + polylineId: const PolylineId('route'), + points: List.from(_routePoints), + color: Colors.white, + width: 6, + patterns: [PatternItem.dot, PatternItem.gap(15)], + jointType: JointType.round, + zIndex: 10, + )); + } + }); + + if (_mapController != null) { + _mapController!.animateCamera(CameraUpdate.newLatLng(newPoint)); + } + } + + void _updateMarkers() { + _markers.removeWhere((m) => m.markerId.value == 'follower'); + _markers.add(Marker( + markerId: const MarkerId('follower'), + position: _currentPosition, + rotation: _calculateRotation(_routePoints), + flat: true, + anchor: const Offset(0.5, 0.5), + icon: _arrowIcon ?? BitmapDescriptor.defaultMarker, + zIndex: 12, + )); + } + + double _calculateRotation(List points) { + if (points.length < 2) return 0; + LatLng p1 = points[points.length - 2]; + LatLng p2 = points.last; + return Geolocator.bearingBetween(p1.latitude, p1.longitude, p2.latitude, p2.longitude); + } + + void _onMapTap(LatLng point) { + if (!_isPlanningMode) return; + setState(() { + if (_plannedStart == null) { + _plannedStart = point; + _markers.add(Marker(markerId: const MarkerId('planned_start'), position: point, icon: _startIcon ?? BitmapDescriptor.defaultMarker, zIndex: 5, infoWindow: const InfoWindow(title: AppStrings.startPoint))); + } else if (_plannedEnd == null) { + _plannedEnd = point; + _markers.add(Marker(markerId: const MarkerId('planned_end'), position: point, icon: _finishIcon ?? BitmapDescriptor.defaultMarker, zIndex: 5, infoWindow: const InfoWindow(title: AppStrings.finishPoint))); + _polylines.add(Polyline(polylineId: const PolylineId('planned_route'), points: [_plannedStart!, _plannedEnd!], color: Colors.white.withOpacity(0.1), width: 2, zIndex: 1)); + } else { + _plannedStart = point; + _plannedEnd = null; + _markers.removeWhere((m) => m.markerId.value.startsWith('planned')); + _polylines.removeWhere((p) => p.polylineId.value == 'planned_route'); + _markers.add(Marker(markerId: const MarkerId('planned_start'), position: point, icon: _startIcon ?? BitmapDescriptor.defaultMarker, zIndex: 5, infoWindow: const InfoWindow(title: AppStrings.startPoint))); + } + }); + } + + void _toggleSimulation() { + if (_isSimulating) { + _simulationTimer?.cancel(); + setState(() => _isSimulating = false); + } else { + setState(() { + _isSimulating = true; + _isPlanningMode = false; + _routePoints.clear(); + _polylines.removeWhere((p) => p.polylineId.value == 'route' || p.polylineId.value == 'route_glow'); + _totalDistance = 0.0; + _currentPosition = _plannedStart ?? _currentPosition; + _routePoints.add(_currentPosition); + _updateMarkers(); + }); + + _simulationTimer = Timer.periodic(const Duration(milliseconds: 100), (timer) { + double latStep = 0.000025; + double lngStep = 0.000025; + + if (_plannedEnd != null) { + double dist = Geolocator.distanceBetween(_currentPosition.latitude, _currentPosition.longitude, _plannedEnd!.latitude, _plannedEnd!.longitude); + if (dist < 2) { + _updatePosition(_plannedEnd!, 0.0); + _toggleSimulation(); + return; + } + latStep = (_plannedEnd!.latitude - _currentPosition.latitude) / (max(dist / 0.8, 1)); + lngStep = (_plannedEnd!.longitude - _currentPosition.longitude) / (max(dist / 0.8, 1)); + } + + LatLng nextPoint = LatLng(_currentPosition.latitude + latStep, _currentPosition.longitude + lngStep); + _updatePosition(nextPoint, 3.5 + Random().nextDouble() * 0.5); + }); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColors.background, + appBar: AppBar(title: Text(_isPlanningMode ? AppStrings.mapTitlePlanning : AppStrings.mapTitleRunning, style: const TextStyle(fontWeight: FontWeight.w900, color: Colors.white, letterSpacing: 2)), centerTitle: true, backgroundColor: Colors.transparent, elevation: 0, leading: IconButton(icon: const Icon(Icons.arrow_back_ios_new, color: Colors.white), onPressed: () => Navigator.pop(context)), actions: [IconButton(icon: Icon(_isPlanningMode ? Icons.check_circle_rounded : Icons.add_location_alt_rounded, color: AppColors.coral, size: 30), onPressed: () => setState(() => _isPlanningMode = !_isPlanningMode))]), + extendBodyBehindAppBar: true, + body: Stack(children: [Center(child: Container(width: MediaQuery.of(context).size.width * 0.94, height: MediaQuery.of(context).size.height * 0.7, decoration: BoxDecoration(color: AppColors.backgroundGrey, borderRadius: BorderRadius.circular(55), border: Border.all(color: Colors.white.withOpacity(0.1), width: 3), boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.7), blurRadius: 50, offset: const Offset(0, 30))]), child: ClipRRect(borderRadius: BorderRadius.circular(52), child: _isLoading ? const Center(child: CircularProgressIndicator(color: AppColors.coral)) : GoogleMap(initialCameraPosition: CameraPosition(target: _currentPosition, zoom: 17.5), onMapCreated: (controller) => _mapController = controller, onTap: _onMapTap, markers: _markers, polylines: _polylines, zoomControlsEnabled: false, myLocationButtonEnabled: false, compassEnabled: false, mapToolbarEnabled: false)))), Positioned(top: 115, left: 45, right: 45, child: Container(padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 25), decoration: BoxDecoration(color: AppColors.background.withOpacity(0.95), borderRadius: BorderRadius.circular(25), border: Border.all(color: Colors.white10), boxShadow: [BoxShadow(color: Colors.black26, blurRadius: 10)]), child: Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [_buildStat(AppStrings.mapPace, "${(_currentSpeed * 3.6).toStringAsFixed(1)}", AppStrings.kmhUnit), Container(width: 1, height: 35, color: Colors.white10), _buildStat(AppStrings.mapRoute, (_totalDistance / 1000).toStringAsFixed(2), AppStrings.kmUnit)]))), if (_isPlanningMode) Positioned(bottom: 140, left: 60, right: 60, child: Container(padding: const EdgeInsets.all(12), decoration: BoxDecoration(color: Colors.black.withOpacity(0.85), borderRadius: BorderRadius.circular(20), border: Border.all(color: AppColors.coral.withOpacity(0.5))), child: const Text(AppStrings.planningInstruction, textAlign: TextAlign.center, style: TextStyle(color: Colors.white, fontSize: 13, fontWeight: FontWeight.bold))))]), + floatingActionButton: FloatingActionButton.extended(onPressed: _toggleSimulation, label: Text(_isSimulating ? AppStrings.btnStop : AppStrings.btnStartRun, style: const TextStyle(fontWeight: FontWeight.w900, letterSpacing: 1.5)), icon: Icon(_isSimulating ? Icons.stop_rounded : Icons.play_arrow_rounded, size: 32), backgroundColor: _isSimulating ? AppColors.coral : Colors.white, foregroundColor: _isSimulating ? Colors.white : AppColors.background, elevation: 15), + floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, + ); + } + + Widget _buildStat(String label, String value, String unit) { + return Column(mainAxisSize: MainAxisSize.min, children: [Text(label, style: const TextStyle(color: Colors.white54, fontSize: 10, fontWeight: FontWeight.w900, letterSpacing: 1.5)), const SizedBox(height: 6), Row(crossAxisAlignment: CrossAxisAlignment.baseline, textBaseline: TextBaseline.alphabetic, children: [Text(value, style: const TextStyle(color: Colors.white, fontSize: 26, fontWeight: FontWeight.w900)), const SizedBox(width: 3), Text(unit, style: const TextStyle(color: Colors.white54, fontSize: 10, fontWeight: FontWeight.bold))])]); + } +} \ No newline at end of file diff --git a/lib/screens/logado_screen.dart b/lib/screens/logado_screen.dart index a8358e4..5bf1d0b 100644 --- a/lib/screens/logado_screen.dart +++ b/lib/screens/logado_screen.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; import '../constants/app_colors.dart'; import '../constants/app_strings.dart'; -import '../screens/setting_screen.dart'; -import '../screens/bluetooth_connection_screen.dart'; -import '../screens/google_maps_screen.dart'; +import 'setting_screen.dart'; +import 'bluethoot_cpnnection_screen.dart'; +import 'google_map_screen.dart'; class LogadoScreen extends StatefulWidget { const LogadoScreen({super.key}); @@ -38,7 +38,7 @@ class _LogadoScreenState extends State { child: CustomPaint( size: const Size(120, 90), painter: TrianglePainter( - color: Colors.grey.shade800.withAlpha(76), + color: Colors.grey.shade800.withValues(alpha: 0.3), ), ), ), @@ -48,7 +48,7 @@ class _LogadoScreenState extends State { child: CustomPaint( size: const Size(140, 105), painter: TrianglePainter( - color: Colors.grey.shade800.withAlpha(89), + color: Colors.grey.shade800.withValues(alpha: 0.35), ), ), ), @@ -58,7 +58,7 @@ class _LogadoScreenState extends State { child: CustomPaint( size: const Size(100, 75), painter: TrianglePainter( - color: Colors.grey.shade800.withAlpha(51), + color: Colors.grey.shade800.withValues(alpha: 0.2), ), ), ), @@ -68,7 +68,7 @@ class _LogadoScreenState extends State { child: CustomPaint( size: const Size(130, 98), painter: TrianglePainter( - color: Colors.grey.shade800.withAlpha(76), + color: Colors.grey.shade800.withValues(alpha: 0.3), ), ), ),