+fix
This commit is contained in:
+48
-26
@@ -1,4 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'package:GeoShare/services/settings_service.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
@@ -27,7 +28,7 @@ class _MapScreenState extends State<MapScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_initLocationAndShare();
|
||||
//_initLocationAndShare();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -93,7 +94,7 @@ class _MapScreenState extends State<MapScreen> {
|
||||
|
||||
_geoTimer = Timer.periodic(
|
||||
const Duration(seconds: 30),
|
||||
(_) => _updateGeolocation(),
|
||||
(_) => _updateGeolocation(),
|
||||
);
|
||||
} catch (_) {
|
||||
setState(() => _loading = false);
|
||||
@@ -150,21 +151,22 @@ class _MapScreenState extends State<MapScreen> {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
builder: (context) => _WatchMenu(
|
||||
token: authProvider.token,
|
||||
onAdd: (shareId) async {
|
||||
await shareProvider.addTracking(shareId, authProvider.token);
|
||||
if (shareProvider.trackedPeople.length == 1) {
|
||||
shareProvider.startTrackingPolling(authProvider.token);
|
||||
}
|
||||
},
|
||||
onRemove: (shareId) {
|
||||
shareProvider.removeTracking(shareId);
|
||||
if (shareProvider.trackedPeople.isEmpty) {
|
||||
shareProvider.stopAllTracking();
|
||||
}
|
||||
},
|
||||
),
|
||||
builder: (context) =>
|
||||
_WatchMenu(
|
||||
token: authProvider.token,
|
||||
onAdd: (shareId) async {
|
||||
await shareProvider.addTracking(shareId, authProvider.token);
|
||||
if (shareProvider.trackedPeople.length == 1) {
|
||||
shareProvider.startTrackingPolling(authProvider.token);
|
||||
}
|
||||
},
|
||||
onRemove: (shareId) {
|
||||
shareProvider.removeTracking(shareId);
|
||||
if (shareProvider.trackedPeople.isEmpty) {
|
||||
shareProvider.stopAllTracking();
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -207,6 +209,7 @@ class _MapScreenState extends State<MapScreen> {
|
||||
final authProvider = context.watch<AuthProvider>();
|
||||
final _ = context.watch<MapProvider>();
|
||||
final shareProvider = context.watch<ShareProvider>();
|
||||
final settings = context.read<SettingsService>();
|
||||
|
||||
if (_loading) {
|
||||
return Scaffold(body: const Center(child: CircularProgressIndicator()));
|
||||
@@ -215,7 +218,8 @@ class _MapScreenState extends State<MapScreen> {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
'Family Safety Map\n${_center.latitude.toStringAsFixed(4)}, ${_center.longitude.toStringAsFixed(4)}',
|
||||
'Карта\n${_center.latitude.toStringAsFixed(4)}, ${_center
|
||||
.longitude.toStringAsFixed(4)}',
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
actions: [
|
||||
@@ -223,7 +227,10 @@ class _MapScreenState extends State<MapScreen> {
|
||||
icon: const Icon(Icons.refresh),
|
||||
onPressed: _updateGeolocation,
|
||||
),
|
||||
IconButton(icon: const Icon(Icons.share), onPressed: _copyShareLink),
|
||||
IconButton(icon: const Icon(Icons.share), onPressed: () {
|
||||
_initLocationAndShare();
|
||||
_copyShareLink();
|
||||
}),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.visibility),
|
||||
onPressed: _openWatchMenu,
|
||||
@@ -236,6 +243,7 @@ class _MapScreenState extends State<MapScreen> {
|
||||
await bgGeo.stop();
|
||||
bgGeo.dispose();
|
||||
authProvider.logout();
|
||||
settings.logOut();
|
||||
Navigator.of(context).pushReplacementNamed('/');
|
||||
},
|
||||
),
|
||||
@@ -287,7 +295,10 @@ class _WatchMenuState extends State<_WatchMenu> {
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.of(context).viewInsets.bottom,
|
||||
bottom: MediaQuery
|
||||
.of(context)
|
||||
.viewInsets
|
||||
.bottom,
|
||||
),
|
||||
child: Container(
|
||||
constraints: const BoxConstraints(maxHeight: 400),
|
||||
@@ -297,7 +308,10 @@ class _WatchMenuState extends State<_WatchMenu> {
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||
color: Theme
|
||||
.of(context)
|
||||
.colorScheme
|
||||
.surfaceContainerHighest,
|
||||
borderRadius: const BorderRadius.vertical(
|
||||
top: Radius.circular(16),
|
||||
),
|
||||
@@ -354,8 +368,9 @@ class _WatchMenuState extends State<_WatchMenu> {
|
||||
title: Text(person.name),
|
||||
subtitle: hasPosition
|
||||
? Text(
|
||||
'${person.position!['y'].toStringAsFixed(4)}, ${person.position!['x'].toStringAsFixed(4)}',
|
||||
)
|
||||
'${person.position!['y'].toStringAsFixed(4)}, ${person
|
||||
.position!['x'].toStringAsFixed(4)}',
|
||||
)
|
||||
: const Text('Нет данных'),
|
||||
trailing: IconButton(
|
||||
icon: const Icon(Icons.close, color: Colors.red),
|
||||
@@ -368,7 +383,10 @@ class _WatchMenuState extends State<_WatchMenu> {
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||
color: Theme
|
||||
.of(context)
|
||||
.colorScheme
|
||||
.surfaceContainerHighest,
|
||||
borderRadius: const BorderRadius.vertical(
|
||||
bottom: Radius.circular(16),
|
||||
),
|
||||
@@ -387,7 +405,9 @@ class _WatchMenuState extends State<_WatchMenu> {
|
||||
),
|
||||
),
|
||||
onSubmitted: (value) {
|
||||
if (value.trim().isNotEmpty) {
|
||||
if (value
|
||||
.trim()
|
||||
.isNotEmpty) {
|
||||
widget.onAdd(value.trim());
|
||||
_controller.clear();
|
||||
}
|
||||
@@ -397,7 +417,9 @@ class _WatchMenuState extends State<_WatchMenu> {
|
||||
const SizedBox(width: 8),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
if (_controller.text.trim().isNotEmpty) {
|
||||
if (_controller.text
|
||||
.trim()
|
||||
.isNotEmpty) {
|
||||
widget.onAdd(_controller.text.trim());
|
||||
_controller.clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user