Refactor: Centralize Google Sign-In config and improve social login UX#8
Open
Refactor: Centralize Google Sign-In config and improve social login UX#8
Conversation
This commit refactors how Google Sign-In is configured by centralizing it within the Koin dependency graph, and improves the user experience for social logins by adding distinct loading states for each provider.
### Core Architecture & Configuration:
- **Centralized `GoogleSignInConfig`**: The `GoogleSignInConfig` is no longer passed via a `LoginLibraryConfig` wrapper. Instead, it's provided directly to `initLoginKoin` and injected into the Koin dependency graph, making it available throughout the library.
- **Simplified Koin Initialization**: The `initLoginKoin` function is simplified to accept `googleSignInConfig` directly, streamlining the library's setup in both Android and iOS app modules.
- **Domain Model Relocation**: The `GoogleSignInConfig` class has been moved from the `config` package to `domain/model` to better align with the project's architecture.
### UI/UX Improvements:
- **Provider-Specific Loading States**:
- The `LoginUiState` now uses a `loadingProvider: String?` property instead of a generic `isLoading: Boolean`. This allows the UI to show a loading indicator on the specific social login button that was clicked (e.g., "google", "phone") or on the email sign-in button ("email").
- The `DefaultSocialButton` and its implementations (`GoogleSocialButton`, `PhoneSocialButton`) have been updated to accept an `isLoading` state, displaying a `CircularProgressIndicator` when active.
- Other buttons on the screen are disabled when any login process is active, preventing concurrent actions.
- **Refactored Social Login Section**:
- The `SocialLoginButtonsSection` now receives the `loadingProvider` state to correctly render the loading status for each button.
- The old, more complex `SocialLoginButtons.kt` file has been removed in favor of a cleaner implementation in `DefaultSocialButton.kt`.
### Other Changes:
- **Session Refresh**: The `ProfileViewModel` now calls `authRepository.refreshSession()` instead of the removed `getCurrentSession()` to fetch user data, ensuring the session is up-to-date.
- **Code Cleanup**: Removed the now-redundant `getCurrentSession()` method from `AuthRepository` and its implementation.
- **Android Manifest**: Added the `INTERNET` permission to the `composeApp` manifest, which was missing.
This commit introduces the `actual` implementation of `GoogleAuthProvider` for the iOS source set. While the full integration with the Google Sign-In SDK for iOS is pending, this provides the necessary class structure to satisfy multiplatform requirements. - **iOS Implementation**: Added `GoogleAuthProvider` in `iosMain`, implementing the `AuthProvider` interface for the `IdentityProvider.Google` type. - **Placeholder Logic**: The `signIn` method currently returns an `AuthError.OperationNotAllowed` failure, and `signOut` returns `AuthResult.SignOutSuccess` as placeholders for the native SDK integration.
This commit removes the `GoogleSignInConfig` data class from the `domain/model` package. This configuration object, which previously held `webClientId` and `iosClientId` for Google Sign-In, is no longer required in this location.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit refactors how Google Sign-In is configured by centralizing it within the Koin dependency graph, and improves the user experience for social logins by adding distinct loading states for each provider.
Core Architecture & Configuration:
GoogleSignInConfig: TheGoogleSignInConfigis no longer passed via aLoginLibraryConfigwrapper. Instead, it's provided directly toinitLoginKoinand injected into the Koin dependency graph, making it available throughout the library.initLoginKoinfunction is simplified to acceptgoogleSignInConfigdirectly, streamlining the library's setup in both Android and iOS app modules.GoogleSignInConfigclass has been moved from theconfigpackage todomain/modelto better align with the project's architecture.UI/UX Improvements:
LoginUiStatenow uses aloadingProvider: String?property instead of a genericisLoading: Boolean. This allows the UI to show a loading indicator on the specific social login button that was clicked (e.g., "google", "phone") or on the email sign-in button ("email").DefaultSocialButtonand its implementations (GoogleSocialButton,PhoneSocialButton) have been updated to accept anisLoadingstate, displaying aCircularProgressIndicatorwhen active.SocialLoginButtonsSectionnow receives theloadingProviderstate to correctly render the loading status for each button.SocialLoginButtons.ktfile has been removed in favor of a cleaner implementation inDefaultSocialButton.kt.Other Changes:
ProfileViewModelnow callsauthRepository.refreshSession()instead of the removedgetCurrentSession()to fetch user data, ensuring the session is up-to-date.getCurrentSession()method fromAuthRepositoryand its implementation.INTERNETpermission to thecomposeAppmanifest, which was missing.