subspace model and view

This commit is contained in:
hannathkadher
2025-01-05 14:06:46 +04:00
parent 691beb2e86
commit d2d5e76102

View File

@ -128,96 +128,121 @@ class CreateSpaceModelDialog extends StatelessWidget {
Widget _buildSubspacesSection( Widget _buildSubspacesSection(
BuildContext context, List<SubspaceTemplateModel> subspaces) { BuildContext context, List<SubspaceTemplateModel> subspaces) {
final screenWidth = MediaQuery.of(context).size.width;
return Container( return Container(
child: subspaces.isEmpty child: subspaces.isEmpty
? TextButton( ? TextButton(
style: TextButton.styleFrom( style: TextButton.styleFrom(
overlayColor: Colors.transparent, overlayColor: Colors.transparent,
), ),
onPressed: () async { onPressed: () async {
final result = await showDialog<List<SubspaceTemplateModel>>( final result = await showDialog<List<SubspaceTemplateModel>>(
barrierDismissible: false, barrierDismissible: false,
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return CreateSubSpaceModelDialog( return CreateSubSpaceModelDialog(
isEdit: true, isEdit: true,
dialogTitle: subspaces.isEmpty dialogTitle: subspaces.isEmpty
? 'Create Sub-space' ? 'Create Sub-space'
: 'Edit Sub-space', : 'Edit Sub-space',
existingSubSpaces: subspaces, existingSubSpaces: subspaces,
); );
}, },
); );
if (result != null) { if (result != null) {
subspaces.clear(); subspaces.clear();
subspaces.addAll(result); subspaces.addAll(result);
context context
.read<CreateSpaceModelBloc>() .read<CreateSpaceModelBloc>()
.add(AddSubspacesToSpaceTemplate(subspaces)); .add(AddSubspacesToSpaceTemplate(subspaces));
} }
}, },
child: const ButtonContentWidget( child: const ButtonContentWidget(
icon: Icons.add, icon: Icons.add,
label: 'Create Sub Space', label: 'Create Sub Space',
), ),
) )
: Row( : SizedBox(
children: [ width: screenWidth * 0.25, // Set the desired width
Expanded( child: Container(
child: TextField( padding: const EdgeInsets.all(
readOnly: true, 8.0), // Add padding around the content
decoration: InputDecoration( decoration: BoxDecoration(
filled: true, color: ColorsManager.textFieldGreyColor, // Background color
fillColor: ColorsManager.whiteColors, borderRadius: BorderRadius.circular(15), // Rounded corners
hintText: subspaces.map((e) => e.subspaceName).join(", "), border: Border.all(
hintStyle: color: ColorsManager.textFieldGreyColor, // Border color
const TextStyle(color: ColorsManager.spaceColor), width: 3.0, // Border width
border: OutlineInputBorder( ),
borderRadius: BorderRadius.circular(10), ),
borderSide: BorderSide.none, child: Wrap(
spacing: 8.0, // Spacing between chips
runSpacing: 8.0, // Spacing between rows of chips
children: [
...subspaces.map(
(subspace) => Chip(
label: Text(
subspace.subspaceName,
style: const TextStyle(
color: ColorsManager.spaceColor), // Text color
),
backgroundColor:
Colors.white, // Chip background color
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(16), // Rounded chip
side: const BorderSide(
color:
ColorsManager.spaceColor), // Border color
),
),
), ),
), GestureDetector(
), onTap: () async {
), final result =
const SizedBox(width: 10), await showDialog<List<SubspaceTemplateModel>>(
TextButton( barrierDismissible: false,
onPressed: () async { context: context,
final result = builder: (BuildContext context) {
await showDialog<List<SubspaceTemplateModel>>( return CreateSubSpaceModelDialog(
barrierDismissible: false, isEdit: true,
context: context, dialogTitle: 'Edit Sub-space',
builder: (BuildContext context) { existingSubSpaces: subspaces,
return CreateSubSpaceModelDialog( );
isEdit: true, },
dialogTitle: 'Edit Sub-space', );
existingSubSpaces: subspaces,
);
},
);
if (result != null) { if (result != null) {
subspaces.clear(); subspaces.clear();
subspaces.addAll(result); subspaces.addAll(result);
context context
.read<CreateSpaceModelBloc>() .read<CreateSpaceModelBloc>()
.add(AddSubspacesToSpaceTemplate(subspaces)); .add(AddSubspacesToSpaceTemplate(subspaces));
} }
}, },
style: TextButton.styleFrom( child: Chip(
backgroundColor: ColorsManager.whiteColors, label: const Text(
shape: RoundedRectangleBorder( 'Edit',
borderRadius: BorderRadius.circular(8), style: TextStyle(
side: BorderSide(color: ColorsManager.spaceColor), color: ColorsManager
), .spaceColor), // Text color for "Edit"
), ),
child: const Text( backgroundColor:
'Edit', Colors.white, // Background color for "Edit"
style: TextStyle(color: ColorsManager.spaceColor), shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(16), // Rounded chip
side: const BorderSide(
color:
ColorsManager.spaceColor), // Border color
),
),
),
],
), ),
), ),
], ));
),
);
} }
} }