mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-11-27 09:24:56 +00:00
Compare commits
37 Commits
SP-1433-FE
...
SP-1441-FE
| Author | SHA1 | Date | |
|---|---|---|---|
| 62fb8b3097 | |||
| 065bd33511 | |||
| e45f57ca03 | |||
| a8430a7d3d | |||
| 7ef6020dd8 | |||
| 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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -225,7 +225,7 @@ class DraggableCard extends StatelessWidget {
|
|||||||
if (function.functionCode == 'temp_set' || function.functionCode == 'temp_current') {
|
if (function.functionCode == 'temp_set' || function.functionCode == 'temp_current') {
|
||||||
return '${(function.value / 10).toStringAsFixed(0)}°C';
|
return '${(function.value / 10).toStringAsFixed(0)}°C';
|
||||||
} else if (function.functionCode.contains('countdown')) {
|
} else if (function.functionCode.contains('countdown')) {
|
||||||
final seconds = function.value.toInt();
|
final seconds = function.value?.toInt() ?? 0;
|
||||||
if (seconds >= 3600) {
|
if (seconds >= 3600) {
|
||||||
final hours = (seconds / 3600).floor();
|
final hours = (seconds / 3600).floor();
|
||||||
final remainingMinutes = ((seconds % 3600) / 60).floor();
|
final remainingMinutes = ((seconds % 3600) / 60).floor();
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||||
|
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/ac/ac_function.dart';
|
import 'package:syncrow_web/pages/routines/models/ac/ac_function.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/ac/ac_operational_value.dart';
|
import 'package:syncrow_web/pages/routines/models/ac/ac_operational_value.dart';
|
||||||
@ -9,8 +11,6 @@ import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart';
|
|||||||
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
|
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
|
||||||
|
|
||||||
class ACHelper {
|
class ACHelper {
|
||||||
static Future<Map<String, dynamic>?> showACFunctionsDialog({
|
static Future<Map<String, dynamic>?> showACFunctionsDialog({
|
||||||
@ -74,10 +74,8 @@ class ACHelper {
|
|||||||
child: _buildFunctionsList(
|
child: _buildFunctionsList(
|
||||||
context: context,
|
context: context,
|
||||||
acFunctions: acFunctions,
|
acFunctions: acFunctions,
|
||||||
onFunctionSelected:
|
onFunctionSelected: (functionCode, operationName) =>
|
||||||
(functionCode, operationName) => context
|
context.read<FunctionBloc>().add(SelectFunction(
|
||||||
.read<FunctionBloc>()
|
|
||||||
.add(SelectFunction(
|
|
||||||
functionCode: functionCode,
|
functionCode: functionCode,
|
||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
)),
|
)),
|
||||||
@ -191,8 +189,9 @@ class ACHelper {
|
|||||||
required String operationName,
|
required String operationName,
|
||||||
bool? removeComparators,
|
bool? removeComparators,
|
||||||
}) {
|
}) {
|
||||||
|
final initialVal = selectedFunction == 'temp_set' ? 200 : -100;
|
||||||
if (selectedFunction == 'temp_set' || selectedFunction == 'temp_current') {
|
if (selectedFunction == 'temp_set' || selectedFunction == 'temp_current') {
|
||||||
final initialValue = selectedFunctionData?.value ?? 250;
|
final initialValue = selectedFunctionData?.value ?? initialVal;
|
||||||
return _buildTemperatureSelector(
|
return _buildTemperatureSelector(
|
||||||
context: context,
|
context: context,
|
||||||
initialValue: initialValue,
|
initialValue: initialValue,
|
||||||
@ -205,8 +204,7 @@ class ACHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final selectedFn =
|
final selectedFn = acFunctions.firstWhere((f) => f.code == selectedFunction);
|
||||||
acFunctions.firstWhere((f) => f.code == selectedFunction);
|
|
||||||
final values = selectedFn.getOperationalValues();
|
final values = selectedFn.getOperationalValues();
|
||||||
|
|
||||||
return _buildOperationalValuesList(
|
return _buildOperationalValuesList(
|
||||||
@ -287,7 +285,9 @@ class ACHelper {
|
|||||||
functionCode: selectCode,
|
functionCode: selectCode,
|
||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
condition: conditions[index],
|
condition: conditions[index],
|
||||||
value: selectedFunctionData?.value,
|
value: selectedFunctionData?.value ?? selectCode == 'temp_set'
|
||||||
|
? 200
|
||||||
|
: -100,
|
||||||
valueDescription: selectedFunctionData?.valueDescription,
|
valueDescription: selectedFunctionData?.valueDescription,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -302,8 +302,7 @@ class ACHelper {
|
|||||||
minHeight: 40.0,
|
minHeight: 40.0,
|
||||||
minWidth: 40.0,
|
minWidth: 40.0,
|
||||||
),
|
),
|
||||||
isSelected:
|
isSelected: conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||||
conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
|
||||||
children: conditions.map((c) => Text(c)).toList(),
|
children: conditions.map((c) => Text(c)).toList(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -317,6 +316,7 @@ class ACHelper {
|
|||||||
DeviceFunctionData? selectedFunctionData,
|
DeviceFunctionData? selectedFunctionData,
|
||||||
String selectCode,
|
String selectCode,
|
||||||
) {
|
) {
|
||||||
|
final initialVal = selectCode == 'temp_set' ? 200 : -100;
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@ -324,7 +324,7 @@ class ACHelper {
|
|||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
'${(initialValue ?? 200) / 10}°C',
|
'${(initialValue ?? initialVal) / 10}°C',
|
||||||
style: context.textTheme.headlineMedium!.copyWith(
|
style: context.textTheme.headlineMedium!.copyWith(
|
||||||
color: ColorsManager.primaryColorWithOpacity,
|
color: ColorsManager.primaryColorWithOpacity,
|
||||||
),
|
),
|
||||||
@ -397,9 +397,7 @@ class ACHelper {
|
|||||||
style: context.textTheme.bodyMedium,
|
style: context.textTheme.bodyMedium,
|
||||||
),
|
),
|
||||||
trailing: Icon(
|
trailing: Icon(
|
||||||
isSelected
|
isSelected ? Icons.radio_button_checked : Icons.radio_button_unchecked,
|
||||||
? Icons.radio_button_checked
|
|
||||||
: Icons.radio_button_unchecked,
|
|
||||||
size: 24,
|
size: 24,
|
||||||
color: isSelected
|
color: isSelected
|
||||||
? ColorsManager.primaryColorWithOpacity
|
? ColorsManager.primaryColorWithOpacity
|
||||||
@ -415,8 +413,7 @@ class ACHelper {
|
|||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
value: value.value,
|
value: value.value,
|
||||||
condition: selectedFunctionData?.condition,
|
condition: selectedFunctionData?.condition,
|
||||||
valueDescription:
|
valueDescription: selectedFunctionData?.valueDescription,
|
||||||
selectedFunctionData?.valueDescription,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -46,7 +46,7 @@ class CpsDialogSliderSelector extends StatelessWidget {
|
|||||||
functionCode: selectedFunction,
|
functionCode: selectedFunction,
|
||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
condition: condition,
|
condition: condition,
|
||||||
value: selectedFunctionData.value,
|
value: selectedFunctionData.value ?? 0,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -164,7 +164,7 @@ class OneGangSwitchHelper {
|
|||||||
required bool removeComparetors,
|
required bool removeComparetors,
|
||||||
}) {
|
}) {
|
||||||
if (selectedFunction == 'countdown_1') {
|
if (selectedFunction == 'countdown_1') {
|
||||||
final initialValue = selectedFunctionData?.value ?? 200;
|
final initialValue = selectedFunctionData?.value ?? 0;
|
||||||
return _buildCountDownSelector(
|
return _buildCountDownSelector(
|
||||||
context: context,
|
context: context,
|
||||||
initialValue: initialValue,
|
initialValue: initialValue,
|
||||||
@ -250,7 +250,7 @@ class OneGangSwitchHelper {
|
|||||||
functionCode: selectCode,
|
functionCode: selectCode,
|
||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
condition: conditions[index],
|
condition: conditions[index],
|
||||||
value: selectedFunctionData?.value,
|
value: selectedFunctionData?.value ?? 0,
|
||||||
valueDescription: selectedFunctionData?.valueDescription,
|
valueDescription: selectedFunctionData?.valueDescription,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -170,7 +170,7 @@ class ThreeGangSwitchHelper {
|
|||||||
if (selectedFunction == 'countdown_1' ||
|
if (selectedFunction == 'countdown_1' ||
|
||||||
selectedFunction == 'countdown_2' ||
|
selectedFunction == 'countdown_2' ||
|
||||||
selectedFunction == 'countdown_3') {
|
selectedFunction == 'countdown_3') {
|
||||||
final initialValue = selectedFunctionData?.value ?? 200;
|
final initialValue = selectedFunctionData?.value ?? 0;
|
||||||
return _buildTemperatureSelector(
|
return _buildTemperatureSelector(
|
||||||
context: context,
|
context: context,
|
||||||
initialValue: initialValue,
|
initialValue: initialValue,
|
||||||
@ -251,7 +251,7 @@ class ThreeGangSwitchHelper {
|
|||||||
functionCode: selectCode,
|
functionCode: selectCode,
|
||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
condition: conditions[index],
|
condition: conditions[index],
|
||||||
value: selectedFunctionData?.value,
|
value: selectedFunctionData?.value ?? 0,
|
||||||
valueDescription: selectedFunctionData?.valueDescription,
|
valueDescription: selectedFunctionData?.valueDescription,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -169,7 +169,7 @@ class TwoGangSwitchHelper {
|
|||||||
}) {
|
}) {
|
||||||
if (selectedFunction == 'countdown_1' ||
|
if (selectedFunction == 'countdown_1' ||
|
||||||
selectedFunction == 'countdown_2') {
|
selectedFunction == 'countdown_2') {
|
||||||
final initialValue = selectedFunctionData?.value ?? 200;
|
final initialValue = selectedFunctionData?.value ?? 0;
|
||||||
return _buildTemperatureSelector(
|
return _buildTemperatureSelector(
|
||||||
context: context,
|
context: context,
|
||||||
initialValue: initialValue,
|
initialValue: initialValue,
|
||||||
@ -250,7 +250,7 @@ class TwoGangSwitchHelper {
|
|||||||
functionCode: selectCode,
|
functionCode: selectCode,
|
||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
condition: conditions[index],
|
condition: conditions[index],
|
||||||
value: selectedFunctionData?.value,
|
value: selectedFunctionData?.value ?? 0,
|
||||||
valueDescription: selectedFunctionData?.valueDescription,
|
valueDescription: selectedFunctionData?.valueDescription,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -36,7 +36,7 @@ class WpsValueSelectorWidget extends StatelessWidget {
|
|||||||
dialogType: dialogType,
|
dialogType: dialogType,
|
||||||
sliderRange: sliderRange,
|
sliderRange: sliderRange,
|
||||||
displayedValue: getDisplayText,
|
displayedValue: getDisplayText,
|
||||||
initialValue: functionData.value ?? 250,
|
initialValue: functionData.value ?? 0.0,
|
||||||
onConditionChanged: (condition) => context.read<FunctionBloc>().add(
|
onConditionChanged: (condition) => context.read<FunctionBloc>().add(
|
||||||
AddFunction(
|
AddFunction(
|
||||||
functionData: DeviceFunctionData(
|
functionData: DeviceFunctionData(
|
||||||
@ -44,7 +44,7 @@ class WpsValueSelectorWidget extends StatelessWidget {
|
|||||||
functionCode: selectedFunction,
|
functionCode: selectedFunction,
|
||||||
operationName: functionData.operationName,
|
operationName: functionData.operationName,
|
||||||
condition: condition,
|
condition: condition,
|
||||||
value: functionData.value,
|
value: functionData.value ?? 0,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -87,7 +87,7 @@ class WpsValueSelectorWidget extends StatelessWidget {
|
|||||||
final intValue = int.tryParse('${functionData.value ?? ''}');
|
final intValue = int.tryParse('${functionData.value ?? ''}');
|
||||||
return switch (functionData.functionCode) {
|
return switch (functionData.functionCode) {
|
||||||
'presence_time' => '${intValue ?? '0'}',
|
'presence_time' => '${intValue ?? '0'}',
|
||||||
'dis_current' => '${intValue ?? '250'}',
|
'dis_current' => '${intValue ?? '0'}',
|
||||||
'illuminance_value' => '${intValue ?? '0'}',
|
'illuminance_value' => '${intValue ?? '0'}',
|
||||||
_ => '$intValue',
|
_ => '$intValue',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -8,19 +8,20 @@ class CustomExpansionTileSpaceTree extends StatelessWidget {
|
|||||||
final bool isSelected;
|
final bool isSelected;
|
||||||
final bool isSoldCheck;
|
final bool isSoldCheck;
|
||||||
final bool isExpanded;
|
final bool isExpanded;
|
||||||
final Function? onExpansionChanged;
|
final void Function()? onExpansionChanged;
|
||||||
final Function? onItemSelected;
|
final void Function()? onItemSelected;
|
||||||
|
|
||||||
const CustomExpansionTileSpaceTree(
|
const CustomExpansionTileSpaceTree({
|
||||||
{super.key,
|
required this.isSelected,
|
||||||
this.spaceId,
|
required this.title,
|
||||||
required this.title,
|
this.spaceId,
|
||||||
this.children,
|
this.children,
|
||||||
this.isExpanded = false,
|
this.onExpansionChanged,
|
||||||
this.onExpansionChanged,
|
this.onItemSelected,
|
||||||
this.onItemSelected,
|
this.isExpanded = false,
|
||||||
required this.isSelected,
|
this.isSoldCheck = false,
|
||||||
this.isSoldCheck = false});
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -30,50 +31,30 @@ class CustomExpansionTileSpaceTree extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Checkbox(
|
Checkbox(
|
||||||
value: isSoldCheck ? null : isSelected,
|
value: isSoldCheck ? null : isSelected,
|
||||||
onChanged: (bool? value) {
|
onChanged: (value) => onItemSelected ?? () {},
|
||||||
if (onItemSelected != null) {
|
|
||||||
onItemSelected!();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
tristate: true,
|
tristate: true,
|
||||||
side: WidgetStateBorderSide.resolveWith((states) {
|
side: WidgetStateBorderSide.resolveWith(
|
||||||
return const BorderSide(color: ColorsManager.grayBorder);
|
(states) => const BorderSide(color: ColorsManager.grayBorder),
|
||||||
}),
|
),
|
||||||
fillColor: WidgetStateProperty.resolveWith((states) {
|
fillColor: WidgetStateProperty.resolveWith((states) {
|
||||||
if (states.contains(WidgetState.selected)) {
|
if (states.contains(WidgetState.selected)) {
|
||||||
return ColorsManager.blue1;
|
return ColorsManager.blue1;
|
||||||
} else {
|
|
||||||
return ColorsManager.checkBoxFillColor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ColorsManager.checkBoxFillColor;
|
||||||
}),
|
}),
|
||||||
checkColor: ColorsManager.whiteColors,
|
checkColor: ColorsManager.whiteColors,
|
||||||
),
|
),
|
||||||
if (children != null && children!.isNotEmpty)
|
_buildExpansionIcon(),
|
||||||
InkWell(
|
|
||||||
onTap: () {
|
|
||||||
if (onExpansionChanged != null) {
|
|
||||||
onExpansionChanged!();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Icon(
|
|
||||||
isExpanded ? Icons.keyboard_arrow_down : Icons.keyboard_arrow_right,
|
|
||||||
color: ColorsManager.lightGrayColor,
|
|
||||||
size: 16.0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () {
|
onTap: onItemSelected,
|
||||||
if (onItemSelected != null) {
|
|
||||||
onItemSelected!();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Text(
|
child: Text(
|
||||||
_capitalizeFirstLetter(title),
|
_capitalizeFirstLetter(title),
|
||||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
color: isSelected
|
color: isSelected
|
||||||
? ColorsManager.blackColor // Change color to black when selected
|
? ColorsManager.blackColor
|
||||||
: ColorsManager.lightGrayColor, // Gray when not selected
|
: ColorsManager.lightGrayColor,
|
||||||
fontWeight: FontWeight.w400,
|
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) {
|
String _capitalizeFirstLetter(String text) {
|
||||||
if (text.isEmpty) return text;
|
if (text.isEmpty) return text;
|
||||||
return text[0].toUpperCase() + text.substring(1);
|
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_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:syncrow_web/common/widgets/search_bar.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_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/space_tree/bloc/space_tree_event.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';
|
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> {
|
class _SpaceTreeViewState extends State<SpaceTreeView> {
|
||||||
final ScrollController _scrollController = ScrollController();
|
late final ScrollController _scrollController;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
_scrollController = ScrollController();
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
@ -34,225 +41,161 @@ class _SpaceTreeViewState extends State<SpaceTreeView> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<SpaceTreeBloc, SpaceTreeState>(builder: (context, state) {
|
return BlocBuilder<SpaceTreeBloc, SpaceTreeState>(builder: (context, state) {
|
||||||
List<CommunityModel> list =
|
final communities = state.searchQuery.isNotEmpty
|
||||||
state.searchQuery.isNotEmpty ? state.filteredCommunity : state.communityList;
|
? state.filteredCommunity
|
||||||
|
: state.communityList;
|
||||||
return Container(
|
return Container(
|
||||||
height: MediaQuery.sizeOf(context).height,
|
height: MediaQuery.sizeOf(context).height,
|
||||||
decoration: widget.isSide == true
|
decoration: widget.isSide == true
|
||||||
? subSectionContainerDecoration.copyWith(color: ColorsManager.whiteColors)
|
? subSectionContainerDecoration.copyWith(
|
||||||
|
color: ColorsManager.whiteColors)
|
||||||
: const BoxDecoration(color: ColorsManager.whiteColors),
|
: const BoxDecoration(color: ColorsManager.whiteColors),
|
||||||
child: state is SpaceTreeLoadingState
|
child: state is SpaceTreeLoadingState
|
||||||
? const Center(child: CircularProgressIndicator())
|
? const Center(child: CircularProgressIndicator())
|
||||||
: Column(
|
: Column(
|
||||||
children: [
|
children: [
|
||||||
widget.isSide == true
|
if (widget.isSide == true)
|
||||||
? Container(
|
Container(
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
color: ColorsManager.circleRolesBackground,
|
color: ColorsManager.circleRolesBackground,
|
||||||
borderRadius: BorderRadius.only(
|
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),
|
),
|
||||||
child: Row(
|
child: Padding(
|
||||||
children: [
|
padding: const EdgeInsets.all(8.0),
|
||||||
Expanded(
|
child: Row(
|
||||||
child: Container(
|
children: [
|
||||||
decoration: BoxDecoration(
|
Expanded(
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(20)),
|
child: Container(
|
||||||
border: Border.all(color: ColorsManager.grayBorder)),
|
decoration: BoxDecoration(
|
||||||
child: TextFormField(
|
borderRadius: const BorderRadius.all(
|
||||||
style: context.textTheme.bodyMedium
|
Radius.circular(20),
|
||||||
?.copyWith(color: ColorsManager.blackColor),
|
),
|
||||||
onChanged: (value) {
|
border: Border.all(
|
||||||
context.read<SpaceTreeBloc>().add(SearchQueryEvent(value));
|
color: ColorsManager.grayBorder,
|
||||||
},
|
),
|
||||||
decoration: textBoxDecoration(radios: 20)!.copyWith(
|
),
|
||||||
fillColor: Colors.white,
|
child: TextFormField(
|
||||||
suffixIcon: Padding(
|
style: context.textTheme.bodyMedium?.copyWith(
|
||||||
padding: const EdgeInsets.only(right: 16),
|
color: ColorsManager.blackColor,
|
||||||
child: SvgPicture.asset(
|
),
|
||||||
Assets.textFieldSearch,
|
onChanged: (value) =>
|
||||||
width: 24,
|
context.read<SpaceTreeBloc>().add(
|
||||||
height: 24,
|
SearchQueryEvent(value),
|
||||||
),
|
),
|
||||||
),
|
decoration:
|
||||||
hintStyle: context.textTheme.bodyMedium?.copyWith(
|
textBoxDecoration(radios: 20)?.copyWith(
|
||||||
fontWeight: FontWeight.w400,
|
fillColor: Colors.white,
|
||||||
fontSize: 12,
|
suffixIcon: Padding(
|
||||||
color: ColorsManager.textGray),
|
padding: const EdgeInsets.only(right: 16),
|
||||||
|
child: SvgPicture.asset(
|
||||||
|
Assets.textFieldSearch,
|
||||||
|
width: 24,
|
||||||
|
height: 24,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
hintStyle:
|
||||||
|
context.textTheme.bodyMedium?.copyWith(
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
fontSize: 12,
|
||||||
|
color: ColorsManager.textGray,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
)
|
|
||||||
: CustomSearchBar(
|
|
||||||
onSearchChanged: (query) {
|
|
||||||
context.read<SpaceTreeBloc>().add(SearchQueryEvent(query));
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
CustomSearchBar(
|
||||||
|
onSearchChanged: (query) => context.read<SpaceTreeBloc>().add(
|
||||||
|
SearchQueryEvent(query),
|
||||||
|
),
|
||||||
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: state.isSearching
|
child: state.isSearching
|
||||||
? const Center(child: CircularProgressIndicator())
|
? const Center(child: CircularProgressIndicator())
|
||||||
: ListView(
|
: SidebarCommunitiesList(
|
||||||
shrinkWrap: true,
|
onScrollToEnd: () => context.read<SpaceTreeBloc>().add(
|
||||||
scrollDirection: Axis.horizontal,
|
PaginationEvent(
|
||||||
children: [
|
state.paginationModel,
|
||||||
Container(
|
state.communityList,
|
||||||
width: MediaQuery.sizeOf(context).width * 0.5,
|
),
|
||||||
padding: const EdgeInsets.all(8.0),
|
),
|
||||||
child: list.isEmpty
|
scrollController: _scrollController,
|
||||||
? Center(
|
communities: communities,
|
||||||
child: Text(
|
itemBuilder: (context, index) {
|
||||||
'No results found',
|
return CustomExpansionTileSpaceTree(
|
||||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
title: communities[index].name,
|
||||||
color: ColorsManager.lightGrayColor,
|
isSelected: state.selectedCommunities
|
||||||
fontWeight: FontWeight.w400,
|
.contains(communities[index].uuid),
|
||||||
),
|
isSoldCheck: state.selectedCommunities
|
||||||
),
|
.contains(communities[index].uuid),
|
||||||
)
|
onExpansionChanged: () =>
|
||||||
: Scrollbar(
|
context.read<SpaceTreeBloc>().add(
|
||||||
scrollbarOrientation: ScrollbarOrientation.left,
|
OnCommunityExpanded(
|
||||||
thumbVisibility: true,
|
communities[index].uuid,
|
||||||
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,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
return CustomExpansionTileSpaceTree(
|
|
||||||
title: list[index].name,
|
|
||||||
isSelected: state.selectedCommunities
|
|
||||||
.contains(list[index].uuid),
|
|
||||||
isSoldCheck: state.selectedCommunities
|
|
||||||
.contains(list[index].uuid),
|
|
||||||
onExpansionChanged: () {
|
|
||||||
context.read<SpaceTreeBloc>().add(
|
|
||||||
OnCommunityExpanded(list[index].uuid));
|
|
||||||
},
|
|
||||||
isExpanded: state.expandedCommunities
|
|
||||||
.contains(list[index].uuid),
|
|
||||||
onItemSelected: () {
|
|
||||||
context.read<SpaceTreeBloc>().add(
|
|
||||||
OnCommunitySelected(list[index].uuid,
|
|
||||||
list[index].spaces));
|
|
||||||
widget.onSelect();
|
|
||||||
},
|
|
||||||
children: list[index].spaces.map((space) {
|
|
||||||
return CustomExpansionTileSpaceTree(
|
|
||||||
title: space.name,
|
|
||||||
isExpanded: state.expandedSpaces
|
|
||||||
.contains(space.uuid),
|
|
||||||
onItemSelected: () {
|
|
||||||
context.read<SpaceTreeBloc>().add(
|
|
||||||
OnSpaceSelected(
|
|
||||||
list[index],
|
|
||||||
space.uuid ?? '',
|
|
||||||
space.children));
|
|
||||||
widget.onSelect();
|
|
||||||
},
|
|
||||||
onExpansionChanged: () {
|
|
||||||
context.read<SpaceTreeBloc>().add(
|
|
||||||
OnSpaceExpanded(list[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]),
|
|
||||||
);
|
|
||||||
}).toList(),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
isExpanded: state.expandedCommunities.contains(
|
||||||
|
communities[index].uuid,
|
||||||
|
),
|
||||||
|
onItemSelected: () {
|
||||||
|
context.read<SpaceTreeBloc>().add(
|
||||||
|
OnCommunitySelected(
|
||||||
|
communities[index].uuid,
|
||||||
|
communities[index].spaces,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
widget.onSelect();
|
||||||
|
},
|
||||||
|
children: communities[index].spaces.map(
|
||||||
|
(space) {
|
||||||
|
return CustomExpansionTileSpaceTree(
|
||||||
|
title: space.name,
|
||||||
|
isExpanded:
|
||||||
|
state.expandedSpaces.contains(space.uuid),
|
||||||
|
onItemSelected: () {
|
||||||
|
context.read<SpaceTreeBloc>().add(
|
||||||
|
OnSpaceSelected(
|
||||||
|
communities[index],
|
||||||
|
space.uuid ?? '',
|
||||||
|
space.children,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
widget.onSelect();
|
||||||
|
},
|
||||||
|
onExpansionChanged: () =>
|
||||||
|
context.read<SpaceTreeBloc>().add(
|
||||||
|
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,
|
||||||
|
communities[index],
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
],
|
},
|
||||||
|
).toList(),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (state.paginationIsLoading) const CircularProgressIndicator(),
|
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(
|
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 space.children.map((child) {
|
||||||
return CustomExpansionTileSpaceTree(
|
return CustomExpansionTileSpaceTree(
|
||||||
isSelected:
|
isSelected: state.selectedSpaces.contains(child.uuid) ||
|
||||||
state.selectedSpaces.contains(child.uuid) || state.soldCheck.contains(child.uuid),
|
state.soldCheck.contains(child.uuid),
|
||||||
isSoldCheck: state.soldCheck.contains(child.uuid),
|
isSoldCheck: state.soldCheck.contains(child.uuid),
|
||||||
title: child.name,
|
title: child.name,
|
||||||
isExpanded: state.expandedSpaces.contains(child.uuid),
|
isExpanded: state.expandedSpaces.contains(child.uuid),
|
||||||
onItemSelected: () {
|
onItemSelected: () {
|
||||||
context
|
context.read<SpaceTreeBloc>().add(
|
||||||
.read<SpaceTreeBloc>()
|
OnSpaceSelected(community, child.uuid ?? '', child.children),
|
||||||
.add(OnSpaceSelected(community, child.uuid ?? '', child.children));
|
);
|
||||||
widget.onSelect();
|
widget.onSelect();
|
||||||
},
|
},
|
||||||
onExpansionChanged: () {
|
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),
|
children: _buildNestedSpaces(context, state, child, community),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -592,6 +592,8 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
|
|||||||
return CreateSubSpaceDialog(
|
return CreateSubSpaceDialog(
|
||||||
spaceName: name,
|
spaceName: name,
|
||||||
dialogTitle: isEdit ? 'Edit Sub-space' : 'Create Sub-space',
|
dialogTitle: isEdit ? 'Edit Sub-space' : 'Create Sub-space',
|
||||||
|
spaceTags: spaceTags,
|
||||||
|
isEdit: isEdit,
|
||||||
products: products,
|
products: products,
|
||||||
existingSubSpaces: existingSubSpaces,
|
existingSubSpaces: existingSubSpaces,
|
||||||
onSave: (slectedSubspaces) {
|
onSave: (slectedSubspaces) {
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.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/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_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/bloc/space_management_event.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.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> {
|
class _SidebarWidgetState extends State<SidebarWidget> {
|
||||||
|
late final ScrollController _scrollController;
|
||||||
|
|
||||||
String _searchQuery = '';
|
String _searchQuery = '';
|
||||||
String? _selectedSpaceUuid;
|
String? _selectedSpaceUuid;
|
||||||
String? _selectedId;
|
String? _selectedId;
|
||||||
@ -37,9 +41,16 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
_selectedId = widget.selectedSpaceUuid;
|
_selectedId = widget.selectedSpaceUuid;
|
||||||
|
_scrollController = ScrollController();
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_scrollController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didUpdateWidget(covariant SidebarWidget oldWidget) {
|
void didUpdateWidget(covariant SidebarWidget oldWidget) {
|
||||||
if (widget.selectedSpaceUuid != oldWidget.selectedSpaceUuid) {
|
if (widget.selectedSpaceUuid != oldWidget.selectedSpaceUuid) {
|
||||||
@ -86,12 +97,14 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
|||||||
return isSpaceSelected || anySubSpaceIsSelected;
|
return isSpaceSelected || anySubSpaceIsSelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const _width = 300.0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final filteredCommunities = _filteredCommunities();
|
final filteredCommunities = _filteredCommunities();
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
width: 300,
|
width: _width,
|
||||||
decoration: subSectionContainerDecoration,
|
decoration: subSectionContainerDecoration,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
@ -103,10 +116,18 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView(
|
child: Visibility(
|
||||||
children: filteredCommunities
|
visible: filteredCommunities.isNotEmpty,
|
||||||
.map((community) => _buildCommunityTile(context, community))
|
replacement: const EmptySearchResultWidget(),
|
||||||
.toList(),
|
child: SidebarCommunitiesList(
|
||||||
|
scrollController: _scrollController,
|
||||||
|
onScrollToEnd: () {},
|
||||||
|
communities: filteredCommunities,
|
||||||
|
itemBuilder: (context, index) => _buildCommunityTile(
|
||||||
|
context,
|
||||||
|
filteredCommunities[index],
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -115,6 +136,17 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildCommunityTile(BuildContext context, CommunityModel community) {
|
Widget _buildCommunityTile(BuildContext context, CommunityModel community) {
|
||||||
|
final spaces = community.spaces
|
||||||
|
.where(
|
||||||
|
(space) =>
|
||||||
|
{
|
||||||
|
SpaceStatus.deleted,
|
||||||
|
SpaceStatus.parentDeleted,
|
||||||
|
}.contains(space.status) ==
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.map((space) => _buildSpaceTile(space: space, community: community))
|
||||||
|
.toList();
|
||||||
return CommunityTile(
|
return CommunityTile(
|
||||||
title: community.name,
|
title: community.name,
|
||||||
key: ValueKey(community.uuid),
|
key: ValueKey(community.uuid),
|
||||||
@ -133,14 +165,7 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
onExpansionChanged: (title, expanded) {},
|
onExpansionChanged: (title, expanded) {},
|
||||||
children: community.spaces
|
children: spaces,
|
||||||
.where((space) {
|
|
||||||
final isDeleted = space.status != SpaceStatus.deleted;
|
|
||||||
final isParentDeleted = space.status != SpaceStatus.parentDeleted;
|
|
||||||
return (isDeleted || isParentDeleted);
|
|
||||||
})
|
|
||||||
.map((space) => _buildSpaceTile(space: space, community: community))
|
|
||||||
.toList(),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,204 +4,222 @@ import 'package:syncrow_web/pages/common/buttons/cancel_button.dart';
|
|||||||
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
|
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/product_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/create_subspace/bloc/subspace_bloc.dart';
|
import 'package:syncrow_web/pages/spaces_management/create_subspace/bloc/subspace_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/create_subspace/bloc/subspace_event.dart';
|
import 'package:syncrow_web/pages/spaces_management/create_subspace/bloc/subspace_event.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/create_subspace/bloc/subspace_state.dart';
|
import 'package:syncrow_web/pages/spaces_management/create_subspace/bloc/subspace_state.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/create_subspace_model/widgets/subspace_chip.dart';
|
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
|
||||||
|
|
||||||
class CreateSubSpaceDialog extends StatefulWidget {
|
class CreateSubSpaceDialog extends StatelessWidget {
|
||||||
|
final bool isEdit;
|
||||||
final String dialogTitle;
|
final String dialogTitle;
|
||||||
final List<SubspaceModel>? existingSubSpaces;
|
final List<SubspaceModel>? existingSubSpaces;
|
||||||
final String? spaceName;
|
final String? spaceName;
|
||||||
|
final List<Tag>? spaceTags;
|
||||||
final List<ProductModel>? products;
|
final List<ProductModel>? products;
|
||||||
final void Function(List<SubspaceModel>?)? onSave;
|
final Function(List<SubspaceModel>?)? onSave;
|
||||||
|
|
||||||
const CreateSubSpaceDialog({
|
const CreateSubSpaceDialog(
|
||||||
required this.dialogTitle,
|
{Key? key,
|
||||||
required this.spaceName,
|
required this.isEdit,
|
||||||
required this.products,
|
required this.dialogTitle,
|
||||||
required this.onSave,
|
this.existingSubSpaces,
|
||||||
this.existingSubSpaces,
|
required this.spaceName,
|
||||||
super.key,
|
required this.spaceTags,
|
||||||
});
|
required this.products,
|
||||||
|
required this.onSave})
|
||||||
@override
|
: super(key: key);
|
||||||
State<CreateSubSpaceDialog> createState() => _CreateSubSpaceDialogState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _CreateSubSpaceDialogState extends State<CreateSubSpaceDialog> {
|
|
||||||
late final TextEditingController _subspaceNameController;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
_subspaceNameController = TextEditingController();
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_subspaceNameController.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocProvider(
|
final screenWidth = MediaQuery.of(context).size.width;
|
||||||
create: (_) {
|
final textController = TextEditingController();
|
||||||
final bloc = SubSpaceBloc();
|
|
||||||
if (widget.existingSubSpaces != null) {
|
return Dialog(
|
||||||
for (final subSpace in widget.existingSubSpaces ?? []) {
|
shape: RoundedRectangleBorder(
|
||||||
bloc.add(AddSubSpace(subSpace));
|
borderRadius: BorderRadius.circular(20),
|
||||||
|
),
|
||||||
|
child: BlocProvider(
|
||||||
|
create: (_) {
|
||||||
|
final bloc = SubSpaceBloc();
|
||||||
|
if (existingSubSpaces != null) {
|
||||||
|
for (var subSpace in existingSubSpaces!) {
|
||||||
|
bloc.add(AddSubSpace(subSpace));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
return bloc;
|
||||||
return bloc;
|
},
|
||||||
},
|
|
||||||
child: Dialog(
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(20),
|
|
||||||
),
|
|
||||||
child: BlocBuilder<SubSpaceBloc, SubSpaceState>(
|
child: BlocBuilder<SubSpaceBloc, SubSpaceState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return Container(
|
return Container(
|
||||||
width: context.screenWidth * 0.35,
|
color: ColorsManager.whiteColors,
|
||||||
color: ColorsManager.whiteColors,
|
child: SizedBox(
|
||||||
padding: const EdgeInsets.all(16),
|
width: screenWidth * 0.35,
|
||||||
child: Column(
|
child: Padding(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
padding: const EdgeInsets.all(16.0),
|
||||||
mainAxisSize: MainAxisSize.min,
|
child: Column(
|
||||||
children: [
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
Text(
|
mainAxisSize: MainAxisSize.min,
|
||||||
widget.dialogTitle,
|
|
||||||
style: context.textTheme.headlineLarge?.copyWith(
|
|
||||||
color: ColorsManager.blackColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
Container(
|
|
||||||
width: context.screenWidth * 0.35,
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
vertical: 10,
|
|
||||||
horizontal: 16,
|
|
||||||
),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: ColorsManager.boxColor,
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
),
|
|
||||||
child: Wrap(
|
|
||||||
spacing: 8,
|
|
||||||
runSpacing: 8,
|
|
||||||
alignment: WrapAlignment.start,
|
|
||||||
crossAxisAlignment: WrapCrossAlignment.center,
|
|
||||||
children: [
|
children: [
|
||||||
...state.subSpaces.asMap().entries.map(
|
Text(
|
||||||
(entry) {
|
dialogTitle,
|
||||||
final index = entry.key;
|
style: Theme.of(context)
|
||||||
final subSpace = entry.value;
|
.textTheme
|
||||||
|
.headlineLarge
|
||||||
final lowerName = subSpace.subspaceName.toLowerCase();
|
?.copyWith(color: ColorsManager.blackColor),
|
||||||
|
|
||||||
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(
|
const SizedBox(height: 16),
|
||||||
width: 200,
|
Container(
|
||||||
child: TextField(
|
width: screenWidth * 0.35,
|
||||||
controller: _subspaceNameController,
|
padding: const EdgeInsets.symmetric(
|
||||||
decoration: InputDecoration(
|
vertical: 10.0, horizontal: 16.0),
|
||||||
border: InputBorder.none,
|
decoration: BoxDecoration(
|
||||||
hintText: state.subSpaces.isEmpty
|
color: ColorsManager.boxColor,
|
||||||
? 'Please enter the name'
|
borderRadius: BorderRadius.circular(10),
|
||||||
: null,
|
),
|
||||||
hintStyle: context.textTheme.bodySmall?.copyWith(
|
child: Wrap(
|
||||||
color: ColorsManager.lightGrayColor,
|
spacing: 8.0,
|
||||||
),
|
runSpacing: 8.0,
|
||||||
),
|
children: [
|
||||||
onSubmitted: (value) {
|
...state.subSpaces.asMap().entries.map(
|
||||||
final trimmedValue = value.trim();
|
(entry) {
|
||||||
if (trimmedValue.isNotEmpty) {
|
final index = entry.key;
|
||||||
context.read<SubSpaceBloc>().add(
|
final subSpace = entry.value;
|
||||||
AddSubSpace(
|
|
||||||
SubspaceModel(
|
final lowerName =
|
||||||
subspaceName: trimmedValue,
|
subSpace.subspaceName.toLowerCase();
|
||||||
disabled: false,
|
|
||||||
|
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 Chip(
|
||||||
|
label: Text(subSpace.subspaceName,
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.bodyMedium
|
||||||
|
?.copyWith(
|
||||||
|
color:
|
||||||
|
ColorsManager.spaceColor)),
|
||||||
|
backgroundColor: ColorsManager.whiteColors,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
side: BorderSide(
|
||||||
|
color: isDuplicate
|
||||||
|
? ColorsManager.red
|
||||||
|
: 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(
|
||||||
_subspaceNameController.clear();
|
Icons.close,
|
||||||
}
|
size: 16,
|
||||||
},
|
color: ColorsManager.lightGrayColor,
|
||||||
style: context.textTheme.bodyMedium,
|
),
|
||||||
|
),
|
||||||
|
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'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (state.errorMessage.isNotEmpty)
|
));
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 8.0),
|
|
||||||
child: Text(
|
|
||||||
state.errorMessage,
|
|
||||||
style: 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.isEmpty
|
|
||||||
? () {
|
|
||||||
final subSpacesBloc = context.read<SubSpaceBloc>();
|
|
||||||
final subSpaces = subSpacesBloc.state.subSpaces;
|
|
||||||
widget.onSave?.call(subSpaces);
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
backgroundColor: ColorsManager.secondaryColor,
|
|
||||||
borderRadius: 10,
|
|
||||||
foregroundColor: state.errorMessage.isNotEmpty
|
|
||||||
? ColorsManager.whiteColorsWithOpacity
|
|
||||||
: ColorsManager.whiteColors,
|
|
||||||
child: const Text('OK'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -1,7 +1,4 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/spaces_management/create_subspace_model/bloc/subspace_model_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/spaces_management/create_subspace_model/bloc/subspace_model_event.dart';
|
|
||||||
import 'package:syncrow_web/pages/spaces_management/create_subspace_model/widgets/subspace_chip.dart';
|
import 'package:syncrow_web/pages/spaces_management/create_subspace_model/widgets/subspace_chip.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/create_subspace_model/widgets/subspaces_textfield.dart';
|
import 'package:syncrow_web/pages/spaces_management/create_subspace_model/widgets/subspaces_textfield.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
||||||
@ -54,9 +51,6 @@ class CreateSubspaceModelChipsBox extends StatelessWidget {
|
|||||||
return SubspaceChip(
|
return SubspaceChip(
|
||||||
subSpace: subSpace,
|
subSpace: subSpace,
|
||||||
isDuplicate: isDuplicate,
|
isDuplicate: isDuplicate,
|
||||||
onDeleted: () => context.read<SubSpaceModelBloc>().add(
|
|
||||||
RemoveSubSpaceModel(subSpace),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/create_subspace_model/bloc/subspace_model_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/create_subspace_model/bloc/subspace_model_event.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
@ -8,12 +11,10 @@ class SubspaceChip extends StatelessWidget {
|
|||||||
required this.subSpace,
|
required this.subSpace,
|
||||||
required this.isDuplicate,
|
required this.isDuplicate,
|
||||||
super.key,
|
super.key,
|
||||||
required this.onDeleted,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
final SubspaceTemplateModel subSpace;
|
final SubspaceTemplateModel subSpace;
|
||||||
final bool isDuplicate;
|
final bool isDuplicate;
|
||||||
final void Function() onDeleted;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -49,7 +50,9 @@ class SubspaceChip extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
onDeleted: onDeleted,
|
onDeleted: () => context.read<SubSpaceModelBloc>().add(
|
||||||
|
RemoveSubSpaceModel(subSpace),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -145,13 +145,11 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
TagChipDisplay(
|
TagChipDisplay(
|
||||||
context,
|
|
||||||
screenWidth: screenWidth,
|
|
||||||
spaceModel: updatedSpaceModel,
|
spaceModel: updatedSpaceModel,
|
||||||
products: products,
|
products: products,
|
||||||
subspaces: subspaces,
|
subspaces: subspaces,
|
||||||
allTags: allTags,
|
allTags: allTags,
|
||||||
spaceNameController: spaceNameController,
|
spaceName: spaceNameController.text,
|
||||||
pageContext: pageContext,
|
pageContext: pageContext,
|
||||||
otherSpaceModels: otherSpaceModels,
|
otherSpaceModels: otherSpaceModels,
|
||||||
allSpaceModels: allSpaceModels,
|
allSpaceModels: allSpaceModels,
|
||||||
|
|||||||
@ -10,139 +10,152 @@ 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/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/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/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 {
|
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 SpaceTemplateModel? spaceModel;
|
||||||
final List<ProductModel>? products;
|
final List<ProductModel>? products;
|
||||||
final List<SubspaceTemplateModel>? subspaces;
|
final List<SubspaceTemplateModel>? subspaces;
|
||||||
final List<String>? allTags;
|
final List<String>? allTags;
|
||||||
final TextEditingController spaceNameController;
|
final String spaceName;
|
||||||
final BuildContext? pageContext;
|
final BuildContext? pageContext;
|
||||||
final List<String>? otherSpaceModels;
|
final List<String>? otherSpaceModels;
|
||||||
final List<SpaceTemplateModel>? allSpaceModels;
|
final List<SpaceTemplateModel>? allSpaceModels;
|
||||||
final List<Tag> projectTags;
|
final List<Tag> projectTags;
|
||||||
|
|
||||||
const TagChipDisplay(BuildContext context,
|
Map<ProductModel, int> get _groupedTags {
|
||||||
{Key? key,
|
final spaceTags = spaceModel?.tags ?? <Tag>[];
|
||||||
required this.screenWidth,
|
|
||||||
required this.spaceModel,
|
final subspaces = spaceModel?.subspaceModels ?? [];
|
||||||
required this.products,
|
final subspaceTags = subspaces.expand((e) => e.tags ?? <Tag>[]).toList();
|
||||||
required this.subspaces,
|
|
||||||
required this.allTags,
|
return TagHelper.groupTags([...spaceTags, ...subspaceTags]);
|
||||||
required this.spaceNameController,
|
}
|
||||||
this.pageContext,
|
|
||||||
this.otherSpaceModels,
|
|
||||||
this.allSpaceModels,
|
|
||||||
required this.projectTags})
|
|
||||||
: super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return (spaceModel?.tags?.isNotEmpty == true ||
|
final hasTags = spaceModel?.tags?.isNotEmpty ?? false;
|
||||||
spaceModel?.subspaceModels?.any((subspace) => subspace.tags?.isNotEmpty == true) ==
|
final hasSubspaceTags =
|
||||||
true)
|
spaceModel?.subspaceModels?.any((e) => e.tags?.isNotEmpty ?? false) ?? false;
|
||||||
? 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: [
|
|
||||||
// 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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
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>(
|
if (hasTags || hasSubspaceTags) {
|
||||||
barrierDismissible: false,
|
return Container(
|
||||||
context: context,
|
width: context.screenWidth * 0.25,
|
||||||
builder: (context) => AssignTagModelsDialog(
|
padding: const EdgeInsets.all(8),
|
||||||
products: products,
|
decoration: BoxDecoration(
|
||||||
allSpaceModels: allSpaceModels,
|
color: ColorsManager.textFieldGreyColor,
|
||||||
subspaces: subspaces,
|
borderRadius: BorderRadius.circular(15),
|
||||||
pageContext: pageContext,
|
border: Border.all(
|
||||||
allTags: allTags,
|
color: ColorsManager.textFieldGreyColor,
|
||||||
spaceModel: spaceModel,
|
width: 3,
|
||||||
otherSpaceModels: otherSpaceModels,
|
),
|
||||||
initialTags: TagHelper.generateInitialTags(
|
),
|
||||||
subspaces: subspaces, spaceTagModels: spaceModel?.tags ?? []),
|
child: Wrap(
|
||||||
title: 'Edit Device',
|
spacing: 8,
|
||||||
addedProducts: TagHelper.createInitialSelectedProducts(
|
runSpacing: 8,
|
||||||
spaceModel?.tags ?? [], subspaces),
|
children: [
|
||||||
spaceName: spaceModel?.modelName ?? '',
|
..._groupedTags.entries.map((entry) => _buildChip(context, entry)),
|
||||||
projectTags: projectTags,
|
_buildEditChip(context),
|
||||||
));
|
],
|
||||||
})
|
),
|
||||||
],
|
);
|
||||||
),
|
}
|
||||||
),
|
|
||||||
)
|
|
||||||
: TextButton(
|
|
||||||
onPressed: () async {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
|
|
||||||
await showDialog<bool>(
|
return _buildAddDevicesButton(context);
|
||||||
barrierDismissible: false,
|
}
|
||||||
context: context,
|
|
||||||
builder: (context) => AddDeviceTypeModelWidget(
|
Widget _buildEditChip(BuildContext context) {
|
||||||
products: products,
|
return EditChip(
|
||||||
subspaces: subspaces,
|
onTap: () => showDialog<void>(
|
||||||
allTags: allTags,
|
context: context,
|
||||||
spaceName: spaceNameController.text,
|
builder: (context) => AssignTagModelsDialog(
|
||||||
pageContext: pageContext,
|
products: products,
|
||||||
isCreate: true,
|
allSpaceModels: allSpaceModels,
|
||||||
spaceModel: spaceModel,
|
subspaces: subspaces,
|
||||||
otherSpaceModels: otherSpaceModels,
|
pageContext: pageContext,
|
||||||
projectTags: projectTags,
|
allTags: allTags,
|
||||||
),
|
spaceModel: spaceModel,
|
||||||
);
|
otherSpaceModels: otherSpaceModels,
|
||||||
},
|
initialTags: TagHelper.generateInitialTags(
|
||||||
style: TextButton.styleFrom(
|
subspaces: subspaces,
|
||||||
padding: EdgeInsets.zero,
|
spaceTagModels: spaceModel?.tags ?? [],
|
||||||
),
|
),
|
||||||
child: const ButtonContentWidget(
|
title: 'Edit Device',
|
||||||
icon: Icons.add,
|
addedProducts: TagHelper.createInitialSelectedProducts(
|
||||||
label: 'Add Devices',
|
spaceModel?.tags ?? [],
|
||||||
),
|
subspaces,
|
||||||
);
|
),
|
||||||
|
spaceName: spaceModel?.modelName ?? '',
|
||||||
|
projectTags: projectTags,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
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: spaceName,
|
||||||
|
pageContext: pageContext,
|
||||||
|
isCreate: true,
|
||||||
|
spaceModel: spaceModel,
|
||||||
|
otherSpaceModels: otherSpaceModels,
|
||||||
|
projectTags: projectTags,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
style: TextButton.styleFrom(
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
),
|
||||||
|
child: const ButtonContentWidget(
|
||||||
|
icon: Icons.add,
|
||||||
|
label: 'Add Devices',
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user