import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:gps/blocs/bloc_provider.dart'; import 'package:gps/blocs/gps_bloc.dart'; import 'package:gps/models/gps_point.dart'; import 'package:gps/widgets/two_parts.dart'; import 'compass.dart'; class GpsPositionWidget extends StatelessWidget { const GpsPositionWidget({ Key? key, }) : super(key: key); @override Widget build(BuildContext context) { final GpsBloc bloc = BlocProvider.of(context); return StreamBuilder( stream: bloc.gpsPoint, builder: (BuildContext context, AsyncSnapshot snapshot) { if (!snapshot.hasData) { return Text(AppLocalizations.of(context)!.noData); } else { final GpsPoint currentLocation = snapshot.data!; final AppLocalizations l = AppLocalizations.of(context)!; return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ TwoParts.fromMillisecondDateTime( l.date, currentLocation.time.toInt() * 1000), TwoParts.fromDouble(l.lat, currentLocation.latitude), TwoParts.fromDouble(l.lon, currentLocation.longitude), TwoParts.fromDouble(l.heading, currentLocation.heading), TwoParts.fromDouble(l.accuracy, currentLocation.accuracy), TwoParts.fromDouble(l.speed, currentLocation.speed), TwoParts.fromInt(l.satNo, currentLocation.satelliteNumber), TwoParts.fromString(l.provider, currentLocation.provider), Compass( degree: currentLocation.heading, width: 200, ), ], ); } }); } }