mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
Improve loading state handling and in FetchRoutineScenesAutomation
.
This commit is contained in:
@ -8,25 +8,17 @@ import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
||||
|
||||
class FetchRoutineScenesAutomation extends StatefulWidget {
|
||||
const FetchRoutineScenesAutomation({super.key});
|
||||
|
||||
@override
|
||||
State<FetchRoutineScenesAutomation> createState() => _FetchRoutineScenesState();
|
||||
}
|
||||
|
||||
class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
||||
class FetchRoutineScenesAutomation extends StatelessWidget
|
||||
with HelperResponsiveLayout {
|
||||
const FetchRoutineScenesAutomation({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<RoutineBloc, RoutineState>(
|
||||
builder: (context, state) {
|
||||
return state.isLoading
|
||||
? const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
)
|
||||
: SingleChildScrollView(
|
||||
if (state.isLoading) const Center(child: CircularProgressIndicator());
|
||||
|
||||
return SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||
child: Column(
|
||||
@ -130,8 +122,8 @@ class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: state.automations.length,
|
||||
itemBuilder: (context, index) {
|
||||
final isLoading = state.automations
|
||||
.contains(state.automations[index].id);
|
||||
final isLoading =
|
||||
state.automations.contains(state.automations[index].id);
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
@ -144,16 +136,15 @@ class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
||||
onChanged: (v) {
|
||||
context.read<RoutineBloc>().add(
|
||||
UpdateAutomationStatus(
|
||||
automationId:
|
||||
state.automations[index].id,
|
||||
automationId: state.automations[index].id,
|
||||
automationStatusUpdate:
|
||||
AutomationStatusUpdate(
|
||||
spaceUuid: state
|
||||
.automations[index].spaceId,
|
||||
spaceUuid:
|
||||
state.automations[index].spaceId,
|
||||
isEnable: v,
|
||||
),
|
||||
communityId: state
|
||||
.automations[index].communityId,
|
||||
communityId:
|
||||
state.automations[index].communityId,
|
||||
),
|
||||
);
|
||||
},
|
||||
@ -172,8 +163,7 @@ class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
||||
);
|
||||
context.read<RoutineBloc>().add(
|
||||
GetAutomationDetails(
|
||||
automationId:
|
||||
state.automations[index].id,
|
||||
automationId: state.automations[index].id,
|
||||
isAutomation: true,
|
||||
isUpdate: true,
|
||||
),
|
||||
|
Reference in New Issue
Block a user