mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-17 02:25:31 +00:00
Compare commits
8 Commits
SP-1435-FE
...
SP-1433-FE
Author | SHA1 | Date | |
---|---|---|---|
ce253b2034 | |||
024fbcdb83 | |||
2a77483f46 | |||
a6fc99443b | |||
ae95d06482 | |||
18c886753d | |||
62bf4f2944 | |||
726c173a76 |
@ -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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
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/pages/routines/bloc/create_routine_bloc/create_routine_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_event.dart';
|
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_event.dart';
|
||||||
|
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_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/create_new_routines/create_new_routines.dart';
|
import 'package:syncrow_web/pages/routines/create_new_routines/create_new_routines.dart';
|
||||||
import 'package:syncrow_web/pages/routines/view/create_new_routine_view.dart';
|
import 'package:syncrow_web/pages/routines/view/create_new_routine_view.dart';
|
||||||
@ -9,7 +9,6 @@ import 'package:syncrow_web/pages/routines/widgets/main_routine_view/fetch_routi
|
|||||||
import 'package:syncrow_web/pages/routines/widgets/main_routine_view/routine_view_card.dart';
|
import 'package:syncrow_web/pages/routines/widgets/main_routine_view/routine_view_card.dart';
|
||||||
import 'package:syncrow_web/pages/space_tree/view/space_tree_view.dart';
|
import 'package:syncrow_web/pages/space_tree/view/space_tree_view.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 RoutinesView extends StatefulWidget {
|
class RoutinesView extends StatefulWidget {
|
||||||
const RoutinesView({super.key});
|
const RoutinesView({super.key});
|
||||||
@ -28,10 +27,9 @@ class _RoutinesViewState extends State<RoutinesView> {
|
|||||||
if (result == null) return;
|
if (result == null) return;
|
||||||
final communityId = result['community'];
|
final communityId = result['community'];
|
||||||
final spaceId = result['space'];
|
final spaceId = result['space'];
|
||||||
final bloc = BlocProvider.of<CreateRoutineBloc>(context);
|
final _bloc = BlocProvider.of<CreateRoutineBloc>(context);
|
||||||
final routineBloc = context.read<RoutineBloc>();
|
final routineBloc = context.read<RoutineBloc>();
|
||||||
bloc.add(
|
_bloc.add(SaveCommunityIdAndSpaceIdEvent(communityID: communityId, spaceID: spaceId));
|
||||||
SaveCommunityIdAndSpaceIdEvent(communityID: communityId, spaceID: spaceId));
|
|
||||||
await Future.delayed(const Duration(seconds: 1));
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
routineBloc.add(const CreateNewRoutineViewEvent(createRoutineView: true));
|
routineBloc.add(const CreateNewRoutineViewEvent(createRoutineView: true));
|
||||||
}
|
}
|
||||||
@ -56,41 +54,43 @@ class _RoutinesViewState extends State<RoutinesView> {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 4,
|
flex: 4,
|
||||||
child: SizedBox(
|
child: ListView(
|
||||||
height: context.screenHeight,
|
children: [
|
||||||
width: context.screenWidth,
|
Container(
|
||||||
child: SingleChildScrollView(
|
padding: const EdgeInsets.all(16),
|
||||||
padding: const EdgeInsetsDirectional.all(16),
|
height: MediaQuery.sizeOf(context).height,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
children: [
|
||||||
spacing: 16,
|
Text(
|
||||||
children: [
|
"Create New Routines",
|
||||||
Text(
|
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||||
"Create New Routines",
|
color: ColorsManager.grayColor,
|
||||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
fontWeight: FontWeight.bold,
|
||||||
color: ColorsManager.grayColor,
|
),
|
||||||
fontWeight: FontWeight.bold,
|
),
|
||||||
),
|
const SizedBox(height: 10),
|
||||||
),
|
RoutineViewCard(
|
||||||
RoutineViewCard(
|
isLoading: false,
|
||||||
isLoading: false,
|
onChanged: (v) {},
|
||||||
onChanged: (v) {},
|
status: '',
|
||||||
status: '',
|
spaceId: '',
|
||||||
spaceId: '',
|
automationId: '',
|
||||||
automationId: '',
|
communityId: '',
|
||||||
communityId: '',
|
sceneId: '',
|
||||||
sceneId: '',
|
cardType: '',
|
||||||
cardType: '',
|
spaceName: '',
|
||||||
spaceName: '',
|
onTap: () => _handleRoutineCreation(context),
|
||||||
onTap: () => _handleRoutineCreation(context),
|
icon: Icons.add,
|
||||||
icon: Icons.add,
|
textString: '',
|
||||||
textString: '',
|
),
|
||||||
),
|
const SizedBox(height: 15),
|
||||||
const FetchRoutineScenesAutomation(),
|
const Expanded(child: FetchRoutineScenesAutomation()),
|
||||||
],
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 50),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
@ -8,182 +8,211 @@ import 'package:syncrow_web/utils/constants/assets.dart';
|
|||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
||||||
|
|
||||||
class FetchRoutineScenesAutomation extends StatelessWidget
|
class FetchRoutineScenesAutomation extends StatefulWidget {
|
||||||
with HelperResponsiveLayout {
|
|
||||||
const FetchRoutineScenesAutomation({super.key});
|
const FetchRoutineScenesAutomation({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<FetchRoutineScenesAutomation> createState() =>
|
||||||
|
_FetchRoutineScenesState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
||||||
|
with HelperResponsiveLayout {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<RoutineBloc, RoutineState>(
|
return BlocBuilder<RoutineBloc, RoutineState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
if (state.isLoading) return const Center(child: CircularProgressIndicator());
|
return state.isLoading
|
||||||
|
? const Center(
|
||||||
return SingleChildScrollView(
|
child: CircularProgressIndicator(),
|
||||||
child: Padding(
|
)
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
: SingleChildScrollView(
|
||||||
child: Column(
|
child: Padding(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||||
mainAxisSize: MainAxisSize.min,
|
child: Column(
|
||||||
children: [
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
_buildListTitle(context, "Scenes (Tab to Run)"),
|
mainAxisSize: MainAxisSize.min,
|
||||||
const SizedBox(height: 10),
|
children: [
|
||||||
Visibility(
|
Text(
|
||||||
visible: state.scenes.isNotEmpty,
|
"Scenes (Tab to Run)",
|
||||||
replacement: _buildEmptyState(context, "No scenes found"),
|
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||||
child: SizedBox(
|
color: ColorsManager.grayColor,
|
||||||
height: 200,
|
fontWeight: FontWeight.bold,
|
||||||
child: _buildScenes(state),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
_buildListTitle(context, "Automations"),
|
|
||||||
const SizedBox(height: 3),
|
|
||||||
Visibility(
|
|
||||||
visible: state.automations.isNotEmpty,
|
|
||||||
replacement: _buildEmptyState(context, "No automations found"),
|
|
||||||
child: SizedBox(
|
|
||||||
height: 200,
|
|
||||||
child: _buildAutomations(state),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildAutomations(RoutineState state) {
|
|
||||||
return ListView.builder(
|
|
||||||
scrollDirection: Axis.horizontal,
|
|
||||||
itemCount: state.automations.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final isLoading = state.automations.contains(state.automations[index].id);
|
|
||||||
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
right: isSmallScreenSize(context) ? 4.0 : 8.0,
|
|
||||||
),
|
|
||||||
child: RoutineViewCard(
|
|
||||||
isLoading: isLoading,
|
|
||||||
onChanged: (v) {
|
|
||||||
context.read<RoutineBloc>().add(
|
|
||||||
UpdateAutomationStatus(
|
|
||||||
automationId: state.automations[index].id,
|
|
||||||
automationStatusUpdate: AutomationStatusUpdate(
|
|
||||||
spaceUuid: state.automations[index].spaceId,
|
|
||||||
isEnable: v,
|
|
||||||
),
|
|
||||||
communityId: state.automations[index].communityId,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
status: state.automations[index].status,
|
|
||||||
communityId: '',
|
|
||||||
spaceId: state.automations[index].spaceId,
|
|
||||||
sceneId: '',
|
|
||||||
automationId: state.automations[index].id,
|
|
||||||
cardType: 'automations',
|
|
||||||
spaceName: state.automations[index].spaceName,
|
|
||||||
onTap: () {
|
|
||||||
BlocProvider.of<RoutineBloc>(context).add(
|
|
||||||
const CreateNewRoutineViewEvent(
|
|
||||||
createRoutineView: true,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
context.read<RoutineBloc>().add(
|
|
||||||
GetAutomationDetails(
|
|
||||||
automationId: state.automations[index].id,
|
|
||||||
isAutomation: true,
|
|
||||||
isUpdate: true,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
textString: state.automations[index].name,
|
|
||||||
icon: state.automations[index].icon ?? Assets.automation,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildScenes(RoutineState state) {
|
|
||||||
return ListView.builder(
|
|
||||||
scrollDirection: Axis.horizontal,
|
|
||||||
itemCount: state.scenes.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final scene = state.scenes[index];
|
|
||||||
final isLoading = state.loadingSceneId == scene.id;
|
|
||||||
|
|
||||||
return Padding(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
right: isSmallScreenSize(context) ? 4.0 : 8.0,
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
RoutineViewCard(
|
|
||||||
isLoading: isLoading,
|
|
||||||
sceneOnTap: () {
|
|
||||||
context.read<RoutineBloc>().add(
|
|
||||||
SceneTrigger(
|
|
||||||
sceneId: scene.id,
|
|
||||||
name: scene.name,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
status: state.scenes[index].status,
|
|
||||||
communityId: state.scenes[index].communityId,
|
|
||||||
spaceId: state.scenes[index].spaceId,
|
|
||||||
sceneId: state.scenes[index].sceneTuyaId!,
|
|
||||||
automationId: state.scenes[index].id,
|
|
||||||
cardType: 'scenes',
|
|
||||||
spaceName: state.scenes[index].spaceName,
|
|
||||||
onTap: () {
|
|
||||||
BlocProvider.of<RoutineBloc>(context).add(
|
|
||||||
const CreateNewRoutineViewEvent(
|
|
||||||
createRoutineView: true,
|
|
||||||
),
|
),
|
||||||
);
|
const SizedBox(height: 10),
|
||||||
context.read<RoutineBloc>().add(
|
if (state.scenes.isEmpty)
|
||||||
GetSceneDetails(
|
Text(
|
||||||
sceneId: state.scenes[index].id,
|
"No scenes found",
|
||||||
isTabToRun: true,
|
style: context.textTheme.bodyMedium?.copyWith(
|
||||||
isUpdate: true,
|
color: ColorsManager.grayColor,
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
},
|
if (state.scenes.isNotEmpty)
|
||||||
textString: state.scenes[index].name,
|
SizedBox(
|
||||||
icon: state.scenes[index].icon ?? Assets.logoHorizontal,
|
height: 200,
|
||||||
isFromScenes: true,
|
child: ListView.builder(
|
||||||
iconInBytes: state.scenes[index].iconInBytes,
|
shrinkWrap: true,
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
itemCount: state.scenes.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final scene = state.scenes[index];
|
||||||
|
final isLoading =
|
||||||
|
state.loadingSceneId == scene.id;
|
||||||
|
|
||||||
|
return Padding(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
right:
|
||||||
|
isSmallScreenSize(context) ? 4.0 : 8.0,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
RoutineViewCard(
|
||||||
|
isLoading: isLoading,
|
||||||
|
sceneOnTap: () {
|
||||||
|
context.read<RoutineBloc>().add(
|
||||||
|
SceneTrigger(
|
||||||
|
sceneId: scene.id,
|
||||||
|
name: scene.name));
|
||||||
|
},
|
||||||
|
status: state.scenes[index].status,
|
||||||
|
communityId:
|
||||||
|
state.scenes[index].communityId ??
|
||||||
|
'',
|
||||||
|
spaceId: state.scenes[index].spaceId,
|
||||||
|
sceneId:
|
||||||
|
state.scenes[index].sceneTuyaId!,
|
||||||
|
automationId: state.scenes[index].id,
|
||||||
|
cardType: 'scenes',
|
||||||
|
spaceName:
|
||||||
|
state.scenes[index].spaceName,
|
||||||
|
onTap: () {
|
||||||
|
BlocProvider.of<RoutineBloc>(context)
|
||||||
|
.add(
|
||||||
|
const CreateNewRoutineViewEvent(
|
||||||
|
createRoutineView: true),
|
||||||
|
);
|
||||||
|
context.read<RoutineBloc>().add(
|
||||||
|
GetSceneDetails(
|
||||||
|
sceneId:
|
||||||
|
state.scenes[index].id,
|
||||||
|
isTabToRun: true,
|
||||||
|
isUpdate: true,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
textString: state.scenes[index].name,
|
||||||
|
icon: state.scenes[index].icon ??
|
||||||
|
Assets.logoHorizontal,
|
||||||
|
isFromScenes: true,
|
||||||
|
iconInBytes:
|
||||||
|
state.scenes[index].iconInBytes,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Text(
|
||||||
|
"Automations",
|
||||||
|
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||||
|
color: ColorsManager.grayColor,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 3),
|
||||||
|
if (state.automations.isEmpty)
|
||||||
|
Text(
|
||||||
|
"No automations found",
|
||||||
|
style: context.textTheme.bodyMedium?.copyWith(
|
||||||
|
color: ColorsManager.grayColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (state.automations.isNotEmpty)
|
||||||
|
SizedBox(
|
||||||
|
height: 200,
|
||||||
|
|
||||||
|
child: ListView.builder(
|
||||||
|
shrinkWrap: true,
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
itemCount: state.automations.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final isLoading = state.automations!
|
||||||
|
.contains(state.automations[index].id);
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
right: isSmallScreenSize(context)
|
||||||
|
? 4.0
|
||||||
|
: 8.0,
|
||||||
|
),
|
||||||
|
child: RoutineViewCard(
|
||||||
|
isLoading: isLoading,
|
||||||
|
onChanged: (v) {
|
||||||
|
context.read<RoutineBloc>().add(
|
||||||
|
UpdateAutomationStatus(
|
||||||
|
automationId: state
|
||||||
|
.automations[index].id,
|
||||||
|
automationStatusUpdate:
|
||||||
|
AutomationStatusUpdate(
|
||||||
|
spaceUuid: state
|
||||||
|
.automations[
|
||||||
|
index]
|
||||||
|
.spaceId,
|
||||||
|
isEnable: v),
|
||||||
|
communityId: state
|
||||||
|
.automations[index]
|
||||||
|
.communityId,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
status: state.automations[index].status,
|
||||||
|
communityId: '',
|
||||||
|
spaceId:
|
||||||
|
state.automations[index].spaceId,
|
||||||
|
sceneId: '',
|
||||||
|
automationId:
|
||||||
|
state.automations[index].id,
|
||||||
|
cardType: 'automations',
|
||||||
|
spaceName:
|
||||||
|
state.automations[index].spaceName,
|
||||||
|
onTap: () {
|
||||||
|
BlocProvider.of<RoutineBloc>(context)
|
||||||
|
.add(
|
||||||
|
const CreateNewRoutineViewEvent(
|
||||||
|
createRoutineView: true),
|
||||||
|
);
|
||||||
|
context.read<RoutineBloc>().add(
|
||||||
|
GetAutomationDetails(
|
||||||
|
automationId: state
|
||||||
|
.automations[index].id,
|
||||||
|
isAutomation: true,
|
||||||
|
isUpdate: true),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
textString:
|
||||||
|
state.automations[index].name,
|
||||||
|
icon: state.automations[index].icon ??
|
||||||
|
Assets.automation,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
);
|
||||||
),
|
},
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildListTitle(BuildContext context, String title) {
|
|
||||||
return Text(
|
|
||||||
title,
|
|
||||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
|
||||||
color: ColorsManager.grayColor,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildEmptyState(BuildContext context, String title) {
|
|
||||||
return Text(
|
|
||||||
title,
|
|
||||||
style: context.textTheme.bodyMedium?.copyWith(
|
|
||||||
color: ColorsManager.grayColor,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
@ -67,6 +66,7 @@ class _RoutineViewCardState extends State<RoutineViewCard> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
// Use widget.<mixinMethod> instead of just <mixinMethod>
|
||||||
final double cardWidth = widget.isSmallScreenSize(context)
|
final double cardWidth = widget.isSmallScreenSize(context)
|
||||||
? 120
|
? 120
|
||||||
: widget.isMediumScreenSize(context)
|
: widget.isMediumScreenSize(context)
|
||||||
@ -127,23 +127,22 @@ class _RoutineViewCardState extends State<RoutineViewCard> {
|
|||||||
)
|
)
|
||||||
else
|
else
|
||||||
CupertinoSwitch(
|
CupertinoSwitch(
|
||||||
activeTrackColor: ColorsManager.primaryColor,
|
activeColor: ColorsManager.primaryColor,
|
||||||
value: widget.status == 'enable',
|
value: widget.status == 'enable',
|
||||||
onChanged: widget.onChanged,
|
onChanged: widget.onChanged,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: const SizedBox(),
|
: const SizedBox(),
|
||||||
Column(
|
InkWell(
|
||||||
children: [
|
onTap: widget.onTap,
|
||||||
Center(
|
child: Column(
|
||||||
child: InkWell(
|
children: [
|
||||||
customBorder: const CircleBorder(),
|
Center(
|
||||||
onTap: widget.onTap,
|
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: ColorsManager.graysColor,
|
color: ColorsManager.graysColor,
|
||||||
shape: BoxShape.circle,
|
borderRadius: BorderRadius.circular(120),
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: ColorsManager.greyColor,
|
color: ColorsManager.greyColor,
|
||||||
width: 2.0,
|
width: 2.0,
|
||||||
@ -159,8 +158,7 @@ class _RoutineViewCardState extends State<RoutineViewCard> {
|
|||||||
height: iconSize,
|
height: iconSize,
|
||||||
width: iconSize,
|
width: iconSize,
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
errorBuilder: (context, error, stackTrace) =>
|
errorBuilder: (context, error, stackTrace) => Image.asset(
|
||||||
Image.asset(
|
|
||||||
Assets.logo,
|
Assets.logo,
|
||||||
height: iconSize,
|
height: iconSize,
|
||||||
width: iconSize,
|
width: iconSize,
|
||||||
@ -173,8 +171,7 @@ class _RoutineViewCardState extends State<RoutineViewCard> {
|
|||||||
width: iconSize,
|
width: iconSize,
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
)
|
)
|
||||||
: (widget.icon is String &&
|
: (widget.icon is String && widget.icon.endsWith('.svg'))
|
||||||
widget.icon.endsWith('.svg'))
|
|
||||||
? SvgPicture.asset(
|
? SvgPicture.asset(
|
||||||
height: iconSize,
|
height: iconSize,
|
||||||
width: iconSize,
|
width: iconSize,
|
||||||
@ -184,54 +181,51 @@ class _RoutineViewCardState extends State<RoutineViewCard> {
|
|||||||
: Icon(
|
: Icon(
|
||||||
widget.icon,
|
widget.icon,
|
||||||
color: ColorsManager.dialogBlueTitle,
|
color: ColorsManager.dialogBlueTitle,
|
||||||
size: widget.isSmallScreenSize(context)
|
size: widget.isSmallScreenSize(context) ? 30 : 40,
|
||||||
? 30
|
|
||||||
: 40,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 8),
|
||||||
const SizedBox(height: 8),
|
Padding(
|
||||||
Padding(
|
padding: const EdgeInsets.symmetric(horizontal: 3),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 3),
|
child: Column(
|
||||||
child: Column(
|
children: [
|
||||||
children: [
|
Text(
|
||||||
Text(
|
widget.textString,
|
||||||
widget.textString,
|
textAlign: TextAlign.center,
|
||||||
textAlign: TextAlign.center,
|
overflow: TextOverflow.ellipsis,
|
||||||
overflow: TextOverflow.ellipsis,
|
maxLines: 1,
|
||||||
maxLines: 1,
|
style: context.textTheme.bodySmall?.copyWith(
|
||||||
style: context.textTheme.bodySmall?.copyWith(
|
color: ColorsManager.blackColor,
|
||||||
color: ColorsManager.blackColor,
|
fontSize: widget.isSmallScreenSize(context) ? 10 : 12,
|
||||||
fontSize: widget.isSmallScreenSize(context) ? 10 : 12,
|
),
|
||||||
),
|
),
|
||||||
),
|
if (widget.spaceName != '')
|
||||||
if (widget.spaceName != '')
|
Row(
|
||||||
Row(
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
children: [
|
||||||
children: [
|
SvgPicture.asset(
|
||||||
SvgPicture.asset(
|
Assets.spaceLocationIcon,
|
||||||
Assets.spaceLocationIcon,
|
fit: BoxFit.contain,
|
||||||
fit: BoxFit.contain,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
widget.spaceName,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
maxLines: 1,
|
|
||||||
style: context.textTheme.bodySmall?.copyWith(
|
|
||||||
color: ColorsManager.blackColor,
|
|
||||||
fontSize:
|
|
||||||
widget.isSmallScreenSize(context) ? 10 : 12,
|
|
||||||
),
|
),
|
||||||
),
|
Text(
|
||||||
],
|
widget.spaceName,
|
||||||
),
|
textAlign: TextAlign.center,
|
||||||
],
|
overflow: TextOverflow.ellipsis,
|
||||||
|
maxLines: 1,
|
||||||
|
style: context.textTheme.bodySmall?.copyWith(
|
||||||
|
color: ColorsManager.blackColor,
|
||||||
|
fontSize: widget.isSmallScreenSize(context) ? 10 : 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -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?.call(),
|
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),
|
||||||
);
|
);
|
||||||
|
@ -592,8 +592,6 @@ 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,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(),
|
||||||
);
|
);
|
||||||
|
@ -4,222 +4,204 @@ 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 StatelessWidget {
|
class CreateSubSpaceDialog extends StatefulWidget {
|
||||||
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 Function(List<SubspaceModel>?)? onSave;
|
final void Function(List<SubspaceModel>?)? onSave;
|
||||||
|
|
||||||
const CreateSubSpaceDialog(
|
const CreateSubSpaceDialog({
|
||||||
{Key? key,
|
required this.dialogTitle,
|
||||||
required this.isEdit,
|
required this.spaceName,
|
||||||
required this.dialogTitle,
|
required this.products,
|
||||||
this.existingSubSpaces,
|
required this.onSave,
|
||||||
required this.spaceName,
|
this.existingSubSpaces,
|
||||||
required this.spaceTags,
|
super.key,
|
||||||
required this.products,
|
});
|
||||||
required this.onSave})
|
|
||||||
: super(key: key);
|
@override
|
||||||
|
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) {
|
||||||
final screenWidth = MediaQuery.of(context).size.width;
|
return BlocProvider(
|
||||||
final textController = TextEditingController();
|
create: (_) {
|
||||||
|
final bloc = SubSpaceBloc();
|
||||||
return Dialog(
|
if (widget.existingSubSpaces != null) {
|
||||||
shape: RoundedRectangleBorder(
|
for (final subSpace in widget.existingSubSpaces ?? []) {
|
||||||
borderRadius: BorderRadius.circular(20),
|
bloc.add(AddSubSpace(subSpace));
|
||||||
),
|
|
||||||
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(
|
||||||
color: ColorsManager.whiteColors,
|
width: context.screenWidth * 0.35,
|
||||||
child: SizedBox(
|
color: ColorsManager.whiteColors,
|
||||||
width: screenWidth * 0.35,
|
padding: const EdgeInsets.all(16),
|
||||||
child: Padding(
|
child: Column(
|
||||||
padding: const EdgeInsets.all(16.0),
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
child: Column(
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
children: [
|
||||||
mainAxisSize: MainAxisSize.min,
|
Text(
|
||||||
|
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: [
|
||||||
Text(
|
...state.subSpaces.asMap().entries.map(
|
||||||
dialogTitle,
|
(entry) {
|
||||||
style: Theme.of(context)
|
final index = entry.key;
|
||||||
.textTheme
|
final subSpace = entry.value;
|
||||||
.headlineLarge
|
|
||||||
?.copyWith(color: ColorsManager.blackColor),
|
final lowerName = subSpace.subspaceName.toLowerCase();
|
||||||
|
|
||||||
|
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),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
SizedBox(
|
||||||
Container(
|
width: 200,
|
||||||
width: screenWidth * 0.35,
|
child: TextField(
|
||||||
padding: const EdgeInsets.symmetric(
|
controller: _subspaceNameController,
|
||||||
vertical: 10.0, horizontal: 16.0),
|
decoration: InputDecoration(
|
||||||
decoration: BoxDecoration(
|
border: InputBorder.none,
|
||||||
color: ColorsManager.boxColor,
|
hintText: state.subSpaces.isEmpty
|
||||||
borderRadius: BorderRadius.circular(10),
|
? 'Please enter the name'
|
||||||
),
|
: null,
|
||||||
child: Wrap(
|
hintStyle: context.textTheme.bodySmall?.copyWith(
|
||||||
spacing: 8.0,
|
color: ColorsManager.lightGrayColor,
|
||||||
runSpacing: 8.0,
|
),
|
||||||
children: [
|
),
|
||||||
...state.subSpaces.asMap().entries.map(
|
onSubmitted: (value) {
|
||||||
(entry) {
|
final trimmedValue = value.trim();
|
||||||
final index = entry.key;
|
if (trimmedValue.isNotEmpty) {
|
||||||
final subSpace = entry.value;
|
context.read<SubSpaceBloc>().add(
|
||||||
|
AddSubSpace(
|
||||||
final lowerName =
|
SubspaceModel(
|
||||||
subSpace.subspaceName.toLowerCase();
|
subspaceName: trimmedValue,
|
||||||
|
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(
|
);
|
||||||
Icons.close,
|
_subspaceNameController.clear();
|
||||||
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,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/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';
|
||||||
@ -51,6 +54,9 @@ class CreateSubspaceModelChipsBox extends StatelessWidget {
|
|||||||
return SubspaceChip(
|
return SubspaceChip(
|
||||||
subSpace: subSpace,
|
subSpace: subSpace,
|
||||||
isDuplicate: isDuplicate,
|
isDuplicate: isDuplicate,
|
||||||
|
onDeleted: () => context.read<SubSpaceModelBloc>().add(
|
||||||
|
RemoveSubSpaceModel(subSpace),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -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/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';
|
||||||
@ -11,10 +8,12 @@ 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) {
|
||||||
@ -50,9 +49,7 @@ class SubspaceChip extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
onDeleted: () => context.read<SubSpaceModelBloc>().add(
|
onDeleted: onDeleted,
|
||||||
RemoveSubSpaceModel(subSpace),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,11 +145,13 @@ 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,
|
||||||
spaceName: spaceNameController.text,
|
spaceNameController: spaceNameController,
|
||||||
pageContext: pageContext,
|
pageContext: pageContext,
|
||||||
otherSpaceModels: otherSpaceModels,
|
otherSpaceModels: otherSpaceModels,
|
||||||
allSpaceModels: allSpaceModels,
|
allSpaceModels: allSpaceModels,
|
||||||
|
@ -10,152 +10,139 @@ 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 {
|
||||||
const TagChipDisplay({
|
final double screenWidth;
|
||||||
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 String spaceName;
|
final TextEditingController spaceNameController;
|
||||||
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;
|
||||||
|
|
||||||
Map<ProductModel, int> get _groupedTags {
|
const TagChipDisplay(BuildContext context,
|
||||||
final spaceTags = spaceModel?.tags ?? <Tag>[];
|
{Key? key,
|
||||||
|
required this.screenWidth,
|
||||||
final subspaces = spaceModel?.subspaceModels ?? [];
|
required this.spaceModel,
|
||||||
final subspaceTags = subspaces.expand((e) => e.tags ?? <Tag>[]).toList();
|
required this.products,
|
||||||
|
required this.subspaces,
|
||||||
return TagHelper.groupTags([...spaceTags, ...subspaceTags]);
|
required this.allTags,
|
||||||
}
|
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) {
|
||||||
final hasTags = spaceModel?.tags?.isNotEmpty ?? false;
|
return (spaceModel?.tags?.isNotEmpty == true ||
|
||||||
final hasSubspaceTags =
|
spaceModel?.subspaceModels?.any((subspace) => subspace.tags?.isNotEmpty == true) ==
|
||||||
spaceModel?.subspaceModels?.any((e) => e.tags?.isNotEmpty ?? false) ?? false;
|
true)
|
||||||
|
? 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();
|
||||||
|
|
||||||
if (hasTags || hasSubspaceTags) {
|
await showDialog<bool>(
|
||||||
return Container(
|
barrierDismissible: false,
|
||||||
width: context.screenWidth * 0.25,
|
context: context,
|
||||||
padding: const EdgeInsets.all(8),
|
builder: (context) => AssignTagModelsDialog(
|
||||||
decoration: BoxDecoration(
|
products: products,
|
||||||
color: ColorsManager.textFieldGreyColor,
|
allSpaceModels: allSpaceModels,
|
||||||
borderRadius: BorderRadius.circular(15),
|
subspaces: subspaces,
|
||||||
border: Border.all(
|
pageContext: pageContext,
|
||||||
color: ColorsManager.textFieldGreyColor,
|
allTags: allTags,
|
||||||
width: 3,
|
spaceModel: spaceModel,
|
||||||
),
|
otherSpaceModels: otherSpaceModels,
|
||||||
),
|
initialTags: TagHelper.generateInitialTags(
|
||||||
child: Wrap(
|
subspaces: subspaces, spaceTagModels: spaceModel?.tags ?? []),
|
||||||
spacing: 8,
|
title: 'Edit Device',
|
||||||
runSpacing: 8,
|
addedProducts: TagHelper.createInitialSelectedProducts(
|
||||||
children: [
|
spaceModel?.tags ?? [], subspaces),
|
||||||
..._groupedTags.entries.map((entry) => _buildChip(context, entry)),
|
spaceName: spaceModel?.modelName ?? '',
|
||||||
_buildEditChip(context),
|
projectTags: projectTags,
|
||||||
],
|
));
|
||||||
),
|
})
|
||||||
);
|
],
|
||||||
}
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: TextButton(
|
||||||
|
onPressed: () async {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
|
||||||
return _buildAddDevicesButton(context);
|
await showDialog<bool>(
|
||||||
}
|
barrierDismissible: false,
|
||||||
|
context: context,
|
||||||
Widget _buildEditChip(BuildContext context) {
|
builder: (context) => AddDeviceTypeModelWidget(
|
||||||
return EditChip(
|
products: products,
|
||||||
onTap: () => showDialog<void>(
|
subspaces: subspaces,
|
||||||
context: context,
|
allTags: allTags,
|
||||||
builder: (context) => AssignTagModelsDialog(
|
spaceName: spaceNameController.text,
|
||||||
products: products,
|
pageContext: pageContext,
|
||||||
allSpaceModels: allSpaceModels,
|
isCreate: true,
|
||||||
subspaces: subspaces,
|
spaceModel: spaceModel,
|
||||||
pageContext: pageContext,
|
otherSpaceModels: otherSpaceModels,
|
||||||
allTags: allTags,
|
projectTags: projectTags,
|
||||||
spaceModel: spaceModel,
|
),
|
||||||
otherSpaceModels: otherSpaceModels,
|
);
|
||||||
initialTags: TagHelper.generateInitialTags(
|
},
|
||||||
subspaces: subspaces,
|
style: TextButton.styleFrom(
|
||||||
spaceTagModels: spaceModel?.tags ?? [],
|
padding: EdgeInsets.zero,
|
||||||
),
|
),
|
||||||
title: 'Edit Device',
|
child: const ButtonContentWidget(
|
||||||
addedProducts: TagHelper.createInitialSelectedProducts(
|
icon: Icons.add,
|
||||||
spaceModel?.tags ?? [],
|
label: 'Add Devices',
|
||||||
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