mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
- Refactor the code in _RoutinesViewState to improve readability and maintainability.
- Update the indentation and add padding to the child widgets in the Column. - Add a bottom padding to the empty state text in _buildEmptyState.
This commit is contained in:
@ -30,8 +30,8 @@ class _RoutinesViewState extends State<RoutinesView> {
|
|||||||
final spaceId = result['space'];
|
final spaceId = result['space'];
|
||||||
final bloc = BlocProvider.of<CreateRoutineBloc>(context);
|
final bloc = BlocProvider.of<CreateRoutineBloc>(context);
|
||||||
final routineBloc = context.read<RoutineBloc>();
|
final routineBloc = context.read<RoutineBloc>();
|
||||||
bloc.add(
|
bloc.add(SaveCommunityIdAndSpaceIdEvent(
|
||||||
SaveCommunityIdAndSpaceIdEvent(communityID: communityId, spaceID: spaceId));
|
communityID: communityId, spaceID: spaceId));
|
||||||
await Future.delayed(const Duration(seconds: 1));
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
routineBloc.add(const CreateNewRoutineViewEvent(createRoutineView: true));
|
routineBloc.add(const CreateNewRoutineViewEvent(createRoutineView: true));
|
||||||
}
|
}
|
||||||
@ -61,34 +61,38 @@ class _RoutinesViewState extends State<RoutinesView> {
|
|||||||
width: context.screenWidth,
|
width: context.screenWidth,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
padding: const EdgeInsetsDirectional.all(16),
|
padding: const EdgeInsetsDirectional.all(16),
|
||||||
child: Column(
|
child: Padding(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
padding: const EdgeInsets.only(left: 20),
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
child: Column(
|
||||||
spacing: 16,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
Text(
|
spacing: 16,
|
||||||
"Create New Routines",
|
children: [
|
||||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
Text(
|
||||||
color: ColorsManager.grayColor,
|
"Create New Routines",
|
||||||
fontWeight: FontWeight.bold,
|
style:
|
||||||
),
|
Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||||
),
|
color: ColorsManager.grayColor,
|
||||||
RoutineViewCard(
|
fontWeight: FontWeight.bold,
|
||||||
isLoading: false,
|
),
|
||||||
onChanged: (v) {},
|
),
|
||||||
status: '',
|
RoutineViewCard(
|
||||||
spaceId: '',
|
isLoading: false,
|
||||||
automationId: '',
|
onChanged: (v) {},
|
||||||
communityId: '',
|
status: '',
|
||||||
sceneId: '',
|
spaceId: '',
|
||||||
cardType: '',
|
automationId: '',
|
||||||
spaceName: '',
|
communityId: '',
|
||||||
onTap: () => _handleRoutineCreation(context),
|
sceneId: '',
|
||||||
icon: Icons.add,
|
cardType: '',
|
||||||
textString: '',
|
spaceName: '',
|
||||||
),
|
onTap: () => _handleRoutineCreation(context),
|
||||||
const FetchRoutineScenesAutomation(),
|
icon: Icons.add,
|
||||||
],
|
textString: '',
|
||||||
|
),
|
||||||
|
const FetchRoutineScenesAutomation(),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -16,7 +16,8 @@ class FetchRoutineScenesAutomation extends StatelessWidget
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<RoutineBloc, RoutineState>(
|
return BlocBuilder<RoutineBloc, RoutineState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
if (state.isLoading) return const Center(child: CircularProgressIndicator());
|
if (state.isLoading)
|
||||||
|
return const Center(child: CircularProgressIndicator());
|
||||||
|
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
@ -40,7 +41,8 @@ class FetchRoutineScenesAutomation extends StatelessWidget
|
|||||||
const SizedBox(height: 3),
|
const SizedBox(height: 3),
|
||||||
Visibility(
|
Visibility(
|
||||||
visible: state.automations.isNotEmpty,
|
visible: state.automations.isNotEmpty,
|
||||||
replacement: _buildEmptyState(context, "No automations found"),
|
replacement:
|
||||||
|
_buildEmptyState(context, "No automations found"),
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 200,
|
height: 200,
|
||||||
child: _buildAutomations(state),
|
child: _buildAutomations(state),
|
||||||
@ -59,7 +61,8 @@ class FetchRoutineScenesAutomation extends StatelessWidget
|
|||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
itemCount: state.automations.length,
|
itemCount: state.automations.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final isLoading = state.automations.contains(state.automations[index].id);
|
final isLoading =
|
||||||
|
state.automations.contains(state.automations[index].id);
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
@ -179,10 +182,13 @@ class FetchRoutineScenesAutomation extends StatelessWidget
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildEmptyState(BuildContext context, String title) {
|
Widget _buildEmptyState(BuildContext context, String title) {
|
||||||
return Text(
|
return Padding(
|
||||||
title,
|
padding: const EdgeInsets.only(bottom: 100),
|
||||||
style: context.textTheme.bodyMedium?.copyWith(
|
child: Text(
|
||||||
color: ColorsManager.grayColor,
|
title,
|
||||||
|
style: context.textTheme.bodyMedium?.copyWith(
|
||||||
|
color: ColorsManager.grayColor,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user