content: import 'package:firebase_auth/firebase_auth.dart';
  import 'package:flutter/material.dart';
  import 'package:flutterfire_samples/res/custom_colors.dart';
  import 'package:flutterfire_samples/authentication/google_sign_in/utils/authentication.dart';
  import 'package:flutterfire_samples/common/widgets/app_bar_title.dart';
  
  import 'sign_in_screen.dart';
  
  class UserInfoScreen extends StatefulWidget {
    const UserInfoScreen({Key? key, required User user})
        : _user = user,
          super(key: key);
  
    final User _user;
  
    @override
    UserInfoScreenState createState() => UserInfoScreenState();
  }
  
  class UserInfoScreenState extends State<UserInfoScreen> {
    late User _user;
    bool _isSigningOut = false;
  
    Route _routeToSignInScreen() {
      return PageRouteBuilder(
        pageBuilder: (context, animation, secondaryAnimation) =>
            const SignInScreen(),
        transitionsBuilder: (context, animation, secondaryAnimation, child) {
          var begin = const Offset(-1.0, 0.0);
          var end = Offset.zero;
          var curve = Curves.ease;
  
          var tween =
              Tween(begin: begin, end: end).chain(CurveTween(curve: curve));
  
          return SlideTransition(
            position: animation.drive(tween),
            child: child,
          );
        },
      );
    }
  
    @override
    void initState() {
      _user = widget._user;
  
      super.initState();
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        backgroundColor: Palette.firebaseNavy,
        appBar: AppBar(
          elevation: 0,
          backgroundColor: Palette.firebaseNavy,
          title: const AppBarTitle(
            sectionName: 'Authentication',
          ),
        ),
        body: SafeArea(
          child: Padding(
            padding: const EdgeInsets.only(
              left: 16.0,
              right: 16.0,
              bottom: 20.0,
            ),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Row(),
                _user.photoURL != null
                    ? ClipOval(
                        child: Material(
                          color: Palette.firebaseGrey.withOpacity(0.3),
                          child: Image.network(
                            _user.photoURL!,
                            fit: BoxFit.fitHeight,
                          ),
                        ),
                      )
                    : ClipOval(
                        child: Material(
                          color: Palette.firebaseGrey.withOpacity(0.3),
                          child: const Padding(
                            padding: EdgeInsets.all(16.0),
                            child: Icon(
                              Icons.person,
                              size: 60,
                              color: Palette.firebaseGrey,
                            ),
                          ),
                        ),
                      ),
                const SizedBox(height: 16.0),
                const Text(
                  'Hello',
                  style: TextStyle(
                    color: Palette.firebaseGrey,
                    fontSize: 26,
                  ),
                ),
                const SizedBox(height: 8.0),
                Text(
                  _user.displayName!,
                  style: const TextStyle(
                    color: Palette.firebaseYellow,
                    fontSize: 26,
                  ),
                ),
                const SizedBox(height: 8.0),
                Text(
                  '( ${_user.email!} )',
                  style: const TextStyle(
                    color: Palette.firebaseOrange,
                    fontSize: 20,
                    letterSpacing: 0.5,
                  ),
                ),
                const SizedBox(height: 24.0),
                Text(
                  'You are now signed in using your Google account. To sign out of your account click the "Sign Out" button below.',
                  style: TextStyle(
                      color: Palette.firebaseGrey.withOpacity(0.8),
                      fontSize: 14,
                      letterSpacing: 0.2),
                ),
                const SizedBox(height: 16.0),
                _isSigningOut
                    ? const CircularProgressIndicator(
                        valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
                      )
                    : ElevatedButton(
                        style: ButtonStyle(
                          backgroundColor: MaterialStateProperty.all(
                            Colors.redAccent,
                          ),
                          shape: MaterialStateProperty.all(
                            RoundedRectangleBorder(
                              borderRadius: BorderRadius.circular(10),
                            ),
                          ),
                        ),
                        onPressed: () async {
                          setState(() {
                            _isSigningOut = true;
                          });
                          await Authentication.signOut(context: context);
                          setState(() {
                            _isSigningOut = false;
                          });
                          if (!mounted) return;
                          Navigator.of(context)
                              .pushReplacement(_routeToSignInScreen());
                        },
                        child: const Padding(
                          padding: EdgeInsets.only(top: 8.0, bottom: 8.0),
                          child: Text(
                            'Sign Out',
                            style: TextStyle(
                              fontSize: 20,
                              fontWeight: FontWeight.bold,
                              color: Colors.white,
                              letterSpacing: 2,
                            ),
                          ),
                        ),
                      ),
              ],
            ),
          ),
        ),
      );
    }
  }
  