1
0
forked from baron/baron-sso
Files
baron-sso/frontend/lib/features/auth/presentation/login_screen.dart

145 lines
4.9 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:google_fonts/google_fonts.dart';
class LoginScreen extends ConsumerStatefulWidget {
const LoginScreen({super.key});
@override
ConsumerState<LoginScreen> createState() => _LoginScreenState();
}
class _LoginScreenState extends ConsumerState<LoginScreen>
with SingleTickerProviderStateMixin {
late TabController _tabController;
final TextEditingController _emailController = TextEditingController();
final TextEditingController _passwordController = TextEditingController();
final TextEditingController _phoneController = TextEditingController();
@override
void initState() {
super.initState();
_tabController = TabController(length: 2, vsync: this);
}
@override
void dispose() {
_tabController.dispose();
_emailController.dispose();
_passwordController.dispose();
_phoneController.dispose();
super.dispose();
}
void _handleEmailLogin() {
// TODO: Implement Descope Email/Password Flow
debugPrint("Email Login: ${_emailController.text}");
}
void _handleSmsLogin() {
// TODO: Implement Descope SMS Enchanted Link Flow
debugPrint("SMS Login: ${_phoneController.text}");
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
constraints: const BoxConstraints(maxWidth: 400),
padding: const EdgeInsets.all(24),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
"Baron SSO",
style: GoogleFonts.outfit(
fontSize: 32,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
),
const SizedBox(height: 40),
// Tab Bar
TabBar(
controller: _tabController,
tabs: const [
Tab(text: "Email"),
Tab(text: "Phone (SMS)"),
],
),
const SizedBox(height: 24),
// Tab View Content
SizedBox(
height: 300, // Slightly increased height for content
child: TabBarView(
controller: _tabController,
children: [
// Email/Password Form
Column(
children: [
TextField(
controller: _emailController,
decoration: const InputDecoration(
labelText: "Email",
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.email_outlined),
),
),
const SizedBox(height: 16),
TextField(
controller: _passwordController,
obscureText: true,
decoration: const InputDecoration(
labelText: "Password",
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.lock_outline),
),
),
const SizedBox(height: 24),
FilledButton(
onPressed: _handleEmailLogin,
style: FilledButton.styleFrom(
minimumSize: const Size.fromHeight(50),
),
child: const Text("Sign In"),
),
],
),
// Phone/SMS Form
Column(
children: [
TextField(
controller: _phoneController,
decoration: const InputDecoration(
labelText: "Phone Number",
hintText: "+82 10-1234-5678",
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.phone_android),
),
),
const SizedBox(height: 24),
FilledButton(
onPressed: _handleSmsLogin,
style: FilledButton.styleFrom(
minimumSize: const Size.fromHeight(50),
),
child: const Text("Send Login Link"),
),
],
),
],
),
),
],
),
),
),
);
}
}