Fixed list issue in the manage home screen

This commit is contained in:
Abdullah Alassaf
2025-02-20 10:50:47 +03:00
parent 450b773921
commit 0b45d61b25

View File

@ -16,85 +16,74 @@ class ManageHomeView extends StatelessWidget {
var spaces = HomeCubit.getInstance().spaces; var spaces = HomeCubit.getInstance().spaces;
return DefaultScaffold( return DefaultScaffold(
title: 'Manage Your Home', title: 'Manage Your Home',
child: spaces == null height: MediaQuery.sizeOf(context).height,
child: spaces.isEmpty
? const Center( ? const Center(
child: BodyMedium(text: 'No spaces found'), child: BodyMedium(text: 'No spaces found'),
) )
: Column( : DefaultContainer(
children: [ padding: EdgeInsets.symmetric(horizontal: 20, vertical: 25),
DefaultContainer( child: ListView.builder(
padding: const EdgeInsets.symmetric( itemCount: spaces.length,
horizontal: 25, itemBuilder: (context, index) {
vertical: 20, if (index == spaces.length - 1) {
), return InkWell(
child: Column( onTap: () {
mainAxisSize: MainAxisSize.min, Navigator.of(context).push(CustomPageRoute(
mainAxisAlignment: MainAxisAlignment.start, builder: (context) => HomeSettingsView(
children: List.generate( space: spaces[index],
spaces.length, )));
(index) { },
if (index == spaces.length - 1) { child: Row(
return InkWell( mainAxisAlignment: MainAxisAlignment.spaceBetween,
onTap: () { children: [
Navigator.of(context).push(CustomPageRoute( BodyMedium(text: StringHelpers.toTitleCase(spaces[index].name)),
builder: (context) => HomeSettingsView( const Icon(
space: spaces[index], Icons.arrow_forward_ios,
))); color: ColorsManager.greyColor,
}, size: 15,
child: Row( )
mainAxisAlignment: MainAxisAlignment.spaceBetween, ],
children: [ ),
BodyMedium(text: StringHelpers.toTitleCase(spaces[index].name)), );
const Icon( }
Icons.arrow_forward_ios, return InkWell(
color: ColorsManager.greyColor, onTap: () {
size: 15, //TODO refactor the routing to use named routes
) // Navigator.of(context).pushNamed(
], // '/home_settings',
), // arguments: spaces[index],
); // );
}
return InkWell(
onTap: () {
//TODO refactor the routing to use named routes
// Navigator.of(context).pushNamed(
// '/home_settings',
// arguments: spaces[index],
// );
Navigator.of(context).push(CustomPageRoute( Navigator.of(context).push(CustomPageRoute(
builder: (context) => HomeSettingsView( builder: (context) => HomeSettingsView(
space: spaces[index], space: spaces[index],
))); )));
}, },
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Row( BodyMedium(text: HomeCubit.getInstance().spaces[index].name),
mainAxisAlignment: MainAxisAlignment.spaceBetween, const Icon(
children: [ Icons.arrow_forward_ios,
BodyMedium(text: HomeCubit.getInstance().spaces![index].name),
const Icon(
Icons.arrow_forward_ios,
color: ColorsManager.greyColor,
size: 15,
)
],
),
Container(
margin: const EdgeInsets.symmetric(vertical: 15),
height: 1,
color: ColorsManager.greyColor, color: ColorsManager.greyColor,
), size: 15,
)
], ],
), ),
); Container(
}, margin: const EdgeInsets.symmetric(vertical: 15),
), height: 1,
), color: ColorsManager.greyColor,
), ),
], ],
),
);
}),
)); ));
} }
} }