Compare commits
No commits in common. "26380dc55be8072265797b9b2b61f2349023383a" and "6626de94be7e25672ed8012236ab176731ae5ba3" have entirely different histories.
26380dc55b
...
6626de94be
@ -2,18 +2,11 @@ import 'package:flutter/cupertino.dart';
|
||||
|
||||
class MapState extends ChangeNotifier {
|
||||
bool _isLocationLock = false;
|
||||
bool _isCurrentlyFetchin = true;
|
||||
|
||||
bool get followLocation => _isLocationLock;
|
||||
bool get isCurrentlyFetching => _isCurrentlyFetchin;
|
||||
|
||||
toggleLocationLock() {
|
||||
_isLocationLock = !_isLocationLock;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
set setNetworkActivity(bool active) {
|
||||
_isCurrentlyFetchin = active;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LoadingContainer extends StatelessWidget {
|
||||
final bool loading;
|
||||
final bool fetching;
|
||||
final Widget child;
|
||||
const LoadingContainer({required this.loading, required this.fetching, required this.child, super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if(loading) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
if(fetching) const LinearProgressIndicator(),
|
||||
Expanded(child: child),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
@ -1,12 +1,10 @@
|
||||
import 'package:app/extensions/obtainProviderExtension.dart';
|
||||
import 'package:app/state/mapState.dart';
|
||||
import 'package:app/util/loadingContainer.dart';
|
||||
import 'package:app/util/watchState.dart';
|
||||
import 'package:app/view/appInfo.dart';
|
||||
import 'package:app/view/status.dart';
|
||||
import 'package:app/view/map.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class HomeView extends StatefulWidget {
|
||||
const HomeView({super.key});
|
||||
@ -44,23 +42,14 @@ class _HomePageState extends State<HomeView> {
|
||||
child: WatchState<MapState>((context, state) => Icon(state.followLocation ? Icons.my_location : Icons.location_disabled)),
|
||||
onPressed: () => context.obtainState<MapState>().toggleLocationLock(),
|
||||
),
|
||||
body: Column(
|
||||
body: const Column(
|
||||
children: [
|
||||
const SizedBox(
|
||||
SizedBox(
|
||||
height: 100,
|
||||
child: StatusView(),
|
||||
),
|
||||
Expanded(
|
||||
child: Consumer<MapState>(
|
||||
builder: (context, state, child) {
|
||||
return LoadingContainer(
|
||||
loading: child == null,
|
||||
fetching: state.isCurrentlyFetching,
|
||||
child: const MapView(),
|
||||
);
|
||||
},
|
||||
child: const MapView(),
|
||||
),
|
||||
child: MapView(),
|
||||
)
|
||||
],
|
||||
),
|
||||
|
Reference in New Issue
Block a user