Skip to content

Commit

Permalink
add UI for authentication screens
Browse files Browse the repository at this point in the history
  • Loading branch information
hassan-kamel committed May 3, 2024
1 parent 47023a4 commit 3c51898
Show file tree
Hide file tree
Showing 15 changed files with 530 additions and 21 deletions.
1 change: 1 addition & 0 deletions assets/icons/apple.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/icons/google.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions assets/icons/vector.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 6 additions & 7 deletions lib/app_router.dart
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:go_router/go_router.dart';
import 'package:minly_media_mobile/presentation/screens/signin_or_signup.dart';

import 'presentation/screens/home_tabs/create_post.dart';
import 'presentation/screens/home_tabs/feeds.dart';
import 'presentation/screens/home_tabs/profile.dart';
import 'presentation/screens/home_tabs/reels.dart';
import 'presentation/screens/home_tabs/search.dart';

import 'presentation/screens/home.dart';
import 'presentation/screens/login.dart';
import 'presentation/screens/signup.dart';

// Create keys for `root` & `section` navigator avoiding unnecessary rebuilds
final _rootNavigatorKey = GlobalKey<NavigatorState>();
final _sectionNavigatorKey = GlobalKey<NavigatorState>();

final GoRouter appRouter = GoRouter(
navigatorKey: _rootNavigatorKey,
initialLocation: '/feed',
initialLocation: '/auth',
routes: <RouteBase>[
StatefulShellRoute.indexedStack(
builder: (context, state, navigationShell) {
Expand All @@ -27,10 +25,11 @@ final GoRouter appRouter = GoRouter(
branches: [
// The route branch for the 1º Tab
StatefulShellBranch(
initialLocation: '/feeds',
navigatorKey: _sectionNavigatorKey,
routes: <RouteBase>[
GoRoute(
path: '/feed',
path: '/feeds',
builder: (context, state) => const FeedsTab(),
),
],
Expand Down Expand Up @@ -69,6 +68,6 @@ final GoRouter appRouter = GoRouter(
])
],
),
GoRoute(path: '/login', builder: (context, state) => const LoginPage()),
GoRoute(path: '/signup', builder: (context, state) => const SignupPage()),
GoRoute(
path: '/auth', builder: (context, state) => const LoginOrRegister()),
]);
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:minly_media_mobile/app_router.dart';
import 'package:minly_media_mobile/business-logic/bloc/post_bloc.dart';
import 'package:minly_media_mobile/business-logic/bloc/post/post_bloc.dart';

void main() {
runApp(const MinlyMediaApp());
Expand Down
2 changes: 1 addition & 1 deletion lib/presentation/screens/home_tabs/feeds.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:minly_media_mobile/business-logic/bloc/post_bloc.dart';
import 'package:minly_media_mobile/business-logic/bloc/post/post_bloc.dart';
import 'package:minly_media_mobile/presentation/widgets/post.dart';

class FeedsTab extends StatefulWidget {
Expand Down
206 changes: 200 additions & 6 deletions lib/presentation/screens/login.dart
Original file line number Diff line number Diff line change
@@ -1,21 +1,215 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

import 'package:minly_media_mobile/presentation/widgets/button.dart';
import 'package:minly_media_mobile/presentation/widgets/square_tile.dart';
import 'package:minly_media_mobile/presentation/widgets/text_field.dart';

class LoginPage extends StatefulWidget {
const LoginPage({super.key});
final Function()? onTap;
LoginPage({super.key, required this.onTap});

@override
State<LoginPage> createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
final emailController = TextEditingController();

final passwordController = TextEditingController();

void signUserIn(BuildContext context) async {
context.go("/feeds");
// show loading circle
// showDialog(
// context: context,
// builder: (context) {
// return const Center(
// child: CircularProgressIndicator(),
// );
// });
}

void genericErrorMessage(String message) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(message),
actions: [
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: Text('OK'),
),
],
);
},
);
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Login'),
),
body: const Center(
child: Text('Scaffold Body'),
backgroundColor: Color.fromARGB(255, 243, 243, 243),
resizeToAvoidBottomInset: true,
body: SafeArea(
child: SingleChildScrollView(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(height: 50),
//logo
const Icon(
Icons.lock_person,
size: 150,
),
const SizedBox(height: 10),
//welcome back you been missed

Text(
'Welcome back you\'ve been missed',
style: TextStyle(
color: Colors.grey[700],
fontSize: 15,
),
),
const SizedBox(height: 25),

//username
MyTextField(
controller: emailController,
hintText: 'Username or email',
obscureText: false,
),

const SizedBox(height: 15),
//password
MyTextField(
controller: passwordController,
hintText: 'Password',
obscureText: true,
),
const SizedBox(height: 15),

//sign in button
MyButton(
onTap: () {
signUserIn(context);
},
text: 'Sign In',
),
const SizedBox(height: 20),

//forgot passowrd

Padding(
padding: const EdgeInsets.all(5.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Forgot your login details? ',
style: TextStyle(
color: Colors.grey.shade600, fontSize: 12),
),
Text(
'Get help logging in.',
style: TextStyle(
color: Colors.blue.shade900,
fontSize: 15,
fontWeight: FontWeight.bold,
),
)
],
),
),

const SizedBox(
height: 10,
),

// continue with
Padding(
padding: const EdgeInsets.symmetric(horizontal: 25),
child: Row(
children: [
Expanded(
child: Divider(
thickness: 0.5,
color: Colors.grey.shade400,
),
),
Padding(
padding: const EdgeInsets.only(left: 8, right: 8),
child: Text(
'OR',
style: TextStyle(color: Colors.grey.shade600),
),
),
Expanded(
child: Divider(
thickness: 0.5,
color: Colors.grey.shade400,
),
),
],
),
),
const SizedBox(height: 60),

//google + apple button

Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
//google buttom
SquareTile(
onTap: () {},
imagePath: 'assets/icons/google.svg',
height: 70,
),

SizedBox(width: 20),
// apple buttom
SquareTile(
onTap: () {},
imagePath: 'assets/icons/vector.svg',
height: 70,
),
],
),
const SizedBox(
height: 100,
),

// not a memeber ? register now

Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Not a member? ',
style: TextStyle(color: Colors.grey[600], fontSize: 12),
),
GestureDetector(
onTap: widget.onTap,
child: Text(
'Register now',
style: TextStyle(
color: Colors.blue[900],
fontWeight: FontWeight.bold,
fontSize: 15),
),
),
],
)
],
),
),
),
),
);
}
Expand Down
34 changes: 34 additions & 0 deletions lib/presentation/screens/signin_or_signup.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import 'package:flutter/material.dart';
import 'package:minly_media_mobile/presentation/screens/login.dart';
import 'package:minly_media_mobile/presentation/screens/signup.dart';

class LoginOrRegister extends StatefulWidget {
const LoginOrRegister({super.key});

@override
State<LoginOrRegister> createState() => _LoginOrRegisterState();
}

class _LoginOrRegisterState extends State<LoginOrRegister> {
bool showLoginPage = true;

// toggle between login and register page
void togglePages() {
setState(() {
showLoginPage = !showLoginPage;
});
}

@override
Widget build(BuildContext context) {
if (showLoginPage) {
return LoginPage(
onTap: togglePages,
);
} else {
return SignupPage(
onTap: togglePages,
);
}
}
}
Loading

0 comments on commit 3c51898

Please sign in to comment.