generateSocialLogin static method

String generateSocialLogin(
  1. String projectName
)

Implementation

static String generateSocialLogin(String projectName) {
  return '''
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:$projectName/shared/widgets/widgets.dart';

class LoginScreen extends StatefulWidget {
const LoginScreen({Key? key}) : super(key: key);

@override
State<LoginScreen> createState() => _LoginScreenState();
}

class _LoginScreenState extends State<LoginScreen> {
bool _isLoading = false;

Future<void> _handleSocialSignIn(SocialAuthProvider provider) async {
  setState(() => _isLoading = true);

  // TODO: Implement Social Sign-In
  await Future.delayed(const Duration(seconds: 2));

  if (mounted) {
    setState(() => _isLoading = false);
    context.go('/');
  }
}

@override
Widget build(BuildContext context) {
  final theme = Theme.of(context);
  final size = MediaQuery.of(context).size;
  final isTablet = size.width > 600;

  return Scaffold(
    body: SafeArea(
      child: Center(
        child: SingleChildScrollView(
          padding: const EdgeInsets.all(24),
          child: ConstrainedBox(
            constraints: BoxConstraints(maxWidth: isTablet ? 500 : double.infinity),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.stretch,
              children: [
                Icon(Icons.rocket_launch, size: 100, color: theme.colorScheme.primary),
                const SizedBox(height: 32),
                Text('Welcome', style: theme.textTheme.displayLarge, textAlign: TextAlign.center),
                const SizedBox(height: 8),
                Text(
                  'Sign in with your preferred method',
                  style: theme.textTheme.bodyMedium,
                  textAlign: TextAlign.center,
                ),
                const SizedBox(height: 64),
                SocialAuthButton(
                  provider: SocialAuthProvider.google,
                  onPressed: _isLoading ? () {} : () => _handleSocialSignIn(SocialAuthProvider.google),
                  isLoading: _isLoading,
                ),
                const SizedBox(height: 16),
                SocialAuthButton(
                  provider: SocialAuthProvider.apple,
                  onPressed: _isLoading ? () {} : () => _handleSocialSignIn(SocialAuthProvider.apple),
                  isLoading: _isLoading,
                ),
                if (_isLoading) ...[
                  const SizedBox(height: 24),
                  const Center(child: CircularProgressIndicator()),
                ],
                const SizedBox(height: 48),
                Text(
                  'By continuing, you agree to our Terms of Service\\nand Privacy Policy',
                  style: theme.textTheme.bodySmall,
                  textAlign: TextAlign.center,
                ),
              ],
            ),
          ),
        ),
      ),
    ),
  );
}
}
''';
}