mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-14 17:25:50 +00:00
Compare commits
43 Commits
Fix-Factor
...
SP-1440-FE
Author | SHA1 | Date | |
---|---|---|---|
67a164e6d2 | |||
cf20bdcd42 | |||
84264391d9 | |||
2e4f904d3a | |||
c46cfb48a8 | |||
a0dd128557 | |||
34fa426163 | |||
1407c173b0 | |||
a8430a7d3d | |||
7ef6020dd8 | |||
d538b3667e | |||
01d5cb48cc | |||
3216d6b879 | |||
52e1ff94de | |||
0cc867a4ea | |||
3de7606a00 | |||
f709b92e12 | |||
f1667d4458 | |||
b4f03ab6c3 | |||
4c38c50649 | |||
8b441aaf46 | |||
afdd44e098 | |||
fc1d394509 | |||
dce44e20ec | |||
91c4c772b5 | |||
9044645f95 | |||
7699453e6d | |||
d1a21be983 | |||
db8e5a4aa6 | |||
fa5bb350c3 | |||
920827d763 | |||
d3902d622e | |||
a4432656ab | |||
90e0d2f52b | |||
08e5e17910 | |||
f57348e5cd | |||
be168aed93 | |||
a66784473f | |||
c0a963ded5 | |||
7945cefe53 | |||
7d0e50fb1d | |||
117f6190dd | |||
748c67fd8b |
26
lib/common/widgets/empty_search_result_widget.dart
Normal file
26
lib/common/widgets/empty_search_result_widget.dart
Normal file
@ -0,0 +1,26 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
|
||||
class EmptySearchResultWidget extends StatelessWidget {
|
||||
const EmptySearchResultWidget({
|
||||
this.message = 'No results found',
|
||||
super.key,
|
||||
});
|
||||
|
||||
final String message;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
child: Text(
|
||||
message,
|
||||
textAlign: TextAlign.center,
|
||||
style: context.textTheme.bodySmall?.copyWith(
|
||||
color: ColorsManager.lightGreyColor,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
53
lib/common/widgets/sidebar_communities_list.dart
Normal file
53
lib/common/widgets/sidebar_communities_list.dart
Normal file
@ -0,0 +1,53 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
|
||||
class SidebarCommunitiesList extends StatelessWidget {
|
||||
const SidebarCommunitiesList({
|
||||
required this.communities,
|
||||
required this.itemBuilder,
|
||||
required this.scrollController,
|
||||
required this.onScrollToEnd,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final List<CommunityModel> communities;
|
||||
final Widget Function(BuildContext context, int index) itemBuilder;
|
||||
final ScrollController scrollController;
|
||||
final void Function() onScrollToEnd;
|
||||
|
||||
bool _onNotification(ScrollEndNotification notification) {
|
||||
final hasReachedEnd = notification.metrics.extentAfter == 0;
|
||||
if (hasReachedEnd) {
|
||||
onScrollToEnd.call();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: SizedBox(
|
||||
width: context.screenWidth * 0.5,
|
||||
child: Scrollbar(
|
||||
scrollbarOrientation: ScrollbarOrientation.left,
|
||||
thumbVisibility: true,
|
||||
controller: scrollController,
|
||||
child: NotificationListener<ScrollEndNotification>(
|
||||
onNotification: _onNotification,
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
padding: const EdgeInsetsDirectional.only(start: 16),
|
||||
itemCount: communities.length,
|
||||
controller: scrollController,
|
||||
itemBuilder: itemBuilder,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -55,12 +55,12 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
||||
final isSmallScreen = isSmallScreenSize(context);
|
||||
final isMediumScreen = isMediumScreenSize(context);
|
||||
Size size = MediaQuery.of(context).size;
|
||||
late ScrollController _scrollController;
|
||||
_scrollController = ScrollController();
|
||||
late ScrollController scrollController;
|
||||
scrollController = ScrollController();
|
||||
|
||||
void _scrollToCenter() {
|
||||
final double middlePosition = _scrollController.position.maxScrollExtent / 2;
|
||||
_scrollController.animateTo(
|
||||
void scrollToCenter() {
|
||||
final double middlePosition = scrollController.position.maxScrollExtent / 2;
|
||||
scrollController.animateTo(
|
||||
middlePosition,
|
||||
duration: const Duration(seconds: 1),
|
||||
curve: Curves.easeInOut,
|
||||
@ -68,7 +68,7 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
||||
}
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_scrollToCenter();
|
||||
scrollToCenter();
|
||||
});
|
||||
|
||||
return Stack(
|
||||
@ -76,7 +76,7 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
||||
FirstLayer(
|
||||
second: Center(
|
||||
child: ListView(
|
||||
controller: _scrollController,
|
||||
controller: scrollController,
|
||||
shrinkWrap: true,
|
||||
children: [
|
||||
Container(
|
||||
@ -199,7 +199,7 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
||||
width: size.width * 0.9,
|
||||
child: DropdownButtonHideUnderline(
|
||||
child: DropdownButton2<String>(
|
||||
style: TextStyle(color: Colors.black),
|
||||
style: const TextStyle(color: Colors.black),
|
||||
isExpanded: true,
|
||||
hint: Text(
|
||||
'Select your region/country',
|
||||
@ -336,6 +336,16 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
||||
obscureText: loginBloc.obscureText,
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
controller: loginBloc.loginPasswordController,
|
||||
onFieldSubmitted: (value) {
|
||||
if (loginBloc.loginFormKey.currentState!.validate()) {
|
||||
loginBloc.add(LoginButtonPressed(
|
||||
username: loginBloc.loginEmailController.text,
|
||||
password: value,
|
||||
));
|
||||
} else {
|
||||
loginBloc.add(ChangeValidateEvent());
|
||||
}
|
||||
},
|
||||
decoration: textBoxDecoration()!.copyWith(
|
||||
hintText: 'At least 8 characters',
|
||||
hintStyle: Theme.of(context)
|
||||
@ -393,7 +403,7 @@ class _LoginWebPageState extends State<LoginWebPage> with HelperResponsiveLayout
|
||||
Transform.scale(
|
||||
scale: 1.2,
|
||||
child: Checkbox(
|
||||
fillColor: MaterialStateProperty.all<Color>(Colors.white),
|
||||
fillColor: WidgetStateProperty.all<Color>(Colors.white),
|
||||
activeColor: Colors.white,
|
||||
value: loginBloc.isChecked,
|
||||
checkColor: Colors.black,
|
||||
|
@ -5,7 +5,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
|
||||
import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
@ -15,13 +14,18 @@ class SaveRoutineHelper {
|
||||
static Future<void> showSaveRoutineDialog(BuildContext context) async {
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
builder: (context) {
|
||||
return BlocBuilder<RoutineBloc, RoutineState>(
|
||||
builder: (context, state) {
|
||||
final selectedConditionLabel = state.selectedAutomationOperator == 'and'
|
||||
? 'All Conditions are met'
|
||||
: 'Any Condition is met';
|
||||
|
||||
return AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
content: Container(
|
||||
width: MediaQuery.sizeOf(context).width * 0.5,
|
||||
width: context.screenWidth * 0.5,
|
||||
height: 500,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
@ -29,25 +33,128 @@ class SaveRoutineHelper {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
DialogHeader('Create a scene: ${state.routineName ?? ""}'),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
const SizedBox(height: 18),
|
||||
Text(
|
||||
'Create a scene: ${state.routineName ?? ""}',
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.headlineMedium!.copyWith(
|
||||
color: ColorsManager.primaryColorWithOpacity,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 18),
|
||||
_buildDivider(),
|
||||
_buildListsLabelRow(selectedConditionLabel),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.symmetric(
|
||||
horizontal: 16,
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
spacing: 24,
|
||||
children: [
|
||||
// Left side - IF
|
||||
Expanded(
|
||||
child: ListView(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
shrinkWrap: true,
|
||||
children: [
|
||||
const Text(
|
||||
'IF:',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
_buildIfConditions(state, context),
|
||||
Container(
|
||||
width: 1,
|
||||
color: ColorsManager.greyColor.withValues(alpha: 0.8),
|
||||
),
|
||||
_buildThenActions(state, context),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildDivider(),
|
||||
const SizedBox(height: 8),
|
||||
_buildDialogFooter(context, state),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
static Container _buildDivider() {
|
||||
return Container(
|
||||
height: 1,
|
||||
width: double.infinity,
|
||||
color: ColorsManager.greyColor,
|
||||
);
|
||||
}
|
||||
|
||||
static Widget _buildListsLabelRow(String selectedConditionLabel) {
|
||||
const textStyle = TextStyle(
|
||||
fontSize: 16,
|
||||
);
|
||||
return Container(
|
||||
color: ColorsManager.backgroundColor.withValues(alpha: 0.5),
|
||||
padding: const EdgeInsetsDirectional.all(20),
|
||||
child: Row(
|
||||
spacing: 16,
|
||||
children: [
|
||||
Expanded(child: Text('IF: $selectedConditionLabel', style: textStyle)),
|
||||
const Expanded(child: Text('THEN:', style: textStyle)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static Widget _buildDialogFooter(BuildContext context, RoutineState state) {
|
||||
return Row(
|
||||
spacing: 16,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
DialogFooterButton(
|
||||
text: 'Cancel',
|
||||
onTap: () => Navigator.pop(context),
|
||||
),
|
||||
DialogFooterButton(
|
||||
text: 'Confirm',
|
||||
onTap: () {
|
||||
if (state.isAutomation) {
|
||||
if (state.isUpdate ?? false) {
|
||||
context.read<RoutineBloc>().add(const UpdateAutomation());
|
||||
} else {
|
||||
context.read<RoutineBloc>().add(const CreateAutomationEvent());
|
||||
}
|
||||
} else {
|
||||
if (state.isUpdate ?? false) {
|
||||
context.read<RoutineBloc>().add(const UpdateScene());
|
||||
} else {
|
||||
context.read<RoutineBloc>().add(const CreateSceneEvent());
|
||||
}
|
||||
}
|
||||
|
||||
Navigator.pop(context);
|
||||
},
|
||||
textColor: ColorsManager.primaryColorWithOpacity,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
static Widget _buildThenActions(RoutineState state, BuildContext context) {
|
||||
return Expanded(
|
||||
child: ListView(
|
||||
// shrinkWrap: true,
|
||||
children: state.thenItems.map((item) {
|
||||
final functions = state.selectedFunctions[item['uniqueCustomId']] ?? [];
|
||||
return functionRow(item, context, functions);
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static Widget _buildIfConditions(RoutineState state, BuildContext context) {
|
||||
return Expanded(
|
||||
child: ListView(
|
||||
// shrinkWrap: true,
|
||||
children: [
|
||||
if (state.isTabToRun)
|
||||
ListTile(
|
||||
leading: SvgPicture.asset(
|
||||
@ -65,75 +172,14 @@ class SaveRoutineHelper {
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
// Right side - THEN items
|
||||
|
||||
Expanded(
|
||||
child: ListView(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
shrinkWrap: true,
|
||||
children: [
|
||||
const Text(
|
||||
'THEN:',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
...state.thenItems.map((item) {
|
||||
final functions =
|
||||
state.selectedFunctions[item['uniqueCustomId']] ?? [];
|
||||
return functionRow(item, context, functions);
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// if (state.errorMessage != null || state.errorMessage!.isNotEmpty)
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: Text(
|
||||
// state.errorMessage!,
|
||||
// style: const TextStyle(color: Colors.red),
|
||||
// ),
|
||||
// ),
|
||||
DialogFooter(
|
||||
onCancel: () => Navigator.pop(context),
|
||||
onConfirm: () async {
|
||||
if (state.isAutomation) {
|
||||
if (state.isUpdate ?? false) {
|
||||
context.read<RoutineBloc>().add(const UpdateAutomation());
|
||||
} else {
|
||||
context.read<RoutineBloc>().add(const CreateAutomationEvent());
|
||||
}
|
||||
} else {
|
||||
if (state.isUpdate ?? false) {
|
||||
context.read<RoutineBloc>().add(const UpdateScene());
|
||||
} else {
|
||||
context.read<RoutineBloc>().add(const CreateSceneEvent());
|
||||
}
|
||||
}
|
||||
// if (state.errorMessage == null || state.errorMessage!.isEmpty) {
|
||||
Navigator.pop(context);
|
||||
// }
|
||||
},
|
||||
isConfirmEnabled: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
static Widget functionRow(
|
||||
dynamic item, BuildContext context, List<DeviceFunctionData> functions) {
|
||||
dynamic item,
|
||||
BuildContext context,
|
||||
List<DeviceFunctionData> functions,
|
||||
) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 6),
|
||||
child: Row(
|
||||
@ -142,18 +188,35 @@ class SaveRoutineHelper {
|
||||
Expanded(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
spacing: 8,
|
||||
spacing: 17,
|
||||
children: [
|
||||
item['type'] == 'tap_to_run' || item['type'] == 'scene'
|
||||
? Image.memory(
|
||||
base64Decode(item['icon']),
|
||||
Container(
|
||||
width: 22,
|
||||
height: 22,
|
||||
padding: const EdgeInsetsDirectional.all(4),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: ColorsManager.textFieldGreyColor,
|
||||
border: Border.all(
|
||||
color: ColorsManager.neutralGray,
|
||||
width: 1.5,
|
||||
),
|
||||
),
|
||||
child: Center(
|
||||
child: item['type'] == 'tap_to_run' || item['type'] == 'scene'
|
||||
? Image.memory(
|
||||
base64Decode(item['icon']),
|
||||
width: 12,
|
||||
height: 22,
|
||||
fit: BoxFit.scaleDown,
|
||||
)
|
||||
: SvgPicture.asset(
|
||||
item['imagePath'],
|
||||
width: 22,
|
||||
height: 22,
|
||||
width: 12,
|
||||
height: 12,
|
||||
fit: BoxFit.scaleDown,
|
||||
),
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Column(
|
||||
@ -166,19 +229,25 @@ class SaveRoutineHelper {
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: context.textTheme.bodySmall?.copyWith(
|
||||
fontSize: 14,
|
||||
fontSize: 15,
|
||||
color: ColorsManager.textPrimaryColor,
|
||||
),
|
||||
),
|
||||
Wrap(
|
||||
runSpacing: 16,
|
||||
spacing: 4,
|
||||
children: functions
|
||||
.map((f) => Text(
|
||||
'${f.operationName}: ${f.value}',
|
||||
style: context.textTheme.bodySmall
|
||||
?.copyWith(color: ColorsManager.grayColor, fontSize: 8),
|
||||
.map(
|
||||
(function) => Text(
|
||||
'${function.operationName}: ${function.value}',
|
||||
style: context.textTheme.bodySmall?.copyWith(
|
||||
color: ColorsManager.grayColor,
|
||||
fontSize: 8,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 3,
|
||||
))
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
],
|
||||
@ -197,7 +266,13 @@ class SaveRoutineHelper {
|
||||
child: Row(
|
||||
spacing: 2,
|
||||
children: [
|
||||
SizedBox(width: 8, height: 8, child: SvgPicture.asset(Assets.deviceTagIcon)),
|
||||
SizedBox(
|
||||
width: 8,
|
||||
height: 8,
|
||||
child: SvgPicture.asset(
|
||||
Assets.deviceTagIcon,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
item['tag'] ?? '',
|
||||
textAlign: TextAlign.center,
|
||||
@ -218,7 +293,12 @@ class SaveRoutineHelper {
|
||||
spacing: 2,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 8, height: 8, child: SvgPicture.asset(Assets.spaceLocationIcon)),
|
||||
width: 8,
|
||||
height: 8,
|
||||
child: SvgPicture.asset(
|
||||
Assets.spaceLocationIcon,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
item['subSpace'] ?? '',
|
||||
textAlign: TextAlign.center,
|
||||
|
@ -28,32 +28,40 @@ class DialogFooter extends StatelessWidget {
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
_buildFooterButton(
|
||||
context: context,
|
||||
DialogFooterButton(
|
||||
text: 'Cancel',
|
||||
onTap: onCancel,
|
||||
),
|
||||
if (isConfirmEnabled) ...[
|
||||
Container(width: 1, height: 50, color: ColorsManager.greyColor),
|
||||
_buildFooterButton(
|
||||
context: context,
|
||||
DialogFooterButton(
|
||||
text: 'Confirm',
|
||||
onTap: onConfirm,
|
||||
textColor:
|
||||
isConfirmEnabled ? ColorsManager.primaryColorWithOpacity : Colors.red,
|
||||
textColor: isConfirmEnabled
|
||||
? ColorsManager.primaryColorWithOpacity
|
||||
: Colors.red,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildFooterButton({
|
||||
required BuildContext context,
|
||||
required String text,
|
||||
required VoidCallback? onTap,
|
||||
Color? textColor,
|
||||
}) {
|
||||
class DialogFooterButton extends StatelessWidget {
|
||||
const DialogFooterButton({
|
||||
required this.text,
|
||||
required this.onTap,
|
||||
this.textColor,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final String text;
|
||||
final VoidCallback? onTap;
|
||||
final Color? textColor;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Expanded(
|
||||
child: TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
|
@ -16,6 +16,7 @@ class DialogHeader extends StatelessWidget {
|
||||
),
|
||||
Text(
|
||||
title,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
||||
color: ColorsManager.primaryColorWithOpacity,
|
||||
fontWeight: FontWeight.bold,
|
||||
|
@ -8,19 +8,20 @@ class CustomExpansionTileSpaceTree extends StatelessWidget {
|
||||
final bool isSelected;
|
||||
final bool isSoldCheck;
|
||||
final bool isExpanded;
|
||||
final Function? onExpansionChanged;
|
||||
final Function? onItemSelected;
|
||||
final void Function()? onExpansionChanged;
|
||||
final void Function()? onItemSelected;
|
||||
|
||||
const CustomExpansionTileSpaceTree(
|
||||
{super.key,
|
||||
this.spaceId,
|
||||
const CustomExpansionTileSpaceTree({
|
||||
required this.isSelected,
|
||||
required this.title,
|
||||
this.spaceId,
|
||||
this.children,
|
||||
this.isExpanded = false,
|
||||
this.onExpansionChanged,
|
||||
this.onItemSelected,
|
||||
required this.isSelected,
|
||||
this.isSoldCheck = false});
|
||||
this.isExpanded = false,
|
||||
this.isSoldCheck = false,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -30,50 +31,30 @@ class CustomExpansionTileSpaceTree extends StatelessWidget {
|
||||
children: [
|
||||
Checkbox(
|
||||
value: isSoldCheck ? null : isSelected,
|
||||
onChanged: (bool? value) {
|
||||
if (onItemSelected != null) {
|
||||
onItemSelected!();
|
||||
}
|
||||
},
|
||||
onChanged: (value) => onItemSelected?.call(),
|
||||
tristate: true,
|
||||
side: WidgetStateBorderSide.resolveWith((states) {
|
||||
return const BorderSide(color: ColorsManager.grayBorder);
|
||||
}),
|
||||
side: WidgetStateBorderSide.resolveWith(
|
||||
(states) => const BorderSide(color: ColorsManager.grayBorder),
|
||||
),
|
||||
fillColor: WidgetStateProperty.resolveWith((states) {
|
||||
if (states.contains(WidgetState.selected)) {
|
||||
return ColorsManager.blue1;
|
||||
} else {
|
||||
return ColorsManager.checkBoxFillColor;
|
||||
}
|
||||
|
||||
return ColorsManager.checkBoxFillColor;
|
||||
}),
|
||||
checkColor: ColorsManager.whiteColors,
|
||||
),
|
||||
if (children != null && children!.isNotEmpty)
|
||||
InkWell(
|
||||
onTap: () {
|
||||
if (onExpansionChanged != null) {
|
||||
onExpansionChanged!();
|
||||
}
|
||||
},
|
||||
child: Icon(
|
||||
isExpanded ? Icons.keyboard_arrow_down : Icons.keyboard_arrow_right,
|
||||
color: ColorsManager.lightGrayColor,
|
||||
size: 16.0,
|
||||
),
|
||||
),
|
||||
_buildExpansionIcon(),
|
||||
Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
if (onItemSelected != null) {
|
||||
onItemSelected!();
|
||||
}
|
||||
},
|
||||
onTap: onItemSelected,
|
||||
child: Text(
|
||||
_capitalizeFirstLetter(title),
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
color: isSelected
|
||||
? ColorsManager.blackColor // Change color to black when selected
|
||||
: ColorsManager.lightGrayColor, // Gray when not selected
|
||||
? ColorsManager.blackColor
|
||||
: ColorsManager.lightGrayColor,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
@ -92,6 +73,20 @@ class CustomExpansionTileSpaceTree extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildExpansionIcon() {
|
||||
return Visibility(
|
||||
visible: children != null && children!.isNotEmpty,
|
||||
child: InkWell(
|
||||
onTap: onExpansionChanged,
|
||||
child: Icon(
|
||||
isExpanded ? Icons.keyboard_arrow_down : Icons.keyboard_arrow_right,
|
||||
color: ColorsManager.lightGrayColor,
|
||||
size: 16.0,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _capitalizeFirstLetter(String text) {
|
||||
if (text.isEmpty) return text;
|
||||
return text[0].toUpperCase() + text.substring(1);
|
||||
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:syncrow_web/common/widgets/search_bar.dart';
|
||||
import 'package:syncrow_web/common/widgets/sidebar_communities_list.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_bloc.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_event.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_state.dart';
|
||||
@ -23,7 +24,13 @@ class SpaceTreeView extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _SpaceTreeViewState extends State<SpaceTreeView> {
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
late final ScrollController _scrollController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_scrollController = ScrollController();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
@ -34,23 +41,27 @@ class _SpaceTreeViewState extends State<SpaceTreeView> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<SpaceTreeBloc, SpaceTreeState>(builder: (context, state) {
|
||||
List<CommunityModel> list =
|
||||
state.searchQuery.isNotEmpty ? state.filteredCommunity : state.communityList;
|
||||
final communities = state.searchQuery.isNotEmpty
|
||||
? state.filteredCommunity
|
||||
: state.communityList;
|
||||
return Container(
|
||||
height: MediaQuery.sizeOf(context).height,
|
||||
decoration: widget.isSide == true
|
||||
? subSectionContainerDecoration.copyWith(color: ColorsManager.whiteColors)
|
||||
? subSectionContainerDecoration.copyWith(
|
||||
color: ColorsManager.whiteColors)
|
||||
: const BoxDecoration(color: ColorsManager.whiteColors),
|
||||
child: state is SpaceTreeLoadingState
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: Column(
|
||||
children: [
|
||||
widget.isSide == true
|
||||
? Container(
|
||||
if (widget.isSide == true)
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: ColorsManager.circleRolesBackground,
|
||||
borderRadius: BorderRadius.only(
|
||||
topRight: Radius.circular(20), topLeft: Radius.circular(20)),
|
||||
topRight: Radius.circular(20),
|
||||
topLeft: Radius.circular(20),
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
@ -59,15 +70,23 @@ class _SpaceTreeViewState extends State<SpaceTreeView> {
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(20)),
|
||||
border: Border.all(color: ColorsManager.grayBorder)),
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(20),
|
||||
),
|
||||
border: Border.all(
|
||||
color: ColorsManager.grayBorder,
|
||||
),
|
||||
),
|
||||
child: TextFormField(
|
||||
style: context.textTheme.bodyMedium
|
||||
?.copyWith(color: ColorsManager.blackColor),
|
||||
onChanged: (value) {
|
||||
context.read<SpaceTreeBloc>().add(SearchQueryEvent(value));
|
||||
},
|
||||
decoration: textBoxDecoration(radios: 20)!.copyWith(
|
||||
style: context.textTheme.bodyMedium?.copyWith(
|
||||
color: ColorsManager.blackColor,
|
||||
),
|
||||
onChanged: (value) =>
|
||||
context.read<SpaceTreeBloc>().add(
|
||||
SearchQueryEvent(value),
|
||||
),
|
||||
decoration:
|
||||
textBoxDecoration(radios: 20)?.copyWith(
|
||||
fillColor: Colors.white,
|
||||
suffixIcon: Padding(
|
||||
padding: const EdgeInsets.only(right: 16),
|
||||
@ -77,10 +96,12 @@ class _SpaceTreeViewState extends State<SpaceTreeView> {
|
||||
height: 24,
|
||||
),
|
||||
),
|
||||
hintStyle: context.textTheme.bodyMedium?.copyWith(
|
||||
hintStyle:
|
||||
context.textTheme.bodyMedium?.copyWith(
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 12,
|
||||
color: ColorsManager.textGray),
|
||||
color: ColorsManager.textGray,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -89,170 +110,92 @@ class _SpaceTreeViewState extends State<SpaceTreeView> {
|
||||
),
|
||||
),
|
||||
)
|
||||
: CustomSearchBar(
|
||||
onSearchChanged: (query) {
|
||||
context.read<SpaceTreeBloc>().add(SearchQueryEvent(query));
|
||||
},
|
||||
else
|
||||
CustomSearchBar(
|
||||
onSearchChanged: (query) => context.read<SpaceTreeBloc>().add(
|
||||
SearchQueryEvent(query),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Expanded(
|
||||
child: state.isSearching
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: ListView(
|
||||
shrinkWrap: true,
|
||||
scrollDirection: Axis.horizontal,
|
||||
children: [
|
||||
Container(
|
||||
width: MediaQuery.sizeOf(context).width * 0.5,
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: list.isEmpty
|
||||
? Center(
|
||||
child: Text(
|
||||
'No results found',
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
color: ColorsManager.lightGrayColor,
|
||||
fontWeight: FontWeight.w400,
|
||||
: SidebarCommunitiesList(
|
||||
onScrollToEnd: () => context.read<SpaceTreeBloc>().add(
|
||||
PaginationEvent(
|
||||
state.paginationModel,
|
||||
state.communityList,
|
||||
),
|
||||
),
|
||||
)
|
||||
: Scrollbar(
|
||||
scrollbarOrientation: ScrollbarOrientation.left,
|
||||
thumbVisibility: true,
|
||||
controller: _scrollController,
|
||||
child: NotificationListener(
|
||||
onNotification: (notification) {
|
||||
if (notification is ScrollEndNotification &&
|
||||
notification.metrics.extentAfter == 0) {
|
||||
// If the user has reached the end of the list Load more data
|
||||
context.read<SpaceTreeBloc>().add(PaginationEvent(
|
||||
state.paginationModel, state.communityList));
|
||||
}
|
||||
return false;
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 16),
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: list.length,
|
||||
controller: _scrollController,
|
||||
scrollController: _scrollController,
|
||||
communities: communities,
|
||||
itemBuilder: (context, index) {
|
||||
return CustomExpansionTileSpaceTree(
|
||||
title: list[index].name,
|
||||
title: communities[index].name,
|
||||
isSelected: state.selectedCommunities
|
||||
.contains(list[index].uuid),
|
||||
.contains(communities[index].uuid),
|
||||
isSoldCheck: state.selectedCommunities
|
||||
.contains(list[index].uuid),
|
||||
onExpansionChanged: () {
|
||||
.contains(communities[index].uuid),
|
||||
onExpansionChanged: () =>
|
||||
context.read<SpaceTreeBloc>().add(
|
||||
OnCommunityExpanded(list[index].uuid));
|
||||
},
|
||||
isExpanded: state.expandedCommunities
|
||||
.contains(list[index].uuid),
|
||||
OnCommunityExpanded(
|
||||
communities[index].uuid,
|
||||
),
|
||||
),
|
||||
isExpanded: state.expandedCommunities.contains(
|
||||
communities[index].uuid,
|
||||
),
|
||||
onItemSelected: () {
|
||||
context.read<SpaceTreeBloc>().add(
|
||||
OnCommunitySelected(list[index].uuid,
|
||||
list[index].spaces));
|
||||
OnCommunitySelected(
|
||||
communities[index].uuid,
|
||||
communities[index].spaces,
|
||||
),
|
||||
);
|
||||
widget.onSelect();
|
||||
},
|
||||
children: list[index].spaces.map((space) {
|
||||
children: communities[index].spaces.map(
|
||||
(space) {
|
||||
return CustomExpansionTileSpaceTree(
|
||||
title: space.name,
|
||||
isExpanded: state.expandedSpaces
|
||||
.contains(space.uuid),
|
||||
isExpanded:
|
||||
state.expandedSpaces.contains(space.uuid),
|
||||
onItemSelected: () {
|
||||
context.read<SpaceTreeBloc>().add(
|
||||
OnSpaceSelected(
|
||||
list[index],
|
||||
communities[index],
|
||||
space.uuid ?? '',
|
||||
space.children));
|
||||
space.children,
|
||||
),
|
||||
);
|
||||
widget.onSelect();
|
||||
},
|
||||
onExpansionChanged: () {
|
||||
onExpansionChanged: () =>
|
||||
context.read<SpaceTreeBloc>().add(
|
||||
OnSpaceExpanded(list[index].uuid,
|
||||
space.uuid ?? ''));
|
||||
},
|
||||
OnSpaceExpanded(
|
||||
communities[index].uuid,
|
||||
space.uuid ?? '',
|
||||
),
|
||||
),
|
||||
isSelected: state.selectedSpaces
|
||||
.contains(space.uuid) ||
|
||||
state.soldCheck.contains(space.uuid),
|
||||
isSoldCheck:
|
||||
state.soldCheck.contains(space.uuid),
|
||||
children: _buildNestedSpaces(
|
||||
context, state, space, list[index]),
|
||||
context,
|
||||
state,
|
||||
space,
|
||||
communities[index],
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
},
|
||||
).toList(),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
),
|
||||
if (state.paginationIsLoading) const CircularProgressIndicator(),
|
||||
// Expanded(
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: list.isEmpty
|
||||
// ? Center(
|
||||
// child: Text(
|
||||
// 'No results found',
|
||||
// style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
// color: ColorsManager.lightGrayColor, // Gray when not selected
|
||||
// fontWeight: FontWeight.w400,
|
||||
// ),
|
||||
// ),
|
||||
// )
|
||||
// : ListView(
|
||||
// shrinkWrap: true,
|
||||
// children: list
|
||||
// .map(
|
||||
// (community) => CustomExpansionTileSpaceTree(
|
||||
// title: community.name,
|
||||
// isSelected:
|
||||
// state.selectedCommunities.contains(community.uuid),
|
||||
// isSoldCheck:
|
||||
// state.selectedCommunities.contains(community.uuid),
|
||||
// onExpansionChanged: () {
|
||||
// context
|
||||
// .read<SpaceTreeBloc>()
|
||||
// .add(OnCommunityExpanded(community.uuid));
|
||||
// },
|
||||
// isExpanded:
|
||||
// state.expandedCommunities.contains(community.uuid),
|
||||
// onItemSelected: () {
|
||||
// context.read<SpaceTreeBloc>().add(
|
||||
// OnCommunitySelected(community.uuid, community.spaces));
|
||||
|
||||
// onSelect();
|
||||
// },
|
||||
// children: community.spaces.map((space) {
|
||||
// return CustomExpansionTileSpaceTree(
|
||||
// title: space.name,
|
||||
// isExpanded: state.expandedSpaces.contains(space.uuid),
|
||||
// onItemSelected: () {
|
||||
// context.read<SpaceTreeBloc>().add(OnSpaceSelected(
|
||||
// community.uuid, space.uuid ?? '', space.children));
|
||||
// onSelect();
|
||||
// },
|
||||
// onExpansionChanged: () {
|
||||
// context.read<SpaceTreeBloc>().add(
|
||||
// OnSpaceExpanded(community.uuid, space.uuid ?? ''));
|
||||
// },
|
||||
// isSelected: state.selectedSpaces.contains(space.uuid) ||
|
||||
// state.soldCheck.contains(space.uuid),
|
||||
// isSoldCheck: state.soldCheck.contains(space.uuid),
|
||||
// children: _buildNestedSpaces(
|
||||
// context, state, space, community.uuid),
|
||||
// );
|
||||
// }).toList(),
|
||||
// ),
|
||||
// )
|
||||
// .toList(),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
);
|
||||
@ -260,22 +203,28 @@ class _SpaceTreeViewState extends State<SpaceTreeView> {
|
||||
}
|
||||
|
||||
List<Widget> _buildNestedSpaces(
|
||||
BuildContext context, SpaceTreeState state, SpaceModel space, CommunityModel community) {
|
||||
BuildContext context,
|
||||
SpaceTreeState state,
|
||||
SpaceModel space,
|
||||
CommunityModel community,
|
||||
) {
|
||||
return space.children.map((child) {
|
||||
return CustomExpansionTileSpaceTree(
|
||||
isSelected:
|
||||
state.selectedSpaces.contains(child.uuid) || state.soldCheck.contains(child.uuid),
|
||||
isSelected: state.selectedSpaces.contains(child.uuid) ||
|
||||
state.soldCheck.contains(child.uuid),
|
||||
isSoldCheck: state.soldCheck.contains(child.uuid),
|
||||
title: child.name,
|
||||
isExpanded: state.expandedSpaces.contains(child.uuid),
|
||||
onItemSelected: () {
|
||||
context
|
||||
.read<SpaceTreeBloc>()
|
||||
.add(OnSpaceSelected(community, child.uuid ?? '', child.children));
|
||||
context.read<SpaceTreeBloc>().add(
|
||||
OnSpaceSelected(community, child.uuid ?? '', child.children),
|
||||
);
|
||||
widget.onSelect();
|
||||
},
|
||||
onExpansionChanged: () {
|
||||
context.read<SpaceTreeBloc>().add(OnSpaceExpanded(community.uuid, child.uuid ?? ''));
|
||||
context.read<SpaceTreeBloc>().add(
|
||||
OnSpaceExpanded(community.uuid, child.uuid ?? ''),
|
||||
);
|
||||
},
|
||||
children: _buildNestedSpaces(context, state, child, community),
|
||||
);
|
||||
|
@ -1,6 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/common/widgets/empty_search_result_widget.dart';
|
||||
import 'package:syncrow_web/common/widgets/search_bar.dart';
|
||||
import 'package:syncrow_web/common/widgets/sidebar_communities_list.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_bloc.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_event.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
||||
@ -30,6 +32,8 @@ class SidebarWidget extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _SidebarWidgetState extends State<SidebarWidget> {
|
||||
late final ScrollController _scrollController;
|
||||
|
||||
String _searchQuery = '';
|
||||
String? _selectedSpaceUuid;
|
||||
String? _selectedId;
|
||||
@ -37,9 +41,16 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
||||
@override
|
||||
void initState() {
|
||||
_selectedId = widget.selectedSpaceUuid;
|
||||
_scrollController = ScrollController();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_scrollController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant SidebarWidget oldWidget) {
|
||||
if (widget.selectedSpaceUuid != oldWidget.selectedSpaceUuid) {
|
||||
@ -86,12 +97,14 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
||||
return isSpaceSelected || anySubSpaceIsSelected;
|
||||
}
|
||||
|
||||
static const _width = 300.0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final filteredCommunities = _filteredCommunities();
|
||||
|
||||
return Container(
|
||||
width: 300,
|
||||
width: _width,
|
||||
decoration: subSectionContainerDecoration,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@ -103,10 +116,18 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: filteredCommunities
|
||||
.map((community) => _buildCommunityTile(context, community))
|
||||
.toList(),
|
||||
child: Visibility(
|
||||
visible: filteredCommunities.isNotEmpty,
|
||||
replacement: const EmptySearchResultWidget(),
|
||||
child: SidebarCommunitiesList(
|
||||
scrollController: _scrollController,
|
||||
onScrollToEnd: () {},
|
||||
communities: filteredCommunities,
|
||||
itemBuilder: (context, index) => _buildCommunityTile(
|
||||
context,
|
||||
filteredCommunities[index],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@ -134,11 +155,12 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
||||
},
|
||||
onExpansionChanged: (title, expanded) {},
|
||||
children: community.spaces
|
||||
.where((space) {
|
||||
final isDeleted = space.status != SpaceStatus.deleted;
|
||||
final isParentDeleted = space.status != SpaceStatus.parentDeleted;
|
||||
return (isDeleted || isParentDeleted);
|
||||
})
|
||||
.where(
|
||||
(space) => {
|
||||
SpaceStatus.deleted,
|
||||
SpaceStatus.parentDeleted,
|
||||
}.contains(space.status),
|
||||
)
|
||||
.map((space) => _buildSpaceTile(space: space, community: community))
|
||||
.toList(),
|
||||
);
|
||||
|
@ -145,13 +145,11 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
TagChipDisplay(
|
||||
context,
|
||||
screenWidth: screenWidth,
|
||||
spaceModel: updatedSpaceModel,
|
||||
products: products,
|
||||
subspaces: subspaces,
|
||||
allTags: allTags,
|
||||
spaceNameController: spaceNameController,
|
||||
spaceName: spaceNameController.text,
|
||||
pageContext: pageContext,
|
||||
otherSpaceModels: otherSpaceModels,
|
||||
allSpaceModels: allSpaceModels,
|
||||
|
@ -10,90 +10,77 @@ import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_
|
||||
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/button_content_widget.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/tag_model/views/add_device_type_model_widget.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
|
||||
class TagChipDisplay extends StatelessWidget {
|
||||
final double screenWidth;
|
||||
const TagChipDisplay({
|
||||
required this.spaceModel,
|
||||
required this.products,
|
||||
required this.subspaces,
|
||||
required this.allTags,
|
||||
required this.spaceName,
|
||||
required this.projectTags,
|
||||
this.pageContext,
|
||||
this.otherSpaceModels,
|
||||
this.allSpaceModels,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final SpaceTemplateModel? spaceModel;
|
||||
final List<ProductModel>? products;
|
||||
final List<SubspaceTemplateModel>? subspaces;
|
||||
final List<String>? allTags;
|
||||
final TextEditingController spaceNameController;
|
||||
final String spaceName;
|
||||
final BuildContext? pageContext;
|
||||
final List<String>? otherSpaceModels;
|
||||
final List<SpaceTemplateModel>? allSpaceModels;
|
||||
final List<Tag> projectTags;
|
||||
|
||||
const TagChipDisplay(BuildContext context,
|
||||
{Key? key,
|
||||
required this.screenWidth,
|
||||
required this.spaceModel,
|
||||
required this.products,
|
||||
required this.subspaces,
|
||||
required this.allTags,
|
||||
required this.spaceNameController,
|
||||
this.pageContext,
|
||||
this.otherSpaceModels,
|
||||
this.allSpaceModels,
|
||||
required this.projectTags})
|
||||
: super(key: key);
|
||||
Map<ProductModel, int> get _groupedTags {
|
||||
final spaceTags = spaceModel?.tags ?? <Tag>[];
|
||||
|
||||
final subspaces = spaceModel?.subspaceModels ?? [];
|
||||
final subspaceTags = subspaces.expand((e) => e.tags ?? <Tag>[]).toList();
|
||||
|
||||
return TagHelper.groupTags([...spaceTags, ...subspaceTags]);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return (spaceModel?.tags?.isNotEmpty == true ||
|
||||
spaceModel?.subspaceModels?.any((subspace) => subspace.tags?.isNotEmpty == true) ==
|
||||
true)
|
||||
? SizedBox(
|
||||
width: screenWidth * 0.25,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
final hasTags = spaceModel?.tags?.isNotEmpty ?? false;
|
||||
final hasSubspaceTags =
|
||||
spaceModel?.subspaceModels?.any((e) => e.tags?.isNotEmpty ?? false) ?? false;
|
||||
|
||||
if (hasTags || hasSubspaceTags) {
|
||||
return Container(
|
||||
width: context.screenWidth * 0.25,
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: ColorsManager.textFieldGreyColor,
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
border: Border.all(
|
||||
color: ColorsManager.textFieldGreyColor,
|
||||
width: 3.0, // Border width
|
||||
width: 3,
|
||||
),
|
||||
),
|
||||
child: Wrap(
|
||||
spacing: 8.0,
|
||||
runSpacing: 8.0,
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: [
|
||||
// Combine tags from spaceModel and subspaces
|
||||
...TagHelper.groupTags([
|
||||
...?spaceModel?.tags,
|
||||
...?spaceModel?.subspaceModels?.expand((subspace) => subspace.tags ?? [])
|
||||
]).entries.map(
|
||||
(entry) => Chip(
|
||||
avatar: SizedBox(
|
||||
width: 24,
|
||||
height: 24,
|
||||
child: SvgPicture.asset(
|
||||
entry.key.icon ?? 'assets/icons/gateway.svg',
|
||||
fit: BoxFit.contain,
|
||||
..._groupedTags.entries.map((entry) => _buildChip(context, entry)),
|
||||
_buildEditChip(context),
|
||||
],
|
||||
),
|
||||
),
|
||||
label: Text(
|
||||
'x${entry.value}', // Show count
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.copyWith(color: ColorsManager.spaceColor),
|
||||
),
|
||||
backgroundColor: ColorsManager.whiteColors,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
side: const BorderSide(
|
||||
color: ColorsManager.spaceColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
EditChip(onTap: () async {
|
||||
// Use the Navigator's context for showDialog
|
||||
Navigator.of(context).pop();
|
||||
);
|
||||
}
|
||||
|
||||
await showDialog<bool>(
|
||||
barrierDismissible: false,
|
||||
return _buildAddDevicesButton(context);
|
||||
}
|
||||
|
||||
Widget _buildEditChip(BuildContext context) {
|
||||
return EditChip(
|
||||
onTap: () => showDialog<void>(
|
||||
context: context,
|
||||
builder: (context) => AssignTagModelsDialog(
|
||||
products: products,
|
||||
@ -104,38 +91,64 @@ class TagChipDisplay extends StatelessWidget {
|
||||
spaceModel: spaceModel,
|
||||
otherSpaceModels: otherSpaceModels,
|
||||
initialTags: TagHelper.generateInitialTags(
|
||||
subspaces: subspaces, spaceTagModels: spaceModel?.tags ?? []),
|
||||
subspaces: subspaces,
|
||||
spaceTagModels: spaceModel?.tags ?? [],
|
||||
),
|
||||
title: 'Edit Device',
|
||||
addedProducts: TagHelper.createInitialSelectedProducts(
|
||||
spaceModel?.tags ?? [], subspaces),
|
||||
spaceModel?.tags ?? [],
|
||||
subspaces,
|
||||
),
|
||||
spaceName: spaceModel?.modelName ?? '',
|
||||
projectTags: projectTags,
|
||||
));
|
||||
})
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
: TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
);
|
||||
}
|
||||
|
||||
await showDialog<bool>(
|
||||
barrierDismissible: false,
|
||||
Widget _buildChip(
|
||||
BuildContext context,
|
||||
MapEntry<ProductModel, int> entry,
|
||||
) {
|
||||
return Chip(
|
||||
backgroundColor: ColorsManager.whiteColors,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
side: const BorderSide(
|
||||
color: ColorsManager.spaceColor,
|
||||
),
|
||||
),
|
||||
avatar: SvgPicture.asset(
|
||||
entry.key.icon ?? Assets.gateway,
|
||||
fit: BoxFit.contain,
|
||||
height: 24,
|
||||
width: 24,
|
||||
),
|
||||
label: Text(
|
||||
'${entry.value}',
|
||||
style: context.textTheme.bodySmall!.copyWith(
|
||||
color: ColorsManager.spaceColor,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAddDevicesButton(BuildContext context) {
|
||||
return TextButton(
|
||||
onPressed: () => showDialog<void>(
|
||||
context: context,
|
||||
builder: (context) => AddDeviceTypeModelWidget(
|
||||
products: products,
|
||||
subspaces: subspaces,
|
||||
allTags: allTags,
|
||||
spaceName: spaceNameController.text,
|
||||
spaceName: spaceName,
|
||||
pageContext: pageContext,
|
||||
isCreate: true,
|
||||
spaceModel: spaceModel,
|
||||
otherSpaceModels: otherSpaceModels,
|
||||
projectTags: projectTags,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
style: TextButton.styleFrom(
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
|
Reference in New Issue
Block a user