mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 14:47:23 +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>(
|
||||
builder: (context, state) {
|
||||
return Container(
|
||||
color: ColorsManager.whiteColors,
|
||||
child: SizedBox(
|
||||
width: context.screenWidth * 0.35,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
color: ColorsManager.whiteColors,
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
dialogTitle,
|
||||
style: Theme.of(context).textTheme.headlineLarge?.copyWith(
|
||||
style: context.textTheme.headlineLarge?.copyWith(
|
||||
color: ColorsManager.blackColor,
|
||||
),
|
||||
),
|
||||
@ -73,8 +71,8 @@ class CreateSubSpaceDialog extends StatelessWidget {
|
||||
Container(
|
||||
width: context.screenWidth * 0.35,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 10.0,
|
||||
horizontal: 16.0,
|
||||
vertical: 10,
|
||||
horizontal: 16,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.boxColor,
|
||||
@ -91,15 +89,13 @@ class CreateSubSpaceDialog extends StatelessWidget {
|
||||
final index = entry.key;
|
||||
final subSpace = entry.value;
|
||||
|
||||
final lowerName =
|
||||
subSpace.subspaceName.toLowerCase();
|
||||
final lowerName = subSpace.subspaceName.toLowerCase();
|
||||
|
||||
final duplicateIndices = state.subSpaces
|
||||
.asMap()
|
||||
.entries
|
||||
.where((e) =>
|
||||
e.value.subspaceName.toLowerCase() ==
|
||||
lowerName)
|
||||
e.value.subspaceName.toLowerCase() == lowerName)
|
||||
.map((e) => e.key)
|
||||
.toList();
|
||||
final isDuplicate = duplicateIndices.length > 1 &&
|
||||
@ -125,10 +121,7 @@ class CreateSubSpaceDialog extends StatelessWidget {
|
||||
hintText: state.subSpaces.isEmpty
|
||||
? 'Please enter the name'
|
||||
: null,
|
||||
hintStyle: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall
|
||||
?.copyWith(
|
||||
hintStyle: context.textTheme.bodySmall?.copyWith(
|
||||
color: ColorsManager.lightGrayColor,
|
||||
),
|
||||
),
|
||||
@ -145,7 +138,7 @@ class CreateSubSpaceDialog extends StatelessWidget {
|
||||
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),
|
||||
child: Text(
|
||||
state.errorMessage,
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
style: context.textTheme.bodySmall?.copyWith(
|
||||
color: ColorsManager.warningRed,
|
||||
),
|
||||
),
|
||||
@ -175,16 +168,14 @@ class CreateSubSpaceDialog extends StatelessWidget {
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: DefaultButton(
|
||||
onPressed: (state.errorMessage.isNotEmpty)
|
||||
? null
|
||||
: () async {
|
||||
final subSpaces = context
|
||||
.read<SubSpaceBloc>()
|
||||
.state
|
||||
.subSpaces;
|
||||
onSave!(subSpaces);
|
||||
onPressed: state.errorMessage.isEmpty
|
||||
? () {
|
||||
final subSpacesBloc = context.read<SubSpaceBloc>();
|
||||
final subSpaces = subSpacesBloc.state.subSpaces;
|
||||
onSave?.call(subSpaces);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
}
|
||||
: null,
|
||||
backgroundColor: ColorsManager.secondaryColor,
|
||||
borderRadius: 10,
|
||||
foregroundColor: state.errorMessage.isNotEmpty
|
||||
@ -197,8 +188,6 @@ class CreateSubSpaceDialog extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
Reference in New Issue
Block a user