Mudança no mapa e Tela inicial
This commit is contained in:
@@ -10,6 +10,14 @@ class AppStrings {
|
|||||||
static const String history = "Histórico";
|
static const String history = "Histórico";
|
||||||
static const String notifications = "Notificações";
|
static const String notifications = "Notificações";
|
||||||
static const String profile = "Perfil";
|
static const String profile = "Perfil";
|
||||||
|
static const String welcome = "Bem-vindo";
|
||||||
|
static const String myActivities = "Minhas Atividades";
|
||||||
|
static const String bestDistance = "Melhor Distância";
|
||||||
|
static const String bestSpeed = "Velocidade Máxima";
|
||||||
|
static const String connectDevice = "Conectar Dispositivo";
|
||||||
|
static const String viewMap = "Ver Mapa";
|
||||||
|
static const String dailyGoal = "Meta Diária";
|
||||||
|
static const String startTraining = "INICIAR TREINO";
|
||||||
|
|
||||||
// Bluetooth Screen
|
// Bluetooth Screen
|
||||||
static const String bluetoothTitle = "DISPOSITIVOS";
|
static const String bluetoothTitle = "DISPOSITIVOS";
|
||||||
@@ -58,6 +66,10 @@ class AppStrings {
|
|||||||
static const String markDestination = "Marcar Destino";
|
static const String markDestination = "Marcar Destino";
|
||||||
static const String chooseRoute = "Escolher Rota";
|
static const String chooseRoute = "Escolher Rota";
|
||||||
static const String confirmDestination = "Confirmar Destino?";
|
static const String confirmDestination = "Confirmar Destino?";
|
||||||
|
static const String startRunQuestion = "Iniciar Corrida?";
|
||||||
|
static const String startRunDescription = "Deseja começar o monitoramento agora?";
|
||||||
|
static const String prepare = "PREPARAR";
|
||||||
|
static const String maxSpeed = "VELOCIDADE MÁX";
|
||||||
static const String cancel = "Cancelar";
|
static const String cancel = "Cancelar";
|
||||||
static const String yes = "Sim";
|
static const String yes = "Sim";
|
||||||
static const String runFinished = "Corrida Finalizada!";
|
static const String runFinished = "Corrida Finalizada!";
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import 'package:flutter/foundation.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||||
import 'package:geolocator/geolocator.dart';
|
import 'package:geolocator/geolocator.dart';
|
||||||
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
|
|
||||||
import '../constants/app_colors.dart';
|
import '../constants/app_colors.dart';
|
||||||
import '../constants/app_strings.dart';
|
import '../constants/app_strings.dart';
|
||||||
|
|
||||||
@@ -16,34 +15,28 @@ class GoogleMapScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _GoogleMapScreenState extends State<GoogleMapScreen> {
|
class _GoogleMapScreenState extends State<GoogleMapScreen> {
|
||||||
// CONFIGURAÇÃO: Insira aqui sua chave da Google Cloud com Directions API ativa
|
|
||||||
final String googleApiKey = "AIzaSyCk84rxmF044cxKLABf55rEKHDqOcyoV5k";
|
|
||||||
|
|
||||||
GoogleMapController? _mapController;
|
GoogleMapController? _mapController;
|
||||||
StreamSubscription<Position>? _positionStreamSubscription;
|
StreamSubscription<Position>? _positionStreamSubscription;
|
||||||
Timer? _stopwatchTimer;
|
Timer? _stopwatchTimer;
|
||||||
|
|
||||||
DateTime? _lastUpdate;
|
DateTime? _lastUpdate;
|
||||||
final List<LatLng> _routePoints = [];
|
final List<LatLng> _routePoints = [];
|
||||||
List<LatLng> _remainingPlannedPoints = []; // Lista para o trajeto que encurta
|
|
||||||
final Set<Polyline> _polylines = {};
|
final Set<Polyline> _polylines = {};
|
||||||
final Set<Marker> _markers = {};
|
final Set<Marker> _markers = {};
|
||||||
|
|
||||||
LatLng? _plannedEnd;
|
|
||||||
bool _isPlanningMode = false;
|
|
||||||
bool _isRunning = false;
|
bool _isRunning = false;
|
||||||
bool _isLoading = true;
|
bool _isLoading = true;
|
||||||
|
|
||||||
double _currentSpeed = 0.0;
|
double _currentSpeed = 0.0;
|
||||||
|
double _maxSpeed = 0.0;
|
||||||
double _totalDistance = 0.0;
|
double _totalDistance = 0.0;
|
||||||
LatLng _currentPosition = const LatLng(38.7223, -9.1393);
|
LatLng _currentPosition = const LatLng(0, 0);
|
||||||
|
|
||||||
int _secondsElapsed = 0;
|
int _secondsElapsed = 0;
|
||||||
int _countdownValue = 3;
|
int _countdownValue = 3;
|
||||||
bool _isCountingDown = false;
|
bool _isCountingDown = false;
|
||||||
|
|
||||||
BitmapDescriptor? _arrowIcon;
|
BitmapDescriptor? _arrowIcon;
|
||||||
BitmapDescriptor? _finishIcon;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -52,36 +45,11 @@ class _GoogleMapScreenState extends State<GoogleMapScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _setupIconsAndTracking() async {
|
Future<void> _setupIconsAndTracking() async {
|
||||||
_finishIcon = await _createPremiumMarker(AppColors.coral, Icons.flag_rounded, 65);
|
// Icons reduced by ~70% as requested
|
||||||
// Borda agora é proporcional ao tamanho (25).
|
_arrowIcon = await _createArrowMarker(Colors.black, Colors.white, 25);
|
||||||
_arrowIcon = await _createArrowMarker(Colors.black, Colors.white, 85);
|
|
||||||
await _initTracking();
|
await _initTracking();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<BitmapDescriptor> _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.bytes(byteData!.buffer.asUint8List());
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<BitmapDescriptor> _createArrowMarker(Color color, Color borderColor, double size) async {
|
Future<BitmapDescriptor> _createArrowMarker(Color color, Color borderColor, double size) async {
|
||||||
final ui.PictureRecorder recorder = ui.PictureRecorder();
|
final ui.PictureRecorder recorder = ui.PictureRecorder();
|
||||||
final Canvas canvas = Canvas(recorder);
|
final Canvas canvas = Canvas(recorder);
|
||||||
@@ -93,17 +61,16 @@ class _GoogleMapScreenState extends State<GoogleMapScreen> {
|
|||||||
path.close();
|
path.close();
|
||||||
|
|
||||||
canvas.drawPath(
|
canvas.drawPath(
|
||||||
path.shift(const Offset(0, 4)),
|
path.shift(const Offset(0, 2)),
|
||||||
Paint()
|
Paint()
|
||||||
..color = Colors.black38
|
..color = Colors.black38
|
||||||
..maskFilter = const MaskFilter.blur(BlurStyle.normal, 4));
|
..maskFilter = const MaskFilter.blur(BlurStyle.normal, 2));
|
||||||
canvas.drawPath(path, Paint()..color = color);
|
canvas.drawPath(path, Paint()..color = color);
|
||||||
|
|
||||||
// CORREÇÃO: Borda escala proporcionalmente (12% do tamanho)
|
|
||||||
double strokeWidth = size * 0.12;
|
double strokeWidth = size * 0.12;
|
||||||
canvas.drawPath(path, Paint()..color = borderColor..style = ui.PaintingStyle.stroke..strokeWidth = strokeWidth);
|
canvas.drawPath(path, Paint()..color = borderColor..style = ui.PaintingStyle.stroke..strokeWidth = strokeWidth);
|
||||||
|
|
||||||
final ui.Image image = await recorder.endRecording().toImage(size.toInt(), size.toInt() + 6);
|
final ui.Image image = await recorder.endRecording().toImage(size.toInt(), size.toInt() + 4);
|
||||||
final ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png);
|
final ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png);
|
||||||
return BitmapDescriptor.bytes(byteData!.buffer.asUint8List());
|
return BitmapDescriptor.bytes(byteData!.buffer.asUint8List());
|
||||||
}
|
}
|
||||||
@@ -126,21 +93,19 @@ class _GoogleMapScreenState extends State<GoogleMapScreen> {
|
|||||||
}
|
}
|
||||||
Position position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.bestForNavigation);
|
Position position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.bestForNavigation);
|
||||||
_currentPosition = LatLng(position.latitude, position.longitude);
|
_currentPosition = LatLng(position.latitude, position.longitude);
|
||||||
|
|
||||||
// Adiciona ponto inicial para permitir rotação imediata
|
|
||||||
_routePoints.add(_currentPosition);
|
_routePoints.add(_currentPosition);
|
||||||
|
|
||||||
setState(() => _isLoading = false);
|
setState(() => _isLoading = false);
|
||||||
_updateMarkers(); // Força a exibição imediata
|
_updateMarkers();
|
||||||
_startLocationStream();
|
_startLocationStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _startLocationStream() {
|
void _startLocationStream() {
|
||||||
_positionStreamSubscription = Geolocator.getPositionStream(
|
_positionStreamSubscription = Geolocator.getPositionStream(
|
||||||
locationSettings: const LocationSettings(accuracy: LocationAccuracy.bestForNavigation, distanceFilter: 0)
|
locationSettings: const LocationSettings(accuracy: LocationAccuracy.bestForNavigation, distanceFilter: 1)
|
||||||
).listen((Position position) {
|
).listen((Position position) {
|
||||||
final now = DateTime.now();
|
final now = DateTime.now();
|
||||||
if (_lastUpdate == null || now.difference(_lastUpdate!).inMilliseconds > 500) {
|
if (_lastUpdate == null || now.difference(_lastUpdate!).inMilliseconds > 1000) {
|
||||||
_lastUpdate = now;
|
_lastUpdate = now;
|
||||||
_updatePosition(LatLng(position.latitude, position.longitude), position.speed);
|
_updatePosition(LatLng(position.latitude, position.longitude), position.speed);
|
||||||
}
|
}
|
||||||
@@ -150,45 +115,30 @@ class _GoogleMapScreenState extends State<GoogleMapScreen> {
|
|||||||
void _updatePosition(LatLng newPoint, double speed) {
|
void _updatePosition(LatLng newPoint, double speed) {
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
|
double currentSpeedKmh = speed * 3.6;
|
||||||
|
if (currentSpeedKmh < 0) currentSpeedKmh = 0;
|
||||||
|
|
||||||
|
_currentSpeed = currentSpeedKmh;
|
||||||
|
|
||||||
if (_isRunning) {
|
if (_isRunning) {
|
||||||
if (_routePoints.isNotEmpty) {
|
if (currentSpeedKmh > _maxSpeed) {
|
||||||
_totalDistance += Geolocator.distanceBetween(_currentPosition.latitude, _currentPosition.longitude, newPoint.latitude, newPoint.longitude);
|
_maxSpeed = currentSpeedKmh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_totalDistance += Geolocator.distanceBetween(
|
||||||
|
_currentPosition.latitude, _currentPosition.longitude,
|
||||||
|
newPoint.latitude, newPoint.longitude
|
||||||
|
);
|
||||||
|
|
||||||
_routePoints.add(newPoint);
|
_routePoints.add(newPoint);
|
||||||
_updateTraveledPolylines();
|
_updateTraveledPolylines();
|
||||||
|
|
||||||
// Lógica para consumir o trajeto planejado à medida que passamos por ele
|
|
||||||
if (_remainingPlannedPoints.isNotEmpty) {
|
|
||||||
while (_remainingPlannedPoints.length > 1) {
|
|
||||||
double distanceToPoint = Geolocator.distanceBetween(
|
|
||||||
newPoint.latitude, newPoint.longitude,
|
|
||||||
_remainingPlannedPoints[0].latitude, _remainingPlannedPoints[0].longitude
|
|
||||||
);
|
|
||||||
// Se estivermos a menos de 15m do ponto do trajeto, removemo-lo
|
|
||||||
if (distanceToPoint < 15) {
|
|
||||||
_remainingPlannedPoints.removeAt(0);
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_updateRemainingPolyline();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Antes da corrida, mantém os últimos pontos para calcular a rotação
|
|
||||||
if (_routePoints.length >= 2) _routePoints.removeAt(0);
|
if (_routePoints.length >= 2) _routePoints.removeAt(0);
|
||||||
_routePoints.add(newPoint);
|
_routePoints.add(newPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
_currentSpeed = speed >= 0 ? speed : 0;
|
|
||||||
_currentPosition = newPoint;
|
_currentPosition = newPoint;
|
||||||
_updateMarkers();
|
_updateMarkers();
|
||||||
|
|
||||||
if (_plannedEnd != null && _isRunning) {
|
|
||||||
double distToEnd = Geolocator.distanceBetween(newPoint.latitude, newPoint.longitude, _plannedEnd!.latitude, _plannedEnd!.longitude);
|
|
||||||
if (distToEnd < 15) {
|
|
||||||
_finishRun();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (_mapController != null) {
|
if (_mapController != null) {
|
||||||
@@ -198,30 +148,29 @@ class _GoogleMapScreenState extends State<GoogleMapScreen> {
|
|||||||
|
|
||||||
void _updateTraveledPolylines() {
|
void _updateTraveledPolylines() {
|
||||||
if (_routePoints.length > 1) {
|
if (_routePoints.length > 1) {
|
||||||
_polylines.removeWhere((p) => p.polylineId.value == 'route' || p.polylineId.value == 'route_glow');
|
_polylines.clear();
|
||||||
_polylines.add(Polyline(polylineId: const PolylineId('route_glow'), points: List.from(_routePoints), color: Colors.cyanAccent.withOpacity(0.3), width: 14, zIndex: 9));
|
// Glow effect for the trail
|
||||||
_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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _updateRemainingPolyline() {
|
|
||||||
_polylines.removeWhere((p) => p.polylineId.value == 'planned_preview');
|
|
||||||
if (_remainingPlannedPoints.isNotEmpty) {
|
|
||||||
// A linha coral começa na posição atual do usuário e segue o que resta
|
|
||||||
List<LatLng> pointsToDraw = [_currentPosition, ..._remainingPlannedPoints];
|
|
||||||
_polylines.add(Polyline(
|
_polylines.add(Polyline(
|
||||||
polylineId: const PolylineId('planned_preview'),
|
polylineId: const PolylineId('route_glow'),
|
||||||
points: pointsToDraw,
|
points: List.from(_routePoints),
|
||||||
color: AppColors.coral.withOpacity(0.5),
|
color: AppColors.coral.withOpacity(0.3),
|
||||||
width: 4,
|
width: 12,
|
||||||
patterns: [PatternItem.dash(20), PatternItem.gap(10)],
|
zIndex: 9
|
||||||
zIndex: 8,
|
));
|
||||||
|
// Main trail line
|
||||||
|
_polylines.add(Polyline(
|
||||||
|
polylineId: const PolylineId('route'),
|
||||||
|
points: List.from(_routePoints),
|
||||||
|
color: AppColors.coral,
|
||||||
|
width: 5,
|
||||||
|
jointType: JointType.round,
|
||||||
|
zIndex: 10
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _updateMarkers() {
|
void _updateMarkers() {
|
||||||
_markers.removeWhere((m) => m.markerId.value == 'follower');
|
_markers.clear();
|
||||||
_markers.add(Marker(
|
_markers.add(Marker(
|
||||||
markerId: const MarkerId('follower'),
|
markerId: const MarkerId('follower'),
|
||||||
position: _currentPosition,
|
position: _currentPosition,
|
||||||
@@ -240,97 +189,23 @@ class _GoogleMapScreenState extends State<GoogleMapScreen> {
|
|||||||
return Geolocator.bearingBetween(p1.latitude, p1.longitude, p2.latitude, p2.longitude);
|
return Geolocator.bearingBetween(p1.latitude, p1.longitude, p2.latitude, p2.longitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<LatLng>> _getRoutePolyline(LatLng start, LatLng end) async {
|
void _showStartConfirmation() {
|
||||||
try {
|
|
||||||
PolylinePoints polylinePoints = PolylinePoints();
|
|
||||||
PolylineResult result = await polylinePoints.getRouteBetweenCoordinates(
|
|
||||||
request: PolylineRequest(
|
|
||||||
origin: PointLatLng(start.latitude, start.longitude),
|
|
||||||
destination: PointLatLng(end.latitude, end.longitude),
|
|
||||||
mode: TravelMode.walking,
|
|
||||||
),
|
|
||||||
googleApiKey: googleApiKey,
|
|
||||||
);
|
|
||||||
|
|
||||||
List<LatLng> coords = [];
|
|
||||||
if (result.points.isNotEmpty) {
|
|
||||||
for (var point in result.points) {
|
|
||||||
coords.add(LatLng(point.latitude, point.longitude));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return coords;
|
|
||||||
} catch (e) {
|
|
||||||
debugPrint("Erro ao buscar rota: $e");
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onMapTap(LatLng point) async {
|
|
||||||
if (!_isPlanningMode) return;
|
|
||||||
|
|
||||||
setState(() {
|
|
||||||
_plannedEnd = point;
|
|
||||||
_markers.removeWhere((m) => m.markerId.value == 'planned_end');
|
|
||||||
_markers.add(Marker(markerId: const MarkerId('planned_end'), position: point, icon: _finishIcon ?? BitmapDescriptor.defaultMarker, zIndex: 5, infoWindow: InfoWindow(title: AppStrings.finishPoint)));
|
|
||||||
});
|
|
||||||
|
|
||||||
List<LatLng> streetPoints = await _getRoutePolyline(_currentPosition, point);
|
|
||||||
if (streetPoints.isEmpty) {
|
|
||||||
streetPoints = [_currentPosition, point];
|
|
||||||
}
|
|
||||||
|
|
||||||
setState(() {
|
|
||||||
_remainingPlannedPoints = List.from(streetPoints);
|
|
||||||
_updateRemainingPolyline();
|
|
||||||
});
|
|
||||||
|
|
||||||
_showConfirmationDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _showStartOptions() {
|
|
||||||
showModalBottomSheet(
|
|
||||||
context: context,
|
|
||||||
backgroundColor: Colors.transparent,
|
|
||||||
builder: (context) => Container(
|
|
||||||
margin: const EdgeInsets.all(20),
|
|
||||||
decoration: BoxDecoration(color: AppColors.backgroundGrey, borderRadius: BorderRadius.circular(30), border: Border.all(color: Colors.white10)),
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
const SizedBox(height: 15),
|
|
||||||
Container(width: 40, height: 4, decoration: BoxDecoration(color: Colors.white24, borderRadius: BorderRadius.circular(2))),
|
|
||||||
const SizedBox(height: 25),
|
|
||||||
_buildOptionTile(Icons.location_on_rounded, AppStrings.markDestination, () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
setState(() => _isPlanningMode = true);
|
|
||||||
}),
|
|
||||||
const Divider(color: Colors.white10, indent: 20, endIndent: 20),
|
|
||||||
_buildOptionTile(Icons.history_rounded, AppStrings.chooseRoute, () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
}),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _showConfirmationDialog() {
|
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => AlertDialog(
|
builder: (context) => AlertDialog(
|
||||||
backgroundColor: AppColors.backgroundGrey,
|
backgroundColor: AppColors.backgroundGrey,
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(25)),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(25)),
|
||||||
title: Text(AppStrings.confirmDestination, style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold)),
|
title: const Text("Iniciar Corrida?", style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold)),
|
||||||
|
content: const Text("Deseja começar o monitoramento agora?", style: TextStyle(color: Colors.white70)),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(onPressed: () => Navigator.pop(context), child: Text(AppStrings.cancel, style: const TextStyle(color: Colors.white54))),
|
TextButton(onPressed: () => Navigator.pop(context), child: const Text(AppStrings.cancel, style: TextStyle(color: Colors.white54))),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
_startCountdown();
|
_startCountdown();
|
||||||
},
|
},
|
||||||
style: ElevatedButton.styleFrom(backgroundColor: AppColors.coral, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15))),
|
style: ElevatedButton.styleFrom(backgroundColor: AppColors.coral, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15))),
|
||||||
child: Text(AppStrings.yes, style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold)),
|
child: const Text(AppStrings.yes, style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold)),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -341,7 +216,6 @@ class _GoogleMapScreenState extends State<GoogleMapScreen> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
_isCountingDown = true;
|
_isCountingDown = true;
|
||||||
_countdownValue = 3;
|
_countdownValue = 3;
|
||||||
_isPlanningMode = false;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Timer.periodic(const Duration(seconds: 1), (timer) {
|
Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||||
@@ -359,9 +233,11 @@ class _GoogleMapScreenState extends State<GoogleMapScreen> {
|
|||||||
_isCountingDown = false;
|
_isCountingDown = false;
|
||||||
_isRunning = true;
|
_isRunning = true;
|
||||||
_totalDistance = 0.0;
|
_totalDistance = 0.0;
|
||||||
|
_maxSpeed = 0.0;
|
||||||
_secondsElapsed = 0;
|
_secondsElapsed = 0;
|
||||||
_routePoints.clear();
|
_routePoints.clear();
|
||||||
_routePoints.add(_currentPosition);
|
_routePoints.add(_currentPosition);
|
||||||
|
_polylines.clear();
|
||||||
});
|
});
|
||||||
|
|
||||||
_stopwatchTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
_stopwatchTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
|
||||||
@@ -371,40 +247,127 @@ class _GoogleMapScreenState extends State<GoogleMapScreen> {
|
|||||||
|
|
||||||
void _finishRun() {
|
void _finishRun() {
|
||||||
_stopwatchTimer?.cancel();
|
_stopwatchTimer?.cancel();
|
||||||
|
final finalRoute = List<LatLng>.from(_routePoints);
|
||||||
|
final finalDistance = _totalDistance;
|
||||||
|
final finalTime = _secondsElapsed;
|
||||||
|
final finalMaxSpeed = _maxSpeed;
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_isRunning = false;
|
_isRunning = false;
|
||||||
_remainingPlannedPoints.clear();
|
|
||||||
_polylines.removeWhere((p) => p.polylineId.value == 'planned_preview');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
showDialog(
|
showGeneralDialog(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
builder: (context) => AlertDialog(
|
barrierLabel: "Resultados",
|
||||||
backgroundColor: AppColors.backgroundGrey,
|
pageBuilder: (context, anim1, anim2) => const SizedBox(),
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)),
|
transitionBuilder: (context, anim1, anim2, child) {
|
||||||
content: Column(
|
return FadeTransition(
|
||||||
mainAxisSize: MainAxisSize.min,
|
opacity: anim1,
|
||||||
children: [
|
child: ScaleTransition(
|
||||||
const Icon(Icons.check_circle_rounded, color: Colors.greenAccent, size: 70),
|
scale: anim1,
|
||||||
const SizedBox(height: 20),
|
child: AlertDialog(
|
||||||
Text(AppStrings.runFinished, style: const TextStyle(color: Colors.white, fontSize: 22, fontWeight: FontWeight.w900)),
|
backgroundColor: AppColors.background,
|
||||||
const SizedBox(height: 25),
|
contentPadding: EdgeInsets.zero,
|
||||||
_buildResultRow(AppStrings.totalDistance, _formatDistance(_totalDistance)),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(35), side: const BorderSide(color: Colors.white10, width: 2)),
|
||||||
const SizedBox(height: 15),
|
content: Container(
|
||||||
_buildResultRow(AppStrings.totalTime, _formatTime(_secondsElapsed)),
|
width: MediaQuery.of(context).size.width * 0.85,
|
||||||
const SizedBox(height: 30),
|
padding: const EdgeInsets.all(25),
|
||||||
SizedBox(
|
child: Column(
|
||||||
width: double.infinity,
|
mainAxisSize: MainAxisSize.min,
|
||||||
child: ElevatedButton(
|
children: [
|
||||||
onPressed: () => Navigator.pop(context),
|
Container(
|
||||||
style: ElevatedButton.styleFrom(backgroundColor: AppColors.coral, padding: const EdgeInsets.symmetric(vertical: 15), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15))),
|
padding: const EdgeInsets.all(15),
|
||||||
child: Text(AppStrings.close, style: const TextStyle(fontWeight: FontWeight.bold)),
|
decoration: const BoxDecoration(color: AppColors.coral, shape: BoxShape.circle),
|
||||||
|
child: const Icon(Icons.emoji_events_rounded, color: Colors.white, size: 40),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
const Text(AppStrings.runFinished, style: TextStyle(color: Colors.white, fontSize: 24, fontWeight: FontWeight.w900, letterSpacing: 1)),
|
||||||
|
const SizedBox(height: 30),
|
||||||
|
|
||||||
|
// Mini Map Container
|
||||||
|
Container(
|
||||||
|
height: 180,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColors.backgroundGrey,
|
||||||
|
borderRadius: BorderRadius.circular(25),
|
||||||
|
border: Border.all(color: Colors.white10),
|
||||||
|
),
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(23),
|
||||||
|
child: GoogleMap(
|
||||||
|
initialCameraPosition: CameraPosition(target: finalRoute.isNotEmpty ? finalRoute.first : _currentPosition, zoom: 15),
|
||||||
|
onMapCreated: (controller) {
|
||||||
|
if (finalRoute.isNotEmpty) {
|
||||||
|
Future.delayed(const Duration(milliseconds: 500), () {
|
||||||
|
controller.animateCamera(CameraUpdate.newLatLngBounds(
|
||||||
|
_getBounds(finalRoute), 40
|
||||||
|
));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
polylines: {
|
||||||
|
Polyline(polylineId: const PolylineId('final_path'), points: finalRoute, color: AppColors.coral, width: 4)
|
||||||
|
},
|
||||||
|
zoomControlsEnabled: false,
|
||||||
|
myLocationButtonEnabled: false,
|
||||||
|
compassEnabled: false,
|
||||||
|
mapToolbarEnabled: false,
|
||||||
|
liteModeEnabled: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 25),
|
||||||
|
|
||||||
|
_buildResultRow(AppStrings.totalDistance, _formatDistance(finalDistance)),
|
||||||
|
const Divider(color: Colors.white10, height: 25),
|
||||||
|
_buildResultRow(AppStrings.totalTime, _formatTime(finalTime)),
|
||||||
|
const Divider(color: Colors.white10, height: 25),
|
||||||
|
_buildResultRow("VELOCIDADE MÁX", "${finalMaxSpeed.toStringAsFixed(1)} ${AppStrings.kmhUnit}"),
|
||||||
|
|
||||||
|
const SizedBox(height: 35),
|
||||||
|
SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
setState(() {
|
||||||
|
_polylines.clear();
|
||||||
|
_routePoints.clear();
|
||||||
|
_routePoints.add(_currentPosition);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
foregroundColor: AppColors.background,
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 18),
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
|
||||||
|
elevation: 0,
|
||||||
|
),
|
||||||
|
child: Text(AppStrings.close.toUpperCase(), style: const TextStyle(fontWeight: FontWeight.w900, letterSpacing: 2)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
);
|
||||||
),
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
LatLngBounds _getBounds(List<LatLng> points) {
|
||||||
|
double? minLat, maxLat, minLng, maxLng;
|
||||||
|
for (LatLng p in points) {
|
||||||
|
if (minLat == null || p.latitude < minLat) minLat = p.latitude;
|
||||||
|
if (maxLat == null || p.latitude > maxLat) maxLat = p.latitude;
|
||||||
|
if (minLng == null || p.longitude < minLng) minLng = p.longitude;
|
||||||
|
if (maxLng == null || p.longitude > maxLng) maxLng = p.longitude;
|
||||||
|
}
|
||||||
|
return LatLngBounds(
|
||||||
|
southwest: LatLng(minLat!, minLng!),
|
||||||
|
northeast: LatLng(maxLat!, maxLng!),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -417,34 +380,77 @@ class _GoogleMapScreenState extends State<GoogleMapScreen> {
|
|||||||
int hours = seconds ~/ 3600;
|
int hours = seconds ~/ 3600;
|
||||||
int minutes = (seconds % 3600) ~/ 60;
|
int minutes = (seconds % 3600) ~/ 60;
|
||||||
int remainingSeconds = seconds % 60;
|
int remainingSeconds = seconds % 60;
|
||||||
return "${hours.toString().padLeft(2, '0')}:${minutes.toString().padLeft(2, '0')}:${remainingSeconds.toString().padLeft(2, '0')}";
|
if (hours > 0) {
|
||||||
|
return "${hours.toString().padLeft(2, '0')}:${minutes.toString().padLeft(2, '0')}:${remainingSeconds.toString().padLeft(2, '0')}";
|
||||||
|
}
|
||||||
|
return "${minutes.toString().padLeft(2, '0')}:${remainingSeconds.toString().padLeft(2, '0')}";
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: AppColors.background,
|
backgroundColor: AppColors.background,
|
||||||
appBar: AppBar(title: Text(_isRunning ? AppStrings.mapTitleRunning : AppStrings.mapTitlePlanning, 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))),
|
appBar: AppBar(
|
||||||
|
title: Text(
|
||||||
|
_isRunning ? AppStrings.mapTitleRunning : AppStrings.appTitle.toUpperCase(),
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.w900, color: Colors.white, letterSpacing: 2, fontSize: 18)
|
||||||
|
),
|
||||||
|
centerTitle: true,
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
elevation: 0,
|
||||||
|
leading: IconButton(
|
||||||
|
icon: const Icon(Icons.arrow_back_ios_new, color: Colors.white),
|
||||||
|
onPressed: () => Navigator.pop(context)
|
||||||
|
)
|
||||||
|
),
|
||||||
extendBodyBehindAppBar: true,
|
extendBodyBehindAppBar: true,
|
||||||
body: Stack(
|
body: Stack(
|
||||||
children: [
|
children: [
|
||||||
|
// Background Map Container
|
||||||
Center(
|
Center(
|
||||||
child: Container(
|
child: Container(
|
||||||
width: MediaQuery.of(context).size.width * 0.94, height: MediaQuery.of(context).size.height * 0.7,
|
width: MediaQuery.of(context).size.width * 0.94,
|
||||||
decoration: BoxDecoration(color: AppColors.backgroundGrey, borderRadius: BorderRadius.circular(55), border: Border.all(color: Colors.white10, width: 3), boxShadow: const [BoxShadow(color: Colors.black54, blurRadius: 40)]),
|
height: MediaQuery.of(context).size.height * 0.72,
|
||||||
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))
|
decoration: BoxDecoration(
|
||||||
|
color: AppColors.backgroundGrey,
|
||||||
|
borderRadius: BorderRadius.circular(55),
|
||||||
|
border: Border.all(color: Colors.white10, width: 3),
|
||||||
|
boxShadow: const [BoxShadow(color: Colors.black54, blurRadius: 40, spreadRadius: -10)]
|
||||||
|
),
|
||||||
|
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,
|
||||||
|
markers: _markers,
|
||||||
|
polylines: _polylines,
|
||||||
|
zoomControlsEnabled: false,
|
||||||
|
myLocationButtonEnabled: false,
|
||||||
|
compassEnabled: false,
|
||||||
|
mapToolbarEnabled: false,
|
||||||
|
style: null, // You can add custom styling here
|
||||||
|
)
|
||||||
|
)
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// Stats Overlay
|
||||||
Positioned(
|
Positioned(
|
||||||
top: 115, left: 20, right: 20,
|
top: 115, left: 25, right: 25,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 20),
|
padding: const EdgeInsets.symmetric(vertical: 22, horizontal: 10),
|
||||||
decoration: BoxDecoration(color: AppColors.background.withOpacity(0.95), borderRadius: BorderRadius.circular(25), border: Border.all(color: Colors.white10)),
|
decoration: BoxDecoration(
|
||||||
|
color: AppColors.background.withOpacity(0.9),
|
||||||
|
borderRadius: BorderRadius.circular(30),
|
||||||
|
border: Border.all(color: Colors.white10),
|
||||||
|
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.3), blurRadius: 15)]
|
||||||
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
_buildStat(AppStrings.mapPace, (_currentSpeed * 3.6).toStringAsFixed(1), AppStrings.kmhUnit),
|
_buildStat(AppStrings.mapPace, _currentSpeed.toStringAsFixed(1), AppStrings.kmhUnit),
|
||||||
_buildDivider(),
|
_buildDivider(),
|
||||||
_buildStat(AppStrings.mapRoute, _formatDistanceValue(_totalDistance), _totalDistance < 1000 ? AppStrings.metersUnit : AppStrings.kmUnit),
|
_buildStat(AppStrings.mapRoute, _formatDistanceValue(_totalDistance), _totalDistance < 1000 ? AppStrings.metersUnit : AppStrings.kmUnit),
|
||||||
_buildDivider(),
|
_buildDivider(),
|
||||||
@@ -454,51 +460,49 @@ class _GoogleMapScreenState extends State<GoogleMapScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// Countdown Overlay
|
||||||
if (_isCountingDown)
|
if (_isCountingDown)
|
||||||
Container(
|
Container(
|
||||||
color: Colors.black54,
|
color: Colors.black87,
|
||||||
|
width: double.infinity,
|
||||||
|
height: double.infinity,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text("$_countdownValue", style: const TextStyle(color: Colors.white, fontSize: 150, fontWeight: FontWeight.w900)),
|
child: Column(
|
||||||
),
|
mainAxisSize: MainAxisSize.min,
|
||||||
),
|
children: [
|
||||||
|
const Text("PREPARAR", style: TextStyle(color: Colors.white54, fontSize: 24, fontWeight: FontWeight.bold, letterSpacing: 5)),
|
||||||
if (_isPlanningMode)
|
const SizedBox(height: 20),
|
||||||
Positioned(
|
Text("$_countdownValue", style: const TextStyle(color: AppColors.coral, fontSize: 160, fontWeight: FontWeight.w900)),
|
||||||
bottom: 120, left: 60, right: 60,
|
],
|
||||||
child: Container(
|
),
|
||||||
padding: const EdgeInsets.all(15),
|
|
||||||
decoration: BoxDecoration(color: AppColors.coral.withOpacity(0.9), borderRadius: BorderRadius.circular(20)),
|
|
||||||
child: Text(AppStrings.markDestination, textAlign: TextAlign.center, style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold)),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
floatingActionButton: FloatingActionButton.extended(
|
floatingActionButton: Padding(
|
||||||
onPressed: _isRunning ? _finishRun : _showStartOptions,
|
padding: const EdgeInsets.only(bottom: 20.0),
|
||||||
label: Text(_isRunning ? AppStrings.btnStop : AppStrings.btnStartRun, style: const TextStyle(fontWeight: FontWeight.w900, letterSpacing: 1.5)),
|
child: FloatingActionButton.extended(
|
||||||
icon: Icon(_isRunning ? Icons.stop_rounded : Icons.play_arrow_rounded, size: 32),
|
onPressed: _isRunning ? _finishRun : _showStartConfirmation,
|
||||||
backgroundColor: _isRunning ? AppColors.coral : Colors.white,
|
label: Text(
|
||||||
foregroundColor: _isRunning ? Colors.white : AppColors.background,
|
_isRunning ? AppStrings.btnStop : AppStrings.btnStartRun,
|
||||||
elevation: 15,
|
style: const TextStyle(fontWeight: FontWeight.w900, letterSpacing: 1.5, fontSize: 16)
|
||||||
|
),
|
||||||
|
icon: Icon(_isRunning ? Icons.stop_rounded : Icons.play_arrow_rounded, size: 28),
|
||||||
|
backgroundColor: _isRunning ? AppColors.coral : Colors.white,
|
||||||
|
foregroundColor: _isRunning ? Colors.white : AppColors.background,
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
|
||||||
|
elevation: 10,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
|
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildOptionTile(IconData icon, String title, VoidCallback onTap) {
|
|
||||||
return ListTile(
|
|
||||||
leading: Container(padding: const EdgeInsets.all(8), decoration: BoxDecoration(color: Colors.white.withOpacity(0.05), shape: BoxShape.circle), child: Icon(icon, color: AppColors.coral)),
|
|
||||||
title: Text(title, style: const TextStyle(color: Colors.white, fontWeight: FontWeight.bold)),
|
|
||||||
trailing: const Icon(Icons.arrow_forward_ios_rounded, color: Colors.white24, size: 16),
|
|
||||||
onTap: onTap,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildResultRow(String label, String value) {
|
Widget _buildResultRow(String label, String value) {
|
||||||
return Row(
|
return Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Text(label, style: const TextStyle(color: Colors.white54, fontWeight: FontWeight.bold)),
|
Text(label, style: const TextStyle(color: Colors.white54, fontWeight: FontWeight.bold, fontSize: 13)),
|
||||||
Text(value, style: const TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.w900)),
|
Text(value, style: const TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.w900)),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@@ -515,20 +519,23 @@ class _GoogleMapScreenState extends State<GoogleMapScreen> {
|
|||||||
return "${mins.toString().padLeft(2, '0')}:${secs.toString().padLeft(2, '0')}";
|
return "${mins.toString().padLeft(2, '0')}:${secs.toString().padLeft(2, '0')}";
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildDivider() => Container(width: 1, height: 30, color: Colors.white10);
|
Widget _buildDivider() => Container(width: 1, height: 35, color: Colors.white10);
|
||||||
|
|
||||||
Widget _buildStat(String label, String value, String unit) {
|
Widget _buildStat(String label, String value, String unit) {
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Text(label, style: const TextStyle(color: Colors.white54, fontSize: 9, fontWeight: FontWeight.w900, letterSpacing: 1)),
|
Text(label, style: const TextStyle(color: Colors.white54, fontSize: 10, fontWeight: FontWeight.w900, letterSpacing: 1.5)),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 6),
|
||||||
Row(
|
Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.baseline,
|
crossAxisAlignment: CrossAxisAlignment.baseline,
|
||||||
textBaseline: TextBaseline.alphabetic,
|
textBaseline: TextBaseline.alphabetic,
|
||||||
children: [
|
children: [
|
||||||
Text(value, style: const TextStyle(color: Colors.white, fontSize: 22, fontWeight: FontWeight.w900)),
|
Text(value, style: const TextStyle(color: Colors.white, fontSize: 24, fontWeight: FontWeight.w900)),
|
||||||
if (unit.isNotEmpty) ...[const SizedBox(width: 2), Text(unit, style: const TextStyle(color: Colors.white54, fontSize: 9, fontWeight: FontWeight.bold))],
|
if (unit.isNotEmpty) ...[
|
||||||
|
const SizedBox(width: 3),
|
||||||
|
Text(unit, style: const TextStyle(color: Colors.white38, fontSize: 10, fontWeight: FontWeight.bold))
|
||||||
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import '../constants/app_colors.dart';
|
import '../constants/app_colors.dart';
|
||||||
import '../constants/app_strings.dart';
|
import '../constants/app_strings.dart';
|
||||||
|
import '../services/supabase_service.dart';
|
||||||
import 'setting_screen.dart';
|
import 'setting_screen.dart';
|
||||||
import 'bluethoot_cpnnection_screen.dart';
|
import 'bluetooth_connection_screen.dart';
|
||||||
import 'google_map_screen.dart';
|
import 'google_map_screen.dart';
|
||||||
|
|
||||||
class LogadoScreen extends StatefulWidget {
|
class LogadoScreen extends StatefulWidget {
|
||||||
@@ -13,419 +15,492 @@ class LogadoScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _LogadoScreenState extends State<LogadoScreen> {
|
class _LogadoScreenState extends State<LogadoScreen> {
|
||||||
double progress = 0.65; // Simulação de progresso
|
// Estado dinâmico do utilizador
|
||||||
|
double _dailyGoal = 0.0; // 0.0 significa que ainda não foi definida
|
||||||
|
double _currentDistance = 0.0;
|
||||||
|
double _bestDistance = 12.4; // Exemplo de recorde
|
||||||
|
double _bestSpeed = 16.8; // Exemplo de recorde
|
||||||
|
int _steps = 0;
|
||||||
|
int _totalTimeMinutes = 0;
|
||||||
|
|
||||||
|
double get _progress => _dailyGoal > 0 ? (_currentDistance / _dailyGoal).clamp(0.0, 1.0) : 0.0;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_loadUserData();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _loadUserData() async {
|
||||||
|
// No futuro, aqui buscaríamos os dados reais do Supabase ou Local Storage
|
||||||
|
setState(() {
|
||||||
|
// Simulação de dados carregados
|
||||||
|
_currentDistance = 0.0; // Começa o dia a zero
|
||||||
|
_steps = 0;
|
||||||
|
_totalTimeMinutes = 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showGoalDialog() {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => AlertDialog(
|
||||||
|
backgroundColor: AppColors.backgroundGrey,
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)),
|
||||||
|
title: const Text("Definir Meta Diária", style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold)),
|
||||||
|
content: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
...[5, 10, 15, 20].map((km) => ListTile(
|
||||||
|
title: Text("$km KM", style: const TextStyle(color: Colors.white)),
|
||||||
|
onTap: () {
|
||||||
|
setState(() {
|
||||||
|
_dailyGoal = km.toDouble();
|
||||||
|
});
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
)),
|
||||||
|
const Divider(color: Colors.white10),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.edit_note_rounded, color: AppColors.coral),
|
||||||
|
title: const Text("Personalizado", style: TextStyle(color: AppColors.coral, fontWeight: FontWeight.bold)),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
_showCustomGoalDialog();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showCustomGoalDialog() {
|
||||||
|
final TextEditingController controller = TextEditingController();
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => AlertDialog(
|
||||||
|
backgroundColor: AppColors.backgroundGrey,
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)),
|
||||||
|
title: const Text("Meta Personalizada", style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold)),
|
||||||
|
content: TextField(
|
||||||
|
controller: controller,
|
||||||
|
keyboardType: const TextInputType.numberWithOptions(decimal: true),
|
||||||
|
inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r'^\d+\.?\d*'))],
|
||||||
|
style: const TextStyle(color: Colors.white),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: "Ex: 12.5",
|
||||||
|
hintStyle: const TextStyle(color: Colors.white24),
|
||||||
|
suffixText: "KM",
|
||||||
|
suffixStyle: const TextStyle(color: Colors.white54),
|
||||||
|
enabledBorder: UnderlineInputBorder(borderSide: BorderSide(color: Colors.white24)),
|
||||||
|
focusedBorder: UnderlineInputBorder(borderSide: BorderSide(color: AppColors.coral)),
|
||||||
|
),
|
||||||
|
autofocus: true,
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
|
child: const Text("CANCELAR", style: TextStyle(color: Colors.white54)),
|
||||||
|
),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
final value = double.tryParse(controller.text);
|
||||||
|
if (value != null && value > 0) {
|
||||||
|
setState(() {
|
||||||
|
_dailyGoal = value;
|
||||||
|
});
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: AppColors.coral,
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
|
||||||
|
),
|
||||||
|
child: const Text("DEFINIR", style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final user = SupabaseService.currentUser;
|
||||||
|
final userName = user?.userMetadata?['name'] ?? user?.email?.split('@')[0] ?? 'Corredor';
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: AppColors.background,
|
backgroundColor: AppColors.background,
|
||||||
body: Stack(
|
body: Stack(
|
||||||
children: [
|
children: [
|
||||||
// Background triangles
|
// Background Gradient
|
||||||
Positioned(
|
Positioned.fill(
|
||||||
top: -50,
|
child: Container(
|
||||||
left: -80,
|
decoration: const BoxDecoration(
|
||||||
child: CustomPaint(
|
gradient: LinearGradient(
|
||||||
size: const Size(160, 120),
|
begin: Alignment.topCenter,
|
||||||
painter: TrianglePainter(
|
end: Alignment.bottomCenter,
|
||||||
color: Colors.grey.shade800.withValues(alpha: 0.4),
|
colors: [Color(0xFF2D2D31), AppColors.background],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Positioned(
|
|
||||||
top: 20,
|
|
||||||
right: -60,
|
|
||||||
child: CustomPaint(
|
|
||||||
size: const Size(120, 90),
|
|
||||||
painter: TrianglePainter(
|
|
||||||
color: Colors.grey.shade800.withValues(alpha: 0.3),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
top: 80,
|
|
||||||
left: 40,
|
|
||||||
child: CustomPaint(
|
|
||||||
size: const Size(140, 105),
|
|
||||||
painter: TrianglePainter(
|
|
||||||
color: Colors.grey.shade800.withValues(alpha: 0.35),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
top: 120,
|
|
||||||
right: 80,
|
|
||||||
child: CustomPaint(
|
|
||||||
size: const Size(100, 75),
|
|
||||||
painter: TrianglePainter(
|
|
||||||
color: Colors.grey.shade800.withValues(alpha: 0.2),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
top: 160,
|
|
||||||
left: -40,
|
|
||||||
child: CustomPaint(
|
|
||||||
size: const Size(130, 98),
|
|
||||||
painter: TrianglePainter(
|
|
||||||
color: Colors.grey.shade800.withValues(alpha: 0.3),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Main content
|
|
||||||
SafeArea(
|
SafeArea(
|
||||||
child: Padding(
|
child: Column(
|
||||||
padding: const EdgeInsets.all(24.0),
|
children: [
|
||||||
child: Column(
|
// Header Bar
|
||||||
children: [
|
Padding(
|
||||||
const SizedBox(height: 60),
|
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
||||||
|
child: Row(
|
||||||
// Header with user info
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const Text(
|
Text(
|
||||||
'Bem-vindo!',
|
AppStrings.welcome.toUpperCase(),
|
||||||
style: TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 24,
|
color: Colors.white38,
|
||||||
fontWeight: FontWeight.bold,
|
fontSize: 10,
|
||||||
color: Colors.white,
|
fontWeight: FontWeight.w900,
|
||||||
|
letterSpacing: 2,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'Usuário Logado',
|
userName,
|
||||||
style: TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 16,
|
color: Colors.white,
|
||||||
color: Colors.white.withValues(alpha: 0.7),
|
fontSize: 24,
|
||||||
|
fontWeight: FontWeight.w900,
|
||||||
|
letterSpacing: -0.5,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Container(
|
Row(
|
||||||
width: 50,
|
children: [
|
||||||
height: 50,
|
_buildIconButton(
|
||||||
decoration: BoxDecoration(
|
Icons.bluetooth_audio_rounded,
|
||||||
color: AppColors.buttonColor,
|
() => Navigator.push(context, MaterialPageRoute(builder: (context) => const BluetoothConnectionScreen())),
|
||||||
borderRadius: BorderRadius.circular(25),
|
),
|
||||||
),
|
const SizedBox(width: 12),
|
||||||
child: const Icon(
|
_buildIconButton(
|
||||||
Icons.person,
|
Icons.settings_rounded,
|
||||||
color: Colors.white,
|
() => Navigator.push(context, MaterialPageRoute(builder: (context) => const SettingsScreen())),
|
||||||
size: 30,
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
|
||||||
const SizedBox(height: 40),
|
Expanded(
|
||||||
|
child: SingleChildScrollView(
|
||||||
// Stats cards
|
physics: const BouncingScrollPhysics(),
|
||||||
Row(
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: [
|
|
||||||
_buildStatCard(
|
|
||||||
AppStrings.complete,
|
|
||||||
'85%',
|
|
||||||
AppColors.success,
|
|
||||||
),
|
|
||||||
_buildStatCard(
|
|
||||||
AppStrings.steps,
|
|
||||||
'8,432',
|
|
||||||
AppColors.buttonColor,
|
|
||||||
),
|
|
||||||
_buildStatCard(AppStrings.bpm, '72', AppColors.error),
|
|
||||||
_buildStatCard(AppStrings.kcal, '420', AppColors.coral),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
|
|
||||||
const SizedBox(height: 30),
|
|
||||||
|
|
||||||
// Progress section
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.all(20),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: AppColors.backgroundGrey,
|
|
||||||
borderRadius: BorderRadius.circular(15),
|
|
||||||
),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
|
||||||
|
// Main Tracking Card (Meta Diária)
|
||||||
|
_buildMainTrackingCard(),
|
||||||
|
|
||||||
|
const SizedBox(height: 30),
|
||||||
|
|
||||||
|
// Personal Bests Section
|
||||||
|
const Text(
|
||||||
|
"RECORDS PESSOAIS",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white38,
|
||||||
|
fontSize: 11,
|
||||||
|
fontWeight: FontWeight.w900,
|
||||||
|
letterSpacing: 1.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 15),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
children: [
|
||||||
const Text(
|
Expanded(
|
||||||
'Meta Diária',
|
child: _buildRecordCard(
|
||||||
style: TextStyle(
|
AppStrings.bestDistance,
|
||||||
fontSize: 18,
|
_bestDistance.toStringAsFixed(1),
|
||||||
fontWeight: FontWeight.bold,
|
AppStrings.kmUnit,
|
||||||
color: Colors.white,
|
Icons.auto_graph_rounded,
|
||||||
|
AppColors.coral,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
const SizedBox(width: 15),
|
||||||
'${(progress * 100).toInt()}%',
|
Expanded(
|
||||||
style: const TextStyle(
|
child: _buildRecordCard(
|
||||||
fontSize: 16,
|
AppStrings.bestSpeed,
|
||||||
color: Colors.white,
|
_bestSpeed.toStringAsFixed(1),
|
||||||
|
AppStrings.kmhUnit,
|
||||||
|
Icons.speed_rounded,
|
||||||
|
Colors.cyanAccent,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 15),
|
|
||||||
ClipRRect(
|
const SizedBox(height: 25),
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
child: LinearProgressIndicator(
|
// Steps Section (Atividade Geral)
|
||||||
value: progress,
|
const Text(
|
||||||
minHeight: 8,
|
"ATIVIDADE GERAL",
|
||||||
backgroundColor: AppColors.white.withValues(
|
style: TextStyle(
|
||||||
alpha: 0.1,
|
color: Colors.white38,
|
||||||
),
|
fontSize: 11,
|
||||||
valueColor: const AlwaysStoppedAnimation<Color>(
|
fontWeight: FontWeight.w900,
|
||||||
AppColors.white,
|
letterSpacing: 1.5,
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 15),
|
||||||
|
_buildWideRecordCard(
|
||||||
|
AppStrings.steps,
|
||||||
|
_steps.toString(),
|
||||||
|
"passos hoje",
|
||||||
|
Icons.directions_walk_rounded,
|
||||||
|
AppColors.success,
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(height: 120), // Espaço para o botão inferior
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
const SizedBox(height: 30),
|
],
|
||||||
|
),
|
||||||
// Map preview
|
),
|
||||||
GestureDetector(
|
|
||||||
onTap: () {
|
// Bottom Action Button
|
||||||
// Navigate to GoogleMapScreen
|
Positioned(
|
||||||
Navigator.push(
|
bottom: 30,
|
||||||
context,
|
left: 50,
|
||||||
MaterialPageRoute(
|
right: 50,
|
||||||
builder: (context) => const GoogleMapScreen(),
|
child: Container(
|
||||||
),
|
height: 70,
|
||||||
);
|
decoration: BoxDecoration(
|
||||||
},
|
boxShadow: [
|
||||||
child: Container(
|
BoxShadow(
|
||||||
height: 200,
|
color: AppColors.coral.withValues(alpha: 0.3),
|
||||||
decoration: BoxDecoration(
|
blurRadius: 25,
|
||||||
color: AppColors.backgroundGrey,
|
spreadRadius: -5,
|
||||||
borderRadius: BorderRadius.circular(15),
|
)
|
||||||
),
|
|
||||||
child: const Center(
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
Icons.map_outlined,
|
|
||||||
size: 50,
|
|
||||||
color: Colors.white54,
|
|
||||||
),
|
|
||||||
SizedBox(height: 10),
|
|
||||||
Text(
|
|
||||||
AppStrings.mapPreview,
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white54,
|
|
||||||
fontSize: 16,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: () => Navigator.push(context, MaterialPageRoute(builder: (context) => const GoogleMapScreen())),
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: AppColors.coral,
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(25)),
|
||||||
|
elevation: 0,
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.play_arrow_rounded, size: 30),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Text(
|
||||||
|
AppStrings.startTraining,
|
||||||
|
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w900, letterSpacing: 1.5),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
// Bottom navigation menu
|
|
||||||
Positioned(
|
|
||||||
bottom: 50,
|
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: [
|
|
||||||
_buildMenuButton(Icons.settings_outlined, AppStrings.settings),
|
|
||||||
_buildMenuButton(Icons.group_outlined, AppStrings.groups),
|
|
||||||
_buildMenuButton(Icons.history_rounded, AppStrings.history),
|
|
||||||
_buildMenuButton(
|
|
||||||
Icons.notifications_none_rounded,
|
|
||||||
AppStrings.notifications,
|
|
||||||
showBadge: true,
|
|
||||||
),
|
|
||||||
_buildMenuButton(
|
|
||||||
Icons.person_outline_rounded,
|
|
||||||
AppStrings.profile,
|
|
||||||
isAvatar: true,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
// Bluetooth action button
|
|
||||||
Positioned(
|
|
||||||
top: 60,
|
|
||||||
right: 25,
|
|
||||||
child: _buildSmallActionButton(Icons.bluetooth, AppColors.error),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildStatCard(String title, String value, Color color) {
|
Widget _buildIconButton(IconData icon, VoidCallback onTap) {
|
||||||
|
return GestureDetector(
|
||||||
|
onTap: onTap,
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(12),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white.withValues(alpha: 0.05),
|
||||||
|
borderRadius: BorderRadius.circular(15),
|
||||||
|
border: Border.all(color: Colors.white10),
|
||||||
|
),
|
||||||
|
child: Icon(icon, color: Colors.white, size: 22),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildMainTrackingCard() {
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.all(15),
|
width: double.infinity,
|
||||||
|
padding: const EdgeInsets.all(25),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: AppColors.backgroundGrey,
|
color: AppColors.backgroundGrey,
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(45),
|
||||||
|
border: Border.all(color: Colors.white10, width: 2),
|
||||||
|
boxShadow: const [BoxShadow(color: Colors.black26, blurRadius: 20, offset: Offset(0, 10))],
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Row(
|
||||||
value,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
style: TextStyle(
|
children: [
|
||||||
fontSize: 20,
|
const Text(
|
||||||
fontWeight: FontWeight.bold,
|
AppStrings.dailyGoal,
|
||||||
color: color,
|
style: TextStyle(color: Colors.white54, fontWeight: FontWeight.bold, letterSpacing: 1),
|
||||||
),
|
),
|
||||||
|
if (_dailyGoal > 0)
|
||||||
|
Text(
|
||||||
|
"${(_progress * 100).toInt()}%",
|
||||||
|
style: const TextStyle(color: AppColors.coral, fontWeight: FontWeight.w900),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 5),
|
const SizedBox(height: 20),
|
||||||
Text(
|
Stack(
|
||||||
title,
|
alignment: Alignment.center,
|
||||||
style: const TextStyle(fontSize: 12, color: Colors.white70),
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
width: 180,
|
||||||
|
height: 180,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
value: _progress,
|
||||||
|
strokeWidth: 15,
|
||||||
|
backgroundColor: Colors.white.withValues(alpha: 0.05),
|
||||||
|
valueColor: const AlwaysStoppedAnimation<Color>(AppColors.coral),
|
||||||
|
strokeCap: StrokeCap.round,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (_dailyGoal == 0)
|
||||||
|
GestureDetector(
|
||||||
|
onTap: _showGoalDialog,
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(15),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColors.coral.withValues(alpha: 0.1),
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
child: const Icon(Icons.add_task_rounded, color: AppColors.coral, size: 40),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
const Text(
|
||||||
|
"DEFINIR META",
|
||||||
|
style: TextStyle(color: Colors.white, fontSize: 12, fontWeight: FontWeight.w900, letterSpacing: 1),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const Text("DISTÂNCIA", style: TextStyle(color: Colors.white38, fontSize: 10, fontWeight: FontWeight.bold, letterSpacing: 2)),
|
||||||
|
Text(
|
||||||
|
_currentDistance.toStringAsFixed(1),
|
||||||
|
style: const TextStyle(color: Colors.white, fontSize: 48, fontWeight: FontWeight.w900),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"/ ${_dailyGoal.toStringAsFixed(1)} ${AppStrings.kmUnit}",
|
||||||
|
style: const TextStyle(color: Colors.white54, fontSize: 14, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 30),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
_buildSimpleStat("PASSOS", "${(_steps / 1000).toStringAsFixed(1)}k"),
|
||||||
|
const SizedBox(width: 40),
|
||||||
|
_buildSimpleStat("TEMPO", "${_totalTimeMinutes}m"),
|
||||||
|
],
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildMenuButton(
|
Widget _buildSimpleStat(String label, String value) {
|
||||||
IconData icon,
|
return Column(
|
||||||
String label, {
|
children: [
|
||||||
bool showBadge = false,
|
Text(value, style: const TextStyle(color: Colors.white, fontWeight: FontWeight.w900, fontSize: 16)),
|
||||||
bool isAvatar = false,
|
Text(label, style: const TextStyle(color: Colors.white38, fontSize: 9, fontWeight: FontWeight.bold)),
|
||||||
}) {
|
],
|
||||||
return GestureDetector(
|
);
|
||||||
onTap: () {
|
}
|
||||||
_handleMenuTap(label);
|
|
||||||
},
|
Widget _buildRecordCard(String title, String value, String unit, IconData icon, Color accentColor) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.all(20),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColors.backgroundGrey,
|
||||||
|
borderRadius: BorderRadius.circular(30),
|
||||||
|
border: Border.all(color: Colors.white10),
|
||||||
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
width: 50,
|
padding: const EdgeInsets.all(8),
|
||||||
height: 50,
|
decoration: BoxDecoration(color: accentColor.withValues(alpha: 0.1), shape: BoxShape.circle),
|
||||||
decoration: BoxDecoration(
|
child: Icon(icon, color: accentColor, size: 18),
|
||||||
color: AppColors.backgroundGrey,
|
|
||||||
borderRadius: BorderRadius.circular(25),
|
|
||||||
),
|
|
||||||
child: Stack(
|
|
||||||
children: [
|
|
||||||
Center(child: Icon(icon, color: Colors.white, size: 24)),
|
|
||||||
if (showBadge)
|
|
||||||
Positioned(
|
|
||||||
top: 8,
|
|
||||||
right: 8,
|
|
||||||
child: Container(
|
|
||||||
width: 8,
|
|
||||||
height: 8,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: AppColors.error,
|
|
||||||
borderRadius: BorderRadius.circular(4),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 15),
|
||||||
Text(
|
Row(
|
||||||
label,
|
crossAxisAlignment: CrossAxisAlignment.baseline,
|
||||||
style: const TextStyle(fontSize: 12, color: Colors.white70),
|
textBaseline: TextBaseline.alphabetic,
|
||||||
|
children: [
|
||||||
|
Text(value, style: const TextStyle(color: Colors.white, fontSize: 22, fontWeight: FontWeight.w900)),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
Text(unit, style: const TextStyle(color: Colors.white38, fontSize: 10, fontWeight: FontWeight.bold)),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
|
Text(title, style: const TextStyle(color: Colors.white54, fontSize: 9, fontWeight: FontWeight.bold, letterSpacing: 0.5)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildSmallActionButton(IconData icon, Color color) {
|
Widget _buildWideRecordCard(String title, String value, String unit, IconData icon, Color accentColor) {
|
||||||
return GestureDetector(
|
return Container(
|
||||||
onTap: () {
|
width: double.infinity,
|
||||||
Navigator.push(
|
padding: const EdgeInsets.all(20),
|
||||||
context,
|
decoration: BoxDecoration(
|
||||||
MaterialPageRoute(
|
color: AppColors.backgroundGrey,
|
||||||
builder: (context) => const BluetoothConnectionScreen(),
|
borderRadius: BorderRadius.circular(30),
|
||||||
|
border: Border.all(color: Colors.white10),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(12),
|
||||||
|
decoration: BoxDecoration(color: accentColor.withValues(alpha: 0.1), shape: BoxShape.circle),
|
||||||
|
child: Icon(icon, color: accentColor, size: 24),
|
||||||
),
|
),
|
||||||
);
|
const SizedBox(width: 20),
|
||||||
},
|
Column(
|
||||||
child: Container(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
width: 45,
|
children: [
|
||||||
height: 45,
|
Row(
|
||||||
decoration: BoxDecoration(
|
crossAxisAlignment: CrossAxisAlignment.baseline,
|
||||||
color: color,
|
textBaseline: TextBaseline.alphabetic,
|
||||||
borderRadius: BorderRadius.circular(22.5),
|
children: [
|
||||||
boxShadow: [
|
Text(value, style: const TextStyle(color: Colors.white, fontSize: 24, fontWeight: FontWeight.w900)),
|
||||||
BoxShadow(
|
const SizedBox(width: 6),
|
||||||
color: color.withValues(alpha: 0.3),
|
Text(unit, style: const TextStyle(color: Colors.white38, fontSize: 12, fontWeight: FontWeight.bold)),
|
||||||
blurRadius: 10,
|
],
|
||||||
spreadRadius: 2,
|
),
|
||||||
),
|
Text(title, style: const TextStyle(color: Colors.white54, fontSize: 11, fontWeight: FontWeight.bold, letterSpacing: 0.5)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
child: Icon(icon, color: Colors.white, size: 20),
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleMenuTap(String label) {
|
|
||||||
switch (label) {
|
|
||||||
case 'Configurações':
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => const SettingsScreen()),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case 'Perfil':
|
|
||||||
// Navigate to profile
|
|
||||||
break;
|
|
||||||
case 'Histórico':
|
|
||||||
// Navigate to history
|
|
||||||
break;
|
|
||||||
case 'Grupos':
|
|
||||||
// Navigate to groups
|
|
||||||
break;
|
|
||||||
case 'Notificações':
|
|
||||||
// Navigate to notifications
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Custom painter for triangles
|
|
||||||
class TrianglePainter extends CustomPainter {
|
|
||||||
final Color color;
|
|
||||||
|
|
||||||
TrianglePainter({required this.color});
|
|
||||||
|
|
||||||
@override
|
|
||||||
void paint(Canvas canvas, Size size) {
|
|
||||||
final paint = Paint()
|
|
||||||
..color = color
|
|
||||||
..style = PaintingStyle.fill;
|
|
||||||
|
|
||||||
final path = Path();
|
|
||||||
path.moveTo(size.width / 2, 0);
|
|
||||||
path.lineTo(0, size.height);
|
|
||||||
path.lineTo(size.width, size.height);
|
|
||||||
path.close();
|
|
||||||
|
|
||||||
canvas.drawPath(path, paint);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool shouldRepaint(covariant CustomPainter oldDelegate) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user