This commit is contained in:
mohammadnemer1
2025-02-11 11:05:31 +03:00
committed by GitHub
18 changed files with 80 additions and 95 deletions

View File

@ -1,2 +1,3 @@
ENV_NAME=development
BASE_URL=https://syncrow-dev.azurewebsites.net
BASE_URL=https://syncrow-dev.azurewebsites.net
projectId=0e62577c-06fa-41b9-8a92-99a21fbaf51c

View File

@ -1,2 +1,3 @@
ENV_NAME=production
BASE_URL=https://syncrow-staging.azurewebsites.net
BASE_URL=https://syncrow-staging.azurewebsites.net
projectId=bcda711e-9fc2-4168-a05e-171b4026d1ff

View File

@ -1,2 +1,3 @@
ENV_NAME=staging
BASE_URL=https://syncrow-staging.azurewebsites.net
BASE_URL=https://syncrow-staging.azurewebsites.net
projectId=bcda711e-9fc2-4168-a05e-171b4026d1ff

View File

@ -136,7 +136,6 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
ac.acSwitch = acSwitchValue;
}
}
_setAllAcsTempsAndSwitches();
_emitAcsStatus(emit);
@ -458,24 +457,27 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
}
void _getCounterValue(GetCounterEvent event, Emitter<AcsState> emit) async {
try {
emit(AcsLoadingState());
var response = await DevicesAPI.getDeviceStatus(acId);
List<StatusModel> statusModelList = [];
for (var status in response['status']) {
statusModelList.add(StatusModel.fromJson(status));
}
deviceStatus =
AcStatusModel.fromJson(response['productUuid'], statusModelList);
if (event.deviceCode == 'countdown_time') {
deviceStatus.countdown1 > 0
? _onStartTimer(deviceStatus.countdown1)
: emit(UpdateTimerState(seconds: deviceStatus.countdown1));
}
} catch (e) {
emit(AcsFailedState(errorMessage: e.toString()));
return;
emit(AcsLoadingState());
var response = await DevicesAPI.getDeviceStatus(acId);
List<StatusModel> statusModelList = [];
for (var status in response['status']) {
statusModelList.add(StatusModel.fromJson(status));
}
deviceStatus =
AcStatusModel.fromJson(response['productUuid'], statusModelList);
deviceStatus.countdown1;
var duration;
if (deviceStatus.countdown1 == 5) {
duration = const Duration(minutes: 30);
var countNum = duration.inSeconds;
_onStartTimer(countNum);
} else if (deviceStatus.countdown1 > 5) {
duration = Duration(minutes: deviceStatus.countdown1 * 6);
var countNum = duration.inSeconds;
_onStartTimer(countNum);
} else {
_timer?.cancel();
emit(TimerRunComplete());
}
}

View File

@ -48,7 +48,6 @@ class DevicesCubit extends Cubit<DevicesState> {
return _instance ??= DevicesCubit._();
}
@override
Future<void> close() {
_instance = null;
@ -478,8 +477,7 @@ class DevicesCubit extends Cubit<DevicesState> {
final statusIndex =
device.status.indexWhere((s) => s.code == switchCode);
if (statusIndex != -1) {
final currentValue = device.status[statusIndex].value ?? false;
final toggledValue = !currentValue;
final toggledValue = control.value;
final controlRequest = DeviceControlModel(
code: switchCode, value: toggledValue, deviceId: deviceUuid);
final response =
@ -518,8 +516,7 @@ class DevicesCubit extends Cubit<DevicesState> {
final statusIndex =
device.status.indexWhere((s) => s.code == switchCode);
if (statusIndex != -1) {
final currentValue = device.status[statusIndex].value ?? false;
final toggledValue = !currentValue;
final toggledValue = control.value;
final controlRequest = DeviceControlModel(
code: switchCode, value: toggledValue, deviceId: deviceUuid);
final response =
@ -556,8 +553,7 @@ class DevicesCubit extends Cubit<DevicesState> {
final statusIndex =
device.status.indexWhere((s) => s.code == switchCode);
if (statusIndex != -1) {
final currentValue = device.status[statusIndex].value ?? false;
final toggledValue = !currentValue;
final toggledValue = control.value;
final controlRequest = DeviceControlModel(
code: switchCode, value: toggledValue, deviceId: deviceUuid);
final response =
@ -589,8 +585,7 @@ class DevicesCubit extends Cubit<DevicesState> {
final statusIndex = device.status.indexWhere((s) => s.code == 'switch_1');
if (statusIndex != -1) {
final currentValue = device.status[statusIndex].value ?? false;
final toggledValue = !currentValue;
final toggledValue = control.value;
final controlRequest = DeviceControlModel(
code: 'switch_1', value: toggledValue, deviceId: deviceUuid);
final response =

View File

@ -43,6 +43,7 @@ class AcInterfaceControls extends StatelessWidget {
PageRouteBuilder(
pageBuilder: (context, animation1, animation2) =>
AcTimerPage(
deviceStatus: deviceStatus,
device: deviceModel,
deviceCode: deviceModel.type!,
switchCode: '',

View File

@ -7,7 +7,7 @@ import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_st
import 'package:syncrow_app/features/devices/bloc/acs_bloc/acs_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/acs_bloc/acs_event.dart';
import 'package:syncrow_app/features/devices/bloc/acs_bloc/acs_state.dart';
import 'package:syncrow_app/features/devices/model/ac_model.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/devices/view/widgets/ACs/custom_halfhour_timer_picker.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
@ -20,10 +20,13 @@ class AcTimerPage extends StatelessWidget {
final DeviceModel device;
final String deviceCode;
final String switchCode;
final AcStatusModel deviceStatus;
const AcTimerPage(
{required this.device,
required this.deviceCode,
required this.switchCode,
required this.deviceStatus,
super.key});
@override
@ -37,27 +40,24 @@ class AcTimerPage extends StatelessWidget {
create: (context) => ACsBloc(acId: device.uuid ?? ''),
child: BlocBuilder<ACsBloc, AcsState>(
builder: (context, state) {
final oneGangBloc = BlocProvider.of<ACsBloc>(context);
final acBloc = BlocProvider.of<ACsBloc>(context);
Duration duration = Duration.zero;
int selectedValue = 0;
int countNum = 0;
if (state is UpdateTimerState) {
if (state is AcsInitialState) {
acBloc.add(GetCounterEvent(deviceCode: deviceCode));
} else if (state is UpdateTimerState) {
countNum = state.seconds;
} else if (state is TimerRunInProgress) {
countNum = state.remainingTime;
} else if (state is TimerRunComplete) {
countNum = 0;
}
// else if (state is LoadingNewSate) {
// countNum = 0;
// }
return PopScope(
canPop: false,
onPopInvoked: (didPop) {
if (!didPop) {
oneGangBloc.add(OnClose());
acBloc.add(OnClose());
Navigator.pop(context);
}
},
@ -90,7 +90,7 @@ class AcTimerPage extends StatelessWidget {
),
),
Center(
child: Container(
child: SizedBox(
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
@ -102,7 +102,7 @@ class AcTimerPage extends StatelessWidget {
.slidingBlueColor,
fontSize: 40,
)
: Container(
: SizedBox(
child: CustomHalfHourPicker(
onValueChanged: (value) {
selectedValue =
@ -120,8 +120,6 @@ class AcTimerPage extends StatelessWidget {
countNum =
duration.inSeconds;
}
print(
"Selected Value: $selectedValue, Duration: $duration");
},
),
),
@ -131,12 +129,14 @@ class AcTimerPage extends StatelessWidget {
return;
}
if (countNum > 0) {
oneGangBloc.add(SetCounterValue(
acBloc.add(SetCounterValue(
seconds: countNum,
deviceCode:'countdown_time',
deviceCode:
'countdown_time',
duration: selectedValue));
} else if (duration != Duration.zero) {
oneGangBloc.add(SetCounterValue(
} else if (duration !=
Duration.zero) {
acBloc.add(SetCounterValue(
seconds: 0,
deviceCode:
'countdown_time',

View File

@ -4,7 +4,6 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/acs_bloc/acs_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/acs_bloc/acs_event.dart';
import 'package:syncrow_app/features/devices/bloc/acs_bloc/acs_state.dart';
import 'package:syncrow_app/features/devices/model/ac_model.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/devices/view/widgets/ACs/ac_interface.dart';
import 'package:syncrow_app/features/devices/view/widgets/ACs/acs_list.dart';
@ -23,8 +22,6 @@ class ACsView extends StatelessWidget {
@override
Widget build(BuildContext context) {
print("ACsView deviceModel UUID: ${deviceModel?.uuid}");
return BlocProvider(
create: (context) => ACsBloc(acId: deviceModel?.uuid ?? '')
..add(AcsInitial(allAcs: deviceModel != null ? false : true)),
@ -41,7 +38,6 @@ class ACsView extends StatelessWidget {
extendBody: true,
appBar: deviceModel != null
? DeviceAppbar(
//BlocProvider.of<ACsBloc>(context).deviceStatus.acSwitch.toString()
value: true,
deviceName: deviceModel!.name!,
deviceUuid: deviceModel!.uuid!,

View File

@ -306,7 +306,7 @@ class CeilingSensorInterface extends StatelessWidget {
.toString()
.toLowerCase()
.replaceAll('sec', 's')
.replaceAll('1hr', '1hour'), // Replacing "sec" with "s"
.replaceAll('1hr', '1hour'),
code: 'nobody_time'));
}
} else if (title == 'Maximum Distance') {
@ -344,7 +344,7 @@ class CeilingSensorInterface extends StatelessWidget {
context,
MaterialPageRoute(builder: (context) => const CeilingHelpDescription()),
);
} else if (title == 'Induction History') {
} else if (title == 'Presence Record') {
Navigator.push(
context,
MaterialPageRoute(
@ -393,7 +393,7 @@ class CeilingSensorInterface extends StatelessWidget {
'val': nobodyTimeVal,
},
{
'title': 'Induction History',
'title': 'Presence Record',
'icon': Assets.assetsIconsPresenceSensorAssetsInductionRecording,
'page': null,
'withArrow': false,

View File

@ -31,12 +31,12 @@ class MaxDistanceControl extends StatefulWidget {
}
int _parseValue(String value) {
if (value.endsWith('sec')) {
return int.parse(value.replaceAll('sec', '').trim());
if (value.endsWith('s')) {
return int.parse(value.replaceAll('s', '').trim());
} else if (value.endsWith('min')) {
return int.parse(value.replaceAll('min', '').trim()) * 60;
} else if (value.endsWith('hr')) {
return int.parse(value.replaceAll('hr', '').trim()) * 3600;
} else if (value.endsWith('hour')) {
return int.parse(value.replaceAll('hour', '').trim()) * 3600;
}
return 0; // Default to 0 if the format is unrecognized
}
@ -58,7 +58,7 @@ class MaxDistanceControlState extends State<MaxDistanceControl> {
String _formatLabel(double seconds) {
if (seconds == 0) return 'None';
if (seconds < 60) return '${seconds.toInt()}sec';
if (seconds < 60) return '${seconds.toInt()}s';
if (seconds < 3600) {
final minutes = (seconds / 60).round();
return '${minutes}min';
@ -90,7 +90,6 @@ class MaxDistanceControlState extends State<MaxDistanceControl> {
@override
Widget build(BuildContext context) {
final double currentSeconds = _stepValues[_currentIndex];
return Dialog(
child: Container(
decoration: BoxDecoration(
@ -128,7 +127,9 @@ class MaxDistanceControlState extends State<MaxDistanceControl> {
mainAxisAlignment: MainAxisAlignment.center,
children: [
TitleMedium(
text: _formatLabel(currentSeconds),
text: _formatLabel(currentSeconds)
.replaceAll('1hr', '1hour')
.replaceAllMapped(RegExp(r's$'), (match) => 'sec'),
style: context.titleMedium.copyWith(
color: Colors.black,
fontWeight: FontsManager.bold,

View File

@ -21,32 +21,28 @@ class DevicesViewBody extends StatelessWidget {
return BlocBuilder<HomeCubit, HomeState>(
builder: (context, homeState) {
final homeCubit = HomeCubit.getInstance();
// Handle state priority: Errors first
if (homeState is ActivationError) {
return const CreateUnitWidget();
}
// Handle loading states
if (homeState is GetSpacesLoading || homeState is HomeLoading) {
return const Center(child: CircularProgressIndicator());
}
// Handle error states
if (homeState is GetSpacesError) {
return const CreateUnitWidget();
}
// Handle success states
if (homeState is GetSpacesSuccess ||
homeState is RoomUnSelected ||
homeState is RoomSelected ||
homeState is NavChangePage) {
homeState is NavChangePage ||
homeState is GetSpaceRoomsSuccess) {
// Show empty state if no spaces
if (homeCubit.spaces.isEmpty) {
return const CreateUnitWidget();
}
return BlocBuilder<DevicesCubit, DevicesState>(
builder: (context, devicesState) {
// Devices loading states
@ -55,7 +51,6 @@ class DevicesViewBody extends StatelessWidget {
devicesState is GetDevicesLoading) {
return const Center(child: CircularProgressIndicator());
}
// Devices error state
if (devicesState is GetDevicesError) {
return Center(child: BodyLarge(text: devicesState.errorMsg));
@ -65,7 +60,6 @@ class DevicesViewBody extends StatelessWidget {
},
);
}
// Fallback for unknown states
return const Center(child: BodyLarge(text: ''));
},
@ -74,7 +68,6 @@ class DevicesViewBody extends StatelessWidget {
Widget _buildMainContent(BuildContext context, HomeCubit homeCubit) {
final devicesCubit = context.read<DevicesCubit>();
return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,

View File

@ -154,11 +154,11 @@ class MenuCubit extends Cubit<MenuState> {
'title': 'Legal Information',
'color': const Color(0xFF001B72),
'buttons': [
{
'title': 'About',
'Icon': Assets.assetsIconsMenuIconsLeagalInfoIconsAbout,
'page': null
},
// {
// 'title': 'About',
// 'Icon': Assets.assetsIconsMenuIconsLeagalInfoIconsAbout,
// 'page': null
// },
{
'title': 'Privacy Policy',
'Icon': Assets.assetsIconsMenuIconsLeagalInfoIconsPrivacyPolicy,
@ -176,7 +176,7 @@ class MenuCubit extends Cubit<MenuState> {
Future<void> fetchMenuSections() async {
emit(MenuLoading());
try {
emit(MenuItemsLoaded(menuSections));
emit(MenuItemsLoaded(menuSections));
} catch (e) {
emit(MenuError(e.toString()));
}

View File

@ -51,14 +51,11 @@ class DevicesAPI {
static Future<Map<String, dynamic>> controlDevice(
DeviceControlModel controlModel, String deviceId) async {
try {
print('object-*/-*/-*/${controlModel.toJson()}');
final response = await _httpService.post(
path: ApiEndpoints.controlDevice.replaceAll('{deviceUuid}', deviceId),
body: controlModel.toJson(),
showServerMessage: true,
expectedResponseModel: (json) {
print('object-*/-*/-*/${json}');
return json;
},
);
@ -191,7 +188,6 @@ class DevicesAPI {
path: ApiEndpoints.deviceByUuid.replaceAll('{deviceUuid}', deviceId),
showServerMessage: false,
expectedResponseModel: (json) {
print('object-*-*-*${json}');
return json;
});
return response;
@ -229,7 +225,7 @@ class DevicesAPI {
.replaceAll('{communityUuid}', communityUuid)
.replaceAll('{spaceUuid}', spaceUuid)
.replaceAll('{subSpaceUuid}', roomId)
.replaceAll('{projectUuid}', TempConst.projectId);
.replaceAll('{projectUuid}', TempConst.projectIdDev);
final response = await _httpService.get(
path: path,
@ -569,21 +565,16 @@ class DevicesAPI {
required String communityUuid,
required String spaceUuid,
}) async {
print('communityUuid=$communityUuid');
print('spaceUuid=$spaceUuid');
print('projectUuid=${TempConst.projectId}');
try {
final String path = ApiEndpoints.getAllDevices
.replaceAll('{communityUuid}', communityUuid)
.replaceAll('{spaceUuid}', spaceUuid)
.replaceAll('{projectUuid}', TempConst.projectId);
.replaceAll('{projectUuid}', TempConst.projectIdDev);
final response = await _httpService.get(
path: path,
showServerMessage: false,
expectedResponseModel: (json) {
print('response-*/-*/$json');
final data = json['data'];
if (data == null || data.isEmpty) {

View File

@ -150,7 +150,7 @@ class HomeCreation {
final fullPath = ApiEndpoints.addSubSpace
.replaceAll('{communityUuid}', communityId)
.replaceAll('{spaceUuid}', spaceId)
.replaceAll('{projectUuid}', TempConst.projectId);
.replaceAll('{projectUuid}', TempConst.projectIdDev);
final response = await _httpService.post(
path: fullPath,
body: body,

View File

@ -40,7 +40,7 @@ class HomeManagementAPI {
final path = ApiEndpoints.spaceDevices
.replaceAll('{communityUuid}', communityUuid)
.replaceAll('{spaceUuid}', spaceUuid)
.replaceAll('{projectUuid}', TempConst.projectId);
.replaceAll('{projectUuid}', TempConst.projectIdDev);
await _httpService.get(
path: path,
@ -67,6 +67,7 @@ class HomeManagementAPI {
try {
final response = await _httpService.post(
path: ApiEndpoints.assignDeviceToRoom
.replaceAll('{projectUuid}', TempConst.projectIdDev)
.replaceAll('{communityUuid}', communityId)
.replaceAll('{spaceUuid}', spaceId)
.replaceAll('{subSpaceUuid}', subSpaceId)
@ -90,7 +91,7 @@ class HomeManagementAPI {
.replaceAll('{spaceUuid}', spaceId)
.replaceAll('{subSpaceUuid}', subSpaceId)
.replaceAll('{deviceUuid}', deviceId)
.replaceAll('{projectUuid}', TempConst.projectId),
.replaceAll('{projectUuid}', TempConst.projectIdDev),
expectedResponseModel: (json) {
return json;
},

View File

@ -57,7 +57,7 @@ class SceneApi {
path: ApiEndpoints.getUnitScenes
.replaceAll('{spaceUuid}', unitId)
.replaceAll('{communityUuid}', communityId)
.replaceAll('{projectUuid}', TempConst.projectId),
.replaceAll('{projectUuid}', TempConst.projectIdDev),
queryParameters: {'showInHomePage': showInDevice},
showServerMessage: false,
expectedResponseModel: (json) {

View File

@ -38,7 +38,7 @@ class SpacesAPI {
final path = ApiEndpoints.listSubspace
.replaceFirst('{communityUuid}', communityId)
.replaceFirst('{spaceUuid}', spaceId)
.replaceAll('{projectUuid}', TempConst.projectId);
.replaceAll('{projectUuid}', TempConst.projectIdDev);
final response = await _httpService.get(
path: path,
@ -71,7 +71,7 @@ class SpacesAPI {
path: ApiEndpoints.invitationCode
.replaceAll('{unitUuid}', unitId)
.replaceAll('{communityUuid}', communityId)
.replaceAll('{projectUuid}', TempConst.projectId),
.replaceAll('{projectUuid}', TempConst.projectIdDev),
showServerMessage: false,
expectedResponseModel: (json) {
if (json != null && json['data'] != null) {

View File

@ -1,3 +1,5 @@
import 'package:flutter_dotenv/flutter_dotenv.dart';
class TempConst {
static const projectId = '0e62577c-06fa-41b9-8a92-99a21fbaf51c';
static String projectIdDev = dotenv.env['projectId'] ?? '';
}