mirror of
https://github.com/Dvorinka/1356.git
synced 2026-06-03 19:42:57 +00:00
37ffb93923
Version: 1.1.0 Major changes: - Implemented complete Flutter app structure with all core features - Added comprehensive UI screens for auth, countdown, goals, profile, settings, and social features - Integrated Supabase backend with authentication and data repositories - Added offline support with Hive caching and local storage - Implemented comprehensive routing with go_router - Added location services with Google Maps integration - Implemented notifications and home widget support - Added voice recording capabilities and AI chat features - Created comprehensive test suite and documentation - Added Android and iOS platform configurations - Implemented achievements system and social features - Added calendar integration and bucket list functionality This represents a complete Phase 1 milestone with 3,775 additions across 31 files.
113 lines
3.0 KiB
Dart
113 lines
3.0 KiB
Dart
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import '../../../data/repositories/auth_repository.dart';
|
|
import '../../../data/models/user_model.dart';
|
|
import '../../../core/services/analytics_service.dart';
|
|
|
|
final authControllerProvider = StateNotifierProvider<AuthController, User?>((ref) {
|
|
return AuthController(ref.read(authRepositoryProvider));
|
|
});
|
|
|
|
final authRepositoryProvider = Provider<AuthRepository>((ref) {
|
|
return AuthRepository();
|
|
});
|
|
|
|
class AuthController extends StateNotifier<User?> {
|
|
final AuthRepository _authRepository;
|
|
final AnalyticsService _analytics = AnalyticsService();
|
|
|
|
AuthController(this._authRepository) : super(null) {
|
|
_init();
|
|
}
|
|
|
|
void _init() {
|
|
state = _authRepository.currentUser;
|
|
_authRepository.authStateChanges.listen((user) {
|
|
state = user;
|
|
if (user != null) {
|
|
_analytics.setUserId(user.id);
|
|
}
|
|
});
|
|
}
|
|
|
|
bool get isAuthenticated => _authRepository.isAuthenticated;
|
|
|
|
String? get currentUserId => _authRepository.currentUserId;
|
|
|
|
Future<bool> isSessionValid() async {
|
|
return await _authRepository.isSessionValid();
|
|
}
|
|
|
|
Future<void> refreshSession() async {
|
|
await _authRepository.refreshSession();
|
|
}
|
|
|
|
Future<void> signInWithEmail(String email, String password) async {
|
|
await _authRepository.signInWithEmail(email, password);
|
|
_analytics.logSignIn(method: 'email');
|
|
}
|
|
|
|
Future<void> signUpWithEmail(String email, String password, String username) async {
|
|
await _authRepository.signUpWithEmail(email, password, username);
|
|
_analytics.logSignUp(method: 'email');
|
|
}
|
|
|
|
Future<void> signInWithGoogle() async {
|
|
await _authRepository.signInWithGoogle();
|
|
_analytics.logSignIn(method: 'google');
|
|
}
|
|
|
|
Future<void> signInWithApple() async {
|
|
await _authRepository.signInWithApple();
|
|
_analytics.logSignIn(method: 'apple');
|
|
}
|
|
|
|
Future<void> signInWithGithub() async {
|
|
await _authRepository.signInWithGithub();
|
|
_analytics.logSignIn(method: 'github');
|
|
}
|
|
|
|
Future<void> signOut() async {
|
|
await _authRepository.signOut();
|
|
state = null;
|
|
_analytics.logSignOut();
|
|
_analytics.reset();
|
|
}
|
|
|
|
Future<void> resetPassword(String email) async {
|
|
await _authRepository.resetPassword(email);
|
|
}
|
|
|
|
Future<void> updateProfile({
|
|
String? username,
|
|
String? bio,
|
|
String? avatarUrl,
|
|
bool? isPublicProfile,
|
|
}) async {
|
|
final updatedFields = <String>[];
|
|
if (username != null) updatedFields.add('username');
|
|
if (bio != null) updatedFields.add('bio');
|
|
if (avatarUrl != null) updatedFields.add('avatar');
|
|
if (isPublicProfile != null) {
|
|
updatedFields.add('visibility');
|
|
_analytics.logProfileVisibilityChanged(isPublic: isPublicProfile);
|
|
}
|
|
|
|
await _authRepository.updateProfile(
|
|
username: username,
|
|
bio: bio,
|
|
avatarUrl: avatarUrl,
|
|
isPublicProfile: isPublicProfile,
|
|
);
|
|
|
|
if (updatedFields.isNotEmpty) {
|
|
_analytics.logProfileUpdated(fieldsUpdated: updatedFields.join(','));
|
|
}
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_authRepository.dispose();
|
|
super.dispose();
|
|
}
|
|
}
|