Add Android support with configurable server URL and location permissions
- Add shared_preferences for persisting server URL - Add SettingsService and PlatformService - Add server URL input field on non-web platforms - Make ApiConfig baseUrl configurable at runtime - Add Android location permissions (ACCESS_FINE/COURSE_LOCATION, INTERNET) - Request location permission on login and map init - Fix geo_id type: use String instead of int (UUID format) - Align share_service with API spec: remove unique_id, use share_id only - Fix watch endpoint response: last_update instead of created_at - Add error handling with SnackBars for geo operations - Wrap login screen in SingleChildScrollView for keyboard handling - Update map tile layer with userAgentPackageName for OSM
This commit is contained in:
@@ -5,24 +5,24 @@ import '../services/auth_service.dart';
|
||||
|
||||
class AuthProvider with ChangeNotifier {
|
||||
final AuthService _authService;
|
||||
|
||||
|
||||
String _token = '';
|
||||
bool _isLoading = false;
|
||||
String _error = '';
|
||||
|
||||
AuthProvider({AuthService? authService})
|
||||
: _authService = authService ?? AuthService();
|
||||
|
||||
|
||||
AuthProvider({AuthService? authService})
|
||||
: _authService = authService ?? AuthService();
|
||||
|
||||
String get token => _token;
|
||||
bool get isLoggedIn => _token.isNotEmpty;
|
||||
bool get isLoading => _isLoading;
|
||||
String get error => _error;
|
||||
|
||||
|
||||
Future<void> login(String login, String password) async {
|
||||
_isLoading = true;
|
||||
_error = '';
|
||||
notifyListeners();
|
||||
|
||||
|
||||
try {
|
||||
var response = await _authService.login(login, password);
|
||||
var data = jsonDecode(response);
|
||||
@@ -37,14 +37,18 @@ class AuthProvider with ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> register(String login, String password) async {
|
||||
|
||||
Future<void> register(
|
||||
String login,
|
||||
String password,
|
||||
String secretKeyHash,
|
||||
) async {
|
||||
_isLoading = true;
|
||||
_error = '';
|
||||
notifyListeners();
|
||||
|
||||
|
||||
try {
|
||||
await _authService.register(login, password);
|
||||
await _authService.register(login, password, secretKeyHash);
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
_error = e.toString();
|
||||
@@ -55,9 +59,14 @@ class AuthProvider with ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void setError(String message) {
|
||||
_error = message;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void logout() {
|
||||
_token = '';
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user