Skip to content

Oauth - OAuth UI Components and Provider Config (Flutter) #3334

@coderabbitai

Description

@coderabbitai

Problem

The app lacks reusable OAuth UI widgets and a provider configuration to drive UX consistently.

Scope

  • Widgets: OAuthButton, OAuthLoginSection.
  • Config: oauth_config.dart storing constants for provider names/colors/scopes.

Approach

  • Keep UI simple and composable; loading/disabled support.

Dependencies

  • Blocked By:
  • Blocks:

Files to Modify/Create

  • talawa/lib/widgets/oauth/oauth_button.dart
  • talawa/lib/widgets/oauth/oauth_login_section.dart
  • talawa/lib/config/oauth_config.dart

Acceptance Criteria

  • All existing functionality must be maintained
  • Implementation must ensure no breaking changes when PR is merged

Testing Requirements

  • All tests must pass successfully
  • Code coverage must be >= 96%

Sample Code

This sample code is only representative of what could be done. It is provided only to give a general outline. You will need to use your initiative and industry best practices to find a solution that is suitable for the application.

// talawa/lib/widgets/oauth/oauth_button.dart
import 'package:flutter/material.dart';
class OAuthButton extends StatelessWidget {
  final String label; final Color color; final VoidCallback onPressed; final bool loading;
  const OAuthButton({super.key, required this.label, required this.color, required this.onPressed, this.loading=false});
  @override Widget build(BuildContext context) {
    return ElevatedButton(
      onPressed: loading?null:onPressed,
      style: ElevatedButton.styleFrom(backgroundColor: color),
      child: loading? const CircularProgressIndicator.adaptive() : Text(label),
    );
  }
}
// talawa/lib/config/oauth_config.dart
class OAuthConfig {
  static const googleClientId = String.fromEnvironment('GOOGLE_CLIENT_ID', defaultValue: '');
  static const googleRedirectUri = String.fromEnvironment('GOOGLE_REDIRECT_URI', defaultValue: 'talawa://oauth/callback');
  static const githubClientId = String.fromEnvironment('GITHUB_CLIENT_ID', defaultValue: '');
  static const githubRedirectUri = String.fromEnvironment('GITHUB_REDIRECT_URI', defaultValue: 'talawa://oauth/callback');
}

Metadata

Metadata

Labels

dartPull requests that update Dart codesecuritySecurity fix

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions