mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-25 11:17:55 +00:00
Initialized Auth pages for future work
Implemented Login functionality
This commit is contained in:
@@ -22,7 +22,7 @@ class AuthViewBody extends StatelessWidget {
|
||||
DefaultTextButton(
|
||||
text: 'Login',
|
||||
onPressed: () {
|
||||
Navigator.popAndPushNamed(context, Routes.homeRoute);
|
||||
Navigator.pushNamed(context, Routes.authLogin);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
@@ -31,18 +31,6 @@ class AuthViewBody extends StatelessWidget {
|
||||
isSecondary: true,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Center(
|
||||
child: InkWell(
|
||||
onTap: () {},
|
||||
child: const Text(
|
||||
'Try as a Guest',
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class DidntGetCodeView extends StatelessWidget {
|
||||
const DidntGetCodeView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Placeholder();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart';
|
||||
import 'package:syncrow_app/navigation/routing_constants.dart';
|
||||
import 'package:syncrow_app/utils/context_extension.dart';
|
||||
|
||||
class LoginUserAgreement extends StatelessWidget {
|
||||
const LoginUserAgreement({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<AuthCubit, AuthState>(
|
||||
builder: (context, state) {
|
||||
return Row(
|
||||
children: [
|
||||
Checkbox(
|
||||
value: AuthCubit.get(context).agreeToTerms,
|
||||
onChanged: (value) => AuthCubit.get(context).changeAgreeToTerms(),
|
||||
),
|
||||
Expanded(
|
||||
child: RichText(
|
||||
softWrap: true,
|
||||
maxLines: 2,
|
||||
text: TextSpan(
|
||||
text: 'I Agree to the ',
|
||||
style: context.bodySmall,
|
||||
children: [
|
||||
TextSpan(
|
||||
text: 'Privacy Policy',
|
||||
style: context.bodySmall.copyWith(
|
||||
color: Colors.blue,
|
||||
decoration: TextDecoration.underline,
|
||||
decorationColor: Colors.blue,
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
Navigator.pushNamed(context, Routes.policyRoute);
|
||||
},
|
||||
),
|
||||
TextSpan(
|
||||
text: ' and ',
|
||||
style: context.bodySmall,
|
||||
),
|
||||
TextSpan(
|
||||
text: 'User Agreement',
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
Navigator.pushNamed(context, Routes.termsRoute);
|
||||
},
|
||||
style: const TextStyle(
|
||||
color: Colors.blue,
|
||||
decoration: TextDecoration.underline,
|
||||
decorationColor: Colors.blue,
|
||||
),
|
||||
),
|
||||
const TextSpan(
|
||||
text: '.',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart';
|
||||
import 'package:syncrow_app/features/auth/view/widgets/login/login_user_agreement.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_text_button.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/title_medium.dart';
|
||||
import 'package:syncrow_app/navigation/routing_constants.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||
|
||||
class LoginView extends StatelessWidget {
|
||||
const LoginView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
//TODO move to strings manager
|
||||
|
||||
return BlocConsumer<AuthCubit, AuthState>(
|
||||
listener: (context, state) {
|
||||
if (state is AuthError) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(state.message),
|
||||
),
|
||||
);
|
||||
} else if (state is AuthSuccess) {
|
||||
Navigator.pushNamed(context, Routes.homeRoute);
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: Constants.defaultPadding,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const TitleMedium(
|
||||
text: 'Login',
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
TextField(
|
||||
controller: AuthCubit.get(context).emailController,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Email',
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide.none,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
filled: true,
|
||||
fillColor: ColorsManager.backgroundColor.withAlpha(100),
|
||||
floatingLabelBehavior: FloatingLabelBehavior.never,
|
||||
contentPadding: const EdgeInsets.all(10),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
TextField(
|
||||
controller: AuthCubit.get(context).passwordController,
|
||||
obscureText: !AuthCubit.get(context).isPasswordVisible,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'Password',
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide.none,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
AuthCubit.get(context).isPasswordVisible
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off,
|
||||
),
|
||||
onPressed: () {
|
||||
AuthCubit.get(context).changePasswordVisibility();
|
||||
},
|
||||
),
|
||||
filled: true,
|
||||
fillColor: ColorsManager.backgroundColor.withAlpha(100),
|
||||
floatingLabelBehavior: FloatingLabelBehavior.never,
|
||||
contentPadding: const EdgeInsets.all(10),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const LoginUserAgreement(),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
state is AuthLoading
|
||||
? const CircularProgressIndicator()
|
||||
: Expanded(
|
||||
child: DefaultTextButton(
|
||||
enabled: AuthCubit.get(context).agreeToTerms,
|
||||
text: "Login",
|
||||
onPressed: () {
|
||||
AuthCubit.get(context).login();
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class OneTimePasswordView extends StatelessWidget {
|
||||
const OneTimePasswordView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Placeholder();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class PrivacyPolicyView extends StatelessWidget {
|
||||
const PrivacyPolicyView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Placeholder();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SignUpView extends StatelessWidget {
|
||||
const SignUpView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Placeholder();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class UserAgreementView extends StatelessWidget {
|
||||
const UserAgreementView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Placeholder();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user