Skip to content
Snippets Groups Projects
Select Git revision
  • 3af0a0b54922fb205dbd00d80f4d632f0ea89ab5
  • main default protected
  • music_player
  • WirMachenFirebaseMitRein
  • madlen
  • mergeHELL
  • ede
  • spotify-api
8 results

widgets.dart

  • widgets.dart 2.38 KiB
    import 'package:firebase_auth/firebase_auth.dart';
    import 'package:flutter/material.dart';
    
    import 'login.dart';
    
    //Widgets für den Login/Registrations Screen
    
    Container loginRegisterButton(
    BuildContext context, bool isLogin, Function onTap) {
      return Container(
        width: MediaQuery.of(context).size.width,
        height: 50,
        margin: EdgeInsets.fromLTRB(0, 10, 0, 20),
            decoration: BoxDecoration(borderRadius: BorderRadius.circular(50)),
            child: ElevatedButton(
              onPressed: (){
                onTap();
              },
              style: ButtonStyle(
              backgroundColor: MaterialStateColor.resolveWith((states){
                if(states.contains(MaterialState.pressed)){
                  return Colors.black;
                }
                  return Colors.white;
                }),
                shape: MaterialStateProperty.all<RoundedRectangleBorder>(
                  RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)))),
              child: Text(
                isLogin? 'Login' : 'Registrate',
                style: const TextStyle(
                  color: Colors.black),
                ),
            )
        );
    }
    Container signOutButton(
        BuildContext context) {
      return Container(
          width: MediaQuery
              .of(context)
              .size
              .width,
          height: 50,
          margin: EdgeInsets.fromLTRB(0, 10, 0, 20),
          decoration: BoxDecoration(borderRadius: BorderRadius.circular(50)),
          child: ElevatedButton(
            onPressed: () {
              FirebaseAuth.instance.signOut().then((value) {
                Navigator.push(context, MaterialPageRoute(builder:
                    (context) => LoginPage()));
              });
            },
            style: ButtonStyle(
                backgroundColor: MaterialStateColor.resolveWith((states) {
                  if (states.contains(MaterialState.pressed)) {
                    return Colors.black;
                  }
                  return Colors.white;
                }),
                shape: MaterialStateProperty.all<RoundedRectangleBorder>(
                    RoundedRectangleBorder(
                        borderRadius: BorderRadius.circular(30)))),
            child: const Text(
              "Sign Out",
              style: TextStyle(
                  color: Colors.black),
            ),
          )
      );
    }