mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-17 02:25:31 +00:00
Compare commits
12 Commits
SP-1278-FE
...
Fix-Factor
Author | SHA1 | Date | |
---|---|---|---|
72ae3b1727 | |||
e0be44a507 | |||
d4a7dd5854 | |||
50eb890d18 | |||
9eefd522b7 | |||
4989a0e95c | |||
3c6b9f9ef4 | |||
86b8771694 | |||
ea1d3d18c8 | |||
1bfab8cc76 | |||
7dcaa20da1 | |||
616adccfdd |
@ -25,7 +25,7 @@ jobs:
|
|||||||
- name: Set up Flutter
|
- name: Set up Flutter
|
||||||
uses: subosito/flutter-action@v2
|
uses: subosito/flutter-action@v2
|
||||||
with:
|
with:
|
||||||
flutter-version: '3.22.2' # Specify the Flutter version you want to use
|
flutter-version: '3.27.3' # Specify the Flutter version you want to use
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: flutter pub get
|
run: flutter pub get
|
||||||
|
@ -25,7 +25,7 @@ jobs:
|
|||||||
- name: Set up Flutter
|
- name: Set up Flutter
|
||||||
uses: subosito/flutter-action@v2
|
uses: subosito/flutter-action@v2
|
||||||
with:
|
with:
|
||||||
flutter-version: '3.22.2' # Specify the Flutter version you want to use
|
flutter-version: '3.27.3' # Specify the Flutter version you want to use
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: flutter pub get
|
run: flutter pub get
|
||||||
|
@ -239,8 +239,6 @@ SOS
|
|||||||
// tempIcon = Assets.gang3touch;
|
// tempIcon = Assets.gang3touch;
|
||||||
} else if (type == DeviceType.WaterLeak) {
|
} else if (type == DeviceType.WaterLeak) {
|
||||||
tempIcon = Assets.waterLeakNormal;
|
tempIcon = Assets.waterLeakNormal;
|
||||||
} else if (type == DeviceType.WaterLeak) {
|
|
||||||
tempIcon = Assets.waterLeakNormal;
|
|
||||||
} else {
|
} else {
|
||||||
tempIcon = Assets.logoHorizontal;
|
tempIcon = Assets.logoHorizontal;
|
||||||
}
|
}
|
||||||
|
@ -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),
|
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
},
|
],
|
||||||
),
|
);
|
||||||
),
|
},
|
||||||
],
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -684,40 +684,45 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
? '${action.entityId}_automation'
|
? '${action.entityId}_automation'
|
||||||
: action.actionExecutor == 'delay'
|
: action.actionExecutor == 'delay'
|
||||||
? '${action.entityId}_delay'
|
? '${action.entityId}_delay'
|
||||||
: action.entityId;
|
: const Uuid().v4();
|
||||||
|
|
||||||
if (!deviceCards.containsKey(deviceId)) {
|
// if (!deviceCards.containsKey(deviceId)) {
|
||||||
deviceCards[deviceId] = {
|
deviceCards[deviceId] = {
|
||||||
'entityId': action.entityId,
|
'entityId': action.entityId,
|
||||||
'deviceId': action.actionExecutor == 'delay' ? 'delay' : action.entityId,
|
'deviceId': action.actionExecutor == 'delay' ? 'delay' : action.entityId,
|
||||||
'uniqueCustomId': action.type == 'automation' || action.actionExecutor == 'delay'
|
'uniqueCustomId': action.type == 'automation' || action.actionExecutor == 'delay'
|
||||||
? const Uuid().v4()
|
? action.entityId
|
||||||
: action.entityId,
|
: const Uuid().v4(),
|
||||||
'title': action.actionExecutor == 'delay'
|
'title': action.actionExecutor == 'delay'
|
||||||
? 'Delay'
|
? 'Delay'
|
||||||
: action.type == 'automation'
|
: action.type == 'automation'
|
||||||
? action.name ?? 'Automation'
|
? action.name ?? 'Automation'
|
||||||
: (matchingDevice?.name ?? 'Device'),
|
: (matchingDevice?.name ?? 'Device'),
|
||||||
'productType': action.productType,
|
'productType': action.productType,
|
||||||
'functions': matchingDevice?.functions,
|
'functions': matchingDevice?.functions,
|
||||||
'imagePath': action.type == 'automation'
|
'imagePath': action.type == 'automation'
|
||||||
? Assets.automation
|
? Assets.automation
|
||||||
: action.actionExecutor == 'delay'
|
: action.actionExecutor == 'delay'
|
||||||
? Assets.delay
|
? Assets.delay
|
||||||
: matchingDevice?.getDefaultIcon(action.productType),
|
: matchingDevice?.getDefaultIcon(action.productType),
|
||||||
'device': matchingDevice,
|
'device': matchingDevice,
|
||||||
'name': action.name,
|
'name': action.name,
|
||||||
'type': action.type,
|
'type': action.type,
|
||||||
};
|
'tag': matchingDevice?.deviceTags?.isNotEmpty ?? false
|
||||||
}
|
? matchingDevice?.deviceTags![0].name ?? ''
|
||||||
|
: '',
|
||||||
|
'subSpace': matchingDevice?.deviceSubSpace?.subspaceName ?? '',
|
||||||
|
};
|
||||||
|
// }
|
||||||
|
|
||||||
final cardData = deviceCards[deviceId]!;
|
final cardData = deviceCards[deviceId]!;
|
||||||
final uniqueCustomId = cardData['uniqueCustomId'].toString();
|
final uniqueCustomId = cardData['uniqueCustomId'].toString();
|
||||||
|
|
||||||
|
if (!updatedFunctions.containsKey(uniqueCustomId)) {
|
||||||
|
updatedFunctions[uniqueCustomId] = [];
|
||||||
|
}
|
||||||
|
|
||||||
if (action.type == 'automation') {
|
if (action.type == 'automation') {
|
||||||
if (!updatedFunctions.containsKey(uniqueCustomId)) {
|
|
||||||
updatedFunctions[uniqueCustomId] = [];
|
|
||||||
}
|
|
||||||
updatedFunctions[uniqueCustomId]!.add(
|
updatedFunctions[uniqueCustomId]!.add(
|
||||||
DeviceFunctionData(
|
DeviceFunctionData(
|
||||||
entityId: action.entityId,
|
entityId: action.entityId,
|
||||||
@ -728,14 +733,11 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
);
|
);
|
||||||
// emit(state.copyWith(automationActionExecutor: action.actionExecutor));
|
// emit(state.copyWith(automationActionExecutor: action.actionExecutor));
|
||||||
} else if (action.executorProperty != null && action.actionExecutor != 'delay') {
|
} else if (action.executorProperty != null && action.actionExecutor != 'delay') {
|
||||||
// if (!updatedFunctions.containsKey(uniqueCustomId)) {
|
final functions = matchingDevice?.functions ?? [];
|
||||||
// updatedFunctions[uniqueCustomId] = [];
|
|
||||||
// }
|
|
||||||
final functions = matchingDevice?.functions;
|
|
||||||
final functionCode = action.executorProperty?.functionCode;
|
final functionCode = action.executorProperty?.functionCode;
|
||||||
for (DeviceFunction function in functions ?? []) {
|
for (DeviceFunction function in functions) {
|
||||||
if (function.code == functionCode) {
|
if (function.code == functionCode) {
|
||||||
updatedFunctions[const Uuid().v4()]!.add(
|
updatedFunctions[uniqueCustomId]!.add(
|
||||||
DeviceFunctionData(
|
DeviceFunctionData(
|
||||||
entityId: action.entityId,
|
entityId: action.entityId,
|
||||||
functionCode: functionCode ?? '',
|
functionCode: functionCode ?? '',
|
||||||
@ -747,9 +749,6 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (action.actionExecutor == 'delay') {
|
} else if (action.actionExecutor == 'delay') {
|
||||||
if (!updatedFunctions.containsKey(uniqueCustomId)) {
|
|
||||||
updatedFunctions[uniqueCustomId] = [];
|
|
||||||
}
|
|
||||||
final delayFunction = DelayFunction(
|
final delayFunction = DelayFunction(
|
||||||
deviceId: action.entityId,
|
deviceId: action.entityId,
|
||||||
deviceName: 'Delay',
|
deviceName: 'Delay',
|
||||||
@ -1156,21 +1155,25 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
final deviceId = condition.entityId;
|
final deviceId = const Uuid().v4();
|
||||||
|
|
||||||
if (!deviceIfCards.containsKey(deviceId)) {
|
// if (!deviceIfCards.containsKey(deviceId)) {
|
||||||
deviceIfCards[deviceId] = {
|
deviceIfCards[deviceId] = {
|
||||||
'entityId': condition.entityId,
|
'entityId': condition.entityId,
|
||||||
'deviceId': condition.entityId,
|
'deviceId': condition.entityId,
|
||||||
'uniqueCustomId': const Uuid().v4(),
|
'uniqueCustomId': const Uuid().v4(),
|
||||||
'title': matchingDevice.name ?? 'Device',
|
'title': matchingDevice.name ?? 'Device',
|
||||||
'productType': condition.productType,
|
'productType': condition.productType,
|
||||||
'functions': matchingDevice.functions,
|
'functions': matchingDevice.functions,
|
||||||
'imagePath': matchingDevice.getDefaultIcon(condition.productType),
|
'imagePath': matchingDevice.getDefaultIcon(condition.productType),
|
||||||
'device': matchingDevice,
|
'device': matchingDevice,
|
||||||
'type': 'condition',
|
'type': 'condition',
|
||||||
};
|
'tag': matchingDevice.deviceTags?.isNotEmpty ?? false
|
||||||
}
|
? matchingDevice.deviceTags![0].name
|
||||||
|
: '',
|
||||||
|
'subSpace': matchingDevice.deviceSubSpace?.subspaceName ?? '',
|
||||||
|
};
|
||||||
|
// }
|
||||||
|
|
||||||
final cardData = deviceIfCards[deviceId]!;
|
final cardData = deviceIfCards[deviceId]!;
|
||||||
final uniqueCustomId = cardData['uniqueCustomId'].toString();
|
final uniqueCustomId = cardData['uniqueCustomId'].toString();
|
||||||
@ -1206,35 +1209,38 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
final deviceId =
|
final deviceId = const Uuid().v4();
|
||||||
action.actionExecutor == 'delay' ? '${action.entityId}_delay' : action.entityId;
|
|
||||||
|
|
||||||
if (!deviceThenCards.containsKey(deviceId)) {
|
// if (!deviceThenCards.containsKey(deviceId)) {
|
||||||
deviceThenCards[deviceId] = {
|
deviceThenCards[deviceId] = {
|
||||||
'entityId': action.entityId,
|
'entityId': action.entityId,
|
||||||
'deviceId': action.actionExecutor == 'delay' ? 'delay' : action.entityId,
|
'deviceId': action.actionExecutor == 'delay' ? 'delay' : action.entityId,
|
||||||
'uniqueCustomId': const Uuid().v4(),
|
'uniqueCustomId': const Uuid().v4(),
|
||||||
'title': action.actionExecutor == 'delay'
|
'title': action.actionExecutor == 'delay'
|
||||||
? 'Delay'
|
? 'Delay'
|
||||||
: (action.type == 'scene' || action.type == 'automation')
|
: (action.type == 'scene' || action.type == 'automation')
|
||||||
? action.name
|
? action.name
|
||||||
: (matchingDevice.name ?? 'Device'),
|
: (matchingDevice.name ?? 'Device'),
|
||||||
'productType': action.productType,
|
'productType': action.productType,
|
||||||
'functions': matchingDevice.functions,
|
'functions': matchingDevice.functions,
|
||||||
'imagePath': action.actionExecutor == 'delay'
|
'imagePath': action.actionExecutor == 'delay'
|
||||||
? Assets.delay
|
? Assets.delay
|
||||||
: action.type == 'automation'
|
: action.type == 'automation'
|
||||||
? Assets.automation
|
? Assets.automation
|
||||||
: matchingDevice.getDefaultIcon(action.productType),
|
: matchingDevice.getDefaultIcon(action.productType),
|
||||||
'device': matchingDevice,
|
'device': matchingDevice,
|
||||||
'type': action.type == 'scene'
|
'type': action.type == 'scene'
|
||||||
? 'scene'
|
? 'scene'
|
||||||
: action.type == 'automation'
|
: action.type == 'automation'
|
||||||
? 'automation'
|
? 'automation'
|
||||||
: 'action',
|
: 'action',
|
||||||
'icon': action.icon ?? '',
|
'icon': action.icon ?? '',
|
||||||
};
|
'tag': matchingDevice.deviceTags?.isNotEmpty ?? false
|
||||||
}
|
? matchingDevice.deviceTags![0].name
|
||||||
|
: '',
|
||||||
|
'subSpace': matchingDevice.deviceSubSpace?.subspaceName ?? '',
|
||||||
|
};
|
||||||
|
// }
|
||||||
|
|
||||||
final cardData = deviceThenCards[deviceId]!;
|
final cardData = deviceThenCards[deviceId]!;
|
||||||
final uniqueCustomId = cardData['uniqueCustomId'].toString();
|
final uniqueCustomId = cardData['uniqueCustomId'].toString();
|
||||||
|
@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.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/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/device_functions.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/pages/routines/widgets/dialog_footer.dart';
|
import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
@ -20,7 +21,7 @@ class SaveRoutineHelper {
|
|||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
content: Container(
|
content: Container(
|
||||||
width: 600,
|
width: MediaQuery.sizeOf(context).width * 0.5,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
@ -30,14 +31,15 @@ class SaveRoutineHelper {
|
|||||||
children: [
|
children: [
|
||||||
DialogHeader('Create a scene: ${state.routineName ?? ""}'),
|
DialogHeader('Create a scene: ${state.routineName ?? ""}'),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
// Left side - IF
|
// Left side - IF
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: ListView(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
shrinkWrap: true,
|
||||||
children: [
|
children: [
|
||||||
const Text(
|
const Text(
|
||||||
'IF:',
|
'IF:',
|
||||||
@ -59,26 +61,7 @@ class SaveRoutineHelper {
|
|||||||
...state.ifItems.map((item) {
|
...state.ifItems.map((item) {
|
||||||
final functions =
|
final functions =
|
||||||
state.selectedFunctions[item['uniqueCustomId']] ?? [];
|
state.selectedFunctions[item['uniqueCustomId']] ?? [];
|
||||||
return ListTile(
|
return functionRow(item, context, functions);
|
||||||
leading: SvgPicture.asset(
|
|
||||||
item['imagePath'],
|
|
||||||
width: 22,
|
|
||||||
height: 22,
|
|
||||||
),
|
|
||||||
title:
|
|
||||||
Text(item['title'], style: const TextStyle(fontSize: 14)),
|
|
||||||
subtitle: Wrap(
|
|
||||||
children: functions
|
|
||||||
.map((f) => Text(
|
|
||||||
'${f.operationName}: ${f.value}, ',
|
|
||||||
style: const TextStyle(
|
|
||||||
color: ColorsManager.grayColor, fontSize: 8),
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
maxLines: 3,
|
|
||||||
))
|
|
||||||
.toList(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -87,8 +70,9 @@ class SaveRoutineHelper {
|
|||||||
// Right side - THEN items
|
// Right side - THEN items
|
||||||
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: ListView(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
shrinkWrap: true,
|
||||||
children: [
|
children: [
|
||||||
const Text(
|
const Text(
|
||||||
'THEN:',
|
'THEN:',
|
||||||
@ -100,37 +84,7 @@ class SaveRoutineHelper {
|
|||||||
...state.thenItems.map((item) {
|
...state.thenItems.map((item) {
|
||||||
final functions =
|
final functions =
|
||||||
state.selectedFunctions[item['uniqueCustomId']] ?? [];
|
state.selectedFunctions[item['uniqueCustomId']] ?? [];
|
||||||
return ListTile(
|
return functionRow(item, context, functions);
|
||||||
leading: item['type'] == 'tap_to_run' || item['type'] == 'scene'
|
|
||||||
? Image.memory(
|
|
||||||
base64Decode(item['icon']),
|
|
||||||
width: 22,
|
|
||||||
height: 22,
|
|
||||||
)
|
|
||||||
: SvgPicture.asset(
|
|
||||||
item['imagePath'],
|
|
||||||
width: 22,
|
|
||||||
height: 22,
|
|
||||||
),
|
|
||||||
title: Text(
|
|
||||||
item['title'],
|
|
||||||
style: context.textTheme.bodySmall?.copyWith(
|
|
||||||
fontSize: 14,
|
|
||||||
color: ColorsManager.grayColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
subtitle: Wrap(
|
|
||||||
children: functions
|
|
||||||
.map((f) => Text(
|
|
||||||
'${f.operationName}: ${f.value}, ',
|
|
||||||
style: context.textTheme.bodySmall?.copyWith(
|
|
||||||
color: ColorsManager.grayColor, fontSize: 8),
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
maxLines: 3,
|
|
||||||
))
|
|
||||||
.toList(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -177,4 +131,112 @@ class SaveRoutineHelper {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Widget functionRow(
|
||||||
|
dynamic item, BuildContext context, List<DeviceFunctionData> functions) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 6),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
spacing: 8,
|
||||||
|
children: [
|
||||||
|
item['type'] == 'tap_to_run' || item['type'] == 'scene'
|
||||||
|
? Image.memory(
|
||||||
|
base64Decode(item['icon']),
|
||||||
|
width: 22,
|
||||||
|
height: 22,
|
||||||
|
)
|
||||||
|
: SvgPicture.asset(
|
||||||
|
item['imagePath'],
|
||||||
|
width: 22,
|
||||||
|
height: 22,
|
||||||
|
),
|
||||||
|
Flexible(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
spacing: 2,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
item['title'],
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: context.textTheme.bodySmall?.copyWith(
|
||||||
|
fontSize: 14,
|
||||||
|
color: ColorsManager.textPrimaryColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Wrap(
|
||||||
|
children: functions
|
||||||
|
.map((f) => Text(
|
||||||
|
'${f.operationName}: ${f.value}',
|
||||||
|
style: context.textTheme.bodySmall
|
||||||
|
?.copyWith(color: ColorsManager.grayColor, fontSize: 8),
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
maxLines: 3,
|
||||||
|
))
|
||||||
|
.toList(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
spacing: 2,
|
||||||
|
children: [
|
||||||
|
Visibility(
|
||||||
|
visible: item['tag'] != null && item['tag'] != '',
|
||||||
|
child: Row(
|
||||||
|
spacing: 2,
|
||||||
|
children: [
|
||||||
|
SizedBox(width: 8, height: 8, child: SvgPicture.asset(Assets.deviceTagIcon)),
|
||||||
|
Text(
|
||||||
|
item['tag'] ?? '',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
maxLines: 1,
|
||||||
|
style: context.textTheme.bodySmall?.copyWith(
|
||||||
|
color: ColorsManager.lightGreyColor,
|
||||||
|
fontSize: 9,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Visibility(
|
||||||
|
visible: item['subSpace'] != null && item['subSpace'] != '',
|
||||||
|
child: Row(
|
||||||
|
spacing: 2,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
width: 8, height: 8, child: SvgPicture.asset(Assets.spaceLocationIcon)),
|
||||||
|
Text(
|
||||||
|
item['subSpace'] ?? '',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
maxLines: 1,
|
||||||
|
style: context.textTheme.bodySmall?.copyWith(
|
||||||
|
color: ColorsManager.lightGreyColor,
|
||||||
|
fontSize: 9,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,7 @@ class _RoutinesViewState extends State<RoutinesView> {
|
|||||||
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(
|
_bloc.add(SaveCommunityIdAndSpaceIdEvent(communityID: communityId, spaceID: spaceId));
|
||||||
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));
|
||||||
}
|
}
|
||||||
@ -49,7 +48,8 @@ class _RoutinesViewState extends State<RoutinesView> {
|
|||||||
child: SpaceTreeView(
|
child: SpaceTreeView(
|
||||||
onSelect: () => context.read<RoutineBloc>()
|
onSelect: () => context.read<RoutineBloc>()
|
||||||
..add(const LoadScenes())
|
..add(const LoadScenes())
|
||||||
..add(const LoadAutomation()),
|
..add(const LoadAutomation())
|
||||||
|
..add(FetchDevicesInRoutine()),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -64,11 +64,10 @@ class _RoutinesViewState extends State<RoutinesView> {
|
|||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Create New Routines",
|
"Create New Routines",
|
||||||
style:
|
style: Theme.of(context).textTheme.titleLarge?.copyWith(
|
||||||
Theme.of(context).textTheme.titleLarge?.copyWith(
|
color: ColorsManager.grayColor,
|
||||||
color: ColorsManager.grayColor,
|
fontWeight: FontWeight.bold,
|
||||||
fontWeight: FontWeight.bold,
|
),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
RoutineViewCard(
|
RoutineViewCard(
|
||||||
|
@ -8,12 +8,12 @@ class DialogFooter extends StatelessWidget {
|
|||||||
final int? dialogWidth;
|
final int? dialogWidth;
|
||||||
|
|
||||||
const DialogFooter({
|
const DialogFooter({
|
||||||
Key? key,
|
super.key,
|
||||||
required this.onCancel,
|
required this.onCancel,
|
||||||
required this.onConfirm,
|
required this.onConfirm,
|
||||||
required this.isConfirmEnabled,
|
required this.isConfirmEnabled,
|
||||||
this.dialogWidth,
|
this.dialogWidth,
|
||||||
}) : super(key: key);
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -28,21 +28,19 @@ class DialogFooter extends StatelessWidget {
|
|||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
_buildFooterButton(
|
||||||
child: _buildFooterButton(
|
context: context,
|
||||||
context,
|
text: 'Cancel',
|
||||||
'Cancel',
|
onTap: onCancel,
|
||||||
onCancel,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
if (isConfirmEnabled) ...[
|
if (isConfirmEnabled) ...[
|
||||||
Container(width: 1, height: 50, color: ColorsManager.greyColor),
|
Container(width: 1, height: 50, color: ColorsManager.greyColor),
|
||||||
Expanded(
|
_buildFooterButton(
|
||||||
child: _buildFooterButton(
|
context: context,
|
||||||
context,
|
text: 'Confirm',
|
||||||
'Confirm',
|
onTap: onConfirm,
|
||||||
onConfirm,
|
textColor:
|
||||||
),
|
isConfirmEnabled ? ColorsManager.primaryColorWithOpacity : Colors.red,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
@ -50,24 +48,24 @@ class DialogFooter extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildFooterButton(
|
Widget _buildFooterButton({
|
||||||
BuildContext context,
|
required BuildContext context,
|
||||||
String text,
|
required String text,
|
||||||
VoidCallback? onTap,
|
required VoidCallback? onTap,
|
||||||
) {
|
Color? textColor,
|
||||||
return GestureDetector(
|
}) {
|
||||||
onTap: onTap,
|
return Expanded(
|
||||||
child: SizedBox(
|
child: TextButton(
|
||||||
height: 50,
|
style: TextButton.styleFrom(
|
||||||
child: Center(
|
foregroundColor: ColorsManager.primaryColorWithOpacity,
|
||||||
child: Text(
|
disabledForegroundColor: ColorsManager.primaryColor,
|
||||||
text,
|
),
|
||||||
style: Theme.of(context).textTheme.bodyMedium!.copyWith(
|
onPressed: onTap,
|
||||||
color: text == 'Confirm'
|
child: Text(
|
||||||
? ColorsManager.primaryColorWithOpacity
|
text,
|
||||||
: ColorsManager.textGray,
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||||
),
|
color: textColor ?? ColorsManager.textGray,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -69,9 +69,9 @@ class DraggableCard extends StatelessWidget {
|
|||||||
Card(
|
Card(
|
||||||
color: ColorsManager.whiteColors,
|
color: ColorsManager.whiteColors,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: padding ?? const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
width: 110,
|
width: 110,
|
||||||
height: deviceFunctions.isEmpty ? 160 : 170,
|
height: deviceFunctions.isEmpty ? 160 : 180,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
@ -103,16 +103,14 @@ class DraggableCard extends StatelessWidget {
|
|||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 3),
|
padding: const EdgeInsets.symmetric(horizontal: 3),
|
||||||
child: Flexible(
|
child: Text(
|
||||||
child: Text(
|
deviceData['title'] ?? deviceData['name'] ?? title,
|
||||||
deviceData['title'] ?? deviceData['name'] ?? title,
|
textAlign: TextAlign.center,
|
||||||
textAlign: TextAlign.center,
|
overflow: TextOverflow.ellipsis,
|
||||||
overflow: TextOverflow.ellipsis,
|
maxLines: 2,
|
||||||
maxLines: 2,
|
style: context.textTheme.bodySmall?.copyWith(
|
||||||
style: context.textTheme.bodySmall?.copyWith(
|
color: ColorsManager.blackColor,
|
||||||
color: ColorsManager.blackColor,
|
fontSize: 12,
|
||||||
fontSize: 12,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -131,7 +129,7 @@ class DraggableCard extends StatelessWidget {
|
|||||||
deviceData['tag'] ?? '',
|
deviceData['tag'] ?? '',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
maxLines: 2,
|
maxLines: 1,
|
||||||
style: context.textTheme.bodySmall?.copyWith(
|
style: context.textTheme.bodySmall?.copyWith(
|
||||||
color: ColorsManager.lightGreyColor,
|
color: ColorsManager.lightGreyColor,
|
||||||
fontSize: 9,
|
fontSize: 9,
|
||||||
@ -162,7 +160,7 @@ class DraggableCard extends StatelessWidget {
|
|||||||
deviceData['subSpace'] ?? '',
|
deviceData['subSpace'] ?? '',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
maxLines: 2,
|
maxLines: 1,
|
||||||
style: context.textTheme.bodySmall?.copyWith(
|
style: context.textTheme.bodySmall?.copyWith(
|
||||||
color: ColorsManager.lightGreyColor,
|
color: ColorsManager.lightGreyColor,
|
||||||
fontSize: 9,
|
fontSize: 9,
|
||||||
|
@ -17,90 +17,87 @@ class IfContainer extends StatelessWidget {
|
|||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return DragTarget<Map<String, dynamic>>(
|
return DragTarget<Map<String, dynamic>>(
|
||||||
builder: (context, candidateData, rejectedData) {
|
builder: (context, candidateData, rejectedData) {
|
||||||
return Container(
|
return SingleChildScrollView(
|
||||||
width: double.infinity,
|
child: Container(
|
||||||
padding: const EdgeInsets.all(16),
|
width: double.infinity,
|
||||||
child: Column(
|
padding: const EdgeInsets.all(16),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: Column(
|
||||||
children: [
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
Row(
|
children: [
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
Row(
|
||||||
children: [
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
const Text('IF',
|
|
||||||
style:
|
|
||||||
TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
|
||||||
if (state.isAutomation && state.ifItems.isNotEmpty)
|
|
||||||
AutomationOperatorSelector(
|
|
||||||
selectedOperator: state.selectedAutomationOperator),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
if (state.isTabToRun)
|
|
||||||
const Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
children: [
|
||||||
DraggableCard(
|
const Text('IF',
|
||||||
imagePath: Assets.tabToRun,
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
||||||
title: 'Tab to run',
|
if (state.isAutomation && state.ifItems.isNotEmpty)
|
||||||
deviceData: {},
|
AutomationOperatorSelector(
|
||||||
),
|
selectedOperator: state.selectedAutomationOperator),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (!state.isTabToRun)
|
const SizedBox(height: 16),
|
||||||
Wrap(
|
if (state.isTabToRun)
|
||||||
spacing: 8,
|
const Row(
|
||||||
runSpacing: 8,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: List.generate(
|
children: [
|
||||||
state.ifItems.length,
|
DraggableCard(
|
||||||
(index) => GestureDetector(
|
imagePath: Assets.tabToRun,
|
||||||
onTap: () async {
|
title: 'Tab to run',
|
||||||
if (!state.isTabToRun) {
|
deviceData: {},
|
||||||
final result =
|
),
|
||||||
await DeviceDialogHelper.showDeviceDialog(
|
],
|
||||||
context: context,
|
),
|
||||||
data: state.ifItems[index],
|
if (!state.isTabToRun)
|
||||||
removeComparetors: false,
|
Wrap(
|
||||||
dialogType: "IF");
|
spacing: 8,
|
||||||
|
runSpacing: 8,
|
||||||
|
children: List.generate(
|
||||||
|
state.ifItems.length,
|
||||||
|
(index) => GestureDetector(
|
||||||
|
onTap: () async {
|
||||||
|
if (!state.isTabToRun) {
|
||||||
|
final result = await DeviceDialogHelper.showDeviceDialog(
|
||||||
|
context: context,
|
||||||
|
data: state.ifItems[index],
|
||||||
|
removeComparetors: false,
|
||||||
|
dialogType: "IF");
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
context.read<RoutineBloc>().add(
|
context
|
||||||
AddToIfContainer(
|
.read<RoutineBloc>()
|
||||||
state.ifItems[index], false));
|
.add(AddToIfContainer(state.ifItems[index], false));
|
||||||
} else if (![
|
} else if (![
|
||||||
'AC',
|
'AC',
|
||||||
'1G',
|
'1G',
|
||||||
'2G',
|
'2G',
|
||||||
'3G',
|
'3G',
|
||||||
'WPS',
|
'WPS',
|
||||||
'GW',
|
'GW',
|
||||||
'CPS',
|
'CPS',
|
||||||
].contains(
|
].contains(state.ifItems[index]['productType'])) {
|
||||||
state.ifItems[index]['productType'])) {
|
context
|
||||||
context.read<RoutineBloc>().add(
|
.read<RoutineBloc>()
|
||||||
AddToIfContainer(
|
.add(AddToIfContainer(state.ifItems[index], false));
|
||||||
state.ifItems[index], false));
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
|
||||||
child: DraggableCard(
|
|
||||||
imagePath: state.ifItems[index]['imagePath'] ?? '',
|
|
||||||
title: state.ifItems[index]['title'] ?? '',
|
|
||||||
deviceData: state.ifItems[index],
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 4, vertical: 8),
|
|
||||||
isFromThen: false,
|
|
||||||
isFromIf: true,
|
|
||||||
onRemove: () {
|
|
||||||
context.read<RoutineBloc>().add(RemoveDragCard(
|
|
||||||
index: index,
|
|
||||||
isFromThen: false,
|
|
||||||
key: state.ifItems[index]
|
|
||||||
['uniqueCustomId']));
|
|
||||||
},
|
},
|
||||||
),
|
child: DraggableCard(
|
||||||
)),
|
imagePath: state.ifItems[index]['imagePath'] ?? '',
|
||||||
),
|
title: state.ifItems[index]['title'] ?? '',
|
||||||
],
|
deviceData: state.ifItems[index],
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 8),
|
||||||
|
isFromThen: false,
|
||||||
|
isFromIf: true,
|
||||||
|
onRemove: () {
|
||||||
|
context.read<RoutineBloc>().add(RemoveDragCard(
|
||||||
|
index: index,
|
||||||
|
isFromThen: false,
|
||||||
|
key: state.ifItems[index]['uniqueCustomId']));
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -124,14 +121,10 @@ class IfContainer extends StatelessWidget {
|
|||||||
removeComparetors: false);
|
removeComparetors: false);
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
context
|
context.read<RoutineBloc>().add(AddToIfContainer(mutableData, false));
|
||||||
.read<RoutineBloc>()
|
|
||||||
.add(AddToIfContainer(mutableData, false));
|
|
||||||
} else if (!['AC', '1G', '2G', '3G', 'WPS', 'GW', 'CPS']
|
} else if (!['AC', '1G', '2G', '3G', 'WPS', 'GW', 'CPS']
|
||||||
.contains(mutableData['productType'])) {
|
.contains(mutableData['productType'])) {
|
||||||
context
|
context.read<RoutineBloc>().add(AddToIfContainer(mutableData, false));
|
||||||
.read<RoutineBloc>()
|
|
||||||
.add(AddToIfContainer(mutableData, false));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -177,9 +170,7 @@ class AutomationOperatorSelector extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context
|
context.read<RoutineBloc>().add(const ChangeAutomationOperator(operator: 'or'));
|
||||||
.read<RoutineBloc>()
|
|
||||||
.add(const ChangeAutomationOperator(operator: 'or'));
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
@ -205,9 +196,7 @@ class AutomationOperatorSelector extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context
|
context.read<RoutineBloc>().add(const ChangeAutomationOperator(operator: 'and'));
|
||||||
.read<RoutineBloc>()
|
|
||||||
.add(const ChangeAutomationOperator(operator: 'and'));
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -121,8 +121,7 @@ class _RoutineViewCardState extends State<RoutineViewCard> {
|
|||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: 16,
|
width: 16,
|
||||||
height: 16,
|
height: 16,
|
||||||
child:
|
child: CircularProgressIndicator(strokeWidth: 2),
|
||||||
CircularProgressIndicator(strokeWidth: 2),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -159,9 +158,7 @@ class _RoutineViewCardState extends State<RoutineViewCard> {
|
|||||||
height: iconSize,
|
height: iconSize,
|
||||||
width: iconSize,
|
width: iconSize,
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
errorBuilder:
|
errorBuilder: (context, error, stackTrace) => Image.asset(
|
||||||
(context, error, stackTrace) =>
|
|
||||||
Image.asset(
|
|
||||||
Assets.logo,
|
Assets.logo,
|
||||||
height: iconSize,
|
height: iconSize,
|
||||||
width: iconSize,
|
width: iconSize,
|
||||||
@ -174,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,
|
||||||
@ -185,9 +181,7 @@ 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,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -200,11 +194,10 @@ class _RoutineViewCardState extends State<RoutineViewCard> {
|
|||||||
widget.textString,
|
widget.textString,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
maxLines: 2,
|
maxLines: 1,
|
||||||
style: context.textTheme.bodySmall?.copyWith(
|
style: context.textTheme.bodySmall?.copyWith(
|
||||||
color: ColorsManager.blackColor,
|
color: ColorsManager.blackColor,
|
||||||
fontSize:
|
fontSize: widget.isSmallScreenSize(context) ? 10 : 12,
|
||||||
widget.isSmallScreenSize(context) ? 10 : 12,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (widget.spaceName != '')
|
if (widget.spaceName != '')
|
||||||
@ -220,14 +213,10 @@ class _RoutineViewCardState extends State<RoutineViewCard> {
|
|||||||
widget.spaceName,
|
widget.spaceName,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
maxLines: 2,
|
maxLines: 1,
|
||||||
style:
|
style: context.textTheme.bodySmall?.copyWith(
|
||||||
context.textTheme.bodySmall?.copyWith(
|
|
||||||
color: ColorsManager.blackColor,
|
color: ColorsManager.blackColor,
|
||||||
fontSize:
|
fontSize: widget.isSmallScreenSize(context) ? 10 : 12,
|
||||||
widget.isSmallScreenSize(context)
|
|
||||||
? 10
|
|
||||||
: 12,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.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/view/space_tree_view.dart';
|
import 'package:syncrow_web/pages/space_tree/view/space_tree_view.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/bloc/space_management_event.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_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/product_model.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
|
||||||
@ -107,6 +109,11 @@ class _LoadedSpaceViewState extends State<LoadedSpaceView> {
|
|||||||
selectedSpaceUuid: widget.selectedSpace?.uuid ??
|
selectedSpaceUuid: widget.selectedSpace?.uuid ??
|
||||||
widget.selectedCommunity?.uuid ??
|
widget.selectedCommunity?.uuid ??
|
||||||
'',
|
'',
|
||||||
|
onCreateCommunity: (name, description) {
|
||||||
|
context.read<SpaceManagementBloc>().add(
|
||||||
|
CreateCommunityEvent(name, description, context),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
CommunityStructureArea(
|
CommunityStructureArea(
|
||||||
selectedCommunity: widget.selectedCommunity,
|
selectedCommunity: widget.selectedCommunity,
|
||||||
|
@ -1,19 +1,15 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.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/create_community/view/create_community_dialog.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/constants/assets.dart';
|
||||||
|
|
||||||
class SidebarAddCommunityButton extends StatelessWidget {
|
class SidebarAddCommunityButton extends StatelessWidget {
|
||||||
const SidebarAddCommunityButton({
|
const SidebarAddCommunityButton({
|
||||||
required this.existingCommunityNames,
|
required this.onTap,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
final List<String> existingCommunityNames;
|
final void Function() onTap;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -30,22 +26,9 @@ class SidebarAddCommunityButton extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
onPressed: () => _showCreateCommunityDialog(context),
|
onPressed: onTap,
|
||||||
icon: SvgPicture.asset(Assets.addIcon),
|
icon: SvgPicture.asset(Assets.addIcon),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _showCreateCommunityDialog(BuildContext context) => showDialog<void>(
|
|
||||||
context: context,
|
|
||||||
builder: (context) => CreateCommunityDialog(
|
|
||||||
isEditMode: false,
|
|
||||||
existingCommunityNames: existingCommunityNames,
|
|
||||||
onCreateCommunity: (name, description) {
|
|
||||||
context.read<SpaceManagementBloc>().add(
|
|
||||||
CreateCommunityEvent(name, description, context),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,12 @@ import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
|||||||
import 'package:syncrow_web/utils/style.dart';
|
import 'package:syncrow_web/utils/style.dart';
|
||||||
|
|
||||||
class SidebarHeader extends StatelessWidget {
|
class SidebarHeader extends StatelessWidget {
|
||||||
const SidebarHeader({required this.existingCommunityNames, super.key});
|
const SidebarHeader({
|
||||||
|
required this.onAddCommunity,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
final List<String> existingCommunityNames;
|
final void Function() onAddCommunity;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -23,7 +26,9 @@ class SidebarHeader extends StatelessWidget {
|
|||||||
color: ColorsManager.blackColor,
|
color: ColorsManager.blackColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SidebarAddCommunityButton(existingCommunityNames: existingCommunityNames),
|
SidebarAddCommunityButton(
|
||||||
|
onTap: onAddCommunity,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -8,6 +8,7 @@ import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model
|
|||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/community_tile.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/community_tile.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/sidebar_header.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/sidebar_header.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/space_tile_widget.dart';
|
import 'package:syncrow_web/pages/spaces_management/all_spaces/widgets/space_tile_widget.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/create_community/view/create_community_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/structure_selector/bloc/center_body_bloc.dart';
|
import 'package:syncrow_web/pages/spaces_management/structure_selector/bloc/center_body_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/structure_selector/bloc/center_body_event.dart';
|
import 'package:syncrow_web/pages/spaces_management/structure_selector/bloc/center_body_event.dart';
|
||||||
import 'package:syncrow_web/utils/style.dart';
|
import 'package:syncrow_web/utils/style.dart';
|
||||||
@ -15,9 +16,11 @@ import 'package:syncrow_web/utils/style.dart';
|
|||||||
class SidebarWidget extends StatefulWidget {
|
class SidebarWidget extends StatefulWidget {
|
||||||
final List<CommunityModel> communities;
|
final List<CommunityModel> communities;
|
||||||
final String? selectedSpaceUuid;
|
final String? selectedSpaceUuid;
|
||||||
|
final void Function(String name, String description) onCreateCommunity;
|
||||||
|
|
||||||
const SidebarWidget({
|
const SidebarWidget({
|
||||||
required this.communities,
|
required this.communities,
|
||||||
|
required this.onCreateCommunity,
|
||||||
this.selectedSpaceUuid,
|
this.selectedSpaceUuid,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
@ -94,10 +97,7 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
SidebarHeader(
|
SidebarHeader(onAddCommunity: _onAddCommunity),
|
||||||
existingCommunityNames:
|
|
||||||
widget.communities.map((community) => community.name).toList(),
|
|
||||||
),
|
|
||||||
CustomSearchBar(
|
CustomSearchBar(
|
||||||
onSearchChanged: (query) => setState(() => _searchQuery = query),
|
onSearchChanged: (query) => setState(() => _searchQuery = query),
|
||||||
),
|
),
|
||||||
@ -179,4 +179,26 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _onAddCommunity() => _selectedId?.isNotEmpty ?? true
|
||||||
|
? _clearSelection()
|
||||||
|
: _showCreateCommunityDialog();
|
||||||
|
|
||||||
|
void _clearSelection() {
|
||||||
|
setState(() => _selectedId = '');
|
||||||
|
context.read<SpaceManagementBloc>().add(
|
||||||
|
NewCommunityEvent(communities: widget.communities),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showCreateCommunityDialog() {
|
||||||
|
showDialog<void>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => CreateCommunityDialog(
|
||||||
|
isEditMode: false,
|
||||||
|
existingCommunityNames: widget.communities.map((e) => e.name).toList(),
|
||||||
|
onCreateCommunity: widget.onCreateCommunity,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
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/common/buttons/cancel_button.dart';
|
|
||||||
import 'package:syncrow_web/pages/common/buttons/default_button.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_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/bloc/subspace_model_event.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/create_subspace_model/bloc/subspace_model_state.dart';
|
import 'package:syncrow_web/pages/spaces_management/create_subspace_model/bloc/subspace_model_state.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/create_subspace_model/widgets/create_subspace_model_chips_box.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/create_subspace_model/widgets/create_subspace_model_footer_buttons.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';
|
||||||
|
|
||||||
class CreateSubSpaceModelDialog extends StatelessWidget {
|
class CreateSubSpaceModelDialog extends StatelessWidget {
|
||||||
final bool isEdit;
|
final bool isEdit;
|
||||||
@ -14,211 +15,67 @@ class CreateSubSpaceModelDialog extends StatelessWidget {
|
|||||||
final List<SubspaceTemplateModel>? existingSubSpaces;
|
final List<SubspaceTemplateModel>? existingSubSpaces;
|
||||||
final void Function(List<SubspaceTemplateModel> newSubspaces)? onUpdate;
|
final void Function(List<SubspaceTemplateModel> newSubspaces)? onUpdate;
|
||||||
|
|
||||||
const CreateSubSpaceModelDialog(
|
const CreateSubSpaceModelDialog({
|
||||||
{Key? key,
|
required this.isEdit,
|
||||||
required this.isEdit,
|
required this.dialogTitle,
|
||||||
required this.dialogTitle,
|
this.existingSubSpaces,
|
||||||
this.existingSubSpaces,
|
this.onUpdate,
|
||||||
this.onUpdate})
|
super.key,
|
||||||
: super(key: key);
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final screenWidth = MediaQuery.of(context).size.width;
|
final screenWidth = MediaQuery.of(context).size.width;
|
||||||
final textController = TextEditingController();
|
|
||||||
|
|
||||||
return Dialog(
|
return Dialog(
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
),
|
),
|
||||||
child: BlocProvider(
|
child: BlocProvider(
|
||||||
create: (_) {
|
create: (context) {
|
||||||
final bloc = SubSpaceModelBloc();
|
final bloc = SubSpaceModelBloc();
|
||||||
if (existingSubSpaces != null) {
|
if (existingSubSpaces != null) {
|
||||||
for (var subSpace in existingSubSpaces!) {
|
for (final subSpace in existingSubSpaces ?? []) {
|
||||||
bloc.add(AddSubSpaceModel(subSpace));
|
bloc.add(AddSubSpaceModel(subSpace));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return bloc;
|
return bloc;
|
||||||
},
|
},
|
||||||
child: BlocBuilder<SubSpaceModelBloc, SubSpaceModelState>(
|
child: BlocBuilder<SubSpaceModelBloc, SubSpaceModelState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) => Container(
|
||||||
return Container(
|
color: ColorsManager.whiteColors,
|
||||||
color: ColorsManager.whiteColors,
|
width: screenWidth * 0.3,
|
||||||
child: SizedBox(
|
padding: const EdgeInsets.all(16),
|
||||||
width: screenWidth * 0.3,
|
child: Column(
|
||||||
child: Padding(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
padding: const EdgeInsets.all(16.0),
|
mainAxisSize: MainAxisSize.min,
|
||||||
child: Column(
|
children: [
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
Text(
|
||||||
mainAxisSize: MainAxisSize.min,
|
dialogTitle,
|
||||||
children: [
|
style: context.textTheme.headlineLarge?.copyWith(
|
||||||
Text(
|
color: ColorsManager.blackColor,
|
||||||
dialogTitle,
|
),
|
||||||
style: Theme.of(context)
|
),
|
||||||
.textTheme
|
const SizedBox(height: 16),
|
||||||
.headlineLarge
|
CreateSubspaceModelChipsBox(subSpaces: state.subSpaces),
|
||||||
?.copyWith(color: ColorsManager.blackColor),
|
if (state.errorMessage.isNotEmpty)
|
||||||
),
|
Padding(
|
||||||
const SizedBox(height: 16),
|
padding: const EdgeInsets.only(bottom: 16),
|
||||||
Container(
|
child: Text(
|
||||||
width: screenWidth * 0.35,
|
state.errorMessage,
|
||||||
padding: const EdgeInsets.symmetric(
|
style: context.textTheme.bodySmall?.copyWith(
|
||||||
vertical: 10.0, horizontal: 16.0),
|
color: ColorsManager.red,
|
||||||
decoration: BoxDecoration(
|
),
|
||||||
color: ColorsManager.boxColor,
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
),
|
|
||||||
child: Wrap(
|
|
||||||
spacing: 8.0,
|
|
||||||
runSpacing: 8.0,
|
|
||||||
children: [
|
|
||||||
...state.subSpaces.asMap().entries.map(
|
|
||||||
(entry) {
|
|
||||||
final index = entry.key;
|
|
||||||
final subSpace = entry.value;
|
|
||||||
|
|
||||||
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 Chip(
|
|
||||||
label: Text(subSpace.subspaceName,
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.bodySmall
|
|
||||||
?.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,
|
|
||||||
size: 16,
|
|
||||||
color: ColorsManager.lightGrayColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onDeleted: () => context
|
|
||||||
.read<SubSpaceModelBloc>()
|
|
||||||
.add(RemoveSubSpaceModel(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<SubSpaceModelBloc>().add(
|
|
||||||
AddSubSpaceModel(
|
|
||||||
SubspaceTemplateModel(
|
|
||||||
subspaceName: value.trim(),
|
|
||||||
disabled: false)));
|
|
||||||
textController.clear();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.bodyMedium
|
|
||||||
?.copyWith(
|
|
||||||
color: ColorsManager.blackColor)),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (state.errorMessage.isNotEmpty)
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(bottom: 16.0),
|
|
||||||
child: Text(state.errorMessage,
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
|
||||||
.bodySmall
|
|
||||||
?.copyWith(
|
|
||||||
color: ColorsManager.red,
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
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<SubSpaceModelBloc>()
|
|
||||||
.state
|
|
||||||
.subSpaces;
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
if (onUpdate != null) {
|
|
||||||
onUpdate!(subSpaces);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
backgroundColor: ColorsManager.secondaryColor,
|
|
||||||
borderRadius: 10,
|
|
||||||
foregroundColor: state.errorMessage.isNotEmpty
|
|
||||||
? ColorsManager.whiteColorsWithOpacity
|
|
||||||
: ColorsManager.whiteColors,
|
|
||||||
child: const Text('OK'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
));
|
const SizedBox(height: 16),
|
||||||
},
|
CreateSubspaceModelFooterButtons(
|
||||||
|
onUpdate: onUpdate,
|
||||||
|
errorMessage: state.errorMessage,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -0,0 +1,64 @@
|
|||||||
|
import 'package:flutter/material.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/space_model/models/subspace_template_model.dart';
|
||||||
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
|
class CreateSubspaceModelChipsBox extends StatelessWidget {
|
||||||
|
const CreateSubspaceModelChipsBox({
|
||||||
|
required this.subSpaces,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
final List<SubspaceTemplateModel> subSpaces;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final screenWidth = MediaQuery.of(context).size.width;
|
||||||
|
|
||||||
|
return Container(
|
||||||
|
width: 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: [
|
||||||
|
...subSpaces.asMap().entries.map(
|
||||||
|
(entry) {
|
||||||
|
final index = entry.key;
|
||||||
|
final subSpace = entry.value;
|
||||||
|
|
||||||
|
final lowerName = subSpace.subspaceName.toLowerCase();
|
||||||
|
|
||||||
|
final duplicateIndices = 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: subSpace,
|
||||||
|
isDuplicate: isDuplicate,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SubspacesTextfield(
|
||||||
|
hintText: subSpaces.isEmpty ? 'Please enter the name' : null,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
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/spaces_management/create_subspace_model/bloc/subspace_model_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/spaces_management/space_model/models/subspace_template_model.dart';
|
||||||
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
|
||||||
|
class CreateSubspaceModelFooterButtons extends StatelessWidget {
|
||||||
|
const CreateSubspaceModelFooterButtons({
|
||||||
|
required this.onUpdate,
|
||||||
|
required this.errorMessage,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
final void Function(List<SubspaceTemplateModel> newSubspaces)? onUpdate;
|
||||||
|
final String errorMessage;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: CancelButton(
|
||||||
|
label: 'Cancel',
|
||||||
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Expanded(
|
||||||
|
child: DefaultButton(
|
||||||
|
onPressed: errorMessage.isEmpty
|
||||||
|
? () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
if (onUpdate != null) {
|
||||||
|
final subSpaces =
|
||||||
|
context.read<SubSpaceModelBloc>().state.subSpaces;
|
||||||
|
onUpdate!(subSpaces);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
backgroundColor: ColorsManager.secondaryColor,
|
||||||
|
borderRadius: 10,
|
||||||
|
foregroundColor: errorMessage.isNotEmpty
|
||||||
|
? ColorsManager.whiteColorsWithOpacity
|
||||||
|
: ColorsManager.whiteColors,
|
||||||
|
child: const Text('OK'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
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/utils/color_manager.dart';
|
||||||
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
|
|
||||||
|
class SubspaceChip extends StatelessWidget {
|
||||||
|
const SubspaceChip({
|
||||||
|
required this.subSpace,
|
||||||
|
required this.isDuplicate,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
final SubspaceTemplateModel subSpace;
|
||||||
|
final bool isDuplicate;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Chip(
|
||||||
|
label: Text(
|
||||||
|
subSpace.subspaceName,
|
||||||
|
style: context.textTheme.bodySmall?.copyWith(
|
||||||
|
color: isDuplicate ? ColorsManager.red : ColorsManager.spaceColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
backgroundColor: ColorsManager.whiteColors,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
side: BorderSide(
|
||||||
|
color: isDuplicate ? ColorsManager.red : ColorsManager.transparentColor,
|
||||||
|
width: 0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
deleteIcon: Container(
|
||||||
|
padding: const EdgeInsetsDirectional.all(1),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
border: Border.all(
|
||||||
|
color: ColorsManager.lightGrayColor,
|
||||||
|
width: 1.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: const FittedBox(
|
||||||
|
fit: BoxFit.scaleDown,
|
||||||
|
child: Icon(
|
||||||
|
Icons.close,
|
||||||
|
color: ColorsManager.lightGrayColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onDeleted: () => context.read<SubSpaceModelBloc>().add(
|
||||||
|
RemoveSubSpaceModel(subSpace),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
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/utils/color_manager.dart';
|
||||||
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
|
|
||||||
|
class SubspacesTextfield extends StatefulWidget {
|
||||||
|
const SubspacesTextfield({
|
||||||
|
required this.hintText,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String? hintText;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SubspacesTextfield> createState() => _SubspacesTextfieldState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SubspacesTextfieldState extends State<SubspacesTextfield> {
|
||||||
|
late final TextEditingController _controller;
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
_controller = TextEditingController();
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_controller.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SizedBox(
|
||||||
|
width: 100,
|
||||||
|
child: TextField(
|
||||||
|
controller: _controller,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
border: InputBorder.none,
|
||||||
|
hintText: widget.hintText,
|
||||||
|
hintStyle: context.textTheme.bodySmall?.copyWith(
|
||||||
|
color: ColorsManager.lightGrayColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onSubmitted: (value) {
|
||||||
|
final trimmedValue = value.trim();
|
||||||
|
if (trimmedValue.isNotEmpty) {
|
||||||
|
context.read<SubSpaceModelBloc>().add(
|
||||||
|
AddSubSpaceModel(
|
||||||
|
SubspaceTemplateModel(
|
||||||
|
subspaceName: trimmedValue,
|
||||||
|
disabled: false,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
_controller.clear();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
style: context.textTheme.bodyMedium?.copyWith(
|
||||||
|
color: ColorsManager.blackColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -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