mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-11-26 14:54:56 +00:00
Compare commits
1 Commits
SP-1330-FE
...
Fix-Factor
| Author | SHA1 | Date | |
|---|---|---|---|
| 72ae3b1727 |
@ -1,26 +0,0 @@
|
|||||||
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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,53 +0,0 @@
|
|||||||
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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -19,6 +19,7 @@ class FactoryResetModel {
|
|||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
return {
|
return {
|
||||||
'devicesUuid': devicesUuid,
|
'devicesUuid': devicesUuid,
|
||||||
|
'operationType': operationType,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,6 +34,7 @@ class FactoryResetModel {
|
|||||||
Map<String, dynamic> toMap() {
|
Map<String, dynamic> toMap() {
|
||||||
return {
|
return {
|
||||||
'devicesUuid': devicesUuid,
|
'devicesUuid': devicesUuid,
|
||||||
|
'operationType': operationType,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,3 +58,4 @@ class FactoryResetModel {
|
|||||||
@override
|
@override
|
||||||
int get hashCode => devicesUuid.hashCode;
|
int get hashCode => devicesUuid.hashCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_re
|
|||||||
import 'package:syncrow_web/pages/device_managment/main_door_sensor/bloc/main_door_sensor_bloc.dart';
|
import 'package:syncrow_web/pages/device_managment/main_door_sensor/bloc/main_door_sensor_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/main_door_sensor/bloc/main_door_sensor_event.dart';
|
import 'package:syncrow_web/pages/device_managment/main_door_sensor/bloc/main_door_sensor_event.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart';
|
import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart';
|
||||||
// import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart';
|
|
||||||
|
|
||||||
class MainDoorSensorBatchView extends StatelessWidget {
|
class MainDoorSensorBatchView extends StatelessWidget {
|
||||||
const MainDoorSensorBatchView({super.key, required this.devicesIds});
|
const MainDoorSensorBatchView({super.key, required this.devicesIds});
|
||||||
@ -13,35 +12,31 @@ class MainDoorSensorBatchView extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Row(
|
return BlocProvider(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
create: (context) => MainDoorSensorBloc(),
|
||||||
children: [
|
child: Builder(
|
||||||
// SizedBox(
|
builder: (innerContext) {
|
||||||
// width: 170,
|
return Row(
|
||||||
// height: 140,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
// child: FirmwareUpdateWidget(
|
children: [
|
||||||
// deviceId: devicesIds.first,
|
SizedBox(
|
||||||
// version: 12,
|
width: 170,
|
||||||
// ),
|
height: 140,
|
||||||
// ),
|
child: FactoryResetWidget(
|
||||||
// const SizedBox(
|
callFactoryReset: () {
|
||||||
// width: 12,
|
BlocProvider.of<MainDoorSensorBloc>(innerContext).add(
|
||||||
// ),
|
MainDoorSensorFactoryReset(
|
||||||
SizedBox(
|
deviceId: devicesIds.first,
|
||||||
width: 170,
|
factoryReset: FactoryResetModel(devicesUuid: devicesIds),
|
||||||
height: 140,
|
),
|
||||||
child: FactoryResetWidget(
|
);
|
||||||
callFactoryReset: () {
|
},
|
||||||
BlocProvider.of<MainDoorSensorBloc>(context).add(
|
|
||||||
MainDoorSensorFactoryReset(
|
|
||||||
deviceId: devicesIds.first,
|
|
||||||
factoryReset: FactoryResetModel(devicesUuid: devicesIds),
|
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
},
|
],
|
||||||
),
|
);
|
||||||
),
|
},
|
||||||
],
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,20 +8,19 @@ class CustomExpansionTileSpaceTree extends StatelessWidget {
|
|||||||
final bool isSelected;
|
final bool isSelected;
|
||||||
final bool isSoldCheck;
|
final bool isSoldCheck;
|
||||||
final bool isExpanded;
|
final bool isExpanded;
|
||||||
final void Function()? onExpansionChanged;
|
final Function? onExpansionChanged;
|
||||||
final void Function()? onItemSelected;
|
final Function? onItemSelected;
|
||||||
|
|
||||||
const CustomExpansionTileSpaceTree({
|
const CustomExpansionTileSpaceTree(
|
||||||
required this.isSelected,
|
{super.key,
|
||||||
required this.title,
|
this.spaceId,
|
||||||
this.spaceId,
|
required this.title,
|
||||||
this.children,
|
this.children,
|
||||||
this.onExpansionChanged,
|
this.isExpanded = false,
|
||||||
this.onItemSelected,
|
this.onExpansionChanged,
|
||||||
this.isExpanded = false,
|
this.onItemSelected,
|
||||||
this.isSoldCheck = false,
|
required this.isSelected,
|
||||||
super.key,
|
this.isSoldCheck = false});
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -31,30 +30,50 @@ class CustomExpansionTileSpaceTree extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Checkbox(
|
Checkbox(
|
||||||
value: isSoldCheck ? null : isSelected,
|
value: isSoldCheck ? null : isSelected,
|
||||||
onChanged: (value) => onItemSelected ?? () {},
|
onChanged: (bool? value) {
|
||||||
|
if (onItemSelected != null) {
|
||||||
|
onItemSelected!();
|
||||||
|
}
|
||||||
|
},
|
||||||
tristate: true,
|
tristate: true,
|
||||||
side: WidgetStateBorderSide.resolveWith(
|
side: WidgetStateBorderSide.resolveWith((states) {
|
||||||
(states) => const BorderSide(color: ColorsManager.grayBorder),
|
return 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,
|
||||||
),
|
),
|
||||||
_buildExpansionIcon(),
|
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: onItemSelected,
|
onTap: () {
|
||||||
|
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
|
? ColorsManager.blackColor // Change color to black when selected
|
||||||
: ColorsManager.lightGrayColor,
|
: ColorsManager.lightGrayColor, // Gray when not selected
|
||||||
fontWeight: FontWeight.w400,
|
fontWeight: FontWeight.w400,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -73,20 +92,6 @@ 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,7 +2,6 @@ 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';
|
||||||
@ -24,13 +23,7 @@ class SpaceTreeView extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _SpaceTreeViewState extends State<SpaceTreeView> {
|
class _SpaceTreeViewState extends State<SpaceTreeView> {
|
||||||
late final ScrollController _scrollController;
|
final ScrollController _scrollController = ScrollController();
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
_scrollController = ScrollController();
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
@ -41,161 +34,225 @@ 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) {
|
||||||
final communities = state.searchQuery.isNotEmpty
|
List<CommunityModel> list =
|
||||||
? state.filteredCommunity
|
state.searchQuery.isNotEmpty ? state.filteredCommunity : state.communityList;
|
||||||
: 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(
|
? subSectionContainerDecoration.copyWith(color: ColorsManager.whiteColors)
|
||||||
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: [
|
||||||
if (widget.isSide == true)
|
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),
|
topRight: Radius.circular(20), topLeft: Radius.circular(20)),
|
||||||
topLeft: Radius.circular(20),
|
),
|
||||||
),
|
child: Padding(
|
||||||
),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Padding(
|
child: Row(
|
||||||
padding: const EdgeInsets.all(8.0),
|
children: [
|
||||||
child: Row(
|
Expanded(
|
||||||
children: [
|
child: Container(
|
||||||
Expanded(
|
decoration: BoxDecoration(
|
||||||
child: Container(
|
borderRadius: const BorderRadius.all(Radius.circular(20)),
|
||||||
decoration: BoxDecoration(
|
border: Border.all(color: ColorsManager.grayBorder)),
|
||||||
borderRadius: const BorderRadius.all(
|
child: TextFormField(
|
||||||
Radius.circular(20),
|
style: context.textTheme.bodyMedium
|
||||||
),
|
?.copyWith(color: ColorsManager.blackColor),
|
||||||
border: Border.all(
|
onChanged: (value) {
|
||||||
color: ColorsManager.grayBorder,
|
context.read<SpaceTreeBloc>().add(SearchQueryEvent(value));
|
||||||
),
|
},
|
||||||
),
|
decoration: textBoxDecoration(radios: 20)!.copyWith(
|
||||||
child: TextFormField(
|
fillColor: Colors.white,
|
||||||
style: context.textTheme.bodyMedium?.copyWith(
|
suffixIcon: Padding(
|
||||||
color: ColorsManager.blackColor,
|
padding: const EdgeInsets.only(right: 16),
|
||||||
),
|
child: SvgPicture.asset(
|
||||||
onChanged: (value) =>
|
Assets.textFieldSearch,
|
||||||
context.read<SpaceTreeBloc>().add(
|
width: 24,
|
||||||
SearchQueryEvent(value),
|
height: 24,
|
||||||
),
|
),
|
||||||
decoration:
|
),
|
||||||
textBoxDecoration(radios: 20)?.copyWith(
|
hintStyle: context.textTheme.bodyMedium?.copyWith(
|
||||||
fillColor: Colors.white,
|
fontWeight: FontWeight.w400,
|
||||||
suffixIcon: Padding(
|
fontSize: 12,
|
||||||
padding: const EdgeInsets.only(right: 16),
|
color: ColorsManager.textGray),
|
||||||
child: SvgPicture.asset(
|
|
||||||
Assets.textFieldSearch,
|
|
||||||
width: 24,
|
|
||||||
height: 24,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
hintStyle:
|
|
||||||
context.textTheme.bodyMedium?.copyWith(
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
fontSize: 12,
|
|
||||||
color: ColorsManager.textGray,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
else
|
|
||||||
CustomSearchBar(
|
|
||||||
onSearchChanged: (query) => context.read<SpaceTreeBloc>().add(
|
|
||||||
SearchQueryEvent(query),
|
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
|
: 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())
|
||||||
: SidebarCommunitiesList(
|
: ListView(
|
||||||
onScrollToEnd: () => context.read<SpaceTreeBloc>().add(
|
shrinkWrap: true,
|
||||||
PaginationEvent(
|
scrollDirection: Axis.horizontal,
|
||||||
state.paginationModel,
|
children: [
|
||||||
state.communityList,
|
Container(
|
||||||
),
|
width: MediaQuery.sizeOf(context).width * 0.5,
|
||||||
),
|
padding: const EdgeInsets.all(8.0),
|
||||||
scrollController: _scrollController,
|
child: list.isEmpty
|
||||||
communities: communities,
|
? Center(
|
||||||
itemBuilder: (context, index) {
|
child: Text(
|
||||||
return CustomExpansionTileSpaceTree(
|
'No results found',
|
||||||
title: communities[index].name,
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
isSelected: state.selectedCommunities
|
color: ColorsManager.lightGrayColor,
|
||||||
.contains(communities[index].uuid),
|
fontWeight: FontWeight.w400,
|
||||||
isSoldCheck: state.selectedCommunities
|
),
|
||||||
.contains(communities[index].uuid),
|
),
|
||||||
onExpansionChanged: () =>
|
)
|
||||||
context.read<SpaceTreeBloc>().add(
|
: Scrollbar(
|
||||||
OnCommunityExpanded(
|
scrollbarOrientation: ScrollbarOrientation.left,
|
||||||
communities[index].uuid,
|
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,
|
||||||
|
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(),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -203,28 +260,22 @@ class _SpaceTreeViewState extends State<SpaceTreeView> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> _buildNestedSpaces(
|
List<Widget> _buildNestedSpaces(
|
||||||
BuildContext context,
|
BuildContext context, SpaceTreeState state, SpaceModel space, CommunityModel community) {
|
||||||
SpaceTreeState state,
|
|
||||||
SpaceModel space,
|
|
||||||
CommunityModel community,
|
|
||||||
) {
|
|
||||||
return space.children.map((child) {
|
return space.children.map((child) {
|
||||||
return CustomExpansionTileSpaceTree(
|
return CustomExpansionTileSpaceTree(
|
||||||
isSelected: state.selectedSpaces.contains(child.uuid) ||
|
isSelected:
|
||||||
state.soldCheck.contains(child.uuid),
|
state.selectedSpaces.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.read<SpaceTreeBloc>().add(
|
context
|
||||||
OnSpaceSelected(community, child.uuid ?? '', child.children),
|
.read<SpaceTreeBloc>()
|
||||||
);
|
.add(OnSpaceSelected(community, child.uuid ?? '', child.children));
|
||||||
widget.onSelect();
|
widget.onSelect();
|
||||||
},
|
},
|
||||||
onExpansionChanged: () {
|
onExpansionChanged: () {
|
||||||
context.read<SpaceTreeBloc>().add(
|
context.read<SpaceTreeBloc>().add(OnSpaceExpanded(community.uuid, child.uuid ?? ''));
|
||||||
OnSpaceExpanded(community.uuid, child.uuid ?? ''),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
children: _buildNestedSpaces(context, state, child, community),
|
children: _buildNestedSpaces(context, state, child, community),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
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';
|
||||||
@ -32,8 +30,6 @@ 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;
|
||||||
@ -41,16 +37,9 @@ 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) {
|
||||||
@ -97,14 +86,12 @@ 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: _width,
|
width: 300,
|
||||||
decoration: subSectionContainerDecoration,
|
decoration: subSectionContainerDecoration,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
@ -116,18 +103,10 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Visibility(
|
child: ListView(
|
||||||
visible: filteredCommunities.isNotEmpty,
|
children: filteredCommunities
|
||||||
replacement: const EmptySearchResultWidget(),
|
.map((community) => _buildCommunityTile(context, community))
|
||||||
child: SidebarCommunitiesList(
|
.toList(),
|
||||||
scrollController: _scrollController,
|
|
||||||
onScrollToEnd: () {},
|
|
||||||
communities: filteredCommunities,
|
|
||||||
itemBuilder: (context, index) => _buildCommunityTile(
|
|
||||||
context,
|
|
||||||
filteredCommunities[index],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -155,12 +134,11 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
|||||||
},
|
},
|
||||||
onExpansionChanged: (title, expanded) {},
|
onExpansionChanged: (title, expanded) {},
|
||||||
children: community.spaces
|
children: community.spaces
|
||||||
.where(
|
.where((space) {
|
||||||
(space) => {
|
final isDeleted = space.status != SpaceStatus.deleted;
|
||||||
SpaceStatus.deleted,
|
final isParentDeleted = space.status != SpaceStatus.parentDeleted;
|
||||||
SpaceStatus.parentDeleted,
|
return (isDeleted || isParentDeleted);
|
||||||
}.contains(space.status),
|
})
|
||||||
)
|
|
||||||
.map((space) => _buildSpaceTile(space: space, community: community))
|
.map((space) => _buildSpaceTile(space: space, community: community))
|
||||||
.toList(),
|
.toList(),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -321,13 +321,14 @@ class DevicesManagementApi {
|
|||||||
Future<bool> factoryReset(FactoryResetModel factoryReset, String uuid) async {
|
Future<bool> factoryReset(FactoryResetModel factoryReset, String uuid) async {
|
||||||
try {
|
try {
|
||||||
final response = await HTTPService().post(
|
final response = await HTTPService().post(
|
||||||
path: ApiEndpoints.factoryReset.replaceAll('{deviceUuid}', uuid),
|
path: ApiEndpoints.factoryReset,
|
||||||
body: factoryReset.toMap(),
|
body: factoryReset.toMap(),
|
||||||
showServerMessage: true,
|
showServerMessage: true,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return json['success'] ?? false;
|
return json['success'] ?? false;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint('Error fetching $e');
|
debugPrint('Error fetching $e');
|
||||||
|
|||||||
Reference in New Issue
Block a user