moved loading indicator to gps button

This commit is contained in:
Elias Müller 2024-03-27 18:27:54 +01:00
parent ef8c5e9039
commit bffc603918
4 changed files with 13 additions and 20 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
assets/background/tile.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

BIN
assets/splash/splash512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@ -1,7 +1,6 @@
import 'package:app/extensions/obtainProviderExtension.dart'; import 'package:app/extensions/obtainProviderExtension.dart';
import 'package:app/state/mapState.dart'; import 'package:app/state/mapState.dart';
import 'package:app/state/timeStatusState.dart'; import 'package:app/state/timeStatusState.dart';
import 'package:app/util/loadingContainer.dart';
import 'package:app/util/watchState.dart'; import 'package:app/util/watchState.dart';
import 'package:app/view/appInfo.dart'; import 'package:app/view/appInfo.dart';
import 'package:app/view/locationSearch.dart'; import 'package:app/view/locationSearch.dart';
@ -10,7 +9,6 @@ import 'package:app/view/map.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart'; import 'package:geolocator/geolocator.dart';
import 'package:latlong2/latlong.dart'; import 'package:latlong2/latlong.dart';
import 'package:provider/provider.dart';
class HomeView extends StatefulWidget { class HomeView extends StatefulWidget {
const HomeView({super.key}); const HomeView({super.key});
@ -91,13 +89,17 @@ class _HomePageState extends State<HomeView> {
], ],
), ),
floatingActionButton: FloatingActionButton( floatingActionButton: FloatingActionButton(
child: WatchState<MapState>((context, state) => Icon( child: WatchState<MapState>((context, state) {
locationEnabled if(locationEnabled) {
? state.isCurrentlyLoading if(state.isCurrentlyLoading) {
? Icons.location_searching return const Padding(padding: EdgeInsets.all(15), child: CircularProgressIndicator(strokeWidth: 3));
: Icons.my_location } else {
: Icons.location_disabled return const Icon(Icons.my_location);
)), }
}
return const Icon(Icons.location_disabled);
}),
onPressed: () async { onPressed: () async {
MapState mapState = context.obtainState<MapState>(); MapState mapState = context.obtainState<MapState>();
mapState.setLoading(true); mapState.setLoading(true);
@ -118,17 +120,8 @@ class _HomePageState extends State<HomeView> {
child: StatusView(), child: StatusView(),
); );
}), }),
Expanded( const Expanded(
child: Consumer<MapState>( child: MapView(),
builder: (context, state, child) {
return LoadingContainer(
loading: child == null,
fetching: state.isCurrentlyLoading,
child: const MapView(),
);
},
child: const MapView(),
),
) )
], ],
), ),