getting spaces and rooms from api {null checks}

This commit is contained in:
Mohammad Salameh
2024-03-13 13:52:22 +03:00
parent 0f3cc453ce
commit 024f15728b
26 changed files with 390 additions and 266 deletions
@@ -1,46 +0,0 @@
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/shared_widgets/default_button.dart';
class LoginButton extends StatelessWidget {
const LoginButton({
super.key,
});
@override
Widget build(BuildContext context) {
return BlocBuilder<AuthCubit, AuthState>(
builder: (context, state) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: DefaultButton(
isDone: state is AuthSuccess,
isLoading: state is AuthLoading,
customButtonStyle: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
Colors.black.withOpacity(.25),
),
foregroundColor: MaterialStateProperty.all(
Colors.white,
),
),
child: const Text(
'Login',
),
onPressed: () {
if (AuthCubit.get(context).formKey.currentState!.validate()) {
AuthCubit.get(context).login();
FocusScope.of(context).unfocus();
}
},
),
),
],
);
},
);
}
}
@@ -1,6 +1,8 @@
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/forget_password.dart';
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/utils/resource_manager/styles_manager.dart';
@@ -11,10 +13,11 @@ class LoginForm extends StatelessWidget {
@override
Widget build(BuildContext context) {
var formKey = GlobalKey<FormState>();
return BlocBuilder<AuthCubit, AuthState>(
builder: (context, state) {
return Form(
key: AuthCubit.get(context).formKey,
key: formKey,
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
@@ -40,7 +43,7 @@ class LoginForm extends StatelessWidget {
return null;
},
onTapOutside: (event) {
AuthCubit.get(context).formKey.currentState!.validate();
formKey.currentState!.validate();
},
decoration: defaultInputDecoration(context,
hint: "[email protected]"),
@@ -65,12 +68,44 @@ class LoginForm extends StatelessWidget {
return null;
},
onTapOutside: (event) {
AuthCubit.get(context).formKey.currentState!.validate();
formKey.currentState!.validate();
},
obscureText: !AuthCubit.get(context).isPasswordVisible,
decoration: defaultInputDecoration(context,
hint: "At least 8 characters"),
),
const SizedBox(height: 10),
// const LoginUserAgreement(),
const ForgetPassword(),
const SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: DefaultButton(
isDone: state is AuthSuccess,
isLoading: state is AuthLoading,
customButtonStyle: ButtonStyle(
backgroundColor: MaterialStateProperty.all(
Colors.black.withOpacity(.25),
),
foregroundColor: MaterialStateProperty.all(
Colors.white,
),
),
child: const Text(
'Login',
),
onPressed: () {
if (formKey.currentState!.validate()) {
AuthCubit.get(context).login();
FocusScope.of(context).unfocus();
}
},
),
),
],
)
],
),
),
@@ -3,8 +3,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart';
import 'package:syncrow_app/features/auth/view/widgets/login/dont_have_an_account.dart';
import 'package:syncrow_app/features/auth/view/widgets/login/forget_password.dart';
import 'package:syncrow_app/features/auth/view/widgets/login/login_button.dart';
import 'package:syncrow_app/features/auth/view/widgets/login/login_divider.dart';
import 'package:syncrow_app/features/auth/view/widgets/login/login_form.dart';
import 'package:syncrow_app/features/auth/view/widgets/login/login_with_google_facebook.dart';
@@ -94,11 +92,6 @@ class LoginView extends StatelessWidget {
height: 20,
),
const LoginForm(),
const SizedBox(height: 10),
// const LoginUserAgreement(),
const ForgetPassword(),
const SizedBox(height: 10),
const LoginButton(),
const LoginDivider(),
const LoginWithGoogleFacebook(),
const DontHaveAnAccount(),