mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
Refactor CreateSubSpaceDialog layout for improved readability and maintainability
This commit is contained in:
@ -54,18 +54,16 @@ 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,
|
|
||||||
child: SizedBox(
|
|
||||||
width: context.screenWidth * 0.35,
|
width: context.screenWidth * 0.35,
|
||||||
child: Padding(
|
color: ColorsManager.whiteColors,
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16),
|
||||||
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).textTheme.headlineLarge?.copyWith(
|
style: context.textTheme.headlineLarge?.copyWith(
|
||||||
color: ColorsManager.blackColor,
|
color: ColorsManager.blackColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -73,8 +71,8 @@ class CreateSubSpaceDialog extends StatelessWidget {
|
|||||||
Container(
|
Container(
|
||||||
width: context.screenWidth * 0.35,
|
width: context.screenWidth * 0.35,
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
vertical: 10.0,
|
vertical: 10,
|
||||||
horizontal: 16.0,
|
horizontal: 16,
|
||||||
),
|
),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: ColorsManager.boxColor,
|
color: ColorsManager.boxColor,
|
||||||
@ -91,15 +89,13 @@ class CreateSubSpaceDialog extends StatelessWidget {
|
|||||||
final index = entry.key;
|
final index = entry.key;
|
||||||
final subSpace = entry.value;
|
final subSpace = entry.value;
|
||||||
|
|
||||||
final lowerName =
|
final lowerName = subSpace.subspaceName.toLowerCase();
|
||||||
subSpace.subspaceName.toLowerCase();
|
|
||||||
|
|
||||||
final duplicateIndices = state.subSpaces
|
final duplicateIndices = state.subSpaces
|
||||||
.asMap()
|
.asMap()
|
||||||
.entries
|
.entries
|
||||||
.where((e) =>
|
.where((e) =>
|
||||||
e.value.subspaceName.toLowerCase() ==
|
e.value.subspaceName.toLowerCase() == lowerName)
|
||||||
lowerName)
|
|
||||||
.map((e) => e.key)
|
.map((e) => e.key)
|
||||||
.toList();
|
.toList();
|
||||||
final isDuplicate = duplicateIndices.length > 1 &&
|
final isDuplicate = duplicateIndices.length > 1 &&
|
||||||
@ -125,10 +121,7 @@ class CreateSubSpaceDialog extends StatelessWidget {
|
|||||||
hintText: state.subSpaces.isEmpty
|
hintText: state.subSpaces.isEmpty
|
||||||
? 'Please enter the name'
|
? 'Please enter the name'
|
||||||
: null,
|
: null,
|
||||||
hintStyle: Theme.of(context)
|
hintStyle: context.textTheme.bodySmall?.copyWith(
|
||||||
.textTheme
|
|
||||||
.bodySmall
|
|
||||||
?.copyWith(
|
|
||||||
color: ColorsManager.lightGrayColor,
|
color: ColorsManager.lightGrayColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -145,7 +138,7 @@ class CreateSubSpaceDialog extends StatelessWidget {
|
|||||||
textController.clear();
|
textController.clear();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
style: Theme.of(context).textTheme.bodyMedium,
|
style: context.textTheme.bodyMedium,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -156,7 +149,7 @@ class CreateSubSpaceDialog extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.only(top: 8.0),
|
padding: const EdgeInsets.only(top: 8.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
state.errorMessage,
|
state.errorMessage,
|
||||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
style: context.textTheme.bodySmall?.copyWith(
|
||||||
color: ColorsManager.warningRed,
|
color: ColorsManager.warningRed,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -175,16 +168,14 @@ class CreateSubSpaceDialog extends StatelessWidget {
|
|||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
onPressed: (state.errorMessage.isNotEmpty)
|
onPressed: state.errorMessage.isEmpty
|
||||||
? null
|
? () {
|
||||||
: () async {
|
final subSpacesBloc = context.read<SubSpaceBloc>();
|
||||||
final subSpaces = context
|
final subSpaces = subSpacesBloc.state.subSpaces;
|
||||||
.read<SubSpaceBloc>()
|
onSave?.call(subSpaces);
|
||||||
.state
|
|
||||||
.subSpaces;
|
|
||||||
onSave!(subSpaces);
|
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
}
|
||||||
|
: null,
|
||||||
backgroundColor: ColorsManager.secondaryColor,
|
backgroundColor: ColorsManager.secondaryColor,
|
||||||
borderRadius: 10,
|
borderRadius: 10,
|
||||||
foregroundColor: state.errorMessage.isNotEmpty
|
foregroundColor: state.errorMessage.isNotEmpty
|
||||||
@ -197,8 +188,6 @@ class CreateSubSpaceDialog extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user