Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALTAPPS-1327: iOS hide JetBrains and GitHub social providers with additional tap #1154

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ enum Strings {
static let gitHubAccount = sharedStrings.auth_github_account_text.localized()
static let appleAccount = sharedStrings.auth_apple_account_text.localized()
static let emailText = sharedStrings.auth_email_text.localized()
static let moreOptionsButton = sharedStrings.auth_more_options_btn.localized()
}

// MARK: Credentials
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ final class AuthSocialViewModel: FeatureViewModel<

private let authSocialErrorMapper: AuthSocialErrorMapper

let availableSocialAuthProviders = SocialAuthProvider.allCases.filter(\.isSupported)

var authSocialErrorMessage: String? {
guard let errorState = state as? AuthSocialFeatureStateError else {
return nil
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import SwiftUI

struct AuthSocialControlsView: View {
let socialAuthProviders: [SocialAuthProvider]
let isInSignUpMode: Bool

let errorMessage: String?

let isContinueWithEmailAvailable: Bool

let onSocialAuthProviderClick: ((SocialAuthProvider) -> Void)
let onContinueWithEmailClick: (() -> Void)

@State private var isShowingMoreOptions = false

private var socialAuthProviders: [SocialAuthProvider] {
let providers: [SocialAuthProvider] =
if isInSignUpMode {
isShowingMoreOptions ? [.google, .apple, .jetbrains, .github] : [.google, .apple]
} else {
[.jetbrains, .google, .github, .apple]
}
return providers.filter(\.isSupported)
}

var body: some View {
VStack(spacing: LayoutInsets.smallInset) {
ForEach(socialAuthProviders, id: \.rawValue) { provider in
Expand All @@ -26,7 +36,19 @@ struct AuthSocialControlsView: View {
AuthCredentialsErrorView(message: errorMessage)
}

if isContinueWithEmailAvailable {
if isInSignUpMode {
if !isShowingMoreOptions {
Button(
Strings.Auth.Social.moreOptionsButton,
action: {
withAnimation {
isShowingMoreOptions = true
}
}
)
.padding(.top)
}
} else {
Button(
Strings.Auth.Social.emailText,
action: onContinueWithEmailClick
Expand Down Expand Up @@ -69,18 +91,16 @@ struct AuthSocialControlsView_Previews: PreviewProvider {
static var previews: some View {
Group {
AuthSocialControlsView(
socialAuthProviders: SocialAuthProvider.allCases,
isInSignUpMode: false,
errorMessage: "Error message",
isContinueWithEmailAvailable: true,
onSocialAuthProviderClick: { _ in },
onContinueWithEmailClick: {}
)
.preferredColorScheme(.light)

AuthSocialControlsView(
socialAuthProviders: SocialAuthProvider.allCases,
isInSignUpMode: false,
errorMessage: "Error message",
isContinueWithEmailAvailable: true,
onSocialAuthProviderClick: { _ in },
onContinueWithEmailClick: {}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ struct AuthSocialView: View {
.padding(horizontalSizeClass == .regular ? .bottom : .vertical, appearance.logoWidthHeight)

AuthSocialControlsView(
socialAuthProviders: viewModel.availableSocialAuthProviders,
isInSignUpMode: isInSignUpMode,
errorMessage: viewModel.authSocialErrorMessage,
isContinueWithEmailAvailable: !isInSignUpMode,
onSocialAuthProviderClick: viewModel.signIn(with:),
onContinueWithEmailClick: {
viewModel.logClickedContinueWithEmailEvent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ final class SocialAuthService: SocialAuthServiceProtocol {

// MARK: - SocialAuthProvider -

enum SocialAuthProvider: String, CaseIterable {
enum SocialAuthProvider: String {
case jetbrains
case google
case github
Expand Down
1 change: 1 addition & 0 deletions shared/src/commonMain/moko-resources/base/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<string name="auth_email_text">Continue with email</string>
<string name="auth_social_email_already_used">The email associated with this social network is already in use. Try authorizing via email</string>
<string name="auth_social_email_not_provided_by_social">Authorization error: email is not provided by social network</string>
<string name="auth_more_options_btn">More options</string>

<!-- Auth credentials -->
<string name="auth_credentials_social_text">Continue with social networks</string>
Expand Down
Loading