mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-17 02:25:16 +00:00
removed snackbar calling in any place in the app except in the intercepter to improve
readability and reduce duplication of error message display logic.
This commit is contained in:
@ -20,11 +20,11 @@ class AppLayout extends StatelessWidget {
|
|||||||
return BlocConsumer<AuthCubit, AuthState>(
|
return BlocConsumer<AuthCubit, AuthState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state is AuthError) {
|
if (state is AuthError) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
// ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
// SnackBar(
|
||||||
content: Text(state.message),
|
// content: Text(state.message),
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
Navigator.of(context)
|
Navigator.of(context)
|
||||||
.popUntil((route) => route.settings.name == Routes.authLogin);
|
.popUntil((route) => route.settings.name == Routes.authLogin);
|
||||||
}
|
}
|
||||||
@ -35,11 +35,11 @@ class AppLayout extends StatelessWidget {
|
|||||||
child: BlocConsumer<HomeCubit, HomeState>(
|
child: BlocConsumer<HomeCubit, HomeState>(
|
||||||
listener: (context, state) async {
|
listener: (context, state) async {
|
||||||
if (state is GetSpacesError) {
|
if (state is GetSpacesError) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
// ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
// SnackBar(
|
||||||
content: Text(state.errMessage),
|
// content: Text(state.errMessage),
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
Navigator.of(context).popUntil(
|
Navigator.of(context).popUntil(
|
||||||
(route) => route.settings.name == Routes.authLogin);
|
(route) => route.settings.name == Routes.authLogin);
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,11 @@ class AppBody extends StatelessWidget {
|
|||||||
return BlocConsumer<HomeCubit, HomeState>(
|
return BlocConsumer<HomeCubit, HomeState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state is GetSpacesError) {
|
if (state is GetSpacesError) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
// ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
// SnackBar(
|
||||||
content: Text(state.errMessage),
|
// content: Text(state.errMessage),
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
|
@ -104,14 +104,6 @@ class LoginForm extends StatelessWidget {
|
|||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
isDone: state is AuthLoginSuccess,
|
isDone: state is AuthLoginSuccess,
|
||||||
isLoading: state is AuthLoading,
|
isLoading: state is AuthLoading,
|
||||||
// enabled: AuthCubit.get(context)
|
|
||||||
// .emailController
|
|
||||||
// .text
|
|
||||||
// .isNotEmpty &&
|
|
||||||
// AuthCubit.get(context)
|
|
||||||
// .passwordController
|
|
||||||
// .text
|
|
||||||
// .isNotEmpty,
|
|
||||||
customButtonStyle: ButtonStyle(
|
customButtonStyle: ButtonStyle(
|
||||||
backgroundColor: MaterialStateProperty.all(
|
backgroundColor: MaterialStateProperty.all(
|
||||||
Colors.black.withOpacity(.25),
|
Colors.black.withOpacity(.25),
|
||||||
@ -124,10 +116,14 @@ class LoginForm extends StatelessWidget {
|
|||||||
'Login',
|
'Login',
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (formKey.currentState!.validate()) {
|
bool isValid = formKey.currentState!.validate();
|
||||||
if (state is! AuthLoginLoading) {
|
if (isValid) {
|
||||||
|
if ((state is! AuthLoading)) {
|
||||||
|
print('login');
|
||||||
AuthCubit.get(context).login();
|
AuthCubit.get(context).login();
|
||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
|
} else {
|
||||||
|
formKey.currentState!.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -21,11 +21,11 @@ class LoginView extends StatelessWidget {
|
|||||||
return BlocConsumer<AuthCubit, AuthState>(
|
return BlocConsumer<AuthCubit, AuthState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state is AuthError) {
|
if (state is AuthError) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
// ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
// SnackBar(
|
||||||
content: Text(state.message),
|
// content: Text(state.message),
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
} else if (state is AuthLoginSuccess) {
|
} else if (state is AuthLoginSuccess) {
|
||||||
Navigator.pushNamed(context, Routes.homeRoute);
|
Navigator.pushNamed(context, Routes.homeRoute);
|
||||||
}
|
}
|
||||||
|
@ -27,11 +27,11 @@ class AcInterface extends StatelessWidget {
|
|||||||
child: BlocConsumer<DevicesCubit, DevicesState>(
|
child: BlocConsumer<DevicesCubit, DevicesState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state is DeviceControlError) {
|
if (state is DeviceControlError) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
// ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
// SnackBar(
|
||||||
content: Text(state.errorMsg),
|
// content: Text(state.errorMsg),
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
|
@ -19,25 +19,25 @@ class DevicesViewBody extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocConsumer<DevicesCubit, DevicesState>(
|
return BlocConsumer<DevicesCubit, DevicesState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state is GetDevicesError) {
|
// if (state is GetDevicesError) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
// ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
// SnackBar(
|
||||||
content: Text(state.errorMsg),
|
// content: Text(state.errorMsg),
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
} else if (state is DevicesCategoriesError) {
|
// } else if (state is DevicesCategoriesError) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
// ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
// SnackBar(
|
||||||
content: Text(state.errorMsg),
|
// content: Text(state.errorMsg),
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
} else if (state is DeviceControlError) {
|
// } else if (state is DeviceControlError) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
// ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
// SnackBar(
|
||||||
content: Text(state.errorMsg),
|
// content: Text(state.errorMsg),
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
},
|
},
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
if (state is DevicesLoading ||
|
if (state is DevicesLoading ||
|
||||||
|
Reference in New Issue
Block a user