mirror of
https://github.com/FoggedLens/deflock-app.git
synced 2026-05-22 08:17:23 +02:00
new icons, remove upload dests
This commit is contained in:
@@ -28,6 +28,9 @@ const double kAddPinYOffset = 0.0;
|
||||
const String kClientName = 'DeFlock';
|
||||
const String kClientVersion = '0.9.8';
|
||||
|
||||
// Development/testing features - set to false for production builds
|
||||
const bool kEnableDevelopmentModes = false; // Set to false to hide sandbox/simulate modes and force production mode
|
||||
|
||||
// Marker/node interaction
|
||||
const int kCameraMinZoomLevel = 10; // Minimum zoom to show nodes or warning
|
||||
const Duration kMarkerTapTimeout = Duration(milliseconds: 250);
|
||||
|
||||
@@ -11,6 +11,7 @@ import 'settings_screen_sections/max_nodes_section.dart';
|
||||
import 'settings_screen_sections/tile_provider_section.dart';
|
||||
import 'settings_screen_sections/language_section.dart';
|
||||
import '../services/localization_service.dart';
|
||||
import '../dev_config.dart';
|
||||
|
||||
class SettingsScreen extends StatelessWidget {
|
||||
const SettingsScreen({super.key});
|
||||
@@ -23,28 +24,31 @@ class SettingsScreen extends StatelessWidget {
|
||||
appBar: AppBar(title: Text(LocalizationService.instance.t('settings.title'))),
|
||||
body: ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: const [
|
||||
UploadModeSection(),
|
||||
Divider(),
|
||||
AuthSection(),
|
||||
Divider(),
|
||||
QueueSection(),
|
||||
Divider(),
|
||||
ProfileListSection(),
|
||||
Divider(),
|
||||
OperatorProfileListSection(),
|
||||
Divider(),
|
||||
MaxNodesSection(),
|
||||
Divider(),
|
||||
TileProviderSection(),
|
||||
Divider(),
|
||||
OfflineModeSection(),
|
||||
Divider(),
|
||||
OfflineAreasSection(),
|
||||
Divider(),
|
||||
LanguageSection(),
|
||||
Divider(),
|
||||
AboutSection(),
|
||||
children: [
|
||||
// Only show upload mode section in development builds
|
||||
if (kEnableDevelopmentModes) ...[
|
||||
const UploadModeSection(),
|
||||
const Divider(),
|
||||
],
|
||||
const AuthSection(),
|
||||
const Divider(),
|
||||
const QueueSection(),
|
||||
const Divider(),
|
||||
const ProfileListSection(),
|
||||
const Divider(),
|
||||
const OperatorProfileListSection(),
|
||||
const Divider(),
|
||||
const MaxNodesSection(),
|
||||
const Divider(),
|
||||
const TileProviderSection(),
|
||||
const Divider(),
|
||||
const OfflineModeSection(),
|
||||
const Divider(),
|
||||
const OfflineAreasSection(),
|
||||
const Divider(),
|
||||
const LanguageSection(),
|
||||
const Divider(),
|
||||
const AboutSection(),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -106,6 +106,36 @@ class AuthService {
|
||||
}
|
||||
}
|
||||
|
||||
// Restore login state from stored token (for app startup)
|
||||
Future<String?> restoreLogin() async {
|
||||
if (_mode == UploadMode.simulate) {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final isLoggedIn = prefs.getBool('sim_user_logged_in') ?? false;
|
||||
if (isLoggedIn) {
|
||||
_displayName = 'Demo User';
|
||||
return _displayName;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Get stored token directly from SharedPreferences
|
||||
final accessToken = await getAccessToken();
|
||||
if (accessToken == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
_displayName = await _fetchUsername(accessToken);
|
||||
return _displayName;
|
||||
} catch (e) {
|
||||
print('AuthService: Error restoring login with stored token: $e');
|
||||
log('Error restoring login with stored token: $e');
|
||||
// Token might be expired or invalid, clear it
|
||||
await logout();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> logout() async {
|
||||
if (_mode == UploadMode.simulate) {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
|
||||
@@ -18,7 +18,7 @@ class AuthState extends ChangeNotifier {
|
||||
|
||||
try {
|
||||
if (await _auth.isLoggedIn()) {
|
||||
_username = await _auth.login();
|
||||
_username = await _auth.restoreLogin();
|
||||
}
|
||||
} catch (e) {
|
||||
print("AuthState: Error during auth initialization: $e");
|
||||
@@ -44,7 +44,7 @@ class AuthState extends ChangeNotifier {
|
||||
Future<void> refreshAuthState() async {
|
||||
try {
|
||||
if (await _auth.isLoggedIn()) {
|
||||
_username = await _auth.login();
|
||||
_username = await _auth.restoreLogin();
|
||||
} else {
|
||||
_username = null;
|
||||
}
|
||||
@@ -83,7 +83,7 @@ class AuthState extends ChangeNotifier {
|
||||
if (await _auth.isLoggedIn()) {
|
||||
final isValid = await validateToken();
|
||||
if (isValid) {
|
||||
_username = await _auth.login();
|
||||
_username = await _auth.restoreLogin();
|
||||
} else {
|
||||
await logout(); // This clears _username also.
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
|
||||
import '../models/tile_provider.dart';
|
||||
import '../dev_config.dart';
|
||||
|
||||
// Enum for upload mode (Production, OSM Sandbox, Simulate)
|
||||
enum UploadMode { production, sandbox, simulate }
|
||||
@@ -26,7 +27,7 @@ class SettingsState extends ChangeNotifier {
|
||||
|
||||
bool _offlineMode = false;
|
||||
int _maxCameras = 250;
|
||||
UploadMode _uploadMode = UploadMode.simulate;
|
||||
UploadMode _uploadMode = kEnableDevelopmentModes ? UploadMode.simulate : UploadMode.production;
|
||||
FollowMeMode _followMeMode = FollowMeMode.northUp;
|
||||
List<TileProvider> _tileProviders = [];
|
||||
String _selectedTileTypeId = '';
|
||||
@@ -98,6 +99,13 @@ class SettingsState extends ChangeNotifier {
|
||||
await prefs.setInt(_uploadModePrefsKey, _uploadMode.index);
|
||||
}
|
||||
|
||||
// In production builds, force production mode if development modes are disabled
|
||||
if (!kEnableDevelopmentModes && _uploadMode != UploadMode.production) {
|
||||
debugPrint('SettingsState: Development modes disabled, forcing production mode');
|
||||
_uploadMode = UploadMode.production;
|
||||
await prefs.setInt(_uploadModePrefsKey, _uploadMode.index);
|
||||
}
|
||||
|
||||
// Load tile providers (default to built-in providers if none saved)
|
||||
await _loadTileProviders(prefs);
|
||||
|
||||
@@ -170,6 +178,12 @@ class SettingsState extends ChangeNotifier {
|
||||
}
|
||||
|
||||
Future<void> setUploadMode(UploadMode mode) async {
|
||||
// In production builds, only allow production mode
|
||||
if (!kEnableDevelopmentModes && mode != UploadMode.production) {
|
||||
debugPrint('SettingsState: Development modes disabled, forcing production mode');
|
||||
mode = UploadMode.production;
|
||||
}
|
||||
|
||||
_uploadMode = mode;
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setInt(_uploadModePrefsKey, mode.index);
|
||||
|
||||
Reference in New Issue
Block a user