mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
Refactor SpaceDetailsDialog to improve code readability and structure by simplifying widget hierarchy and enhancing the use of Bloc for state management.
This commit is contained in:
@ -27,57 +27,56 @@ class SpaceDetailsDialog extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) => SpaceDetailsModelBloc(initialState: space),
|
create: (context) => SpaceDetailsModelBloc(initialState: space),
|
||||||
child: Builder(builder: (context) {
|
child: Builder(
|
||||||
final space = context.watch<SpaceDetailsModelBloc>().state;
|
builder: (context) {
|
||||||
return AlertDialog(
|
final space = context.watch<SpaceDetailsModelBloc>().state;
|
||||||
title: title,
|
return AlertDialog(
|
||||||
backgroundColor: ColorsManager.whiteColors,
|
title: title,
|
||||||
content: SizedBox(
|
backgroundColor: ColorsManager.whiteColors,
|
||||||
height: context.screenHeight * 0.25,
|
content: SizedBox(
|
||||||
child: Row(
|
height: context.screenHeight * 0.25,
|
||||||
spacing: 20,
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
spacing: 20,
|
||||||
children: [
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
Expanded(
|
children: [
|
||||||
flex: 1,
|
Expanded(child: SpaceIconPicker(iconPath: space.icon)),
|
||||||
child: SpaceIconPicker(iconPath: space.icon)
|
Expanded(
|
||||||
),
|
flex: 2,
|
||||||
Expanded(
|
child: Column(
|
||||||
flex: 2,
|
mainAxisSize: MainAxisSize.min,
|
||||||
child: Column(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisSize: MainAxisSize.min,
|
children: [
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
SpaceNameTextField(
|
||||||
children: [
|
initialValue: space.spaceName,
|
||||||
SpaceNameTextField(
|
isNameFieldExist: (value) {
|
||||||
initialValue: space.spaceName,
|
final subspaces = space.subspaces;
|
||||||
isNameFieldExist: (value) {
|
if (subspaces.isEmpty) return false;
|
||||||
final subspaces = space.subspaces;
|
return subspaces.any(
|
||||||
if (subspaces.isEmpty) return false;
|
(subspace) => subspace.name == value,
|
||||||
return subspaces.any(
|
);
|
||||||
(subspace) => subspace.name == value,
|
},
|
||||||
);
|
),
|
||||||
},
|
const Spacer(),
|
||||||
),
|
SpaceSubSpacesBox(
|
||||||
const Spacer(),
|
subspaces: space.subspaces,
|
||||||
SpaceSubSpacesBox(
|
),
|
||||||
subspaces: space.subspaces,
|
const SizedBox(height: 16),
|
||||||
),
|
SpaceDetailsDevicesBox(space: space),
|
||||||
const SizedBox(height: 16),
|
],
|
||||||
SpaceDetailsDevicesBox(space: space),
|
),
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
actions: [
|
||||||
actions: [
|
SpaceDetailsActionButtons(
|
||||||
SpaceDetailsActionButtons(
|
onSave: () => onSave(space),
|
||||||
onSave: () => onSave(space),
|
onCancel: Navigator.of(context).pop,
|
||||||
onCancel: Navigator.of(context).pop,
|
),
|
||||||
),
|
],
|
||||||
],
|
);
|
||||||
);
|
},
|
||||||
}),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user