mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
call the new widgets
This commit is contained in:
@ -9,6 +9,10 @@ import 'package:syncrow_web/pages/spaces_management/all_spaces/model/selected_pr
|
|||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/subspace_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/subspace_model.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/tag.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/create_space_widgets/icon_choose_part_widget.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/create_space_widgets/space_model_linking_widget.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/create_space_widgets/space_name_textfield_widget.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/create_space_widgets/sub_space_part_widget.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/dialogs/icon_selection_dialog.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/dialogs/icon_selection_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/assign_tag/views/assign_tag_dialog.dart';
|
import 'package:syncrow_web/pages/spaces_management/assign_tag/views/assign_tag_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/create_subspace/views/create_subspace_model_dialog.dart';
|
import 'package:syncrow_web/pages/spaces_management/create_subspace/views/create_subspace_model_dialog.dart';
|
||||||
@ -116,50 +120,10 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
|||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: Column(
|
child: IconChoosePartWidget(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
selectedIcon: selectedIcon,
|
||||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
showIconSelection: _showIconSelectionDialog,
|
||||||
children: [
|
screenWidth: screenWidth,
|
||||||
const SizedBox(height: 50),
|
|
||||||
Stack(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
width: screenWidth * 0.1,
|
|
||||||
height: screenWidth * 0.1,
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
color: ColorsManager.boxColor,
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SvgPicture.asset(
|
|
||||||
selectedIcon,
|
|
||||||
width: screenWidth * 0.04,
|
|
||||||
height: screenWidth * 0.04,
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
top: 20,
|
|
||||||
right: 20,
|
|
||||||
child: InkWell(
|
|
||||||
onTap: _showIconSelectionDialog,
|
|
||||||
child: Container(
|
|
||||||
width: 24,
|
|
||||||
height: 24,
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
color: Colors.white,
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
),
|
|
||||||
child: SvgPicture.asset(
|
|
||||||
Assets.iconEdit,
|
|
||||||
width: 16,
|
|
||||||
height: 16,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 20),
|
const SizedBox(width: 20),
|
||||||
@ -168,149 +132,46 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
SpaceNameTextfieldWidget(
|
||||||
width: screenWidth * 0.25,
|
isNameFieldExist: isNameFieldExist,
|
||||||
child: TextField(
|
isNameFieldInvalid: isNameFieldInvalid,
|
||||||
controller: nameController,
|
screenWidth: screenWidth,
|
||||||
onChanged: (value) {
|
onChange: (value) {
|
||||||
enteredName = value.trim();
|
enteredName = value.trim();
|
||||||
setState(() {
|
setState(() {
|
||||||
isNameFieldExist = false;
|
isNameFieldExist = false;
|
||||||
isOkButtonEnabled = false;
|
isOkButtonEnabled = false;
|
||||||
isNameFieldInvalid = value.isEmpty;
|
isNameFieldInvalid = value.isEmpty;
|
||||||
|
|
||||||
if (!isNameFieldInvalid) {
|
if (!isNameFieldInvalid) {
|
||||||
if (SpaceHelper.isNameConflict(value,
|
if (SpaceHelper.isNameConflict(
|
||||||
widget.parentSpace, widget.editSpace)) {
|
value, widget.parentSpace, widget.editSpace)) {
|
||||||
isNameFieldExist = true;
|
isNameFieldExist = true;
|
||||||
isOkButtonEnabled = false;
|
isOkButtonEnabled = false;
|
||||||
} else {
|
} else {
|
||||||
isNameFieldExist = false;
|
isNameFieldExist = false;
|
||||||
isOkButtonEnabled = true;
|
isOkButtonEnabled = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
},
|
});
|
||||||
style: Theme.of(context).textTheme.bodyMedium,
|
},
|
||||||
decoration: InputDecoration(
|
|
||||||
hintText: 'Please enter the name',
|
|
||||||
hintStyle: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.bodyMedium!
|
|
||||||
.copyWith(color: ColorsManager.lightGrayColor),
|
|
||||||
filled: true,
|
|
||||||
fillColor: ColorsManager.boxColor,
|
|
||||||
enabledBorder: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
borderSide: BorderSide(
|
|
||||||
color: isNameFieldInvalid || isNameFieldExist
|
|
||||||
? ColorsManager.red
|
|
||||||
: ColorsManager.boxColor,
|
|
||||||
width: 1.5,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
borderSide: const BorderSide(
|
|
||||||
color: ColorsManager.boxColor,
|
|
||||||
width: 1.5,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
if (isNameFieldInvalid)
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 8.0),
|
|
||||||
child: Text(
|
|
||||||
'*Space name should not be empty.',
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.bodySmall
|
|
||||||
?.copyWith(color: ColorsManager.red),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (isNameFieldExist)
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 8.0),
|
|
||||||
child: Text(
|
|
||||||
'*Name already exist',
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.bodySmall
|
|
||||||
?.copyWith(color: ColorsManager.red),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
selectedSpaceModel == null
|
SpaceModelLinkingWidget(
|
||||||
? TextButton(
|
isSpaceModelDisabled: isSpaceModelDisabled,
|
||||||
style: TextButton.styleFrom(
|
onPressed: () {
|
||||||
padding: EdgeInsets.zero,
|
isSpaceModelDisabled
|
||||||
),
|
? null
|
||||||
onPressed: () {
|
: _showLinkSpaceModelDialog(context);
|
||||||
isSpaceModelDisabled
|
},
|
||||||
? null
|
onDeleted: () => setState(() {
|
||||||
: _showLinkSpaceModelDialog(context);
|
selectedSpaceModel = null;
|
||||||
},
|
subspaces = widget.subspaces ?? [];
|
||||||
child: ButtonContentWidget(
|
tags = widget.tags ?? [];
|
||||||
svgAssets: Assets.link,
|
}),
|
||||||
label: 'Link a space model',
|
screenWidth: screenWidth,
|
||||||
disabled: isSpaceModelDisabled,
|
selectedSpaceModel: selectedSpaceModel,
|
||||||
),
|
),
|
||||||
)
|
|
||||||
: Container(
|
|
||||||
width: screenWidth * 0.25,
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
vertical: 10.0, horizontal: 16.0),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: ColorsManager.boxColor,
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
),
|
|
||||||
child: Wrap(
|
|
||||||
spacing: 8.0,
|
|
||||||
runSpacing: 8.0,
|
|
||||||
children: [
|
|
||||||
Chip(
|
|
||||||
label: Text(
|
|
||||||
selectedSpaceModel?.modelName ?? '',
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.bodyMedium!
|
|
||||||
.copyWith(
|
|
||||||
color: ColorsManager.spaceColor),
|
|
||||||
),
|
|
||||||
backgroundColor: ColorsManager.whiteColors,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
side: const BorderSide(
|
|
||||||
color: ColorsManager.transparentColor,
|
|
||||||
width: 0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
deleteIcon: Container(
|
|
||||||
width: 24,
|
|
||||||
height: 24,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
shape: BoxShape.circle,
|
|
||||||
border: Border.all(
|
|
||||||
color: ColorsManager.lightGrayColor,
|
|
||||||
width: 1.5,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: const Icon(
|
|
||||||
Icons.close,
|
|
||||||
size: 16,
|
|
||||||
color: ColorsManager.lightGrayColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onDeleted: () => setState(() {
|
|
||||||
this.selectedSpaceModel = null;
|
|
||||||
subspaces = widget.subspaces ?? [];
|
|
||||||
tags = widget.tags ?? [];
|
|
||||||
})),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 25),
|
const SizedBox(height: 25),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
@ -339,85 +200,22 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 25),
|
const SizedBox(height: 25),
|
||||||
subspaces == null || subspaces!.isEmpty
|
SubSpacePartWidget(
|
||||||
? TextButton(
|
subspaces: subspaces,
|
||||||
style: TextButton.styleFrom(
|
onPressed: () {
|
||||||
padding: EdgeInsets.zero,
|
isTagsAndSubspaceModelDisabled
|
||||||
overlayColor: ColorsManager.transparentColor,
|
? null
|
||||||
),
|
: _showSubSpaceDialog(context, enteredName, [],
|
||||||
onPressed: () async {
|
false, widget.products, subspaces);
|
||||||
isTagsAndSubspaceModelDisabled
|
},
|
||||||
? null
|
isTagsAndSubspaceModelDisabled:
|
||||||
: _showSubSpaceDialog(context, enteredName,
|
isTagsAndSubspaceModelDisabled,
|
||||||
[], false, widget.products, subspaces);
|
screenWidth: screenWidth,
|
||||||
},
|
editChipOnTap: () async {
|
||||||
child: ButtonContentWidget(
|
_showSubSpaceDialog(context, enteredName, [], true,
|
||||||
icon: Icons.add,
|
widget.products, subspaces);
|
||||||
label: 'Create Sub Spaces',
|
},
|
||||||
disabled: isTagsAndSubspaceModelDisabled,
|
),
|
||||||
),
|
|
||||||
)
|
|
||||||
: SizedBox(
|
|
||||||
width: screenWidth * 0.25,
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: ColorsManager.textFieldGreyColor,
|
|
||||||
borderRadius: BorderRadius.circular(15),
|
|
||||||
border: Border.all(
|
|
||||||
color: ColorsManager.textFieldGreyColor,
|
|
||||||
width: 3.0, // Border width
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Wrap(
|
|
||||||
spacing: 8.0,
|
|
||||||
runSpacing: 8.0,
|
|
||||||
children: [
|
|
||||||
if (subspaces != null)
|
|
||||||
...subspaces!.map((subspace) {
|
|
||||||
return Column(
|
|
||||||
crossAxisAlignment:
|
|
||||||
CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
SubspaceNameDisplayWidget(
|
|
||||||
text: subspace.subspaceName,
|
|
||||||
validateName: (updatedName) {
|
|
||||||
bool nameExists =
|
|
||||||
subspaces!.any((s) {
|
|
||||||
bool isSameId = s.internalId ==
|
|
||||||
subspace.internalId;
|
|
||||||
bool isSameName = s.subspaceName
|
|
||||||
.trim()
|
|
||||||
.toLowerCase() ==
|
|
||||||
updatedName
|
|
||||||
.trim()
|
|
||||||
.toLowerCase();
|
|
||||||
|
|
||||||
return !isSameId && isSameName;
|
|
||||||
});
|
|
||||||
|
|
||||||
return !nameExists;
|
|
||||||
},
|
|
||||||
onNameChanged: (updatedName) {
|
|
||||||
setState(() {
|
|
||||||
subspace.subspaceName =
|
|
||||||
updatedName;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
EditChip(
|
|
||||||
onTap: () async {
|
|
||||||
_showSubSpaceDialog(context, enteredName,
|
|
||||||
[], true, widget.products, subspaces);
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
(tags?.isNotEmpty == true ||
|
(tags?.isNotEmpty == true ||
|
||||||
subspaces?.any((subspace) =>
|
subspaces?.any((subspace) =>
|
||||||
|
Reference in New Issue
Block a user