tasktracker/lib/screens/auth_screen.dart

254 lines
7.9 KiB
Dart

import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'login_screen.dart';
import 'register_screen.dart';
class AuthScreen extends StatefulWidget {
const AuthScreen({super.key});
@override
State<AuthScreen> createState() => _AuthScreenState();
}
class _AuthScreenState extends State<AuthScreen>
with SingleTickerProviderStateMixin {
late TabController _tabController;
@override
void initState() {
super.initState();
_tabController = TabController(length: 2, vsync: this);
}
@override
void dispose() {
_tabController.dispose();
super.dispose();
}
Future<void> login(String email, String password) async {
}
Future<void> register(String email, String password, String name) async {
}
Future<void> logout() async {
}
Future<void> oAuthLogin() async {
}
bool isLogged= false;
@override
Widget build(BuildContext context) {
final screenHeight = MediaQuery.of(context).size.height;
// If user is logged in, show logout screen
if (isLogged) {
return Scaffold(
backgroundColor: Colors.grey[50],
body: SafeArea(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 80,
height: 80,
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
borderRadius: BorderRadius.circular(20),
boxShadow: [
BoxShadow(
color: Theme.of(context).primaryColor.withValues(alpha: 0.3),
blurRadius: 20,
offset: const Offset(0, 10),
),
],
),
child: const Icon(
Icons.task_alt,
color: Colors.white,
size: 40,
),
),
const SizedBox(height: 24),
Text(
'Welcome back!',
style: GoogleFonts.poppins(
fontSize: 28,
fontWeight: FontWeight.bold,
color: Colors.grey[800],
),
),
const SizedBox(height: 8),
Text(
"username",
style: GoogleFonts.poppins(
fontSize: 20,
fontWeight: FontWeight.w600,
color: Theme.of(context).primaryColor,
),
),
const SizedBox(height: 4),
Text(
"email or id",
style: GoogleFonts.poppins(
fontSize: 16,
color: Colors.grey[600],
),
),
const SizedBox(height: 40),
ElevatedButton(
onPressed: logout,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.red,
foregroundColor: Colors.white,
padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
elevation: 2,
),
child: Text(
'Logout',
style: GoogleFonts.poppins(
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
),
],
),
),
),
);
}
return Scaffold(
backgroundColor: Colors.grey[50],
body: SafeArea(
child: SingleChildScrollView(
child: Column(
children: [
// Header Section
Container(
width: double.infinity,
padding: const EdgeInsets.all(32.0),
child: Column(
children: [
const SizedBox(height: 40),
// App Logo/Icon
Container(
width: 80,
height: 80,
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
borderRadius: BorderRadius.circular(20),
boxShadow: [
BoxShadow(
color: Theme.of(context).primaryColor.withValues(alpha: 0.3),
blurRadius: 20,
offset: const Offset(0, 10),
),
],
),
child: const Icon(
Icons.task_alt,
color: Colors.white,
size: 40,
),
),
const SizedBox(height: 24),
Text(
'TaskTracker',
style: GoogleFonts.poppins(
fontSize: 32,
fontWeight: FontWeight.bold,
color: Colors.grey[800],
),
),
const SizedBox(height: 8),
Text(
'Manage your tasks efficiently',
style: GoogleFonts.poppins(
fontSize: 16,
color: Colors.grey[600],
),
),
],
),
),
// Tab Bar
Container(
margin: const EdgeInsets.symmetric(horizontal: 24),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: Colors.grey.withValues(alpha: 0.1),
blurRadius: 10,
offset: const Offset(0, 5),
),
],
),
child: TabBar(
controller: _tabController,
indicator: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Theme.of(context).primaryColor,
),
indicatorSize: TabBarIndicatorSize.tab, // Make indicator fill the tab
labelColor: Colors.white,
unselectedLabelColor: Colors.grey[600],
labelStyle: GoogleFonts.poppins(
fontWeight: FontWeight.w600,
fontSize: 16,
),
unselectedLabelStyle: GoogleFonts.poppins(
fontWeight: FontWeight.w500,
fontSize: 16,
),
tabs: const [
Tab(text: 'Login'),
Tab(text: 'Register'),
],
),
),
const SizedBox(height: 24),
// Tab Views
SizedBox(
height: screenHeight * 0.8,
child: TabBarView(
controller: _tabController,
children: [
LoginScreen(
onLogin: login,
onOAuthLogin: () => oAuthLogin(),
),
RegisterScreen(
onRegister: register,
onOAuthRegister: () => oAuthLogin(),
),
],
),
),
],
),
),
),
);
}
}