Skip to content

Commit 8252ff7

Browse files
committed
Full Login Implementation done
1 parent 7fcd2e3 commit 8252ff7

File tree

6 files changed

+515
-12
lines changed

6 files changed

+515
-12
lines changed

android/app/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ android {
4848
applicationId "com.example.rhythm"
4949
// You can update the following values to match your application needs.
5050
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
51-
minSdkVersion 19
51+
minSdkVersion 23
5252
targetSdkVersion flutter.targetSdkVersion
5353
versionCode flutterVersionCode.toInteger()
5454
versionName flutterVersionName
@@ -71,5 +71,6 @@ flutter {
7171
dependencies {
7272
implementation platform('com.google.firebase:firebase-bom:31.0.3')
7373
implementation 'com.google.firebase:firebase-analytics'
74+
implementation 'com.google.firebase:firebase-dynamic-links'
7475
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
7576
}

android/app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="com.example.rhythm">
3-
43
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
54
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
65
<application

images/forgot_password.png

31.1 KB
Loading

lib/pages/onboarding_screen.dart

Lines changed: 77 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// ignore_for_file: avoid_unnecessary_containers, duplicate_ignore
22
import 'package:flutter/material.dart';
33
import 'package:music_player_app/pages/home_page.dart';
4+
import 'package:music_player_app/pages/passwordReset.dart';
5+
import 'package:music_player_app/pages/signup.dart';
46
import 'package:smooth_page_indicator/smooth_page_indicator.dart';
57
import 'package:just_audio/just_audio.dart';
68
import 'package:email_validator/email_validator.dart';
@@ -34,6 +36,7 @@ class _OnboardingPageState extends State<OnboardingPage> {
3436
@override
3537
Widget build(BuildContext context) {
3638
return Scaffold(
39+
backgroundColor: Colors.white,
3740
body: Container(
3841
padding: const EdgeInsets.only(bottom: 80),
3942
child: PageView(
@@ -109,24 +112,35 @@ class _OnboardingPageState extends State<OnboardingPage> {
109112
'RHYTHM Music',
110113
textAlign: TextAlign.center,
111114
style: TextStyle(
112-
fontSize: 50,
115+
fontSize: 30,
113116
fontWeight: FontWeight.bold,
114117
color: Colors.purple),
115118
),
116119
const Text(
117120
'and',
118121
textAlign: TextAlign.center,
119122
style: TextStyle(
120-
fontSize: 50,
123+
fontSize: 30,
121124
fontWeight: FontWeight.bold,
122125
color: Colors.black,
123126
),
124127
),
125128
const Text(
126-
'MP3 Player.',
129+
'MP3 Player',
127130
textAlign: TextAlign.center,
128131
style: TextStyle(
129-
fontSize: 50,
132+
fontSize: 30,
133+
fontWeight: FontWeight.bold,
134+
color: Colors.purple),
135+
),
136+
const SizedBox(
137+
height: 30,
138+
),
139+
const Text(
140+
'Sign In',
141+
textAlign: TextAlign.center,
142+
style: TextStyle(
143+
fontSize: 40,
130144
fontWeight: FontWeight.bold,
131145
color: Colors.purple),
132146
),
@@ -212,6 +226,45 @@ class _OnboardingPageState extends State<OnboardingPage> {
212226
},
213227
),
214228
),
229+
Container(
230+
alignment: Alignment.center,
231+
padding: const EdgeInsets.all(10),
232+
child: TextButton(
233+
onPressed: () {
234+
Navigator.push(
235+
context,
236+
MaterialPageRoute(
237+
builder: (context) =>
238+
SignUp(audioPlayer: widget.audioPlayer),
239+
));
240+
},
241+
child: const Text(
242+
'Not a member? Create account here',
243+
style: TextStyle(
244+
color: Colors.purple,
245+
fontSize: 16,
246+
),
247+
),
248+
),
249+
),
250+
Center(
251+
child: GestureDetector(
252+
child: const Text(
253+
'Forgot Password?',
254+
style: TextStyle(
255+
decoration: TextDecoration.underline,
256+
color: Colors.red,
257+
fontSize: 15,
258+
),
259+
),
260+
onTap: () => Navigator.push(
261+
context,
262+
MaterialPageRoute(
263+
builder: (context) => const PasswordReset(),
264+
),
265+
),
266+
),
267+
),
215268
],
216269
),
217270
),
@@ -291,15 +344,29 @@ class _OnboardingPageState extends State<OnboardingPage> {
291344
);
292345
} on FirebaseAuthException catch (e) {
293346
if (e.code == 'user-not-found') {
294-
const snackBar = SnackBar(
295-
content: Text(
296-
'No user found for that email.',
297-
textAlign: TextAlign.center,
347+
final snackBar = SnackBar(
348+
content: const Text(
349+
'No user found',
350+
textAlign: TextAlign.left,
298351
style: TextStyle(
299352
fontSize: 20,
300353
),
301354
),
302-
backgroundColor: Colors.amber,
355+
action: SnackBarAction(
356+
label: 'Create Account',
357+
textColor: Colors.white,
358+
onPressed: () {
359+
Navigator.push(
360+
context,
361+
MaterialPageRoute(
362+
builder: ((context) => SignUp(
363+
audioPlayer: widget.audioPlayer,
364+
)),
365+
),
366+
);
367+
},
368+
),
369+
backgroundColor: Colors.pink,
303370
);
304371
ScaffoldMessenger.of(context).showSnackBar(snackBar);
305372
} else if (e.code == 'wrong-password') {
@@ -353,7 +420,7 @@ class _OnboardingPageState extends State<OnboardingPage> {
353420
setState(() {
354421
isLoading = true;
355422
});
356-
await Future.delayed(const Duration(seconds: 3));
423+
await Future.delayed(const Duration(seconds: 1));
357424
setState(() {
358425
Navigator.push(
359426
context,

lib/pages/passwordReset.dart

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
import 'package:email_validator/email_validator.dart';
2+
import 'package:firebase_auth/firebase_auth.dart';
3+
import 'package:flutter/material.dart';
4+
5+
class PasswordReset extends StatefulWidget {
6+
const PasswordReset({super.key});
7+
8+
@override
9+
State<PasswordReset> createState() => _PasswordResetState();
10+
}
11+
12+
class _PasswordResetState extends State<PasswordReset> {
13+
final _formkey = GlobalKey<FormState>();
14+
final _emailController = TextEditingController();
15+
16+
//Reset Password Method
17+
Future resetPassword() async {
18+
showDialog(
19+
context: context,
20+
builder: (context) => const Center(
21+
child: CircularProgressIndicator(
22+
color: Colors.green,
23+
),
24+
),
25+
);
26+
await FirebaseAuth.instance
27+
.sendPasswordResetEmail(email: _emailController.text.trim());
28+
const snackBar = SnackBar(
29+
content: Text(
30+
'Email sent successfully. Check spam folder also',
31+
textAlign: TextAlign.center,
32+
style: TextStyle(
33+
fontSize: 20,
34+
),
35+
),
36+
duration: Duration(seconds: 5),
37+
backgroundColor: Colors.green,
38+
);
39+
// ignore: use_build_context_synchronously
40+
ScaffoldMessenger.of(context).showSnackBar(snackBar);
41+
// ignore: use_build_context_synchronously
42+
Navigator.of(context).popUntil((route) => route.isFirst);
43+
}
44+
45+
@override
46+
void dispose() {
47+
_emailController.dispose();
48+
super.dispose();
49+
}
50+
51+
@override
52+
Widget build(BuildContext context) {
53+
return Scaffold(
54+
backgroundColor: Colors.white,
55+
appBar: AppBar(
56+
title: const Text('Password Reset'),
57+
elevation: 8,
58+
centerTitle: true,
59+
backgroundColor: Colors.pink,
60+
),
61+
body: Form(
62+
key: _formkey,
63+
child: ListView(
64+
padding: const EdgeInsets.all(15),
65+
children: [
66+
Image.asset(
67+
'images/forgot_password.png',
68+
height: 200,
69+
),
70+
const SizedBox(
71+
height: 20,
72+
),
73+
const Text(
74+
'A password reset email will be sent to this email',
75+
textAlign: TextAlign.center,
76+
style: TextStyle(
77+
color: Colors.black,
78+
fontSize: 25,
79+
),
80+
),
81+
Container(
82+
margin: const EdgeInsets.all(10),
83+
child: TextFormField(
84+
autofocus: false,
85+
keyboardType: TextInputType.emailAddress,
86+
decoration: InputDecoration(
87+
labelText: 'Email',
88+
labelStyle: const TextStyle(fontWeight: FontWeight.bold),
89+
focusedBorder: const OutlineInputBorder(
90+
borderSide: BorderSide(
91+
color: Colors.purple,
92+
width: 3,
93+
),
94+
),
95+
enabledBorder: const OutlineInputBorder(
96+
borderSide: BorderSide(
97+
color: Colors.purple,
98+
width: 2.0,
99+
),
100+
),
101+
border: OutlineInputBorder(
102+
borderRadius: BorderRadius.circular(15),
103+
),
104+
errorStyle: const TextStyle(
105+
color: Colors.red,
106+
fontSize: 15,
107+
),
108+
),
109+
controller: _emailController,
110+
validator: (value) {
111+
if (!EmailValidator.validate(value!)) {
112+
return 'Please enter valid email';
113+
}
114+
return null;
115+
},
116+
),
117+
),
118+
Container(
119+
margin: const EdgeInsets.all(20),
120+
padding: const EdgeInsets.all(0),
121+
width: double.infinity,
122+
child: ElevatedButton(
123+
onPressed: () {
124+
if (_formkey.currentState!.validate()) {
125+
resetPassword();
126+
}
127+
},
128+
style: ElevatedButton.styleFrom(
129+
backgroundColor: Colors.green,
130+
elevation: 10,
131+
),
132+
child: Row(
133+
mainAxisAlignment: MainAxisAlignment.center,
134+
children: const [
135+
Icon(Icons.email_rounded),
136+
Text(
137+
' Reset Password',
138+
style: TextStyle(
139+
fontSize: 20,
140+
),
141+
),
142+
],
143+
),
144+
),
145+
),
146+
],
147+
),
148+
),
149+
);
150+
}
151+
}

0 commit comments

Comments
 (0)