664 lines
24 KiB
Dart
664 lines
24 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:firebase_core/firebase_core.dart';
|
|
import 'firebase_options.dart';
|
|
import 'screens/home_screen.dart';
|
|
import 'services/notification_service.dart';
|
|
|
|
void main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
await Firebase.initializeApp(
|
|
options: DefaultFirebaseOptions.currentPlatform,
|
|
);
|
|
|
|
NotificationService().initialize();
|
|
|
|
runApp(MyApp());
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
title: 'Connection App',
|
|
theme: ThemeData(primarySwatch: Colors.blue, fontFamily: 'Roboto'),
|
|
home: LandingPage(),
|
|
debugShowCheckedModeBanner: false,
|
|
);
|
|
}
|
|
}
|
|
|
|
class LandingPage extends StatefulWidget {
|
|
@override
|
|
_LandingPageState createState() => _LandingPageState();
|
|
}
|
|
|
|
class _LandingPageState extends State<LandingPage>
|
|
with SingleTickerProviderStateMixin {
|
|
late AnimationController _animationController;
|
|
late Animation<double> _slideAnimation;
|
|
bool _showBottomSheet = false;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_animationController = AnimationController(
|
|
duration: Duration(milliseconds: 800),
|
|
vsync: this,
|
|
);
|
|
_slideAnimation = Tween<double>(begin: 1.0, end: 0.0).animate(
|
|
CurvedAnimation(parent: _animationController, curve: Curves.easeInOut),
|
|
);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_animationController.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
void _showGetStartedBottomSheet() {
|
|
setState(() {
|
|
_showBottomSheet = true;
|
|
});
|
|
_animationController.forward();
|
|
}
|
|
|
|
void _hideBottomSheet() {
|
|
_animationController.reverse().then((_) {
|
|
setState(() {
|
|
_showBottomSheet = false;
|
|
});
|
|
});
|
|
}
|
|
|
|
void _navigateToSignIn() {
|
|
Navigator.of(
|
|
context,
|
|
).push(MaterialPageRoute(builder: (context) => SignInPage()));
|
|
}
|
|
|
|
void _navigateToHome() {
|
|
Navigator.of(
|
|
context,
|
|
).push(MaterialPageRoute(builder: (context) => HomeScreen()));
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: Stack(
|
|
children: [
|
|
// Background gradient
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
colors: [
|
|
Color(0xFF32B0A5), // Teal
|
|
Color(0xFF4600B9), // Purple
|
|
],
|
|
stops: [0.0, 0.5],
|
|
),
|
|
),
|
|
),
|
|
|
|
// Main content
|
|
SafeArea(
|
|
child: Column(
|
|
children: [
|
|
Expanded(
|
|
child: Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
// Logo
|
|
Container(
|
|
padding: EdgeInsets.all(40),
|
|
child: Text(
|
|
'وصال',
|
|
style: TextStyle(
|
|
fontSize: 160,
|
|
fontWeight: FontWeight.w200,
|
|
fontFamily: 'Blaka',
|
|
color: Colors.white,
|
|
shadows: [
|
|
Shadow(
|
|
offset: Offset(2, 2),
|
|
blurRadius: 4,
|
|
color: Colors.black.withOpacity(0.3),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
|
|
SizedBox(height: 60),
|
|
|
|
// Subtitle
|
|
Text(
|
|
'Connections, Made\nEasier!',
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(
|
|
fontSize: 32,
|
|
fontWeight: FontWeight.w600,
|
|
color: Colors.white,
|
|
height: 1.2,
|
|
),
|
|
),
|
|
|
|
SizedBox(height: 80),
|
|
|
|
// Get Started Button
|
|
Container(
|
|
width: 280,
|
|
height: 56,
|
|
child: ElevatedButton(
|
|
onPressed: _showGetStartedBottomSheet,
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Color(0xFF6A4C93),
|
|
foregroundColor: Colors.white,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(28),
|
|
),
|
|
elevation: 8,
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
'Get Started',
|
|
style: TextStyle(
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
SizedBox(width: 8),
|
|
Icon(Icons.arrow_forward, size: 20),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
|
|
SizedBox(height: 24),
|
|
|
|
// Login link
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
GestureDetector(
|
|
onTap: _navigateToHome,
|
|
child: Text(
|
|
'Skip to Home',
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w600,
|
|
decoration: TextDecoration.underline,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
|
|
// Bottom sheet overlay
|
|
if (_showBottomSheet)
|
|
AnimatedBuilder(
|
|
animation: _slideAnimation,
|
|
builder: (context, child) {
|
|
return Positioned(
|
|
bottom: 0,
|
|
left: 0,
|
|
right: 0,
|
|
child: Transform.translate(
|
|
offset: Offset(0, _slideAnimation.value * 400),
|
|
child: Container(
|
|
height: 400,
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.only(
|
|
topLeft: Radius.circular(24),
|
|
topRight: Radius.circular(24),
|
|
),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withOpacity(0.2),
|
|
blurRadius: 20,
|
|
offset: Offset(0, -5),
|
|
),
|
|
],
|
|
),
|
|
child: Column(
|
|
children: [
|
|
// Handle bar
|
|
Container(
|
|
margin: EdgeInsets.only(top: 12),
|
|
width: 40,
|
|
height: 4,
|
|
decoration: BoxDecoration(
|
|
color: Colors.grey[300],
|
|
borderRadius: BorderRadius.circular(2),
|
|
),
|
|
),
|
|
|
|
// Close button
|
|
Align(
|
|
alignment: Alignment.topRight,
|
|
child: IconButton(
|
|
onPressed: _hideBottomSheet,
|
|
icon: Icon(Icons.close, color: Colors.grey[600]),
|
|
),
|
|
),
|
|
|
|
Expanded(
|
|
child: Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 24),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
'Welcome In',
|
|
style: TextStyle(
|
|
fontSize: 28,
|
|
fontWeight: FontWeight.bold,
|
|
color: Colors.black87,
|
|
),
|
|
),
|
|
|
|
SizedBox(height: 12),
|
|
|
|
Text(
|
|
'Join your community.. change your social life!',
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
color: Colors.grey[600],
|
|
),
|
|
),
|
|
|
|
SizedBox(height: 40),
|
|
|
|
// Sign Up button
|
|
Container(
|
|
width: double.infinity,
|
|
height: 56,
|
|
child: ElevatedButton(
|
|
onPressed: () {
|
|
// Handle sign up
|
|
ScaffoldMessenger.of(
|
|
context,
|
|
).showSnackBar(
|
|
SnackBar(
|
|
content: Text('Sign Up pressed'),
|
|
),
|
|
);
|
|
},
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Color(0xFF6A4C93),
|
|
foregroundColor: Colors.white,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(
|
|
12,
|
|
),
|
|
),
|
|
elevation: 2,
|
|
),
|
|
child: Text(
|
|
'Sign Up Now',
|
|
style: TextStyle(
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
|
|
SizedBox(height: 16),
|
|
|
|
// Login button
|
|
Container(
|
|
width: double.infinity,
|
|
height: 56,
|
|
child: OutlinedButton(
|
|
onPressed: _navigateToSignIn,
|
|
style: OutlinedButton.styleFrom(
|
|
foregroundColor: Color(0xFF6A4C93),
|
|
side: BorderSide(
|
|
color: Color(0xFF6A4C93),
|
|
),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(
|
|
12,
|
|
),
|
|
),
|
|
),
|
|
child: Text(
|
|
'Login',
|
|
style: TextStyle(
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class SignInPage extends StatefulWidget {
|
|
@override
|
|
_SignInPageState createState() => _SignInPageState();
|
|
}
|
|
|
|
class _SignInPageState extends State<SignInPage> {
|
|
final _formKey = GlobalKey<FormState>();
|
|
final _emailController = TextEditingController();
|
|
final _passwordController = TextEditingController();
|
|
bool _isPasswordVisible = false;
|
|
bool _isLoading = false;
|
|
|
|
@override
|
|
void dispose() {
|
|
_emailController.dispose();
|
|
_passwordController.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
void _handleSignIn() async {
|
|
if (_formKey.currentState!.validate()) {
|
|
setState(() {
|
|
_isLoading = true;
|
|
});
|
|
|
|
// Simulate API call
|
|
await Future.delayed(Duration(seconds: 2));
|
|
|
|
setState(() {
|
|
_isLoading = false;
|
|
});
|
|
|
|
ScaffoldMessenger.of(
|
|
context,
|
|
).showSnackBar(SnackBar(content: Text('Sign in successful!')));
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: Container(
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
colors: [Color(0xFF32B0A5), Color(0xFF4600B9)],
|
|
stops: [0.0, 0.5],
|
|
),
|
|
),
|
|
child: SafeArea(
|
|
child: Column(
|
|
children: [
|
|
// App bar
|
|
Padding(
|
|
padding: EdgeInsets.all(16),
|
|
child: Row(
|
|
children: [
|
|
IconButton(
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
icon: Icon(Icons.arrow_back, color: Colors.white),
|
|
),
|
|
Text(
|
|
'Sign In',
|
|
style: TextStyle(
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.w600,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
|
|
// Content
|
|
Expanded(
|
|
child: Container(
|
|
margin: EdgeInsets.all(16),
|
|
padding: EdgeInsets.all(24),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(16),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withOpacity(0.1),
|
|
blurRadius: 20,
|
|
offset: Offset(0, 5),
|
|
),
|
|
],
|
|
),
|
|
child: Form(
|
|
key: _formKey,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
SizedBox(height: 20),
|
|
|
|
// Logo
|
|
Center(
|
|
child: Text(
|
|
'وصال',
|
|
style: TextStyle(
|
|
fontSize: 48,
|
|
fontWeight: FontWeight.w200,
|
|
fontFamily: 'Blaka',
|
|
color: Color(0xFF6A4C93),
|
|
),
|
|
),
|
|
),
|
|
|
|
SizedBox(height: 40),
|
|
|
|
// Welcome text
|
|
Text(
|
|
'Welcome Back!',
|
|
style: TextStyle(
|
|
fontSize: 24,
|
|
fontWeight: FontWeight.bold,
|
|
color: Colors.black87,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
|
|
SizedBox(height: 8),
|
|
|
|
Text(
|
|
'Sign in to your account',
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
color: Colors.grey[600],
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
|
|
SizedBox(height: 40),
|
|
|
|
// Email field
|
|
TextFormField(
|
|
controller: _emailController,
|
|
keyboardType: TextInputType.emailAddress,
|
|
decoration: InputDecoration(
|
|
labelText: 'Email',
|
|
prefixIcon: Icon(Icons.email_outlined),
|
|
border: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
focusedBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
borderSide: BorderSide(color: Color(0xFF6A4C93)),
|
|
),
|
|
),
|
|
validator: (value) {
|
|
if (value == null || value.isEmpty) {
|
|
return 'Please enter your email';
|
|
}
|
|
if (!value.contains('@')) {
|
|
return 'Please enter a valid email';
|
|
}
|
|
return null;
|
|
},
|
|
),
|
|
|
|
SizedBox(height: 20),
|
|
|
|
// Password field
|
|
TextFormField(
|
|
controller: _passwordController,
|
|
obscureText: !_isPasswordVisible,
|
|
decoration: InputDecoration(
|
|
labelText: 'Password',
|
|
prefixIcon: Icon(Icons.lock_outline),
|
|
suffixIcon: IconButton(
|
|
icon: Icon(
|
|
_isPasswordVisible
|
|
? Icons.visibility_off
|
|
: Icons.visibility,
|
|
),
|
|
onPressed: () {
|
|
setState(() {
|
|
_isPasswordVisible = !_isPasswordVisible;
|
|
});
|
|
},
|
|
),
|
|
border: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
focusedBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
borderSide: BorderSide(color: Color(0xFF6A4C93)),
|
|
),
|
|
),
|
|
validator: (value) {
|
|
if (value == null || value.isEmpty) {
|
|
return 'Please enter your password';
|
|
}
|
|
if (value.length < 6) {
|
|
return 'Password must be at least 6 characters';
|
|
}
|
|
return null;
|
|
},
|
|
),
|
|
|
|
SizedBox(height: 12),
|
|
|
|
// Forgot password
|
|
Align(
|
|
alignment: Alignment.centerRight,
|
|
child: TextButton(
|
|
onPressed: () {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(
|
|
content: Text('Forgot password pressed'),
|
|
),
|
|
);
|
|
},
|
|
child: Text(
|
|
'Forgot Password?',
|
|
style: TextStyle(
|
|
color: Color(0xFF6A4C93),
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
|
|
SizedBox(height: 30),
|
|
|
|
// Sign in button
|
|
Container(
|
|
height: 56,
|
|
child: ElevatedButton(
|
|
onPressed: _isLoading ? null : _handleSignIn,
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: Color(0xFF6A4C93),
|
|
foregroundColor: Colors.white,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
elevation: 2,
|
|
),
|
|
child: _isLoading
|
|
? CircularProgressIndicator(
|
|
valueColor: AlwaysStoppedAnimation<Color>(
|
|
Colors.white,
|
|
),
|
|
)
|
|
: Text(
|
|
'Sign In',
|
|
style: TextStyle(
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
|
|
SizedBox(height: 20),
|
|
|
|
// Sign up link
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
"Don't have an account? ",
|
|
style: TextStyle(color: Colors.grey[600]),
|
|
),
|
|
GestureDetector(
|
|
onTap: () {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(content: Text('Sign up pressed')),
|
|
);
|
|
},
|
|
child: Text(
|
|
'Sign Up',
|
|
style: TextStyle(
|
|
color: Color(0xFF6A4C93),
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
|
|
Spacer(),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|