mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
added trailing commas wherever neccessary in CreateSubSpaceDialog
.
This commit is contained in:
@ -22,15 +22,16 @@ class CreateSubSpaceDialog extends StatelessWidget {
|
|||||||
final List<ProductModel>? products;
|
final List<ProductModel>? products;
|
||||||
final void Function(List<SubspaceModel>?)? onSave;
|
final void Function(List<SubspaceModel>?)? onSave;
|
||||||
|
|
||||||
const CreateSubSpaceDialog(
|
const CreateSubSpaceDialog({
|
||||||
{super.key,
|
super.key,
|
||||||
required this.isEdit,
|
required this.isEdit,
|
||||||
required this.dialogTitle,
|
required this.dialogTitle,
|
||||||
this.existingSubSpaces,
|
this.existingSubSpaces,
|
||||||
required this.spaceName,
|
required this.spaceName,
|
||||||
required this.spaceTags,
|
required this.spaceTags,
|
||||||
required this.products,
|
required this.products,
|
||||||
required this.onSave});
|
required this.onSave,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -44,7 +45,7 @@ class CreateSubSpaceDialog extends StatelessWidget {
|
|||||||
create: (_) {
|
create: (_) {
|
||||||
final bloc = SubSpaceBloc();
|
final bloc = SubSpaceBloc();
|
||||||
if (existingSubSpaces != null) {
|
if (existingSubSpaces != null) {
|
||||||
for (var subSpace in existingSubSpaces!) {
|
for (final subSpace in existingSubSpaces ?? []) {
|
||||||
bloc.add(AddSubSpace(subSpace));
|
bloc.add(AddSubSpace(subSpace));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -53,143 +54,152 @@ class CreateSubSpaceDialog extends StatelessWidget {
|
|||||||
child: BlocBuilder<SubSpaceBloc, SubSpaceState>(
|
child: BlocBuilder<SubSpaceBloc, SubSpaceState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return Container(
|
return Container(
|
||||||
color: ColorsManager.whiteColors,
|
color: ColorsManager.whiteColors,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: context.screenWidth * 0.35,
|
width: context.screenWidth * 0.35,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
dialogTitle,
|
dialogTitle,
|
||||||
style: Theme.of(context)
|
style: Theme.of(context).textTheme.headlineLarge?.copyWith(
|
||||||
.textTheme
|
color: ColorsManager.blackColor,
|
||||||
.headlineLarge
|
|
||||||
?.copyWith(color: ColorsManager.blackColor),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
Container(
|
|
||||||
width: context.screenWidth * 0.35,
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
vertical: 10.0, horizontal: 16.0),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: ColorsManager.boxColor,
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
),
|
|
||||||
child: Wrap(
|
|
||||||
spacing: 8,
|
|
||||||
runSpacing: 8,
|
|
||||||
alignment: WrapAlignment.start,
|
|
||||||
crossAxisAlignment: WrapCrossAlignment.center,
|
|
||||||
children: [
|
|
||||||
...state.subSpaces.asMap().entries.map(
|
|
||||||
(entry) {
|
|
||||||
final index = entry.key;
|
|
||||||
final subSpace = entry.value;
|
|
||||||
|
|
||||||
final lowerName =
|
|
||||||
subSpace.subspaceName.toLowerCase();
|
|
||||||
|
|
||||||
final duplicateIndices = state.subSpaces
|
|
||||||
.asMap()
|
|
||||||
.entries
|
|
||||||
.where((e) =>
|
|
||||||
e.value.subspaceName.toLowerCase() ==
|
|
||||||
lowerName)
|
|
||||||
.map((e) => e.key)
|
|
||||||
.toList();
|
|
||||||
final isDuplicate = duplicateIndices.length > 1 &&
|
|
||||||
duplicateIndices.indexOf(index) != 0;
|
|
||||||
return SubspaceChip(
|
|
||||||
subSpace: SubspaceTemplateModel(
|
|
||||||
subspaceName: entry.value.subspaceName,
|
|
||||||
disabled: entry.value.disabled,
|
|
||||||
),
|
|
||||||
isDuplicate: isDuplicate,
|
|
||||||
onDeleted: () => context
|
|
||||||
.read<SubSpaceBloc>()
|
|
||||||
.add(RemoveSubSpace(subSpace)),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: 200,
|
|
||||||
child: TextField(
|
|
||||||
controller: textController,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
border: InputBorder.none,
|
|
||||||
hintText: state.subSpaces.isEmpty
|
|
||||||
? 'Please enter the name'
|
|
||||||
: null,
|
|
||||||
hintStyle: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.bodySmall
|
|
||||||
?.copyWith(
|
|
||||||
color:
|
|
||||||
ColorsManager.lightGrayColor)),
|
|
||||||
onSubmitted: (value) {
|
|
||||||
if (value.trim().isNotEmpty) {
|
|
||||||
context.read<SubSpaceBloc>().add(AddSubSpace(
|
|
||||||
SubspaceModel(
|
|
||||||
subspaceName: value.trim(),
|
|
||||||
disabled: false)));
|
|
||||||
textController.clear();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
style: Theme.of(context).textTheme.bodyMedium),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (state.errorMessage.isNotEmpty)
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 8.0),
|
|
||||||
child: Text(state.errorMessage,
|
|
||||||
style:
|
|
||||||
Theme.of(context).textTheme.bodySmall?.copyWith(
|
|
||||||
color: ColorsManager.warningRed,
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: CancelButton(
|
|
||||||
label: 'Cancel',
|
|
||||||
onPressed: () async {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
),
|
||||||
Expanded(
|
const SizedBox(height: 16),
|
||||||
child: DefaultButton(
|
Container(
|
||||||
onPressed: (state.errorMessage.isNotEmpty)
|
width: context.screenWidth * 0.35,
|
||||||
? null
|
padding: const EdgeInsets.symmetric(
|
||||||
: () async {
|
vertical: 10.0,
|
||||||
final subSpaces = context
|
horizontal: 16.0,
|
||||||
.read<SubSpaceBloc>()
|
),
|
||||||
.state
|
decoration: BoxDecoration(
|
||||||
.subSpaces;
|
color: ColorsManager.boxColor,
|
||||||
onSave!(subSpaces);
|
borderRadius: BorderRadius.circular(10),
|
||||||
Navigator.of(context).pop();
|
),
|
||||||
},
|
child: Wrap(
|
||||||
backgroundColor: ColorsManager.secondaryColor,
|
spacing: 8,
|
||||||
borderRadius: 10,
|
runSpacing: 8,
|
||||||
foregroundColor: state.errorMessage.isNotEmpty
|
alignment: WrapAlignment.start,
|
||||||
? ColorsManager.whiteColorsWithOpacity
|
crossAxisAlignment: WrapCrossAlignment.center,
|
||||||
: ColorsManager.whiteColors,
|
children: [
|
||||||
child: const Text('OK'),
|
...state.subSpaces.asMap().entries.map(
|
||||||
|
(entry) {
|
||||||
|
final index = entry.key;
|
||||||
|
final subSpace = entry.value;
|
||||||
|
|
||||||
|
final lowerName =
|
||||||
|
subSpace.subspaceName.toLowerCase();
|
||||||
|
|
||||||
|
final duplicateIndices = state.subSpaces
|
||||||
|
.asMap()
|
||||||
|
.entries
|
||||||
|
.where((e) =>
|
||||||
|
e.value.subspaceName.toLowerCase() ==
|
||||||
|
lowerName)
|
||||||
|
.map((e) => e.key)
|
||||||
|
.toList();
|
||||||
|
final isDuplicate = duplicateIndices.length > 1 &&
|
||||||
|
duplicateIndices.indexOf(index) != 0;
|
||||||
|
return SubspaceChip(
|
||||||
|
subSpace: SubspaceTemplateModel(
|
||||||
|
subspaceName: entry.value.subspaceName,
|
||||||
|
disabled: entry.value.disabled,
|
||||||
|
),
|
||||||
|
isDuplicate: isDuplicate,
|
||||||
|
onDeleted: () => context.read<SubSpaceBloc>().add(
|
||||||
|
RemoveSubSpace(subSpace),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 200,
|
||||||
|
child: TextField(
|
||||||
|
controller: textController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
border: InputBorder.none,
|
||||||
|
hintText: state.subSpaces.isEmpty
|
||||||
|
? 'Please enter the name'
|
||||||
|
: null,
|
||||||
|
hintStyle: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.bodySmall
|
||||||
|
?.copyWith(
|
||||||
|
color: ColorsManager.lightGrayColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onSubmitted: (value) {
|
||||||
|
if (value.trim().isNotEmpty) {
|
||||||
|
context.read<SubSpaceBloc>().add(
|
||||||
|
AddSubSpace(
|
||||||
|
SubspaceModel(
|
||||||
|
subspaceName: value.trim(),
|
||||||
|
disabled: false,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
textController.clear();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
style: Theme.of(context).textTheme.bodyMedium,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
if (state.errorMessage.isNotEmpty)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 8.0),
|
||||||
|
child: Text(
|
||||||
|
state.errorMessage,
|
||||||
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||||
|
color: ColorsManager.warningRed,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: CancelButton(
|
||||||
|
label: 'Cancel',
|
||||||
|
onPressed: () async {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Expanded(
|
||||||
|
child: DefaultButton(
|
||||||
|
onPressed: (state.errorMessage.isNotEmpty)
|
||||||
|
? null
|
||||||
|
: () async {
|
||||||
|
final subSpaces = context
|
||||||
|
.read<SubSpaceBloc>()
|
||||||
|
.state
|
||||||
|
.subSpaces;
|
||||||
|
onSave!(subSpaces);
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
backgroundColor: ColorsManager.secondaryColor,
|
||||||
|
borderRadius: 10,
|
||||||
|
foregroundColor: state.errorMessage.isNotEmpty
|
||||||
|
? ColorsManager.whiteColorsWithOpacity
|
||||||
|
: ColorsManager.whiteColors,
|
||||||
|
child: const Text('OK'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
));
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user