Refactor visibility handling for scenes and automations in FetchRoutineScenesAutomation

This commit is contained in:
Faris Armoush
2025-04-17 13:12:09 +03:00
parent 977875f1f2
commit f912b41fd8

View File

@ -17,10 +17,6 @@ class FetchRoutineScenesAutomation extends StatefulWidget {
class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation> class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
with HelperResponsiveLayout { with HelperResponsiveLayout {
@override
void initState() {
super.initState();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -45,15 +41,15 @@ class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
), ),
), ),
const SizedBox(height: 10), const SizedBox(height: 10),
if (state.scenes.isEmpty) Visibility(
Text( visible: state.scenes.isNotEmpty,
replacement: Text(
"No scenes found", "No scenes found",
style: context.textTheme.bodyMedium?.copyWith( style: context.textTheme.bodyMedium?.copyWith(
color: ColorsManager.grayColor, color: ColorsManager.grayColor,
), ),
), ),
if (state.scenes.isNotEmpty) child: SizedBox(
SizedBox(
height: 200, height: 200,
child: ListView.builder( child: ListView.builder(
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
@ -110,6 +106,7 @@ class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
); );
}), }),
), ),
),
const SizedBox(height: 10), const SizedBox(height: 10),
Text( Text(
"Automations", "Automations",
@ -119,15 +116,15 @@ class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
), ),
), ),
const SizedBox(height: 3), const SizedBox(height: 3),
if (state.automations.isEmpty) Visibility(
Text( visible: state.automations.isNotEmpty,
replacement: Text(
"No automations found", "No automations found",
style: context.textTheme.bodyMedium?.copyWith( style: context.textTheme.bodyMedium?.copyWith(
color: ColorsManager.grayColor, color: ColorsManager.grayColor,
), ),
), ),
if (state.automations.isNotEmpty) child: SizedBox(
SizedBox(
height: 200, height: 200,
child: ListView.builder( child: ListView.builder(
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
@ -192,6 +189,7 @@ class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
}, },
), ),
), ),
)
], ],
), ),
), ),