mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-17 02:25:31 +00:00
Compare commits
42 Commits
SP-1330-FE
...
SP-1447-FE
Author | SHA1 | Date | |
---|---|---|---|
d8afb562eb | |||
32b45ea5d7 | |||
62fb8b3097 | |||
065bd33511 | |||
b9ab782c01 | |||
4d5adf948c | |||
e45f57ca03 | |||
9431eb79c1 | |||
70f1f39fce | |||
f912b41fd8 | |||
977875f1f2 | |||
8136804694 | |||
ce253b2034 | |||
024fbcdb83 | |||
a8430a7d3d | |||
7ef6020dd8 | |||
2a77483f46 | |||
a6fc99443b | |||
ae95d06482 | |||
18c886753d | |||
62bf4f2944 | |||
726c173a76 | |||
d538b3667e | |||
72ae3b1727 | |||
9044645f95 | |||
7699453e6d | |||
d1a21be983 | |||
db8e5a4aa6 | |||
fa5bb350c3 | |||
920827d763 | |||
d3902d622e | |||
a4432656ab | |||
90e0d2f52b | |||
08e5e17910 | |||
f57348e5cd | |||
be168aed93 | |||
a66784473f | |||
c0a963ded5 | |||
7945cefe53 | |||
7d0e50fb1d | |||
117f6190dd | |||
748c67fd8b |
@ -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),
|
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
},
|
],
|
||||||
),
|
);
|
||||||
),
|
},
|
||||||
],
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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_event.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_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/routines/bloc/create_routine_bloc/create_routine_event.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,6 +9,7 @@ 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});
|
||||||
@ -27,9 +28,10 @@ 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(SaveCommunityIdAndSpaceIdEvent(communityID: communityId, spaceID: spaceId));
|
bloc.add(
|
||||||
|
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));
|
||||||
}
|
}
|
||||||
@ -54,43 +56,41 @@ class _RoutinesViewState extends State<RoutinesView> {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 4,
|
flex: 4,
|
||||||
child: ListView(
|
child: SizedBox(
|
||||||
children: [
|
height: context.screenHeight,
|
||||||
Container(
|
width: context.screenWidth,
|
||||||
padding: const EdgeInsets.all(16),
|
child: SingleChildScrollView(
|
||||||
height: MediaQuery.sizeOf(context).height,
|
padding: const EdgeInsetsDirectional.all(16),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
Text(
|
spacing: 16,
|
||||||
"Create New Routines",
|
children: [
|
||||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
Text(
|
||||||
color: ColorsManager.grayColor,
|
"Create New Routines",
|
||||||
fontWeight: FontWeight.bold,
|
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||||
),
|
color: ColorsManager.grayColor,
|
||||||
),
|
fontWeight: FontWeight.bold,
|
||||||
const SizedBox(height: 10),
|
),
|
||||||
RoutineViewCard(
|
),
|
||||||
isLoading: false,
|
RoutineViewCard(
|
||||||
onChanged: (v) {},
|
isLoading: false,
|
||||||
status: '',
|
onChanged: (v) {},
|
||||||
spaceId: '',
|
status: '',
|
||||||
automationId: '',
|
spaceId: '',
|
||||||
communityId: '',
|
automationId: '',
|
||||||
sceneId: '',
|
communityId: '',
|
||||||
cardType: '',
|
sceneId: '',
|
||||||
spaceName: '',
|
cardType: '',
|
||||||
onTap: () => _handleRoutineCreation(context),
|
spaceName: '',
|
||||||
icon: Icons.add,
|
onTap: () => _handleRoutineCreation(context),
|
||||||
textString: '',
|
icon: Icons.add,
|
||||||
),
|
textString: '',
|
||||||
const SizedBox(height: 15),
|
),
|
||||||
const Expanded(child: FetchRoutineScenesAutomation()),
|
const FetchRoutineScenesAutomation(),
|
||||||
],
|
],
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 50),
|
),
|
||||||
],
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
@ -225,7 +225,7 @@ class DraggableCard extends StatelessWidget {
|
|||||||
if (function.functionCode == 'temp_set' || function.functionCode == 'temp_current') {
|
if (function.functionCode == 'temp_set' || function.functionCode == 'temp_current') {
|
||||||
return '${(function.value / 10).toStringAsFixed(0)}°C';
|
return '${(function.value / 10).toStringAsFixed(0)}°C';
|
||||||
} else if (function.functionCode.contains('countdown')) {
|
} else if (function.functionCode.contains('countdown')) {
|
||||||
final seconds = function.value.toInt();
|
final seconds = function.value?.toInt() ?? 0;
|
||||||
if (seconds >= 3600) {
|
if (seconds >= 3600) {
|
||||||
final hours = (seconds / 3600).floor();
|
final hours = (seconds / 3600).floor();
|
||||||
final remainingMinutes = ((seconds % 3600) / 60).floor();
|
final remainingMinutes = ((seconds % 3600) / 60).floor();
|
||||||
|
@ -8,211 +8,182 @@ 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 StatefulWidget {
|
class FetchRoutineScenesAutomation extends StatelessWidget
|
||||||
const FetchRoutineScenesAutomation({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<FetchRoutineScenesAutomation> createState() =>
|
|
||||||
_FetchRoutineScenesState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _FetchRoutineScenesState extends State<FetchRoutineScenesAutomation>
|
|
||||||
with HelperResponsiveLayout {
|
with HelperResponsiveLayout {
|
||||||
@override
|
const FetchRoutineScenesAutomation({super.key});
|
||||||
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) {
|
||||||
return state.isLoading
|
if (state.isLoading) return const Center(child: CircularProgressIndicator());
|
||||||
? const Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
)
|
|
||||||
: SingleChildScrollView(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"Scenes (Tab to Run)",
|
|
||||||
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
|
||||||
color: ColorsManager.grayColor,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
if (state.scenes.isEmpty)
|
|
||||||
Text(
|
|
||||||
"No scenes found",
|
|
||||||
style: context.textTheme.bodyMedium?.copyWith(
|
|
||||||
color: ColorsManager.grayColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (state.scenes.isNotEmpty)
|
|
||||||
SizedBox(
|
|
||||||
height: 200,
|
|
||||||
child: ListView.builder(
|
|
||||||
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(
|
return SingleChildScrollView(
|
||||||
padding: EdgeInsets.only(
|
child: Padding(
|
||||||
right:
|
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||||
isSmallScreenSize(context) ? 4.0 : 8.0,
|
child: Column(
|
||||||
),
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
child: Column(
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
RoutineViewCard(
|
_buildListTitle(context, "Scenes (Tab to Run)"),
|
||||||
isLoading: isLoading,
|
const SizedBox(height: 10),
|
||||||
sceneOnTap: () {
|
Visibility(
|
||||||
context.read<RoutineBloc>().add(
|
visible: state.scenes.isNotEmpty,
|
||||||
SceneTrigger(
|
replacement: _buildEmptyState(context, "No scenes found"),
|
||||||
sceneId: scene.id,
|
child: SizedBox(
|
||||||
name: scene.name));
|
height: 200,
|
||||||
},
|
child: _buildScenes(state),
|
||||||
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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
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,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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,4 +1,5 @@
|
|||||||
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';
|
||||||
@ -66,7 +67,6 @@ 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,22 +127,23 @@ class _RoutineViewCardState extends State<RoutineViewCard> {
|
|||||||
)
|
)
|
||||||
else
|
else
|
||||||
CupertinoSwitch(
|
CupertinoSwitch(
|
||||||
activeColor: ColorsManager.primaryColor,
|
activeTrackColor: ColorsManager.primaryColor,
|
||||||
value: widget.status == 'enable',
|
value: widget.status == 'enable',
|
||||||
onChanged: widget.onChanged,
|
onChanged: widget.onChanged,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
: const SizedBox(),
|
: const SizedBox(),
|
||||||
InkWell(
|
Column(
|
||||||
onTap: widget.onTap,
|
children: [
|
||||||
child: Column(
|
Center(
|
||||||
children: [
|
child: InkWell(
|
||||||
Center(
|
customBorder: const CircleBorder(),
|
||||||
|
onTap: widget.onTap,
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: ColorsManager.graysColor,
|
color: ColorsManager.graysColor,
|
||||||
borderRadius: BorderRadius.circular(120),
|
shape: BoxShape.circle,
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: ColorsManager.greyColor,
|
color: ColorsManager.greyColor,
|
||||||
width: 2.0,
|
width: 2.0,
|
||||||
@ -158,7 +159,8 @@ class _RoutineViewCardState extends State<RoutineViewCard> {
|
|||||||
height: iconSize,
|
height: iconSize,
|
||||||
width: iconSize,
|
width: iconSize,
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
errorBuilder: (context, error, stackTrace) => Image.asset(
|
errorBuilder: (context, error, stackTrace) =>
|
||||||
|
Image.asset(
|
||||||
Assets.logo,
|
Assets.logo,
|
||||||
height: iconSize,
|
height: iconSize,
|
||||||
width: iconSize,
|
width: iconSize,
|
||||||
@ -171,7 +173,8 @@ class _RoutineViewCardState extends State<RoutineViewCard> {
|
|||||||
width: iconSize,
|
width: iconSize,
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
)
|
)
|
||||||
: (widget.icon is String && widget.icon.endsWith('.svg'))
|
: (widget.icon is String &&
|
||||||
|
widget.icon.endsWith('.svg'))
|
||||||
? SvgPicture.asset(
|
? SvgPicture.asset(
|
||||||
height: iconSize,
|
height: iconSize,
|
||||||
width: iconSize,
|
width: iconSize,
|
||||||
@ -181,51 +184,54 @@ class _RoutineViewCardState extends State<RoutineViewCard> {
|
|||||||
: Icon(
|
: Icon(
|
||||||
widget.icon,
|
widget.icon,
|
||||||
color: ColorsManager.dialogBlueTitle,
|
color: ColorsManager.dialogBlueTitle,
|
||||||
size: widget.isSmallScreenSize(context) ? 30 : 40,
|
size: widget.isSmallScreenSize(context)
|
||||||
|
? 30
|
||||||
|
: 40,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
),
|
||||||
Padding(
|
const SizedBox(height: 8),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 3),
|
Padding(
|
||||||
child: Column(
|
padding: const EdgeInsets.symmetric(horizontal: 3),
|
||||||
children: [
|
child: Column(
|
||||||
Text(
|
children: [
|
||||||
widget.textString,
|
Text(
|
||||||
textAlign: TextAlign.center,
|
widget.textString,
|
||||||
overflow: TextOverflow.ellipsis,
|
textAlign: TextAlign.center,
|
||||||
maxLines: 1,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: context.textTheme.bodySmall?.copyWith(
|
maxLines: 1,
|
||||||
color: ColorsManager.blackColor,
|
style: context.textTheme.bodySmall?.copyWith(
|
||||||
fontSize: widget.isSmallScreenSize(context) ? 10 : 12,
|
color: ColorsManager.blackColor,
|
||||||
),
|
fontSize: widget.isSmallScreenSize(context) ? 10 : 12,
|
||||||
),
|
),
|
||||||
if (widget.spaceName != '')
|
),
|
||||||
Row(
|
if (widget.spaceName != '')
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
SvgPicture.asset(
|
children: [
|
||||||
Assets.spaceLocationIcon,
|
SvgPicture.asset(
|
||||||
fit: BoxFit.contain,
|
Assets.spaceLocationIcon,
|
||||||
|
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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||||
|
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/ac/ac_function.dart';
|
import 'package:syncrow_web/pages/routines/models/ac/ac_function.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/ac/ac_operational_value.dart';
|
import 'package:syncrow_web/pages/routines/models/ac/ac_operational_value.dart';
|
||||||
@ -9,8 +11,6 @@ import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart';
|
|||||||
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
|
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
|
||||||
|
|
||||||
class ACHelper {
|
class ACHelper {
|
||||||
static Future<Map<String, dynamic>?> showACFunctionsDialog({
|
static Future<Map<String, dynamic>?> showACFunctionsDialog({
|
||||||
@ -74,10 +74,8 @@ class ACHelper {
|
|||||||
child: _buildFunctionsList(
|
child: _buildFunctionsList(
|
||||||
context: context,
|
context: context,
|
||||||
acFunctions: acFunctions,
|
acFunctions: acFunctions,
|
||||||
onFunctionSelected:
|
onFunctionSelected: (functionCode, operationName) =>
|
||||||
(functionCode, operationName) => context
|
context.read<FunctionBloc>().add(SelectFunction(
|
||||||
.read<FunctionBloc>()
|
|
||||||
.add(SelectFunction(
|
|
||||||
functionCode: functionCode,
|
functionCode: functionCode,
|
||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
)),
|
)),
|
||||||
@ -191,8 +189,9 @@ class ACHelper {
|
|||||||
required String operationName,
|
required String operationName,
|
||||||
bool? removeComparators,
|
bool? removeComparators,
|
||||||
}) {
|
}) {
|
||||||
|
final initialVal = selectedFunction == 'temp_set' ? 200 : -100;
|
||||||
if (selectedFunction == 'temp_set' || selectedFunction == 'temp_current') {
|
if (selectedFunction == 'temp_set' || selectedFunction == 'temp_current') {
|
||||||
final initialValue = selectedFunctionData?.value ?? 250;
|
final initialValue = selectedFunctionData?.value ?? initialVal;
|
||||||
return _buildTemperatureSelector(
|
return _buildTemperatureSelector(
|
||||||
context: context,
|
context: context,
|
||||||
initialValue: initialValue,
|
initialValue: initialValue,
|
||||||
@ -205,8 +204,7 @@ class ACHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final selectedFn =
|
final selectedFn = acFunctions.firstWhere((f) => f.code == selectedFunction);
|
||||||
acFunctions.firstWhere((f) => f.code == selectedFunction);
|
|
||||||
final values = selectedFn.getOperationalValues();
|
final values = selectedFn.getOperationalValues();
|
||||||
|
|
||||||
return _buildOperationalValuesList(
|
return _buildOperationalValuesList(
|
||||||
@ -287,7 +285,9 @@ class ACHelper {
|
|||||||
functionCode: selectCode,
|
functionCode: selectCode,
|
||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
condition: conditions[index],
|
condition: conditions[index],
|
||||||
value: selectedFunctionData?.value,
|
value: selectedFunctionData?.value ?? selectCode == 'temp_set'
|
||||||
|
? 200
|
||||||
|
: -100,
|
||||||
valueDescription: selectedFunctionData?.valueDescription,
|
valueDescription: selectedFunctionData?.valueDescription,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -302,8 +302,7 @@ class ACHelper {
|
|||||||
minHeight: 40.0,
|
minHeight: 40.0,
|
||||||
minWidth: 40.0,
|
minWidth: 40.0,
|
||||||
),
|
),
|
||||||
isSelected:
|
isSelected: conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||||
conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
|
||||||
children: conditions.map((c) => Text(c)).toList(),
|
children: conditions.map((c) => Text(c)).toList(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -317,6 +316,7 @@ class ACHelper {
|
|||||||
DeviceFunctionData? selectedFunctionData,
|
DeviceFunctionData? selectedFunctionData,
|
||||||
String selectCode,
|
String selectCode,
|
||||||
) {
|
) {
|
||||||
|
final initialVal = selectCode == 'temp_set' ? 200 : -100;
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@ -324,7 +324,7 @@ class ACHelper {
|
|||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
'${(initialValue ?? 200) / 10}°C',
|
'${(initialValue ?? initialVal) / 10}°C',
|
||||||
style: context.textTheme.headlineMedium!.copyWith(
|
style: context.textTheme.headlineMedium!.copyWith(
|
||||||
color: ColorsManager.primaryColorWithOpacity,
|
color: ColorsManager.primaryColorWithOpacity,
|
||||||
),
|
),
|
||||||
@ -397,9 +397,7 @@ class ACHelper {
|
|||||||
style: context.textTheme.bodyMedium,
|
style: context.textTheme.bodyMedium,
|
||||||
),
|
),
|
||||||
trailing: Icon(
|
trailing: Icon(
|
||||||
isSelected
|
isSelected ? Icons.radio_button_checked : Icons.radio_button_unchecked,
|
||||||
? Icons.radio_button_checked
|
|
||||||
: Icons.radio_button_unchecked,
|
|
||||||
size: 24,
|
size: 24,
|
||||||
color: isSelected
|
color: isSelected
|
||||||
? ColorsManager.primaryColorWithOpacity
|
? ColorsManager.primaryColorWithOpacity
|
||||||
@ -415,8 +413,7 @@ class ACHelper {
|
|||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
value: value.value,
|
value: value.value,
|
||||||
condition: selectedFunctionData?.condition,
|
condition: selectedFunctionData?.condition,
|
||||||
valueDescription:
|
valueDescription: selectedFunctionData?.valueDescription,
|
||||||
selectedFunctionData?.valueDescription,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -46,7 +46,7 @@ class CpsDialogSliderSelector extends StatelessWidget {
|
|||||||
functionCode: selectedFunction,
|
functionCode: selectedFunction,
|
||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
condition: condition,
|
condition: condition,
|
||||||
value: selectedFunctionData.value,
|
value: selectedFunctionData.value ?? 0,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -164,7 +164,7 @@ class OneGangSwitchHelper {
|
|||||||
required bool removeComparetors,
|
required bool removeComparetors,
|
||||||
}) {
|
}) {
|
||||||
if (selectedFunction == 'countdown_1') {
|
if (selectedFunction == 'countdown_1') {
|
||||||
final initialValue = selectedFunctionData?.value ?? 200;
|
final initialValue = selectedFunctionData?.value ?? 0;
|
||||||
return _buildCountDownSelector(
|
return _buildCountDownSelector(
|
||||||
context: context,
|
context: context,
|
||||||
initialValue: initialValue,
|
initialValue: initialValue,
|
||||||
@ -250,7 +250,7 @@ class OneGangSwitchHelper {
|
|||||||
functionCode: selectCode,
|
functionCode: selectCode,
|
||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
condition: conditions[index],
|
condition: conditions[index],
|
||||||
value: selectedFunctionData?.value,
|
value: selectedFunctionData?.value ?? 0,
|
||||||
valueDescription: selectedFunctionData?.valueDescription,
|
valueDescription: selectedFunctionData?.valueDescription,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -301,12 +301,13 @@ class OneGangSwitchHelper {
|
|||||||
DeviceFunctionData? selectedFunctionData,
|
DeviceFunctionData? selectedFunctionData,
|
||||||
String selectCode,
|
String selectCode,
|
||||||
) {
|
) {
|
||||||
|
const twelveHoursInSeconds = 43200.0;
|
||||||
final operationalValues = SwitchOperationalValue(
|
final operationalValues = SwitchOperationalValue(
|
||||||
icon: '',
|
icon: '',
|
||||||
description: "sec",
|
description: "sec",
|
||||||
value: 0.0,
|
value: 0.0,
|
||||||
minValue: 0,
|
minValue: 0,
|
||||||
maxValue: 86400,
|
maxValue: twelveHoursInSeconds,
|
||||||
stepValue: 1,
|
stepValue: 1,
|
||||||
);
|
);
|
||||||
return Slider(
|
return Slider(
|
||||||
|
@ -170,7 +170,7 @@ class ThreeGangSwitchHelper {
|
|||||||
if (selectedFunction == 'countdown_1' ||
|
if (selectedFunction == 'countdown_1' ||
|
||||||
selectedFunction == 'countdown_2' ||
|
selectedFunction == 'countdown_2' ||
|
||||||
selectedFunction == 'countdown_3') {
|
selectedFunction == 'countdown_3') {
|
||||||
final initialValue = selectedFunctionData?.value ?? 200;
|
final initialValue = selectedFunctionData?.value ?? 0;
|
||||||
return _buildTemperatureSelector(
|
return _buildTemperatureSelector(
|
||||||
context: context,
|
context: context,
|
||||||
initialValue: initialValue,
|
initialValue: initialValue,
|
||||||
@ -251,7 +251,7 @@ class ThreeGangSwitchHelper {
|
|||||||
functionCode: selectCode,
|
functionCode: selectCode,
|
||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
condition: conditions[index],
|
condition: conditions[index],
|
||||||
value: selectedFunctionData?.value,
|
value: selectedFunctionData?.value ?? 0,
|
||||||
valueDescription: selectedFunctionData?.valueDescription,
|
valueDescription: selectedFunctionData?.valueDescription,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -303,12 +303,13 @@ class ThreeGangSwitchHelper {
|
|||||||
DeviceFunctionData? selectedFunctionData,
|
DeviceFunctionData? selectedFunctionData,
|
||||||
String selectCode,
|
String selectCode,
|
||||||
) {
|
) {
|
||||||
|
const twelveHoursInSeconds = 43200.0;
|
||||||
final operationalValues = SwitchOperationalValue(
|
final operationalValues = SwitchOperationalValue(
|
||||||
icon: '',
|
icon: '',
|
||||||
description: "sec",
|
description: "sec",
|
||||||
value: 0.0,
|
value: 0.0,
|
||||||
minValue: 0,
|
minValue: 0,
|
||||||
maxValue: 86400,
|
maxValue: twelveHoursInSeconds,
|
||||||
stepValue: 1,
|
stepValue: 1,
|
||||||
);
|
);
|
||||||
return Slider(
|
return Slider(
|
||||||
|
@ -169,7 +169,7 @@ class TwoGangSwitchHelper {
|
|||||||
}) {
|
}) {
|
||||||
if (selectedFunction == 'countdown_1' ||
|
if (selectedFunction == 'countdown_1' ||
|
||||||
selectedFunction == 'countdown_2') {
|
selectedFunction == 'countdown_2') {
|
||||||
final initialValue = selectedFunctionData?.value ?? 200;
|
final initialValue = selectedFunctionData?.value ?? 0;
|
||||||
return _buildTemperatureSelector(
|
return _buildTemperatureSelector(
|
||||||
context: context,
|
context: context,
|
||||||
initialValue: initialValue,
|
initialValue: initialValue,
|
||||||
@ -250,7 +250,7 @@ class TwoGangSwitchHelper {
|
|||||||
functionCode: selectCode,
|
functionCode: selectCode,
|
||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
condition: conditions[index],
|
condition: conditions[index],
|
||||||
value: selectedFunctionData?.value,
|
value: selectedFunctionData?.value ?? 0,
|
||||||
valueDescription: selectedFunctionData?.valueDescription,
|
valueDescription: selectedFunctionData?.valueDescription,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -302,12 +302,13 @@ class TwoGangSwitchHelper {
|
|||||||
DeviceFunctionData? selectedFunctionData,
|
DeviceFunctionData? selectedFunctionData,
|
||||||
String selectCode,
|
String selectCode,
|
||||||
) {
|
) {
|
||||||
|
const twelveHoursInSeconds = 43200.0;
|
||||||
final operationalValues = SwitchOperationalValue(
|
final operationalValues = SwitchOperationalValue(
|
||||||
icon: '',
|
icon: '',
|
||||||
description: "sec",
|
description: "sec",
|
||||||
value: 0.0,
|
value: 0.0,
|
||||||
minValue: 0,
|
minValue: 0,
|
||||||
maxValue: 86400,
|
maxValue: twelveHoursInSeconds,
|
||||||
stepValue: 1,
|
stepValue: 1,
|
||||||
);
|
);
|
||||||
return Slider(
|
return Slider(
|
||||||
|
@ -36,7 +36,7 @@ class WpsValueSelectorWidget extends StatelessWidget {
|
|||||||
dialogType: dialogType,
|
dialogType: dialogType,
|
||||||
sliderRange: sliderRange,
|
sliderRange: sliderRange,
|
||||||
displayedValue: getDisplayText,
|
displayedValue: getDisplayText,
|
||||||
initialValue: functionData.value ?? 250,
|
initialValue: functionData.value ?? 0.0,
|
||||||
onConditionChanged: (condition) => context.read<FunctionBloc>().add(
|
onConditionChanged: (condition) => context.read<FunctionBloc>().add(
|
||||||
AddFunction(
|
AddFunction(
|
||||||
functionData: DeviceFunctionData(
|
functionData: DeviceFunctionData(
|
||||||
@ -44,7 +44,7 @@ class WpsValueSelectorWidget extends StatelessWidget {
|
|||||||
functionCode: selectedFunction,
|
functionCode: selectedFunction,
|
||||||
operationName: functionData.operationName,
|
operationName: functionData.operationName,
|
||||||
condition: condition,
|
condition: condition,
|
||||||
value: functionData.value,
|
value: functionData.value ?? 0,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -87,7 +87,7 @@ class WpsValueSelectorWidget extends StatelessWidget {
|
|||||||
final intValue = int.tryParse('${functionData.value ?? ''}');
|
final intValue = int.tryParse('${functionData.value ?? ''}');
|
||||||
return switch (functionData.functionCode) {
|
return switch (functionData.functionCode) {
|
||||||
'presence_time' => '${intValue ?? '0'}',
|
'presence_time' => '${intValue ?? '0'}',
|
||||||
'dis_current' => '${intValue ?? '250'}',
|
'dis_current' => '${intValue ?? '0'}',
|
||||||
'illuminance_value' => '${intValue ?? '0'}',
|
'illuminance_value' => '${intValue ?? '0'}',
|
||||||
_ => '$intValue',
|
_ => '$intValue',
|
||||||
};
|
};
|
||||||
|
@ -31,7 +31,7 @@ class CustomExpansionTileSpaceTree extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Checkbox(
|
Checkbox(
|
||||||
value: isSoldCheck ? null : isSelected,
|
value: isSoldCheck ? null : isSelected,
|
||||||
onChanged: (value) => onItemSelected ?? () {},
|
onChanged: (value) => onItemSelected?.call(),
|
||||||
tristate: true,
|
tristate: true,
|
||||||
side: WidgetStateBorderSide.resolveWith(
|
side: WidgetStateBorderSide.resolveWith(
|
||||||
(states) => const BorderSide(color: ColorsManager.grayBorder),
|
(states) => const BorderSide(color: ColorsManager.grayBorder),
|
||||||
|
@ -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) {
|
||||||
|
@ -136,6 +136,17 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildCommunityTile(BuildContext context, CommunityModel community) {
|
Widget _buildCommunityTile(BuildContext context, CommunityModel community) {
|
||||||
|
final spaces = community.spaces
|
||||||
|
.where(
|
||||||
|
(space) =>
|
||||||
|
{
|
||||||
|
SpaceStatus.deleted,
|
||||||
|
SpaceStatus.parentDeleted,
|
||||||
|
}.contains(space.status) ==
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.map((space) => _buildSpaceTile(space: space, community: community))
|
||||||
|
.toList();
|
||||||
return CommunityTile(
|
return CommunityTile(
|
||||||
title: community.name,
|
title: community.name,
|
||||||
key: ValueKey(community.uuid),
|
key: ValueKey(community.uuid),
|
||||||
@ -154,15 +165,7 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
onExpansionChanged: (title, expanded) {},
|
onExpansionChanged: (title, expanded) {},
|
||||||
children: community.spaces
|
children: spaces,
|
||||||
.where(
|
|
||||||
(space) => {
|
|
||||||
SpaceStatus.deleted,
|
|
||||||
SpaceStatus.parentDeleted,
|
|
||||||
}.contains(space.status),
|
|
||||||
)
|
|
||||||
.map((space) => _buildSpaceTile(space: space, community: community))
|
|
||||||
.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,13 +145,11 @@ class CreateSpaceModelDialog extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
TagChipDisplay(
|
TagChipDisplay(
|
||||||
context,
|
|
||||||
screenWidth: screenWidth,
|
|
||||||
spaceModel: updatedSpaceModel,
|
spaceModel: updatedSpaceModel,
|
||||||
products: products,
|
products: products,
|
||||||
subspaces: subspaces,
|
subspaces: subspaces,
|
||||||
allTags: allTags,
|
allTags: allTags,
|
||||||
spaceNameController: spaceNameController,
|
spaceName: spaceNameController.text,
|
||||||
pageContext: pageContext,
|
pageContext: pageContext,
|
||||||
otherSpaceModels: otherSpaceModels,
|
otherSpaceModels: otherSpaceModels,
|
||||||
allSpaceModels: allSpaceModels,
|
allSpaceModels: allSpaceModels,
|
||||||
|
@ -10,139 +10,152 @@ import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_
|
|||||||
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/button_content_widget.dart';
|
import 'package:syncrow_web/pages/spaces_management/space_model/widgets/button_content_widget.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/tag_model/views/add_device_type_model_widget.dart';
|
import 'package:syncrow_web/pages/spaces_management/tag_model/views/add_device_type_model_widget.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
|
|
||||||
class TagChipDisplay extends StatelessWidget {
|
class TagChipDisplay extends StatelessWidget {
|
||||||
final double screenWidth;
|
const TagChipDisplay({
|
||||||
|
required this.spaceModel,
|
||||||
|
required this.products,
|
||||||
|
required this.subspaces,
|
||||||
|
required this.allTags,
|
||||||
|
required this.spaceName,
|
||||||
|
required this.projectTags,
|
||||||
|
this.pageContext,
|
||||||
|
this.otherSpaceModels,
|
||||||
|
this.allSpaceModels,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
final SpaceTemplateModel? spaceModel;
|
final SpaceTemplateModel? spaceModel;
|
||||||
final List<ProductModel>? products;
|
final List<ProductModel>? products;
|
||||||
final List<SubspaceTemplateModel>? subspaces;
|
final List<SubspaceTemplateModel>? subspaces;
|
||||||
final List<String>? allTags;
|
final List<String>? allTags;
|
||||||
final TextEditingController spaceNameController;
|
final String spaceName;
|
||||||
final BuildContext? pageContext;
|
final BuildContext? pageContext;
|
||||||
final List<String>? otherSpaceModels;
|
final List<String>? otherSpaceModels;
|
||||||
final List<SpaceTemplateModel>? allSpaceModels;
|
final List<SpaceTemplateModel>? allSpaceModels;
|
||||||
final List<Tag> projectTags;
|
final List<Tag> projectTags;
|
||||||
|
|
||||||
const TagChipDisplay(BuildContext context,
|
Map<ProductModel, int> get _groupedTags {
|
||||||
{Key? key,
|
final spaceTags = spaceModel?.tags ?? <Tag>[];
|
||||||
required this.screenWidth,
|
|
||||||
required this.spaceModel,
|
final subspaces = spaceModel?.subspaceModels ?? [];
|
||||||
required this.products,
|
final subspaceTags = subspaces.expand((e) => e.tags ?? <Tag>[]).toList();
|
||||||
required this.subspaces,
|
|
||||||
required this.allTags,
|
return TagHelper.groupTags([...spaceTags, ...subspaceTags]);
|
||||||
required this.spaceNameController,
|
}
|
||||||
this.pageContext,
|
|
||||||
this.otherSpaceModels,
|
|
||||||
this.allSpaceModels,
|
|
||||||
required this.projectTags})
|
|
||||||
: super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return (spaceModel?.tags?.isNotEmpty == true ||
|
final hasTags = spaceModel?.tags?.isNotEmpty ?? false;
|
||||||
spaceModel?.subspaceModels?.any((subspace) => subspace.tags?.isNotEmpty == true) ==
|
final hasSubspaceTags =
|
||||||
true)
|
spaceModel?.subspaceModels?.any((e) => e.tags?.isNotEmpty ?? false) ?? false;
|
||||||
? SizedBox(
|
|
||||||
width: screenWidth * 0.25,
|
|
||||||
child: Container(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: ColorsManager.textFieldGreyColor,
|
|
||||||
borderRadius: BorderRadius.circular(15),
|
|
||||||
border: Border.all(
|
|
||||||
color: ColorsManager.textFieldGreyColor,
|
|
||||||
width: 3.0, // Border width
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Wrap(
|
|
||||||
spacing: 8.0,
|
|
||||||
runSpacing: 8.0,
|
|
||||||
children: [
|
|
||||||
// Combine tags from spaceModel and subspaces
|
|
||||||
...TagHelper.groupTags([
|
|
||||||
...?spaceModel?.tags,
|
|
||||||
...?spaceModel?.subspaceModels?.expand((subspace) => subspace.tags ?? [])
|
|
||||||
]).entries.map(
|
|
||||||
(entry) => Chip(
|
|
||||||
avatar: SizedBox(
|
|
||||||
width: 24,
|
|
||||||
height: 24,
|
|
||||||
child: SvgPicture.asset(
|
|
||||||
entry.key.icon ?? 'assets/icons/gateway.svg',
|
|
||||||
fit: BoxFit.contain,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
label: Text(
|
|
||||||
'x${entry.value}', // Show count
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.bodySmall!
|
|
||||||
.copyWith(color: ColorsManager.spaceColor),
|
|
||||||
),
|
|
||||||
backgroundColor: ColorsManager.whiteColors,
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(16),
|
|
||||||
side: const BorderSide(
|
|
||||||
color: ColorsManager.spaceColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
EditChip(onTap: () async {
|
|
||||||
// Use the Navigator's context for showDialog
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
|
|
||||||
await showDialog<bool>(
|
if (hasTags || hasSubspaceTags) {
|
||||||
barrierDismissible: false,
|
return Container(
|
||||||
context: context,
|
width: context.screenWidth * 0.25,
|
||||||
builder: (context) => AssignTagModelsDialog(
|
padding: const EdgeInsets.all(8),
|
||||||
products: products,
|
decoration: BoxDecoration(
|
||||||
allSpaceModels: allSpaceModels,
|
color: ColorsManager.textFieldGreyColor,
|
||||||
subspaces: subspaces,
|
borderRadius: BorderRadius.circular(15),
|
||||||
pageContext: pageContext,
|
border: Border.all(
|
||||||
allTags: allTags,
|
color: ColorsManager.textFieldGreyColor,
|
||||||
spaceModel: spaceModel,
|
width: 3,
|
||||||
otherSpaceModels: otherSpaceModels,
|
),
|
||||||
initialTags: TagHelper.generateInitialTags(
|
),
|
||||||
subspaces: subspaces, spaceTagModels: spaceModel?.tags ?? []),
|
child: Wrap(
|
||||||
title: 'Edit Device',
|
spacing: 8,
|
||||||
addedProducts: TagHelper.createInitialSelectedProducts(
|
runSpacing: 8,
|
||||||
spaceModel?.tags ?? [], subspaces),
|
children: [
|
||||||
spaceName: spaceModel?.modelName ?? '',
|
..._groupedTags.entries.map((entry) => _buildChip(context, entry)),
|
||||||
projectTags: projectTags,
|
_buildEditChip(context),
|
||||||
));
|
],
|
||||||
})
|
),
|
||||||
],
|
);
|
||||||
),
|
}
|
||||||
),
|
|
||||||
)
|
|
||||||
: TextButton(
|
|
||||||
onPressed: () async {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
|
|
||||||
await showDialog<bool>(
|
return _buildAddDevicesButton(context);
|
||||||
barrierDismissible: false,
|
}
|
||||||
context: context,
|
|
||||||
builder: (context) => AddDeviceTypeModelWidget(
|
Widget _buildEditChip(BuildContext context) {
|
||||||
products: products,
|
return EditChip(
|
||||||
subspaces: subspaces,
|
onTap: () => showDialog<void>(
|
||||||
allTags: allTags,
|
context: context,
|
||||||
spaceName: spaceNameController.text,
|
builder: (context) => AssignTagModelsDialog(
|
||||||
pageContext: pageContext,
|
products: products,
|
||||||
isCreate: true,
|
allSpaceModels: allSpaceModels,
|
||||||
spaceModel: spaceModel,
|
subspaces: subspaces,
|
||||||
otherSpaceModels: otherSpaceModels,
|
pageContext: pageContext,
|
||||||
projectTags: projectTags,
|
allTags: allTags,
|
||||||
),
|
spaceModel: spaceModel,
|
||||||
);
|
otherSpaceModels: otherSpaceModels,
|
||||||
},
|
initialTags: TagHelper.generateInitialTags(
|
||||||
style: TextButton.styleFrom(
|
subspaces: subspaces,
|
||||||
padding: EdgeInsets.zero,
|
spaceTagModels: spaceModel?.tags ?? [],
|
||||||
),
|
),
|
||||||
child: const ButtonContentWidget(
|
title: 'Edit Device',
|
||||||
icon: Icons.add,
|
addedProducts: TagHelper.createInitialSelectedProducts(
|
||||||
label: 'Add Devices',
|
spaceModel?.tags ?? [],
|
||||||
),
|
subspaces,
|
||||||
);
|
),
|
||||||
|
spaceName: spaceModel?.modelName ?? '',
|
||||||
|
projectTags: projectTags,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildChip(
|
||||||
|
BuildContext context,
|
||||||
|
MapEntry<ProductModel, int> entry,
|
||||||
|
) {
|
||||||
|
return Chip(
|
||||||
|
backgroundColor: ColorsManager.whiteColors,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
side: const BorderSide(
|
||||||
|
color: ColorsManager.spaceColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
avatar: SvgPicture.asset(
|
||||||
|
entry.key.icon ?? Assets.gateway,
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
height: 24,
|
||||||
|
width: 24,
|
||||||
|
),
|
||||||
|
label: Text(
|
||||||
|
'${entry.value}',
|
||||||
|
style: context.textTheme.bodySmall!.copyWith(
|
||||||
|
color: ColorsManager.spaceColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildAddDevicesButton(BuildContext context) {
|
||||||
|
return TextButton(
|
||||||
|
onPressed: () => showDialog<void>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => AddDeviceTypeModelWidget(
|
||||||
|
products: products,
|
||||||
|
subspaces: subspaces,
|
||||||
|
allTags: allTags,
|
||||||
|
spaceName: spaceName,
|
||||||
|
pageContext: pageContext,
|
||||||
|
isCreate: true,
|
||||||
|
spaceModel: spaceModel,
|
||||||
|
otherSpaceModels: otherSpaceModels,
|
||||||
|
projectTags: projectTags,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
style: TextButton.styleFrom(
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
),
|
||||||
|
child: const ButtonContentWidget(
|
||||||
|
icon: Icons.add,
|
||||||
|
label: 'Add Devices',
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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