import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../../../data/repositories/auth_repository.dart'; import '../../../data/models/user_model.dart'; final authControllerProvider = StateNotifierProvider((ref) { return AuthController(ref.read(authRepositoryProvider)); }); final authRepositoryProvider = Provider((ref) { return AuthRepository(/* SupabaseClient instance will be injected */); }); class AuthController extends StateNotifier { final AuthRepository _authRepository; AuthController(this._authRepository) : super(null) { _init(); } void _init() { state = _authRepository.currentUser; _authRepository.authStateChanges.listen((user) { state = user; }); } Future signInWithEmail(String email, String password) async { await _authRepository.signInWithEmail(email, password); } Future signUpWithEmail(String email, String password, String username) async { await _authRepository.signUpWithEmail(email, password, username); } Future signInWithGoogle() async { await _authRepository.signInWithGoogle(); } Future signInWithApple() async { await _authRepository.signInWithApple(); } Future signOut() async { await _authRepository.signOut(); } Future resetPassword(String email) async { await _authRepository.resetPassword(email); } Future updateProfile({ String? username, String? bio, String? avatarUrl, bool? isPublicProfile, }) async { await _authRepository.updateProfile( username: username, bio: bio, avatarUrl: avatarUrl, isPublicProfile: isPublicProfile, ); } }