change_settings_code

This commit is contained in:
mohammad
2024-11-26 16:47:07 +03:00
parent f24a32ec7b
commit bb50918f04
44 changed files with 1384 additions and 4290 deletions

View File

@ -2,6 +2,7 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/navigation/routing_constants.dart';
import 'package:syncrow_app/utils/context_extension.dart';

View File

@ -0,0 +1,559 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
import 'package:syncrow_app/features/devices/bloc/device_settings_bloc/device_scene_event.dart';
import 'package:syncrow_app/features/devices/bloc/device_settings_bloc/device_scene_state.dart';
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/devices/model/device_report_model.dart';
import 'package:syncrow_app/features/devices/model/four_scene_model.dart';
import 'package:syncrow_app/features/devices/model/four_scene_switch_model.dart';
import 'package:syncrow_app/features/devices/model/question_model.dart';
import 'package:syncrow_app/features/devices/model/group_devices_model.dart';
import 'package:syncrow_app/features/devices/model/device_info_model.dart';
import 'package:syncrow_app/features/devices/model/status_model.dart';
import 'package:syncrow_app/features/devices/model/subspace_model.dart';
import 'package:syncrow_app/features/scene/model/scenes_model.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/services/api/devices_api.dart';
import 'package:syncrow_app/services/api/home_management_api.dart';
import 'package:syncrow_app/services/api/scene_api.dart';
import 'package:syncrow_app/services/api/spaces_api.dart';
import 'package:syncrow_app/utils/helpers/snack_bar.dart';
class DeviceSettingBloc extends Bloc<DeviceSettingEvent, DeviceSettingState> {
final String deviceId;
DeviceSettingBloc({
required this.deviceId,
}) : super(const DeviceSettingState()) {
on<DeviceSettingInitial>(_fetchDeviceStatus);
on<DeviceSettingInitialInfo>(fetchDeviceInfo);
on<SaveNameEvent>(saveName);
on<ToggleNotificationEvent>(_toggleNotification);
on<ChangeNameEvent>(_changeName);
on<SearchFaqEvent>(_onSearchFaq);
on<FetchRoomsEvent>(_fetchRoomsAndDevices);
on<ChangeSwitchStatusEvent>(changeSwitchStatus);
on<LoadSettings>(_onLoadSettings);
on<SearchSettingsEvent>(searchSetting);
on<AssignRoomEvent>(_assignDevice);
on<SelectOptionEvent>(_onOptionSelected);
on<AddDeviceToGroup>(_addDeviceToGroup);
on<RemoveDeviceFromGroup>(_removeDeviceFromGroup);
on<DeviceSettingInitialQuestion>(_onDeviceSettingInitial);
on<FetchDeviceSetting>(_fetchDeviceSetting);
on<DeviceSettingSwitchInitial>(_fetchDeviceSettingSwitches);
on<AssignDeviceSetting>(assignSetting);
on<GetSettingBySwitchName>(getSettingByName);
on<SelectSettingEvent>(_selectSetting);
on<DeleteDeviceEvent>(deleteDevice);
on<ToggleEnableAlarmEvent>(_toggleLowBattery);
on<ToggleUpdateEvent>(_toggleUpdate);
on<ToggleHelpfulEvent>(_toggleHelpful);
}
final TextEditingController nameController =
TextEditingController(text: deviceName);
bool isSaving = false;
bool editName = false;
final FocusNode focusNode = FocusNode();
bool closingReminder = false;
bool waterAlarm = false;
static String deviceName = '';
static String selectedRoomId = '';
bool selecedSetting = false;
bool enableAlarm = false;
List<FourSceneSwitchModel> fourSetting = [];
String _selectedOption = '';
bool _hasSelectionChanged = false;
FourSceneModelState deviceStatus = FourSceneModelState(
scene_1: '',
scene_2: '',
scene_3: '',
scene_4: '',
scene_id_group_id: '',
switch_backlight: false);
DeviceInfoModel deviceInfo = DeviceInfoModel(
activeTime: 0,
category: "",
categoryName: "",
createTime: 0,
gatewayId: "",
icon: "",
ip: "",
lat: "",
localKey: "",
lon: "",
model: "",
name: "",
nodeId: "",
online: false,
ownerId: "",
productName: "",
sub: false,
timeZone: "",
updateTime: 0,
uuid: "",
productUuid: "",
productType: "",
permissionType: "",
macAddress: "",
subspace: Subspace(
uuid: "",
createdAt: "",
updatedAt: "",
subspaceName: "",
),
);
//============================ get Setting and assign scene =======================
String selectedFormApiSettingId = '';
String selectedSettingId = '';
_selectSetting(SelectSettingEvent event, Emitter<DeviceSettingState> emit) {
emit(DeviceSettingLoadingState());
selectedSettingId = event.selectedSettingId;
emit(SettingSelectionUpdatedState(selectedSettingId: selectedSettingId));
}
void getSettingByName(
GetSettingBySwitchName event, Emitter<DeviceSettingState> emit) async {
// emit(DeviceSettingLoadingState());
try {
final response = await DevicesAPI.getSceneBySwitchName(
deviceId: deviceId, switchName: event.switchName);
selectedFormApiSettingId = response['scene']['uuid'];
emit(UpdateState(device: deviceStatus));
} catch (e) {
emit(DeviceSettingFailedState(errorMessage: e.toString()));
}
}
void _onOptionSelected(
SelectOptionEvent event, Emitter<DeviceSettingState> emit) {
emit(DeviceSettingLoadingState());
_selectedOption = event.selectedOption;
_hasSelectionChanged = true;
emit(OptionSelectedState(
selectedOption: _selectedOption,
hasSelectionChanged: _hasSelectionChanged));
}
void _fetchDeviceSettingSwitches(DeviceSettingSwitchInitial event,
Emitter<DeviceSettingState> emit) async {
emit(DeviceSettingLoadingState());
try {
var response = await DevicesAPI.getFourSceneInfo(deviceId);
Map<String, String> sceneTitles = {
"scene_1": '',
"scene_2": '',
"scene_3": '',
"scene_4": '',
};
for (var item in response) {
if (item["switchName"] != null) {
sceneTitles[item["switchName"]] = item["scene"]["name"] ?? '';
}
}
FourSceneModelState deviceStatus = FourSceneModelState(
scene_1: sceneTitles["scene_1"] ?? '',
scene_2: sceneTitles["scene_2"] ?? '',
scene_3: sceneTitles["scene_3"] ?? '',
scene_4: sceneTitles["scene_4"] ?? '',
scene_id_group_id: '',
switch_backlight: '',
);
emit(UpdateState(device: deviceStatus));
} catch (e) {
emit(DeviceSettingFailedState(errorMessage: e.toString()));
return;
}
}
void assignSetting(
AssignDeviceSetting event, Emitter<DeviceSettingState> emit) async {
emit(DeviceSettingLoadingState());
try {
final response = await DevicesAPI.postFourSceneInfo(
deviceId: deviceId,
sceneUuid: event.sceneUuid,
spaceUuid: event.unit!.id,
switchName: event.switchName);
emit(SaveSelectionSuccessState());
CustomSnackBar.displaySnackBar('Save Successfully');
} catch (e) {
emit(DeviceSettingFailedState(errorMessage: e.toString()));
}
}
void _fetchDeviceSetting(
FetchDeviceSetting event, Emitter<DeviceSettingState> emit) async {
emit(DeviceSettingLoadingState());
try {
var response = await DevicesAPI.getDeviceStatus(deviceId);
List<StatusModel> statusModelList = [];
for (var status in response['status']) {
statusModelList.add(StatusModel.fromJson(status));
}
deviceStatus = FourSceneModelState.fromJson(
statusModelList,
);
emit(UpdateState(device: deviceStatus));
Future.delayed(const Duration(milliseconds: 500));
} catch (e) {
emit(DeviceSettingFailedState(errorMessage: e.toString()));
return;
}
}
//===================== fetch Device Status and info =======================
void _toggleLowBattery(
ToggleEnableAlarmEvent event, Emitter<DeviceSettingState> emit) async {
emit(LoadingNewSate(device: deviceStatus));
try {
enableAlarm = event.isLowBatteryEnabled;
emit(UpdateState(device: deviceStatus));
} catch (e) {
emit(DeviceSettingFailedState(errorMessage: e.toString()));
}
}
void _fetchDeviceStatus(
DeviceSettingInitial event, Emitter<DeviceSettingState> emit) async {
emit(DeviceSettingLoadingState());
try {
var response = await DevicesAPI.getDeviceStatus(deviceId);
List<StatusModel> statusModelList = [];
for (var status in response['status']) {
statusModelList.add(StatusModel.fromJson(status));
}
deviceStatus = FourSceneModelState.fromJson(
statusModelList,
);
emit(SuccessState());
// add(const DeviceSettingSwitchInitial());
} catch (e) {
emit(DeviceSettingFailedState(errorMessage: e.toString()));
return;
}
}
Future fetchDeviceInfo(
DeviceSettingInitialInfo event, Emitter<DeviceSettingState> emit) async {
try {
emit(DeviceSettingLoadingState());
var response = await DevicesAPI.getDeviceInfo(deviceId);
deviceInfo = DeviceInfoModel.fromJson(response);
deviceName = deviceInfo.name;
emit(LoadingDeviceInfo(deviceInfo: deviceInfo));
} catch (e) {
emit(DeviceSettingFailedState(errorMessage: e.toString()));
}
}
void _onSearchFaq(SearchFaqEvent event, Emitter<DeviceSettingState> emit) {
emit(DeviceSettingLoadingState());
List<QuestionModel> _faqQuestions = faqQuestions.where((question) {
return question.question
.toLowerCase()
.contains(event.query.toLowerCase());
}).toList();
emit(FaqSearchState(filteredFaqQuestions: _faqQuestions));
}
//============================ assign Device ==================================
//////////////////////////////////////////////////////////////////////////////
void _toggleNotification(
ToggleNotificationEvent event, Emitter<DeviceSettingState> emit) async {
emit(LoadingNewSate(device: deviceStatus));
try {
enableAlarm = event.isClosingEnabled;
emit(UpdateState(device: deviceStatus));
} catch (e) {
emit(DeviceSettingFailedState(errorMessage: e.toString()));
}
}
DeviceReport recordGroups =
DeviceReport(startTime: '0', endTime: '0', data: []);
//========================= Question and faq ================================
final List<QuestionModel> faqQuestions = [
QuestionModel(
id: 1,
question:
'How does an 4 Setting Switch work? How long will an 4 Setting Switch persist?',
answer:
'Yes. In scenes with high detection requirements, we recommend that you choose phone or message notification in Automation.',
),
QuestionModel(
id: 2,
question: 'Does the 4 Setting Switch support sending notifications?',
answer:
'The SOS alarm will persist until it is manually turned off or after a set time.',
),
QuestionModel(
id: 3,
question:
'Why does the data statistics in the device panel not show the correct data?',
answer: 'Try restarting the device. If it persists, contact support.',
),
QuestionModel(
id: 4,
question:
'How long will the App show offline after a device (low-power devices and normal devices) is powered...',
answer:
'No, a network connection is required to send the alert to your contacts.',
),
];
bool isHelpful = false;
void _toggleHelpful(
ToggleHelpfulEvent event, Emitter<DeviceSettingState> emit) async {
try {
emit(DeviceSettingLoadingState());
isHelpful = event.isHelpful!;
emit(SaveState());
} catch (e) {
emit(
const DeviceSettingFailedState(errorMessage: 'Something went wrong'));
}
}
Future<void> _onDeviceSettingInitial(DeviceSettingInitialQuestion event,
Emitter<DeviceSettingState> emit) async {
emit(DeviceSettingLoadingState());
emit(FaqLoadedState(filteredFaqQuestions: faqQuestions));
}
List<DeviceModel> allDevices = [];
List<SubSpaceModel> roomsList = [];
bool switchStatus = true;
Future<void> changeSwitchStatus(
ChangeSwitchStatusEvent event, Emitter<DeviceSettingState> emit) async {
try {
emit(DeviceSettingLoadingState());
switchStatus = deviceStatus.switch_backlight;
switchStatus = !switchStatus;
final response = await DevicesAPI.controlDevice(
DeviceControlModel(
deviceId: deviceId,
code: 'switch_backlight',
value: switchStatus),
deviceId);
deviceStatus.switch_backlight = switchStatus;
Future.delayed(const Duration(milliseconds: 200), () {
add(const DeviceSettingSwitchInitial());
});
Future.delayed(const Duration(milliseconds: 200), () {
emit(ChangeSwitchState(isEnable: switchStatus));
emit(UpdateState(device: deviceStatus));
});
} catch (_) {
add(const DeviceSettingInitial());
}
}
Future<void> _onLoadSettings(
LoadSettings event, Emitter<DeviceSettingState> emit) async {
emit(DeviceSettingLoadingState());
try {
if (event.unitId.isNotEmpty) {
// allSettings = await DevicesAPI.getDveByUnitId(
// event.unitId, event.unit.community.uuid,
// showInDevice: event.showInDevice);
filteredSettings = allSettings;
emit(SettingLoaded(allSettings));
} else {
emit(const DeviceSettingFailedState(errorMessage: 'Unit ID is empty'));
}
} catch (e) {
emit(
const DeviceSettingFailedState(errorMessage: 'Something went wrong'));
}
}
List<ScenesModel> allSettings = [];
List<ScenesModel> filteredSettings = [];
void searchSetting(
SearchSettingsEvent event, Emitter<DeviceSettingState> emit) {
emit(DeviceSettingLoadingState());
filteredSettings = event.query.isEmpty
? allSettings
: allSettings.where((scene) {
final sceneName = scene.name?.toLowerCase() ?? '';
return sceneName.contains(event.query.toLowerCase());
}).toList();
emit(SearchResultsState());
}
List<GroupDevicesModel> groupDevices = [
GroupDevicesModel(
dec: 'Syncroom', icon: Assets.minusIcon, name: '6 Setting Switch')
];
List<GroupDevicesModel> devices = [
GroupDevicesModel(
dec: 'Syncroom', icon: Assets.addDevicesIcon, name: '6 Setting Switch')
];
// Handler for AddDeviceToGroup
void _addDeviceToGroup(
AddDeviceToGroup event, Emitter<DeviceSettingState> emit) {
devices.remove(event.device);
groupDevices.add(event.device);
for (var device in groupDevices) {
device.icon = event.icon;
}
emit(UpdateStateList(groupDevices: groupDevices, devices: devices));
}
// Handler for RemoveDeviceFromGroup
void _removeDeviceFromGroup(
RemoveDeviceFromGroup event, Emitter<DeviceSettingState> emit) {
groupDevices.remove(event.device);
devices.add(event.device);
for (var device in groupDevices) {
device.icon = event.icon;
}
emit(UpdateStateList(groupDevices: groupDevices, devices: devices));
}
//=========================== assign device to room ==========================
void _assignDevice(
AssignRoomEvent event, Emitter<DeviceSettingState> emit) async {
try {
emit(DeviceSettingLoadingState());
if (_hasSelectionChanged) {
await HomeManagementAPI.assignDeviceToRoom(
event.unit.community.uuid, event.unit.id, event.roomId, deviceId);
final devicesList = await DevicesAPI.getDevicesByRoomId(
communityUuid: event.unit.community.uuid,
spaceUuid: event.unit.id,
roomId: event.roomId);
List<String> allDevicesIds = [];
allDevices.forEach((element) {
allDevicesIds.add(element.uuid!);
});
await HomeCubit.getInstance().fetchUnitsByUserId();
CustomSnackBar.displaySnackBar('Save Successfully');
emit(SaveSelectionSuccessState());
}
} catch (e) {
emit(
const DeviceSettingFailedState(errorMessage: 'Something went wrong'));
return;
}
}
void _fetchRoomsAndDevices(
FetchRoomsEvent event, Emitter<DeviceSettingState> emit) async {
try {
emit(DeviceSettingLoadingState());
roomsList = await SpacesAPI.getSubSpaceBySpaceId(
event.unit.community.uuid, event.unit.id);
emit(FetchRoomsState(devicesList: allDevices, roomsList: roomsList));
} catch (e) {
emit(
const DeviceSettingFailedState(errorMessage: 'Something went wrong'));
return;
}
}
//============================ setting name ==================================
//////////////////////////////////////////////////////////////////////////////
void _changeName(ChangeNameEvent event, Emitter<DeviceSettingState> emit) {
emit(DeviceSettingLoadingState());
editName = event.value!;
if (editName) {
Future.delayed(const Duration(milliseconds: 500), () {
focusNode.requestFocus();
});
} else {
focusNode.unfocus();
}
emit(NameEditingState(editName: editName));
}
bool _validateInputs() {
final nameError = fullNameValidator(nameController.text);
if (nameError != null) {
CustomSnackBar.displaySnackBar(nameError);
return true;
}
return false;
}
String? fullNameValidator(String? value) {
if (value == null) return 'name is required';
final withoutExtraSpaces = value.replaceAll(RegExp(r"\s+"), ' ').trim();
if (withoutExtraSpaces.length < 2 || withoutExtraSpaces.length > 30) {
return 'name must be between 2 and 30 characters long';
}
if (RegExp(r"/[^ a-zA-Z0-9-\']/").hasMatch(withoutExtraSpaces)) {
return 'Only alphanumeric characters, space, dash and single quote are allowed';
}
return null;
}
Future<void> saveName(
SaveNameEvent event, Emitter<DeviceSettingState> emit) async {
if (_validateInputs()) return;
try {
add(const ChangeNameEvent(value: false));
isSaving = true;
emit(DeviceSettingLoadingState());
var response = await DevicesAPI.putDeviceName(
deviceId: deviceId, deviceName: nameController.text);
add(const DeviceSettingInitialInfo());
CustomSnackBar.displaySnackBar('Save Successfully');
emit(SaveState());
} catch (e) {
emit(DeviceSettingFailedState(errorMessage: e.toString()));
} finally {
isSaving = false;
}
}
//====================== update device ==============================
bool enableUpdate = false;
void _toggleUpdate(
ToggleUpdateEvent event, Emitter<DeviceSettingState> emit) async {
try {
emit(DeviceSettingLoadingState());
enableUpdate = event.isUpdateEnabled!;
emit(SaveState());
} catch (e) {
emit(
const DeviceSettingFailedState(errorMessage: 'Something went wrong'));
}
}
deleteDevice(
DeleteDeviceEvent event, Emitter<DeviceSettingState> emit) async {
try {
emit(DeviceSettingLoadingState());
var response = await DevicesAPI.resetDevise(devicesUuid: deviceId);
CustomSnackBar.displaySnackBar('Reset Successfully');
emit(UpdateState(device: deviceStatus));
} catch (e) {
emit(DeviceSettingFailedState(errorMessage: e.toString()));
return;
}
}
}

View File

@ -0,0 +1,171 @@
import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
import 'package:syncrow_app/features/app_layout/model/space_model.dart';
import 'package:syncrow_app/features/devices/model/group_devices_model.dart';
abstract class DeviceSettingEvent extends Equatable {
const DeviceSettingEvent();
@override
List<Object> get props => [];
}
class DeviceSettingInitialInfo extends DeviceSettingEvent {
const DeviceSettingInitialInfo();
}
class DeviceSettingInitial extends DeviceSettingEvent {
const DeviceSettingInitial();
}
class SaveNameEvent extends DeviceSettingEvent {
final String? deviceName;
const SaveNameEvent({this.deviceName});
}
class ToggleEnableAlarmEvent extends DeviceSettingEvent {
final bool isLowBatteryEnabled;
const ToggleEnableAlarmEvent(this.isLowBatteryEnabled);
@override
List<Object> get props => [isLowBatteryEnabled];
}
class ToggleNotificationEvent extends DeviceSettingEvent {
final bool isClosingEnabled;
const ToggleNotificationEvent(this.isClosingEnabled);
@override
List<Object> get props => [isClosingEnabled];
}
class DeleteDeviceEvent extends DeviceSettingEvent {}
class ChangeNameEvent extends DeviceSettingEvent {
final bool? value;
const ChangeNameEvent({this.value});
}
class SearchFaqEvent extends DeviceSettingEvent {
final String query;
const SearchFaqEvent(this.query);
}
class DeviceSettingInitialQuestion extends DeviceSettingEvent {
const DeviceSettingInitialQuestion();
}
class ChangeSwitchStatusEvent extends DeviceSettingEvent {}
class FetchRoomsEvent extends DeviceSettingEvent {
final SpaceModel unit;
const FetchRoomsEvent({required this.unit});
@override
List<Object> get props => [unit];
}
class LoadSettings extends DeviceSettingEvent {
final String unitId;
final bool showInDevice;
final SpaceModel unit;
const LoadSettings(
{required this.unitId, required this.unit, this.showInDevice = false});
@override
List<Object> get props => [unitId, showInDevice];
}
class SelectSettingEvent extends DeviceSettingEvent {
final String selectedSettingId;
// final String unitId;
const SelectSettingEvent({
// required this.unitId,
required this.selectedSettingId,
});
}
class SearchSettingsEvent extends DeviceSettingEvent {
final String query;
const SearchSettingsEvent({
required this.query,
});
}
class SelectOptionEvent extends DeviceSettingEvent {
final dynamic selectedOption;
const SelectOptionEvent({
this.selectedOption,
});
}
class AddDeviceToGroup extends DeviceSettingEvent {
final GroupDevicesModel device;
final String icon;
const AddDeviceToGroup(this.device, this.icon);
}
class RemoveDeviceFromGroup extends DeviceSettingEvent {
final GroupDevicesModel device;
final String icon;
const RemoveDeviceFromGroup(this.device, this.icon);
}
class AssignRoomEvent extends DeviceSettingEvent {
final String roomId;
final SpaceModel unit;
final BuildContext context;
const AssignRoomEvent({
required this.roomId,
required this.unit,
required this.context,
});
@override
List<Object> get props => [
roomId,
unit,
context,
];
}
class FetchDeviceSetting extends DeviceSettingEvent {}
class DeviceSettingSwitchInitial extends DeviceSettingEvent {
const DeviceSettingSwitchInitial();
}
class AssignDeviceSetting extends DeviceSettingEvent {
final String? sceneUuid;
final String? switchName;
final SpaceModel? unit;
const AssignDeviceSetting({
this.sceneUuid,
this.unit,
this.switchName,
});
}
class GetSettingBySwitchName extends DeviceSettingEvent {
final String? switchName;
const GetSettingBySwitchName({this.switchName});
}
class ToggleUpdateEvent extends DeviceSettingEvent {
final bool? isUpdateEnabled;
const ToggleUpdateEvent({this.isUpdateEnabled});
}
class ToggleHelpfulEvent extends DeviceSettingEvent {
final bool? isHelpful;
const ToggleHelpfulEvent({this.isHelpful});
}

View File

@ -0,0 +1,125 @@
import 'package:equatable/equatable.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/devices/model/four_scene_model.dart';
import 'package:syncrow_app/features/devices/model/question_model.dart';
import 'package:syncrow_app/features/devices/model/group_devices_model.dart';
import 'package:syncrow_app/features/devices/model/device_info_model.dart';
import 'package:syncrow_app/features/devices/model/subspace_model.dart';
import 'package:syncrow_app/features/scene/model/scenes_model.dart';
class DeviceSettingState extends Equatable {
const DeviceSettingState();
@override
List<Object> get props => [];
}
class DeviceSettingLoadingState extends DeviceSettingState {}
class UpdateStateList extends DeviceSettingState {
final List<GroupDevicesModel> groupDevices;
final List<GroupDevicesModel> devices;
const UpdateStateList({required this.groupDevices, required this.devices});
}
class DeviceSettingFailedState extends DeviceSettingState {
final String errorMessage;
const DeviceSettingFailedState({required this.errorMessage});
@override
List<Object> get props => [errorMessage];
}
class UpdateState extends DeviceSettingState {
final FourSceneModelState device;
const UpdateState({required this.device});
@override
List<Object> get props => [device];
}
class LoadingNewSate extends DeviceSettingState {
final FourSceneModelState device;
const LoadingNewSate({required this.device});
@override
List<Object> get props => [device];
}
class NameEditingState extends DeviceSettingState {
final bool editName;
const NameEditingState({required this.editName});
}
class FaqLoadedState extends DeviceSettingState {
final List<QuestionModel> filteredFaqQuestions;
const FaqLoadedState({this.filteredFaqQuestions = const []});
}
class FaqSearchState extends DeviceSettingState {
final List<QuestionModel> filteredFaqQuestions;
const FaqSearchState({this.filteredFaqQuestions = const []});
}
class FetchRoomsState extends DeviceSettingState {
final List<SubSpaceModel> roomsList;
final List<DeviceModel> devicesList;
const FetchRoomsState({required this.devicesList, required this.roomsList});
@override
List<Object> get props => [devicesList];
}
class ChangeSwitchState extends DeviceSettingState {
final bool isEnable;
const ChangeSwitchState({required this.isEnable});
}
class SettingLoaded extends DeviceSettingState {
final List<ScenesModel> scenes;
final String? loadingSettingId;
final Map<String, bool> loadingStates;
const SettingLoaded(this.scenes,
{this.loadingSettingId, this.loadingStates = const {}});
}
class SearchResultsState extends DeviceSettingState {}
class SaveState extends DeviceSettingState {}
class SuccessState extends DeviceSettingState {}
class SaveSelectionSuccessState extends DeviceSettingState {}
class OptionSelectedState extends DeviceSettingState {
final String selectedOption;
final bool hasSelectionChanged;
const OptionSelectedState({
required this.selectedOption,
required this.hasSelectionChanged,
});
@override
List<Object> get props => [selectedOption, hasSelectionChanged];
}
class LoadingDeviceInfo extends DeviceSettingState {
final DeviceInfoModel deviceInfo;
const LoadingDeviceInfo({required this.deviceInfo});
@override
List<Object> get props => [deviceInfo];
}
class SettingSelectionUpdatedState extends DeviceSettingState {
final String selectedSettingId;
const SettingSelectionUpdatedState({required this.selectedSettingId});
}

View File

@ -170,7 +170,6 @@ class SosBloc extends Bloc<SosEvent, SosState> {
statusModelList,
);
emit(UpdateState(sensor: deviceStatus));
Future.delayed(const Duration(milliseconds: 500));
} catch (e) {
emit(SosFailedState(errorMessage: e.toString()));

View File

@ -6,17 +6,17 @@ import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_eve
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_state.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/devices/model/question_model.dart';
import 'package:syncrow_app/features/devices/view/widgets/four_scene_switch/four_scene_setting/question_page_four_scene.dart';
import 'package:syncrow_app/features/devices/view/device_settings/question_page.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class FaqFourScenePage extends StatelessWidget {
class FaqSettingPage extends StatelessWidget {
final DeviceModel? device;
const FaqFourScenePage({super.key, this.device});
const FaqSettingPage({super.key, this.device});
@override
Widget build(BuildContext context) {
@ -101,7 +101,8 @@ class FaqFourScenePage extends StatelessWidget {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
QuestionPageFourScene(
QuestionPageSetting(
deviceId: device!.uuid,
questionModel: faq,
)),
);

View File

@ -1,9 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_event.dart';
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_state.dart';
import 'package:syncrow_app/features/devices/bloc/device_settings_bloc/device_scene_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/device_settings_bloc/device_scene_event.dart';
import 'package:syncrow_app/features/devices/bloc/device_settings_bloc/device_scene_state.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
@ -12,23 +12,23 @@ import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dar
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class FourSceneInfoPage extends StatelessWidget {
class SettingInfoPage extends StatelessWidget {
final DeviceModel? device;
const FourSceneInfoPage({super.key, this.device});
const SettingInfoPage({super.key, this.device});
@override
Widget build(BuildContext context) {
return DefaultScaffold(
title: 'Device Information',
child: BlocProvider(
create: (context) => FourSceneBloc(fourSceneId: device?.uuid ?? '')
..add(const FourSceneInitial())
..add(const FourSceneInitialInfo()),
child: BlocBuilder<FourSceneBloc, FourSceneState>(
create: (context) => DeviceSettingBloc(deviceId: device?.uuid ?? '')
..add(const DeviceSettingInitial())
..add(const DeviceSettingInitialInfo()),
child: BlocBuilder<DeviceSettingBloc, DeviceSettingState>(
builder: (context, state) {
final _bloc = BlocProvider.of<FourSceneBloc>(context);
return state is FourSceneLoadingState
final _bloc = BlocProvider.of<DeviceSettingBloc>(context);
return state is DeviceSettingLoadingState
? const Center(
child: DefaultContainer(
width: 50,
@ -37,7 +37,7 @@ class FourSceneInfoPage extends StatelessWidget {
)
: RefreshIndicator(
onRefresh: () async {
_bloc.add(const FourSceneInitial());
_bloc.add(const DeviceSettingInitial());
},
child: DefaultContainer(
child: Padding(

View File

@ -1,19 +1,19 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/app_layout/model/space_model.dart';
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_event.dart';
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_state.dart';
import 'package:syncrow_app/features/devices/bloc/device_settings_bloc/device_scene_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/device_settings_bloc/device_scene_event.dart';
import 'package:syncrow_app/features/devices/bloc/device_settings_bloc/device_scene_state.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class LocationFourScenePage extends StatelessWidget {
class LocationSettingPage extends StatelessWidget {
final SpaceModel? space;
final String? deviceId;
const LocationFourScenePage({
const LocationSettingPage({
super.key,
this.space,
this.deviceId,
@ -25,20 +25,20 @@ class LocationFourScenePage extends StatelessWidget {
return Scaffold(
body: BlocProvider(
create: (context) => FourSceneBloc(fourSceneId: deviceId ?? '')
..add(const FourSceneInitial())
..add(const FourSceneInitialInfo())
create: (context) => DeviceSettingBloc(deviceId: deviceId ?? '')
..add(const DeviceSettingInitial())
..add(const DeviceSettingInitialInfo())
..add(FetchRoomsEvent(unit: space!)),
child: BlocBuilder<FourSceneBloc, FourSceneState>(
child: BlocBuilder<DeviceSettingBloc, DeviceSettingState>(
builder: (context, state) {
final _bloc = BlocProvider.of<FourSceneBloc>(context);
final _bloc = BlocProvider.of<DeviceSettingBloc>(context);
if (state is SaveSelectionSuccessState) {
Future.delayed(const Duration(microseconds: 500), () {
_bloc.add(const FourSceneInitialInfo());
_bloc.add(const DeviceSettingInitialInfo());
Navigator.of(context).pop(true);
});
}
return state is FourSceneLoadingState
return state is DeviceSettingLoadingState
? const Center(
child: DefaultContainer(
width: 50,
@ -48,14 +48,14 @@ class LocationFourScenePage extends StatelessWidget {
)
: DefaultScaffold(
actions: [
BlocBuilder<FourSceneBloc, FourSceneState>(
BlocBuilder<DeviceSettingBloc, DeviceSettingState>(
builder: (context, state) {
final bool canSave = state is OptionSelectedState &&
state.hasSelectionChanged;
return InkWell(
onTap: canSave
? () {
context.read<FourSceneBloc>().add(
context.read<DeviceSettingBloc>().add(
AssignRoomEvent(
context: context,
roomId: roomIdSelected,
@ -107,7 +107,7 @@ class LocationFourScenePage extends StatelessWidget {
label: fromRoom.name!,
isSelected: isSelected,
onTap: (label) {
context.read<FourSceneBloc>().add(
context.read<DeviceSettingBloc>().add(
SelectOptionEvent(
selectedOption: fromRoom.id!,
),

View File

@ -2,21 +2,21 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_event.dart';
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_state.dart';
import 'package:syncrow_app/features/devices/bloc/device_settings_bloc/device_scene_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/device_settings_bloc/device_scene_event.dart';
import 'package:syncrow_app/features/devices/bloc/device_settings_bloc/device_scene_state.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/devices/view/widgets/four_scene_switch/four_scene_setting/location_setting_four_scene.dart';
import 'package:syncrow_app/features/devices/view/device_settings/location_setting.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class FourSceneProfilePage extends StatelessWidget {
class SettingProfilePage extends StatelessWidget {
final DeviceModel? device;
const FourSceneProfilePage({super.key, this.device});
const SettingProfilePage({super.key, this.device});
@override
Widget build(BuildContext context) {
@ -30,13 +30,13 @@ class FourSceneProfilePage extends StatelessWidget {
},
icon: const Icon(Icons.arrow_back_ios)),
child: BlocProvider(
create: (context) => FourSceneBloc(fourSceneId: device?.uuid ?? '')
..add(const FourSceneInitial())
..add(const FourSceneInitialInfo()),
child: BlocBuilder<FourSceneBloc, FourSceneState>(
create: (context) => DeviceSettingBloc(deviceId: device?.uuid ?? '')
..add(const DeviceSettingInitial())
..add(const DeviceSettingInitialInfo()),
child: BlocBuilder<DeviceSettingBloc, DeviceSettingState>(
builder: (context, state) {
final _bloc = BlocProvider.of<FourSceneBloc>(context);
return state is FourSceneLoadingState
final _bloc = BlocProvider.of<DeviceSettingBloc>(context);
return state is DeviceSettingLoadingState
? const Center(
child: DefaultContainer(
width: 50,
@ -45,34 +45,45 @@ class FourSceneProfilePage extends StatelessWidget {
)
: RefreshIndicator(
onRefresh: () async {
_bloc.add(const FourSceneInitial());
_bloc.add(const DeviceSettingInitial());
},
child: ListView(
children: [
CircleAvatar(
radius: 60,
radius: device!.type != "SOS" ? 60 : 52,
backgroundColor: Colors.white,
child: CircleAvatar(
radius: 55,
backgroundColor: ColorsManager.graysColor,
child: ClipOval(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(
height: 10,
),
Center(
child: SvgPicture.asset(
Assets.fourSceneIcon,
fit: BoxFit.contain,
child: device!.type == "SOS"
? ClipOval(
child: SvgPicture.asset(
Assets.sosHomeIcon,
fit: BoxFit.fitHeight,
height: 100,
))
: CircleAvatar(
radius: 55,
backgroundColor: ColorsManager.graysColor,
child: ClipOval(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.center,
children: [
const SizedBox(
height: 10,
),
Center(
child: SvgPicture.asset(
device!.type == "4S"
? Assets.fourSceneIcon
: Assets.sixSceneIcon,
fit: BoxFit.contain,
),
),
],
),
),
],
),
),
),
),
),
const SizedBox(
height: 10,
@ -138,13 +149,13 @@ class FourSceneProfilePage extends StatelessWidget {
onTap: () async {
bool val = await Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => LocationFourScenePage(
builder: (context) => LocationSettingPage(
space: spaces!.first,
deviceId: device?.uuid ?? '',
)),
);
if (val == true) {
_bloc.add(const FourSceneInitialInfo());
_bloc.add(const DeviceSettingInitialInfo());
}
},
child: Row(

View File

@ -1,9 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_event.dart';
import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_state.dart';
import 'package:syncrow_app/features/devices/bloc/device_settings_bloc/device_scene_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/device_settings_bloc/device_scene_event.dart';
import 'package:syncrow_app/features/devices/bloc/device_settings_bloc/device_scene_state.dart';
import 'package:syncrow_app/features/devices/model/question_model.dart';
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
@ -13,22 +13,22 @@ import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dar
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class QuestionPage extends StatelessWidget {
class QuestionPageSetting extends StatelessWidget {
final QuestionModel? questionModel;
const QuestionPage({super.key, this.questionModel});
final String? deviceId;
const QuestionPageSetting({super.key, this.questionModel, this.deviceId});
@override
Widget build(BuildContext context) {
return DefaultScaffold(
title: 'FAQ',
child: BlocProvider(
create: (context) => SosBloc(sosId: '')..add(const SosInitial()),
child: BlocBuilder<SosBloc, SosState>(
create: (context) => DeviceSettingBloc(deviceId: deviceId!)
..add(const DeviceSettingInitial()),
child: BlocBuilder<DeviceSettingBloc, DeviceSettingState>(
builder: (context, state) {
final sensor = BlocProvider.of<SosBloc>(context);
return state is SosLoadingState
final sensor = BlocProvider.of<DeviceSettingBloc>(context);
return state is DeviceSettingLoadingState
? const Center(
child: DefaultContainer(
width: 50,

View File

@ -1,17 +1,16 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_event.dart';
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_state.dart';
import 'package:syncrow_app/features/devices/bloc/device_settings_bloc/device_scene_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/device_settings_bloc/device_scene_event.dart';
import 'package:syncrow_app/features/devices/bloc/device_settings_bloc/device_scene_state.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/devices/model/four_scene_model.dart';
import 'package:syncrow_app/features/devices/view/widgets/four_scene_switch/four_scene_setting/faq_four_scene_page.dart';
import 'package:syncrow_app/features/devices/view/widgets/four_scene_switch/four_scene_setting/four_scene_info_page.dart';
import 'package:syncrow_app/features/devices/view/widgets/four_scene_switch/four_scene_setting/four_scene_profile_page.dart';
import 'package:syncrow_app/features/devices/view/widgets/four_scene_switch/four_scene_setting/four_scene_update_dialog.dart';
import 'package:syncrow_app/features/devices/view/widgets/four_scene_switch/four_scene_setting/four_scene_update_page.dart';
import 'package:syncrow_app/features/devices/view/widgets/four_scene_switch/four_scene_setting/share_four_scene_page.dart';
import 'package:syncrow_app/features/devices/view/device_settings/faq_page.dart';
import 'package:syncrow_app/features/devices/view/device_settings/info_page.dart';
import 'package:syncrow_app/features/devices/view/device_settings/profile_page.dart';
import 'package:syncrow_app/features/devices/view/device_settings/share_Device_page.dart';
import 'package:syncrow_app/features/devices/view/device_settings/update_dialog.dart';
import 'package:syncrow_app/features/devices/view/device_settings/update_page.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/delete_device_dialogs.dart';
@ -21,35 +20,24 @@ import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class FourSceneSettings extends StatelessWidget {
class SettingsPage extends StatelessWidget {
final DeviceModel? device;
const FourSceneSettings({super.key, this.device});
const SettingsPage({super.key, this.device});
@override
Widget build(BuildContext context) {
return DefaultScaffold(
title: 'Device Settings',
child: BlocProvider(
create: (context) => FourSceneBloc(fourSceneId: device?.uuid ?? '')
..add(const FourSceneInitial())
..add(const FourSceneInitialInfo()),
child: BlocBuilder<FourSceneBloc, FourSceneState>(
create: (context) => DeviceSettingBloc(deviceId: device?.uuid ?? '')
..add(const DeviceSettingInitial())
..add(const DeviceSettingInitialInfo()),
child: BlocBuilder<DeviceSettingBloc, DeviceSettingState>(
builder: (context, state) {
final _bloc = BlocProvider.of<FourSceneBloc>(context);
FourSceneModelState model = FourSceneModelState(
scene_1: '',
scene_2: '',
scene_3: '',
scene_4: '',
scene_id_group_id: '',
switch_backlight: '');
if (state is LoadingNewSate) {
model = state.device;
} else if (state is UpdateState) {
model = state.device;
}
return state is FourSceneLoadingState
final _bloc = BlocProvider.of<DeviceSettingBloc>(context);
return state is DeviceSettingLoadingState
? const Center(
child: DefaultContainer(
width: 50,
@ -66,13 +54,13 @@ class FourSceneSettings extends StatelessWidget {
onTap: () async {
bool val = await Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => FourSceneProfilePage(
builder: (context) => SettingProfilePage(
device: device,
),
),
);
if (val == true) {
_bloc.add(const FourSceneInitialInfo());
_bloc.add(const DeviceSettingInitialInfo());
}
},
child: Stack(
@ -136,17 +124,23 @@ class FourSceneSettings extends StatelessWidget {
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Padding(
padding:
const EdgeInsets.only(top: 8),
child: SizedBox(
height: 70,
child: SvgPicture.asset(
Assets.fourSceneIcon,
fit: BoxFit.contain,
),
),
),
device!.type == "SOS"
? ClipOval(
child: SvgPicture.asset(
Assets.sosHomeIcon,
fit: BoxFit.contain,
height: 70,
),
)
: SizedBox(
height: 70,
child: SvgPicture.asset(
device!.type == "4S"
? Assets.fourSceneIcon
: Assets.sixSceneIcon,
fit: BoxFit.contain,
),
),
],
),
),
@ -170,7 +164,7 @@ class FourSceneSettings extends StatelessWidget {
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => FourSceneInfoPage(
builder: (context) => SettingInfoPage(
device: device!,
)),
);
@ -210,7 +204,7 @@ class FourSceneSettings extends StatelessWidget {
value: _bloc.enableAlarm,
onChanged: (p0) {
context
.read<FourSceneBloc>()
.read<DeviceSettingBloc>()
.add(ToggleEnableAlarmEvent(p0));
},
isNotification: true,
@ -237,7 +231,7 @@ class FourSceneSettings extends StatelessWidget {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
ShareFourScenePage(device: device!)),
ShareDevicePage(device: device!)),
);
},
text: 'Share Device',
@ -266,7 +260,7 @@ class FourSceneSettings extends StatelessWidget {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
FaqFourScenePage(device: device!)),
FaqSettingPage(device: device!)),
);
},
text: 'Device FAQ',
@ -296,7 +290,7 @@ class FourSceneSettings extends StatelessWidget {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
const FourSceneUpdatePage()),
const UpdatePageSetting()),
);
},
text: 'Device Update',

View File

@ -14,9 +14,9 @@ import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dar
import 'package:syncrow_app/utils/helpers/custom_page_route.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class ShareFourScenePage extends StatelessWidget {
class ShareDevicePage extends StatelessWidget {
final DeviceModel? device;
const ShareFourScenePage({super.key, this.device});
const ShareDevicePage({super.key, this.device});
@override
Widget build(BuildContext context) {
var spaces = HomeCubit.getInstance().spaces;

View File

@ -2,11 +2,11 @@ import 'package:flutter/material.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class SosUpdateNote extends StatelessWidget {
class UpDateNoteSetting extends StatelessWidget {
final Function()? cancelTab;
final Function()? confirmTab;
const SosUpdateNote({
const UpDateNoteSetting({
super.key,
required this.cancelTab,
required this.confirmTab,

View File

@ -6,7 +6,7 @@ import 'package:percent_indicator/linear_percent_indicator.dart';
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_event.dart';
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_state.dart';
import 'package:syncrow_app/features/devices/view/widgets/four_scene_switch/four_scene_setting/four_scene_update_note.dart';
import 'package:syncrow_app/features/devices/view/device_settings/update_note.dart';
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
@ -14,8 +14,8 @@ import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dar
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class FourSceneUpdatePage extends StatelessWidget {
const FourSceneUpdatePage({super.key});
class UpdatePageSetting extends StatelessWidget {
const UpdatePageSetting({super.key});
@override
Widget build(BuildContext context) {
@ -236,7 +236,7 @@ class NewUpdateContainer extends StatelessWidget {
showDialog(
context: context,
builder: (context) {
return UpDateNote(
return UpDateNoteSetting(
cancelTab: () {
Navigator.of(context).pop();
},

View File

@ -1,158 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_event.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_state.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/devices/model/six_scene_question_model.dart';
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/6_scene_setting/question_page.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class FaqSixScenePage extends StatelessWidget {
final DeviceModel? device;
const FaqSixScenePage({super.key, this.device});
@override
Widget build(BuildContext context) {
TextEditingController _searchController = TextEditingController();
return DefaultScaffold(
title: 'FAQ',
child: BlocProvider(
create: (context) => SixSceneBloc(sixSceneId: device?.uuid ?? '')
..add(const SixSceneInitialQuestion()),
child: BlocBuilder<SixSceneBloc, SixSceneState>(
builder: (context, state) {
final sensor = BlocProvider.of<SixSceneBloc>(context);
List<SixSceneQuestionModel> displayedQuestions = [];
if (state is FaqSearchState) {
displayedQuestions = state.filteredFaqQuestions;
} else if (state is FaqLoadedState) {
displayedQuestions = state.filteredFaqQuestions;
}
return state is SixSceneLoadingState
? const Center(
child: DefaultContainer(
width: 50,
height: 50,
child: CircularProgressIndicator()),
)
: RefreshIndicator(
onRefresh: () async {
// sensor.add(const SosInitial());
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
DefaultContainer(
padding: const EdgeInsets.all(5),
child: TextFormField(
controller: _searchController,
onChanged: (value) {
sensor.add(SearchFaqEvent(value));
},
decoration: InputDecoration(
hintText: 'Enter your questions',
hintStyle: const TextStyle(
color: ColorsManager.textGray,
fontSize: 16,
fontWeight: FontWeight.w400),
suffixIcon: Container(
padding: const EdgeInsets.all(5.0),
margin: const EdgeInsets.all(10.0),
child: SvgPicture.asset(
Assets.searchIcon,
fit: BoxFit.contain,
),
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8.0),
),
),
),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.04,
),
BodyMedium(
text: _searchController.text.isEmpty
? 'Device Related FAQs'
: '${displayedQuestions.length} Help Topics',
fontWeight: FontWeight.w700,
fontSize: 12,
fontColor: ColorsManager.grayColor,
),
const SizedBox(
height: 8,
),
displayedQuestions.isEmpty
? const SizedBox()
: DefaultContainer(
child: ListView.builder(
shrinkWrap: true,
itemCount: displayedQuestions.length,
itemBuilder: (context, index) {
final faq = displayedQuestions[index];
return InkWell(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => QuestionPage(
questionModel: faq,
)),
);
},
child: SizedBox(
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Expanded(
child: BodyMedium(
fontSize: 14,
fontWeight: FontWeight.w400,
text: faq.question,
),
),
const Icon(
Icons.keyboard_arrow_right,
color: ColorsManager.textGray,
),
],
),
),
if (index !=
displayedQuestions.length -
1) // Exclude divider for the last item
const Divider(
color: ColorsManager.dividerColor,
),
],
),
),
);
},
)),
],
),
);
},
),
),
);
}
}

View File

@ -1,226 +0,0 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/app_layout/model/space_model.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_event.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_state.dart';
import 'package:syncrow_app/features/devices/model/four_scene_model.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class LocationSixScenePage extends StatelessWidget {
final SpaceModel? space;
final String? deviceId;
const LocationSixScenePage({
super.key,
this.space,
this.deviceId,
});
@override
Widget build(BuildContext context) {
String roomIdSelected = '';
return Scaffold(
body: BlocProvider(
create: (context) => SixSceneBloc(sixSceneId: deviceId ?? '')
..add(const SixSceneInitial())
..add(const SixSceneInitialInfo())
..add(FetchRoomsEvent(unit: space!)),
child: BlocBuilder<SixSceneBloc, SixSceneState>(
builder: (context, state) {
final _bloc = BlocProvider.of<SixSceneBloc>(context);
FourSceneModelState model = FourSceneModelState(
scene_1: '',
scene_2: '',
scene_3: '',
scene_4: '',
scene_id_group_id: '',
switch_backlight: '');
if (state is SaveSelectionSuccessState) {
new Future.delayed(const Duration(microseconds: 500), () {
_bloc.add(SixSceneInitialInfo());
Navigator.of(context).pop(true);
});
}
return state is SixSceneLoadingState
? const Center(
child: DefaultContainer(
width: 50,
height: 50,
child: CircularProgressIndicator(),
),
)
: DefaultScaffold(
actions: [
BlocBuilder<SixSceneBloc, SixSceneState>(
builder: (context, state) {
final bool canSave = state is OptionSelectedState &&
state.hasSelectionChanged;
return InkWell(
onTap: canSave
? () {
context.read<SixSceneBloc>().add(
AssignRoomEvent(
context: context,
roomId: roomIdSelected,
unit: space!));
}
: null,
child: BodyMedium(
text: 'Save',
fontWeight: FontWeight.w700,
fontSize: 16,
fontColor: canSave
? ColorsManager.slidingBlueColor
: ColorsManager.primaryTextColor,
),
);
},
),
const SizedBox(width: 20),
],
child: RefreshIndicator(
onRefresh: () async {
// sensor.add(const SosInitial());
},
child: ListView(
shrinkWrap: true,
padding: const EdgeInsets.symmetric(vertical: 20),
children: [
const BodyMedium(
text: 'Smart Device Location',
fontWeight: FontWeight.w700,
fontSize: 12,
fontColor: ColorsManager.grayColor,
),
const SizedBox(height: 5),
DefaultContainer(
padding: const EdgeInsets.all(20),
child: ListView.builder(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: _bloc.roomsList.length,
itemBuilder: (context, index) {
final fromRoom = _bloc.roomsList[index];
final isSelected = (state
is OptionSelectedState &&
state.selectedOption == fromRoom.id) ||
(state is! OptionSelectedState &&
fromRoom.id ==
_bloc.deviceInfo.subspace.uuid);
return Column(
children: [
_buildCheckboxOption(
label: fromRoom.name!,
isSelected: isSelected,
onTap: (label) {
context.read<SixSceneBloc>().add(
SelectOptionEvent(
selectedOption: fromRoom.id!,
),
);
roomIdSelected = fromRoom.id!;
},
),
if (index < _bloc.roomsList.length - 1) ...[
const SizedBox(height: 10),
const Divider(
color: ColorsManager.dividerColor,
),
const SizedBox(height: 10),
],
],
);
},
),
),
],
),
),
);
},
),
),
);
}
}
class CircularCheckbox extends StatefulWidget {
final bool value;
final ValueChanged<bool?> onChanged;
CircularCheckbox({required this.value, required this.onChanged});
@override
_CircularCheckboxState createState() => _CircularCheckboxState();
}
class _CircularCheckboxState extends State<CircularCheckbox> {
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
widget.onChanged(!widget.value);
},
child: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: widget.value
? ColorsManager.primaryColorWithOpacity.withOpacity(0.01)
: Colors.grey,
width: 2.0,
),
color: widget.value
? ColorsManager.primaryColorWithOpacity
: Colors.transparent,
),
width: 24.0,
height: 24.0,
child: widget.value
? const Icon(
Icons.check,
color: Colors.white,
size: 16.0,
)
: null,
),
);
}
}
Widget _buildCheckboxOption({
required String label,
required bool isSelected,
required Function(String) onTap,
}) {
return Padding(
padding: const EdgeInsets.only(bottom: 10, top: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
BodyMedium(
text: label,
style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w400),
),
CircularCheckbox(
value: isSelected,
onChanged: (bool? value) {
if (value == true) {
onTap(label);
}
},
),
],
),
);
}
//LocationSixScenePage

View File

@ -1,161 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_event.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_state.dart';
import 'package:syncrow_app/features/devices/model/six_scene_question_model.dart';
import 'package:syncrow_app/features/devices/model/six_scene_model.dart';
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class QuestionPage extends StatelessWidget {
final SixSceneQuestionModel? questionModel;
const QuestionPage({super.key, this.questionModel});
@override
Widget build(BuildContext context) {
return DefaultScaffold(
title: 'FAQ',
child: BlocProvider(
create: (context) =>
SixSceneBloc(sixSceneId: '')..add(const SixSceneInitial()),
child: BlocBuilder<SixSceneBloc, SixSceneState>(
builder: (context, state) {
final sensor = BlocProvider.of<SixSceneBloc>(context);
SixSceneModel model = SixSceneModel(
scene_1: '',
scene_2: '',
scene_3: '',
scene_4: '',
scene_5: '',
scene_6: '',
scene_id_group_id: '',
switch_backlight: '');
if (state is LoadingNewSate) {
model = state.device;
} else if (state is UpdateState) {
model = state.device;
}
return state is SixSceneLoadingState
? const Center(
child: DefaultContainer(
width: 50,
height: 50,
child: CircularProgressIndicator()),
)
: RefreshIndicator(
onRefresh: () async {
sensor.add(const SixSceneInitial());
},
child: Column(
children: [
DefaultContainer(
padding: EdgeInsets.all(15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
BodyLarge(
text: questionModel!.question,
fontSize: 22,
fontWeight: FontWeight.w400,
fontColor: ColorsManager.blackColor,
),
SizedBox(
height: 15,
),
BodyMedium(
text: questionModel!.answer,
fontSize: 14,
fontWeight: FontWeight.w400,
fontColor: ColorsManager.secondaryTextColor,
),
],
),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.15,
),
Center(
child: SizedBox(
width: 180,
child: DefaultButton(
backgroundColor: sensor.isHelpful == true
? ColorsManager.grayColor
: ColorsManager.grayButtonColors,
borderRadius: 50,
onPressed: () {
sensor
.add(ToggleHelpfulEvent(isHelpful: true));
},
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset(
Assets.thumbUp,
fit: BoxFit.fill,
),
const SizedBox(
width: 10,
),
const BodyMedium(
text: 'Helpful',
fontSize: 12,
fontWeight: FontWeight.w400,
fontColor: ColorsManager.blackColor,
),
],
)),
),
),
const SizedBox(
height: 15,
),
Center(
child: SizedBox(
width: 180,
child: DefaultButton(
backgroundColor: sensor.isHelpful == false
? ColorsManager.grayColor
: ColorsManager.grayButtonColors,
borderRadius: 50,
onPressed: () {
sensor.add(
ToggleHelpfulEvent(isHelpful: false));
},
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset(
Assets.thumbDown,
fit: BoxFit.fill,
),
const SizedBox(
width: 10,
),
const BodyMedium(
text: 'Not Helpful',
fontSize: 12,
fontWeight: FontWeight.w400,
fontColor: ColorsManager.blackColor,
),
],
)),
),
),
],
));
},
),
),
);
}
}

View File

@ -1,121 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_event.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_state.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/devices/model/six_scene_model.dart';
import 'package:syncrow_app/features/menu/view/widgets/manage_home/home_settings.dart';
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/utils/helpers/custom_page_route.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class ShareSixScenePage extends StatelessWidget {
final DeviceModel? device;
const ShareSixScenePage({super.key, this.device});
@override
Widget build(BuildContext context) {
var spaces = HomeCubit.getInstance().spaces;
return DefaultScaffold(
title: 'Share Device',
child: BlocProvider(
create: (context) => SixSceneBloc(sixSceneId: device?.uuid ?? '')
..add(const SixSceneInitial()),
child: BlocBuilder<SixSceneBloc, SixSceneState>(
builder: (context, state) {
final sensor = BlocProvider.of<SixSceneBloc>(context);
SixSceneModel model = SixSceneModel(
scene_1: '',
scene_2: '',
scene_3: '',
scene_4: '',
scene_5: '',
scene_6: '',
scene_id_group_id: '',
switch_backlight: '');
if (state is LoadingNewSate) {
model = state.device;
} else if (state is UpdateState) {
model = state.device;
}
return state is LoadingNewSate
? const Center(
child: DefaultContainer(
width: 50,
height: 50,
child: CircularProgressIndicator()),
)
: RefreshIndicator(
onRefresh: () async {
sensor.add(const SixSceneInitial());
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: MediaQuery.of(context).size.height * 0.05,
),
const BodyLarge(
text: 'Sharing Method Not Supported',
fontSize: 15,
fontWeight: FontWeight.w400,
fontColor: ColorsManager.blackColor,
),
const BodyMedium(
text:
'Currently, you cannot use the specified method to share Bluetooth mesh devices Zigbee devices, infrared devices, Bluetooth Beacon Devices, and certain Bluetooth LE devices with other users.',
fontSize: 14,
fontWeight: FontWeight.w400,
fontColor: ColorsManager.secondaryTextColor,
),
const SizedBox(
height: 10,
),
const BodyLarge(
text: 'Recommended Sharing Method',
fontSize: 15,
fontWeight: FontWeight.w400,
fontColor: ColorsManager.blackColor,
),
const BodyMedium(
text:
'If the recipient is a home member or a reliable user, tap Me > Home Management > Add Member and add the recipient to your home. Then, devices in the home can be shared with the recipient in bulk.',
fontSize: 14,
fontWeight: FontWeight.w400,
fontColor: ColorsManager.secondaryTextColor,
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.15,
),
Center(
child: SizedBox(
width: 250,
child: DefaultButton(
backgroundColor: ColorsManager.blueColor1,
borderRadius: 50,
onPressed: () {
Navigator.of(context).push(CustomPageRoute(
builder: (context) => HomeSettingsView(
space: spaces!.first,
)));
},
child: Text('Add Home Member')),
),
)
],
));
},
),
),
);
}
}

View File

@ -1,215 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/svg.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_event.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_state.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/devices/model/six_scene_model.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class SixSceneCreateGroup extends StatelessWidget {
final DeviceModel? device;
const SixSceneCreateGroup({super.key, this.device});
@override
Widget build(BuildContext context) {
return DefaultScaffold(
title: 'Create Group',
child: BlocProvider(
create: (context) => SixSceneBloc(sixSceneId: device?.uuid ?? '')
..add(const SixSceneInitial()),
child: BlocBuilder<SixSceneBloc, SixSceneState>(
builder: (context, state) {
final sensor = BlocProvider.of<SixSceneBloc>(context);
SixSceneModel model = SixSceneModel(
scene_1: '',
scene_2: '',
scene_3: '',
scene_4: '',
scene_5: '',
scene_6: '',
scene_id_group_id: '',
switch_backlight: '');
if (state is LoadingNewSate) {
model = state.device;
} else if (state is UpdateState) {
model = state.device;
}
return state is LoadingNewSate
? const Center(
child: DefaultContainer(
width: 50,
height: 50,
child: CircularProgressIndicator()),
)
: Padding(
padding: EdgeInsets.all(8.0),
child: Column(
children: [
const Padding(
padding: EdgeInsets.only(left: 25, right: 25),
child: BodySmall(
text:
'Devices in the same group can be controlled together',
fontColor: ColorsManager.primaryTextColor,
textAlign: TextAlign.center,
),
),
Flexible(
child: ListView.builder(
itemCount: sensor.groupDevices.length,
itemBuilder: (context, index) {
return InkWell(
onTap: () {
BlocProvider.of<SixSceneBloc>(context).add(
RemoveDeviceFromGroup(
sensor.groupDevices[index],
Assets.addDevicesIcon));
},
child: DefaultContainer(
child: Padding(
padding: const EdgeInsets.all(5.0),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
SvgPicture.asset(
sensor.groupDevices[index].icon!,
fit: BoxFit.contain,
),
const SizedBox(
width: 15,
),
BodyMedium(
text: sensor
.groupDevices[index].name!,
fontColor:
ColorsManager.primaryTextColor,
textAlign: TextAlign.center,
fontSize: 15,
),
],
),
BodyMedium(
text: sensor.groupDevices[index].dec!,
fontColor: ColorsManager.grayColor,
textAlign: TextAlign.center,
fontSize: 15,
),
],
),
)),
);
},
),
),
Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const BodyLarge(
text: 'Devices to be added',
fontColor: ColorsManager.grayColor,
textAlign: TextAlign.center,
fontSize: 12,
fontWeight: FontWeight.w700,
),
const SizedBox(
height: 5,
),
sensor.devices.isNotEmpty
? Expanded(
child: ListView.builder(
itemCount: sensor.devices.length,
itemBuilder: (context, index) {
final device = sensor.devices[index];
return GestureDetector(
onTap: () {
BlocProvider.of<SixSceneBloc>(
context)
.add(AddDeviceToGroup(device,
Assets.minusIcon));
},
child: DefaultContainer(
child: Padding(
padding:
const EdgeInsets.all(5.0),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Row(
children: [
SvgPicture.asset(
device.icon!,
fit: BoxFit.contain,
),
const SizedBox(
width: 15,
),
BodyMedium(
text: device.name!,
fontColor: ColorsManager
.primaryTextColor,
textAlign:
TextAlign.center,
fontSize: 15,
),
],
),
BodyMedium(
text: device.dec!,
fontColor: ColorsManager
.grayColor,
textAlign:
TextAlign.center,
fontSize: 15,
),
],
),
),
),
);
},
),
)
: const Column(
children: [
BodySmall(
text:
'Currently no devices available to create group',
fontColor: ColorsManager.grayColor,
textAlign: TextAlign.center,
fontSize: 12,
fontWeight: FontWeight.w400,
),
],
),
],
),
),
Spacer()
],
),
);
},
),
),
);
}
}

View File

@ -1,156 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_event.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_state.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/devices/model/six_scene_model.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class SixSceneInfoPage extends StatelessWidget {
final DeviceModel? device;
const SixSceneInfoPage({super.key, this.device});
@override
Widget build(BuildContext context) {
return DefaultScaffold(
title: 'Device Information',
child: BlocProvider(
create: (context) => SixSceneBloc(sixSceneId: device?.uuid ?? '')
..add(const SixSceneInitial())
..add(const SixSceneInitialInfo()),
child: BlocBuilder<SixSceneBloc, SixSceneState>(
builder: (context, state) {
final _bloc = BlocProvider.of<SixSceneBloc>(context);
SixSceneModel model = SixSceneModel(
scene_1: '',
scene_2: '',
scene_3: '',
scene_4: '',
scene_5: '',
scene_6: '',
scene_id_group_id: '',
switch_backlight: '');
if (state is LoadingNewSate) {
model = state.device;
} else if (state is UpdateState) {
model = state.device;
}
return state is SixSceneLoadingState
? const Center(
child: DefaultContainer(
width: 50,
height: 50,
child: CircularProgressIndicator()),
)
: RefreshIndicator(
onRefresh: () async {
_bloc.add(const SixSceneInitial());
},
child: DefaultContainer(
child: Padding(
padding: const EdgeInsets.only(left: 5, right: 5),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
const BodyLarge(
text: 'Virtual ID',
fontSize: 15,
fontWeight: FontWeight.w400,
fontColor: ColorsManager.blackColor,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(
width:
MediaQuery.of(context).size.width * 0.61,
child: BodySmall(
text: _bloc.deviceInfo.productUuid,
fontColor: ColorsManager.primaryTextColor,
),
),
InkWell(
onTap: () {
Clipboard.setData(
ClipboardData(
text: _bloc.deviceInfo.productUuid,
),
);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("Copied to Clipboard"),
),
);
},
child: const Row(
children: [
Icon(
Icons.copy,
color: ColorsManager.blueColor,
),
BodyMedium(
text: 'Copy',
fontColor: ColorsManager.blueColor,
),
],
),
)
],
),
const Divider(
color: ColorsManager.dividerColor,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const BodyLarge(
text: 'MAC',
fontSize: 15,
fontWeight: FontWeight.w400,
fontColor: ColorsManager.blackColor,
),
BodySmall(
text: _bloc.deviceInfo.macAddress,
fontColor: ColorsManager.primaryTextColor,
),
],
),
const Divider(
color: ColorsManager.dividerColor,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const BodyLarge(
text: 'Time Zone',
fontSize: 15,
fontWeight: FontWeight.w400,
fontColor: ColorsManager.blackColor,
),
BodySmall(
text: _bloc.deviceInfo.timeZone,
fontColor: ColorsManager.primaryTextColor,
),
],
),
]),
)));
},
),
),
);
}
}

View File

@ -1,189 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_event.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_state.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/devices/model/six_scene_model.dart';
import 'package:syncrow_app/features/devices/view/widgets/four_scene_switch/four_scene_setting/location_setting_four_scene.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class SixSceneProfilePage extends StatelessWidget {
final DeviceModel? device;
const SixSceneProfilePage({super.key, this.device});
@override
Widget build(BuildContext context) {
var spaces = HomeCubit.getInstance().spaces;
return DefaultScaffold(
title: 'Device Settings',
leading: IconButton(
onPressed: () {
Navigator.of(context).pop(true);
},
icon: const Icon(Icons.arrow_back_ios)),
child: BlocProvider(
create: (context) => SixSceneBloc(sixSceneId: device?.uuid ?? '')
..add(const SixSceneInitial())
..add(const SixSceneInitialInfo()),
child: BlocBuilder<SixSceneBloc, SixSceneState>(
builder: (context, state) {
final _bloc = BlocProvider.of<SixSceneBloc>(context);
SixSceneModel model = SixSceneModel(
scene_1: '',
scene_2: '',
scene_3: '',
scene_4: '',
scene_5: '',
scene_6: '',
scene_id_group_id: '',
switch_backlight: '');
if (state is LoadingNewSate) {
model = state.device;
} else if (state is UpdateState) {
model = state.device;
}
return state is SixSceneLoadingState
? const Center(
child: DefaultContainer(
width: 50,
height: 50,
child: CircularProgressIndicator()),
)
: RefreshIndicator(
onRefresh: () async {
_bloc.add(const SixSceneInitial());
},
child: ListView(
children: [
CircleAvatar(
radius: 60,
backgroundColor: Colors.white,
child: CircleAvatar(
radius: 55,
backgroundColor: ColorsManager.graysColor,
child: ClipOval(
child: Center(
child: SvgPicture.asset(
Assets.sixSceneIcon,
fit: BoxFit.cover,
),
),
),
),
),
const SizedBox(
height: 10,
),
SizedBox(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
IntrinsicWidth(
child: ConstrainedBox(
constraints:
const BoxConstraints(maxWidth: 200),
child: TextFormField(
maxLength: 30,
style: const TextStyle(
color: Colors.black,
),
textAlign: TextAlign.center,
focusNode: _bloc.focusNode,
controller: _bloc.nameController,
enabled: _bloc.editName,
onEditingComplete: () {
_bloc.add(const SaveNameEvent());
},
decoration: const InputDecoration(
hintText: "Your Name",
border: InputBorder.none,
fillColor: Colors.white10,
counterText: '',
),
),
),
),
const SizedBox(width: 5),
InkWell(
onTap: () {
_bloc.add(const ChangeNameEvent(value: true));
},
child: const Padding(
padding: EdgeInsets.symmetric(horizontal: 10),
child: Icon(
Icons.edit_outlined,
size: 20,
color: ColorsManager.textPrimaryColor,
),
),
),
],
),
),
const SizedBox(height: 20),
const BodyMedium(
text: 'Smart Device Information',
fontWeight: FontWeight.w700,
fontSize: 12,
fontColor: ColorsManager.grayColor,
),
DefaultContainer(
padding: const EdgeInsets.all(20),
child: InkWell(
onTap: () async {
bool val = await Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => LocationFourScenePage(
space: spaces!.first,
deviceId: device?.uuid ?? '',
)),
);
if (val == true) {
_bloc.add(const SixSceneInitialInfo());
}
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const SizedBox(
child: Text('Location'),
),
Row(
children: [
SizedBox(
child: BodyMedium(
text: _bloc
.deviceInfo.subspace.subspaceName,
fontColor: ColorsManager.textGray,
),
),
const Icon(
Icons.arrow_forward_ios,
size: 15,
color: ColorsManager.textGray,
),
],
)
],
),
),
)
],
),
);
},
),
),
);
}
}

View File

@ -1,413 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_event.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_state.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/devices/model/six_scene_model.dart';
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/6_scene_setting/faq_six_scene_page.dart';
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/6_scene_setting/share_six_scene_page.dart';
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/6_scene_setting/six_scene_info_page.dart';
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/6_scene_setting/six_scene_profile_page.dart';
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/6_scene_setting/six_scene_update_dialog.dart';
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/6_scene_setting/six_scene_update_page.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/delete_device_dialogs.dart';
import 'package:syncrow_app/features/shared_widgets/setting_widget.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class SixSceneSettings extends StatelessWidget {
final DeviceModel? device;
const SixSceneSettings({super.key, this.device});
@override
Widget build(BuildContext context) {
return DefaultScaffold(
title: 'Device Settings',
child: BlocProvider(
create: (context) => SixSceneBloc(sixSceneId: device?.uuid ?? '')
..add(const SixSceneInitial())
..add(const SixSceneInitial())
..add(const SixSceneInitialInfo()),
child: BlocBuilder<SixSceneBloc, SixSceneState>(
builder: (context, state) {
final _bloc = BlocProvider.of<SixSceneBloc>(context);
SixSceneModel model = SixSceneModel(
scene_1: '',
scene_2: '',
scene_3: '',
scene_4: '',
scene_5: '',
scene_6: '',
scene_id_group_id: '',
switch_backlight: '');
if (state is LoadingNewSate) {
model = state.device;
} else if (state is UpdateState) {
model = state.device;
}
return state is SixSceneLoadingState
? const Center(
child: DefaultContainer(
width: 50,
height: 50,
child: CircularProgressIndicator()),
)
: ListView(
children: [
Padding(
padding: const EdgeInsets.symmetric(
vertical: 10,
),
child: InkWell(
onTap: () async {
bool val = await Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => SixSceneProfilePage(
device: device,
),
),
);
if (val == true) {
_bloc.add(const SixSceneInitialInfo());
}
},
child: Stack(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SizedBox(height: 20),
DefaultContainer(
borderRadius: const BorderRadius.all(
Radius.circular(30)),
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Padding(
padding:
const EdgeInsets.only(left: 90),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
BodyMedium(
text: _bloc.deviceInfo.name,
fontWeight: FontWeight.bold,
),
const SizedBox(
height: 5,
),
BodySmall(
text: _bloc.deviceInfo
.subspace.subspaceName),
],
),
const Icon(Icons.edit_sharp)
],
),
),
),
),
],
),
Positioned(
top: 0,
left: 20,
child: CircleAvatar(
radius: 43,
backgroundColor: Colors.white,
child: CircleAvatar(
radius: 40,
backgroundColor: Colors.white,
child: CircleAvatar(
radius: 40,
backgroundColor:
ColorsManager.backgroundColor,
child: SvgPicture.asset(
Assets.sixSceneIcon,
fit: BoxFit.fill,
),
),
)),
),
],
),
),
),
const SizedBox(height: 20),
const BodyMedium(
text: 'Device Management',
fontWeight: FontWeight.w700,
fontSize: 12,
fontColor: ColorsManager.grayColor,
),
DefaultContainer(
child: Column(
children: [
SettingWidget(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => SixSceneInfoPage(
device: device,
)),
);
},
text: 'Device Information',
icon: Assets.infoIcon,
),
// const Divider(
// color: ColorsManager.dividerColor,
// ),
// SettingWidget(
// onTap: () {
// Navigator.of(context).push(
// MaterialPageRoute(
// builder: (context) =>
// ShareSixScenePage(device: device!)),
// );
// },
// text: 'Tap-to Run and Automation',
// icon: Assets.tapRunIcon,
// ),
],
),
),
const SizedBox(height: 20),
const BodyMedium(
text: 'Device Offline Notification',
fontWeight: FontWeight.w700,
fontSize: 12,
fontColor: ColorsManager.grayColor,
),
DefaultContainer(
child: Column(
children: [
SettingWidget(
value: _bloc.enableAlarm,
onChanged: (p0) {
context
.read<SixSceneBloc>()
.add(ToggleEnableAlarmEvent(p0));
},
isNotification: true,
onTap: () {},
text: 'Offline Notification',
icon: Assets.notificationIcon,
),
],
),
),
const SizedBox(height: 20),
const BodyMedium(
text: 'Others',
fontWeight: FontWeight.w700,
fontSize: 12,
fontColor: ColorsManager.grayColor,
),
const SizedBox(height: 5),
DefaultContainer(
child: Column(
children: [
SettingWidget(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
ShareSixScenePage(device: device!)),
);
},
text: 'Share Device',
icon: Assets.shareIcon,
),
// const Divider(
// color: ColorsManager.dividerColor,
// ),
// SettingWidget(
// onTap: () {
// Navigator.of(context).push(
// MaterialPageRoute(
// builder: (context) =>
// SixSceneCreateGroup(device: device!)),
// );
// },
// text: 'Create Group',
// icon: Assets.createGroupIcon,
// ),
const Divider(
color: ColorsManager.dividerColor,
),
SettingWidget(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
FaqSixScenePage(device: device!)),
);
},
text: 'Device FAQ',
icon: Assets.faqIcon,
),
const Divider(
color: ColorsManager.dividerColor,
),
SettingWidget(
onTapUpdate: () {
showDialog(
context: context,
builder: (context) {
return UpdateInfoDialog(
cancelTab: () {
Navigator.of(context).pop();
},
confirmTab: () {
Navigator.of(context).pop();
},
);
},
);
},
isUpdate: true,
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
const SixSceneUpdatePage()),
);
},
text: 'Device Update',
icon: Assets.updateIcon,
),
],
),
),
const SizedBox(height: 20),
InkWell(
onTap: () {
showModalBottomSheet(
context: context,
builder: (BuildContext context) {
return Container(
height: 200,
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const BodyMedium(
text: 'Remove Device',
fontWeight: FontWeight.w700,
fontSize: 16,
fontColor: ColorsManager.red,
),
const SizedBox(height: 10),
const SizedBox(
width: 250,
child: Divider(
color: ColorsManager.dividerColor,
),
),
const SizedBox(height: 10),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
InkWell(
onTap: () {
showDialog(
context: context,
builder: (context) {
return DisconnectDeviceDialog(
cancelTab: () {
Navigator.of(context).pop();
},
confirmTab: () {
Navigator.of(context).pop();
},
);
},
);
},
child: const BodyMedium(
text: 'Disconnect Device',
fontWeight: FontWeight.w400,
fontSize: 15,
fontColor:
ColorsManager.textPrimaryColor,
),
),
const Icon(
Icons.keyboard_arrow_right,
color: ColorsManager.textGray,
)
],
),
const SizedBox(height: 20),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
InkWell(
onTap: () {
showDialog(
context: context,
builder: (context) {
return DisconnectWipeData(
cancelTab: () {
Navigator.of(context).pop();
},
confirmTab: () {
_bloc.add(
DeleteDeviceEvent());
},
);
},
);
},
child: const BodyMedium(
text:
'Disconnect Device and Wipe Data',
fontWeight: FontWeight.w400,
fontSize: 15,
fontColor:
ColorsManager.textPrimaryColor,
),
),
const Icon(
Icons.keyboard_arrow_right,
color: ColorsManager.textGray,
)
],
),
],
),
);
},
);
},
child: const Center(
child: BodyMedium(
text: 'Remove Device',
fontWeight: FontWeight.w400,
fontSize: 15,
fontColor: ColorsManager.red,
),
),
),
],
);
},
),
),
);
}
}

View File

@ -1,118 +0,0 @@
import 'package:flutter/material.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class upDateNote extends StatelessWidget {
final Function()? cancelTab;
final Function()? confirmTab;
const upDateNote({
super.key,
required this.cancelTab,
required this.confirmTab,
});
@override
Widget build(BuildContext context) {
return AlertDialog(
contentPadding: EdgeInsets.zero,
content: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const SizedBox(
height: 10,
),
BodyLarge(
text: 'Update Note',
fontWeight: FontWeight.w700,
fontColor: ColorsManager.switchButton.withOpacity(0.6),
fontSize: 16,
),
const Padding(
padding: EdgeInsets.only(left: 15, right: 15),
child: Divider(
color: ColorsManager.textGray,
),
),
const Padding(
padding: EdgeInsets.only(left: 15, right: 20, top: 15, bottom: 20),
child: Column(
children: [
Center(
child: Text(
'This update may take a long time. Make sure that the device is fully charged. The device will be unavailable during the update.',
textAlign: TextAlign.center,
)),
],
),
),
Row(
children: [
Expanded(
child: Container(
decoration: const BoxDecoration(
border: Border(
right: BorderSide(
color: ColorsManager.textGray,
width: 0.5,
),
top: BorderSide(
color: ColorsManager.textGray,
width: 1.0,
),
)),
child: SizedBox(
child: InkWell(
onTap: cancelTab,
child: const Padding(
padding: const EdgeInsets.only(top: 15, bottom: 15),
child: Center(
child: Text(
'Cancel',
style: TextStyle(
color: ColorsManager.textGray,
fontSize: 14,
fontWeight: FontWeight.w400),
),
),
),
),
),
),
),
Expanded(
child: Container(
decoration: const BoxDecoration(
border: Border(
left: BorderSide(
color: ColorsManager.textGray,
width: 0.5,
),
top: BorderSide(
color: ColorsManager.textGray,
width: 1.0,
),
)),
child: InkWell(
onTap: confirmTab,
child: Padding(
padding: const EdgeInsets.only(top: 15, bottom: 15),
child: Center(
child: Text(
'Start Update',
style: TextStyle(
color:
ColorsManager.switchButton.withOpacity(0.6),
fontSize: 14,
fontWeight: FontWeight.w400),
),
),
)),
))
],
)
],
),
);
}
}

View File

@ -1,352 +0,0 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:percent_indicator/linear_percent_indicator.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_event.dart';
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_state.dart';
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/6_scene_setting/six_scene_update_note.dart';
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class SixSceneUpdatePage extends StatelessWidget {
const SixSceneUpdatePage({super.key});
@override
Widget build(BuildContext context) {
return DefaultScaffold(
title: 'Device Update',
child: BlocProvider(
create: (context) =>
SixSceneBloc(sixSceneId: '')..add(const SixSceneInitial()),
child: BlocBuilder<SixSceneBloc, SixSceneState>(
builder: (context, state) {
final _bloc = BlocProvider.of<SixSceneBloc>(context);
return state is SixSceneLoadingState
? const Center(
child: DefaultContainer(
width: 50,
height: 50,
child: CircularProgressIndicator()),
)
: RefreshIndicator(
onRefresh: () async {},
child: Column(
children: [
// SizedBox(
// height: MediaQuery.of(context).size.height * 0.15,
// ),
DefaultContainer(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 50,
child: ListTile(
contentPadding: EdgeInsets.zero,
leading: SizedBox(
width: 200,
child: Row(
children: [
Container(
padding: const EdgeInsets.all(10),
decoration: const BoxDecoration(
color: ColorsManager
.primaryColor,
borderRadius:
BorderRadius.all(
Radius.circular(50))),
child: SvgPicture.asset(
Assets.checkUpdateIcon,
fit: BoxFit.fill,
height: 25,
),
),
const SizedBox(
width: 10,
),
InkWell(
onTap: () {},
child: const BodyMedium(
text: 'Automatic Update',
fontWeight: FontWeight.normal,
),
),
],
),
),
trailing: Container(
width: 100,
child: Row(
mainAxisAlignment:
MainAxisAlignment.end,
children: [
BodyMedium(
text: _bloc.enableUpdate
? 'true'
: 'Off',
fontColor: ColorsManager.textGray,
),
Transform.scale(
scale: .8,
child: CupertinoSwitch(
value: _bloc.enableUpdate,
onChanged: (value) {
_bloc.add(ToggleUpdateEvent(
isUpdateEnabled: value));
},
applyTheme: true,
),
),
],
),
)),
),
],
),
),
const SizedBox(
height: 10,
),
const UpdateSosContainerWithProgressBar(
sosDescription:
'Connectivity Issue Resolved Fixed a bug that caused the SOS button to disconnect from the app intermittently.',
sosVersion: 'SOS v2.0.5',
),
// const UpdatedContainer(
// sosVersion: 'SOS v1.0.13',
// sosDescription: 'SOS is up to date',
// ),
// const NewUpdateContainer(
// sosVersion: 'SOS v2.0.5',
// sosDescription:
// 'Connectivity Issue Resolved Fixed a bug that caused the SOS button to disconnect from the app intermittently.',
// ),
const SizedBox(
height: 15,
),
],
));
},
),
));
}
}
class UpdatedContainer extends StatelessWidget {
final String? sosVersion;
final String? sosDescription;
const UpdatedContainer({
this.sosVersion,
this.sosDescription,
super.key,
});
@override
Widget build(BuildContext context) {
return DefaultContainer(
height: MediaQuery.of(context).size.height * 0.35,
child: Padding(
padding: const EdgeInsets.all(25),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SvgPicture.asset(
Assets.emptyUpdateIcon,
fit: BoxFit.fill,
),
BodyMedium(
text: sosVersion!,
fontColor: ColorsManager.primaryTextColor,
),
BodyMedium(
text: sosDescription!,
fontColor: ColorsManager.blackColor,
),
],
),
],
),
),
);
}
}
class NewUpdateContainer extends StatelessWidget {
final String? sosVersion;
final String? sosDescription;
const NewUpdateContainer({
this.sosVersion,
this.sosDescription,
super.key,
});
@override
Widget build(BuildContext context) {
return DefaultContainer(
height: MediaQuery.of(context).size.height * 0.50,
child: Padding(
padding: const EdgeInsets.all(25),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SvgPicture.asset(
Assets.emptyUpdateIcon,
fit: BoxFit.fill,
),
const BodyMedium(
text: 'New Update Available Now!',
fontColor: ColorsManager.blueColor,
),
BodyMedium(
text: sosVersion!,
fontColor: ColorsManager.primaryTextColor,
),
Container(
width: MediaQuery.of(context).size.width * 0.7,
child: BodyMedium(
text: sosDescription!,
fontColor: ColorsManager.textPrimaryColor,
textAlign: TextAlign.center,
),
),
SizedBox(
width: MediaQuery.of(context).size.width * 0.6,
child: DefaultButton(
borderRadius: 25,
backgroundColor: ColorsManager.blueColor1,
height: 150,
onPressed: () {
showDialog(
context: context,
builder: (context) {
return upDateNote(
cancelTab: () {
Navigator.of(context).pop();
},
confirmTab: () {
Navigator.of(context).pop();
},
);
},
);
},
child: const BodyMedium(
text: 'Update Now',
fontColor: Colors.white,
fontSize: 16,
fontWeight: FontWeight.w700,
textAlign: TextAlign.center,
),
),
)
],
),
],
),
),
);
}
}
class UpdateSosContainerWithProgressBar extends StatelessWidget {
final String? sosVersion;
final String? sosDescription;
const UpdateSosContainerWithProgressBar({
this.sosVersion,
this.sosDescription,
super.key,
});
@override
Widget build(BuildContext context) {
return Column(
children: [
DefaultContainer(
height: MediaQuery.of(context).size.height * 0.50,
child: Padding(
padding: const EdgeInsets.all(25),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SvgPicture.asset(
Assets.emptyUpdateIcon,
fit: BoxFit.fill,
),
BodyMedium(
text: 'New Update Available Now!',
fontColor: ColorsManager.blueColor,
),
BodyMedium(
text: sosVersion!,
fontColor: ColorsManager.primaryTextColor,
),
SizedBox(
width: MediaQuery.of(context).size.width * 0.7,
child: BodyMedium(
text: sosDescription!,
fontColor: ColorsManager.textPrimaryColor,
textAlign: TextAlign.center,
),
),
LinearPercentIndicator(
barRadius: Radius.circular(10),
width: 170.0,
animation: true,
animationDuration: 1000,
lineHeight: 5.0,
percent: 0.2,
linearStrokeCap: LinearStrokeCap.butt,
progressColor: ColorsManager.blueColor1,
),
SizedBox(
width: MediaQuery.of(context).size.width * 0.7,
child: const BodyMedium(
text: 'Downloading Update please be patient',
fontColor: ColorsManager.textPrimaryColor,
textAlign: TextAlign.center,
),
),
],
),
],
),
),
),
SizedBox(
width: MediaQuery.of(context).size.width * 0.7,
child: const BodyMedium(
text:
'Please keep the power of the device connected during the upgrade process.',
fontColor: ColorsManager.textPrimaryColor,
textAlign: TextAlign.center,
),
),
],
);
}
}

View File

@ -8,7 +8,7 @@ import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_ev
import 'package:syncrow_app/features/devices/bloc/6_scene_switch_bloc/6_scene_state.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/devices/model/six_scene_model.dart';
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/6_scene_setting/six_scene_settings.dart';
import 'package:syncrow_app/features/devices/view/device_settings/settings_page.dart';
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/select_scene_page.dart';
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/select_switch_dialog.dart';
import 'package:syncrow_app/features/devices/view/widgets/6_scene_switch/six_switches_card.dart';
@ -57,7 +57,7 @@ class SixSceneScreen extends StatelessWidget {
onTap: () async {
bool val = await Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => SixSceneSettings(device: device!),
builder: (context) => SettingsPage(device: device!),
),
);
if (val == true) {

View File

@ -6,7 +6,7 @@ import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_eve
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_state.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/devices/model/four_scene_model.dart';
import 'package:syncrow_app/features/devices/view/widgets/four_scene_switch/four_scene_setting/four_scene_settings.dart';
import 'package:syncrow_app/features/devices/view/device_settings/settings_page.dart';
import 'package:syncrow_app/features/devices/view/widgets/four_scene_switch/four_select_scene_page.dart';
import 'package:syncrow_app/features/devices/view/widgets/four_scene_switch/four_select_switch_dialog.dart';
import 'package:syncrow_app/features/devices/view/widgets/four_scene_switch/four_switches_card.dart';
@ -53,7 +53,7 @@ class FourSceneScreen extends StatelessWidget {
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => FourSceneSettings(device: device!),
builder: (context) => SettingsPage(device: device!),
),
);
},

View File

@ -1,118 +0,0 @@
import 'package:flutter/material.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class UpdateInfoDialog extends StatelessWidget {
final Function()? cancelTab;
final Function()? confirmTab;
const UpdateInfoDialog({
super.key,
required this.cancelTab,
required this.confirmTab,
});
@override
Widget build(BuildContext context) {
return AlertDialog(
contentPadding: EdgeInsets.zero,
content: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const SizedBox(
height: 10,
),
BodyLarge(
text: 'Update Available',
fontWeight: FontWeight.w700,
fontColor: ColorsManager.switchButton.withOpacity(0.6),
fontSize: 16,
),
const Padding(
padding: EdgeInsets.only(left: 15, right: 15),
child: Divider(
color: ColorsManager.textGray,
),
),
const Padding(
padding: EdgeInsets.only(left: 15, right: 20, top: 15, bottom: 20),
child: Column(
children: [
Center(
child: Text(
'An update is available for your device. Version 2.1.0 includes new features and important fixes to enhance performance and security.',
textAlign: TextAlign.center,
)),
],
),
),
Row(
children: [
Expanded(
child: Container(
decoration: const BoxDecoration(
border: Border(
right: BorderSide(
color: ColorsManager.textGray,
width: 0.5,
),
top: BorderSide(
color: ColorsManager.textGray,
width: 1.0,
),
)),
child: SizedBox(
child: InkWell(
onTap: cancelTab,
child: const Padding(
padding: const EdgeInsets.only(top: 15, bottom: 15),
child: Center(
child: Text(
'Remind me later',
style: TextStyle(
color: ColorsManager.textGray,
fontSize: 14,
fontWeight: FontWeight.w400),
),
),
),
),
),
),
),
Expanded(
child: Container(
decoration: const BoxDecoration(
border: Border(
left: BorderSide(
color: ColorsManager.textGray,
width: 0.5,
),
top: BorderSide(
color: ColorsManager.textGray,
width: 1.0,
),
)),
child: InkWell(
onTap: confirmTab,
child: Padding(
padding: const EdgeInsets.only(top: 15, bottom: 15),
child: Center(
child: Text(
'Update Now',
style: TextStyle(
color:
ColorsManager.switchButton.withOpacity(0.6),
fontSize: 14,
fontWeight: FontWeight.w400),
),
),
)),
))
],
)
],
),
);
}
}

View File

@ -1,118 +0,0 @@
import 'package:flutter/material.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class UpDateNote extends StatelessWidget {
final Function()? cancelTab;
final Function()? confirmTab;
const UpDateNote({
super.key,
required this.cancelTab,
required this.confirmTab,
});
@override
Widget build(BuildContext context) {
return AlertDialog(
contentPadding: EdgeInsets.zero,
content: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const SizedBox(
height: 10,
),
BodyLarge(
text: 'Update Note',
fontWeight: FontWeight.w700,
fontColor: ColorsManager.switchButton.withOpacity(0.6),
fontSize: 16,
),
const Padding(
padding: EdgeInsets.only(left: 15, right: 15),
child: Divider(
color: ColorsManager.textGray,
),
),
const Padding(
padding: EdgeInsets.only(left: 15, right: 20, top: 15, bottom: 20),
child: Column(
children: [
Center(
child: Text(
'This update may take a long time. Make sure that the device is fully charged. The device will be unavailable during the update.',
textAlign: TextAlign.center,
)),
],
),
),
Row(
children: [
Expanded(
child: Container(
decoration: const BoxDecoration(
border: Border(
right: BorderSide(
color: ColorsManager.textGray,
width: 0.5,
),
top: BorderSide(
color: ColorsManager.textGray,
width: 1.0,
),
)),
child: SizedBox(
child: InkWell(
onTap: cancelTab,
child: const Padding(
padding: const EdgeInsets.only(top: 15, bottom: 15),
child: Center(
child: Text(
'Cancel',
style: TextStyle(
color: ColorsManager.textGray,
fontSize: 14,
fontWeight: FontWeight.w400),
),
),
),
),
),
),
),
Expanded(
child: Container(
decoration: const BoxDecoration(
border: Border(
left: BorderSide(
color: ColorsManager.textGray,
width: 0.5,
),
top: BorderSide(
color: ColorsManager.textGray,
width: 1.0,
),
)),
child: InkWell(
onTap: confirmTab,
child: Padding(
padding: const EdgeInsets.only(top: 15, bottom: 15),
child: Center(
child: Text(
'Start Update',
style: TextStyle(
color:
ColorsManager.switchButton.withOpacity(0.6),
fontSize: 14,
fontWeight: FontWeight.w400),
),
),
)),
))
],
)
],
),
);
}
}

View File

@ -1,142 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_event.dart';
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_state.dart';
import 'package:syncrow_app/features/devices/model/question_model.dart';
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class QuestionPageFourScene extends StatelessWidget {
final QuestionModel? questionModel;
const QuestionPageFourScene({super.key, this.questionModel});
@override
Widget build(BuildContext context) {
return DefaultScaffold(
title: 'FAQ',
child: BlocProvider(
create: (context) =>
FourSceneBloc(fourSceneId: '')..add(const FourSceneInitial()),
child: BlocBuilder<FourSceneBloc, FourSceneState>(
builder: (context, state) {
final sensor = BlocProvider.of<FourSceneBloc>(context);
return state is FourSceneLoadingState
? const Center(
child: DefaultContainer(
width: 50,
height: 50,
child: CircularProgressIndicator()),
)
: Column(
children: [
DefaultContainer(
padding: const EdgeInsets.all(15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
BodyLarge(
text: questionModel!.question,
fontSize: 22,
fontWeight: FontWeight.w400,
fontColor: ColorsManager.blackColor,
),
const SizedBox(
height: 15,
),
BodyMedium(
text: questionModel!.answer,
fontSize: 14,
fontWeight: FontWeight.w400,
fontColor: ColorsManager.secondaryTextColor,
),
],
),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.15,
),
Center(
child: SizedBox(
width: 180,
child: DefaultButton(
backgroundColor: sensor.isHelpful == true
? ColorsManager.grayColor
: ColorsManager.grayButtonColors,
borderRadius: 50,
onPressed: () {
sensor.add(
const ToggleHelpfulEvent(isHelpful: true));
},
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset(
Assets.thumbUp,
fit: BoxFit.fill,
),
const SizedBox(
width: 10,
),
const BodyMedium(
text: 'Helpful',
fontSize: 12,
fontWeight: FontWeight.w400,
fontColor: ColorsManager.blackColor,
),
],
)),
),
),
const SizedBox(
height: 15,
),
Center(
child: SizedBox(
width: 180,
child: DefaultButton(
backgroundColor: sensor.isHelpful == false
? ColorsManager.grayColor
: ColorsManager.grayButtonColors,
borderRadius: 50,
onPressed: () {
sensor.add(
const ToggleHelpfulEvent(isHelpful: false));
},
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset(
Assets.thumbDown,
fit: BoxFit.fill,
),
const SizedBox(
width: 10,
),
const BodyMedium(
text: 'Not Helpful',
fontSize: 12,
fontWeight: FontWeight.w400,
fontColor: ColorsManager.blackColor,
),
],
)),
),
),
],
);
},
),
),
);
}
}

View File

@ -7,14 +7,11 @@ import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_blo
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_event.dart';
import 'package:syncrow_app/features/devices/bloc/four_scene_bloc/four_scene_state.dart';
import 'package:syncrow_app/features/devices/view/widgets/restart_status_dialog.dart';
import 'package:syncrow_app/features/scene/model/scene_settings_route_arguments.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/navigation/navigation_service.dart';
import 'package:syncrow_app/navigation/routing_constants.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class FourSelectSceneFourPage extends StatelessWidget {

View File

@ -68,7 +68,7 @@ class RoomPageSwitch extends StatelessWidget {
Flexible(
child: FittedBox(
child: Text(
device.type ?? "",
device.name ?? "",
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: context.bodyLarge.copyWith(

View File

@ -6,9 +6,9 @@ import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_event.dart';
import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_state.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/devices/model/sos_model.dart';
import 'package:syncrow_app/features/devices/view/device_settings/settings_page.dart';
import 'package:syncrow_app/features/devices/view/widgets/sos/sos_alarm_management_page.dart';
import 'package:syncrow_app/features/devices/view/widgets/sos/sos_records_screen.dart';
import 'package:syncrow_app/features/devices/view/widgets/sos/sos_settings.dart';
import 'package:syncrow_app/features/shared_widgets/battery_bar.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
@ -43,15 +43,15 @@ class SosScreen extends StatelessWidget {
actions: [
InkWell(
onTap: () async {
Navigator.of(context).push(
var val = await Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => SosSettings(device: device!),
builder: (context) => SettingsPage(device: device!),
),
);
// if (val == null) {
// sensor.add(SosInitialDeviseInfo());
// sensor.add(const SosInitial());
// }
if (val == null) {
sensor.add(SosInitialDeviseInfo());
sensor.add(const SosInitial());
}
},
child: SvgPicture.asset(Assets.assetsIconsSettings),
),

View File

@ -1,164 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_event.dart';
import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_state.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/devices/model/question_model.dart';
import 'package:syncrow_app/features/devices/view/widgets/sos/sos_setting/question_page.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class FaqSosPage extends StatelessWidget {
final DeviceModel? device;
const FaqSosPage({super.key, this.device});
@override
Widget build(BuildContext context) {
TextEditingController _searchController = TextEditingController();
return DefaultScaffold(
title: 'FAQ',
child: BlocProvider(
create: (context) =>
SosBloc(sosId: device?.uuid ?? '')..add(const SosInitialQuestion()),
child: BlocBuilder<SosBloc, SosState>(
builder: (context, state) {
final sensor = BlocProvider.of<SosBloc>(context);
List<QuestionModel> displayedQuestions = [];
if (state is FaqSearchState) {
displayedQuestions = state.filteredFaqQuestions;
} else if (state is FaqLoadedState) {
displayedQuestions = state.filteredFaqQuestions;
}
return state is SosLoadingState
? const Center(
child: DefaultContainer(
width: 50,
height: 50,
child: CircularProgressIndicator()),
)
: RefreshIndicator(
onRefresh: () async {
sensor.add(const SosInitial());
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
DefaultContainer(
padding: const EdgeInsets.all(5),
child: TextFormField(
controller: _searchController,
onChanged: (value) {
sensor.add(SearchFaqEvent(value));
},
decoration: InputDecoration(
hintText: 'Enter your questions',
hintStyle: const TextStyle(
color: ColorsManager.textGray,
fontSize: 16,
fontWeight: FontWeight.w400),
suffixIcon: Container(
padding: const EdgeInsets.all(5.0),
margin: const EdgeInsets.all(10.0),
child: SvgPicture.asset(
Assets.searchIcon,
fit: BoxFit.contain,
),
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8.0),
),
),
),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.04,
),
BodyMedium(
text: _searchController.text.isEmpty
? 'Device Related FAQs'
: '${displayedQuestions.length} Help Topics',
fontWeight: FontWeight.w700,
fontSize: 12,
fontColor: ColorsManager.grayColor,
),
const SizedBox(
height: 8,
),
displayedQuestions.isEmpty
? const SizedBox()
: DefaultContainer(
child: ListView.builder(
shrinkWrap: true,
itemCount: displayedQuestions.length,
itemBuilder: (context, index) {
final faq = displayedQuestions[index];
return InkWell(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
QuestionPage(
questionModel: faq,
)),
);
},
child: SizedBox(
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Padding(
padding:
const EdgeInsets.all(8.0),
child: Row(
children: [
Expanded(
child: BodyMedium(
fontSize: 14,
fontWeight:
FontWeight.w400,
text: faq.question,
),
),
const Icon(
Icons.keyboard_arrow_right,
color:
ColorsManager.textGray,
),
],
),
),
if (index !=
displayedQuestions.length -
1) // Exclude divider for the last item
const Divider(
color:
ColorsManager.dividerColor,
),
],
),
),
);
},
),
)
],
),
);
},
),
),
);
}
}

View File

@ -1,211 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/app_layout/model/space_model.dart';
import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_event.dart';
import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_state.dart';
import 'package:syncrow_app/features/devices/model/sos_model.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class LocationSosPage extends StatelessWidget {
final SpaceModel? space;
final String? deviceId;
const LocationSosPage({
super.key,
this.space,
this.deviceId,
});
@override
Widget build(BuildContext context) {
String roomIdSelected = '';
return Scaffold(
body: BlocProvider(
create: (context) => SosBloc(sosId: deviceId ?? '')
..add(const SosInitial())
..add(SosInitialDeviseInfo())
..add(FetchRoomsEvent(unit: space!)),
child: BlocBuilder<SosBloc, SosState>(
builder: (context, state) {
final _bloc = BlocProvider.of<SosBloc>(context);
SosModel model =
SosModel(batteryPercentage: 0, sosContactState: '');
if (state is SaveSelectionSuccessState) {
Future.delayed(const Duration(microseconds: 500), () {
_bloc.add(const SosInitial());
Navigator.of(context).pop(true);
});
}
return state is SosLoadingState
? const Center(
child: DefaultContainer(
width: 50,
height: 50,
child: CircularProgressIndicator(),
),
)
: DefaultScaffold(
actions: [
BlocBuilder<SosBloc, SosState>(
builder: (context, state) {
final bool canSave = state is OptionSelectedState &&
state.hasSelectionChanged;
return InkWell(
onTap: canSave
? () {
context.read<SosBloc>().add(AssignRoomEvent(
context: context,
roomId: roomIdSelected,
unit: space!));
}
: null,
child: BodyMedium(
text: 'Save',
fontWeight: FontWeight.w700,
fontSize: 16,
fontColor: canSave
? ColorsManager.slidingBlueColor
: ColorsManager.primaryTextColor,
),
);
},
),
const SizedBox(width: 20),
],
child: ListView(
shrinkWrap: true,
padding: const EdgeInsets.symmetric(vertical: 20),
children: [
const BodyMedium(
text: 'Smart Device Location',
fontWeight: FontWeight.w700,
fontSize: 12,
fontColor: ColorsManager.grayColor,
),
const SizedBox(height: 5),
DefaultContainer(
padding: const EdgeInsets.all(20),
child: ListView.builder(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: _bloc.roomsList.length,
itemBuilder: (context, index) {
final fromRoom = _bloc.roomsList[index];
final isSelected = (state
is OptionSelectedState &&
state.selectedOption == fromRoom.id) ||
(state is! OptionSelectedState &&
fromRoom.id ==
_bloc.deviceInfo.subspace.uuid);
return Column(
children: [
_buildCheckboxOption(
label: fromRoom.name!,
isSelected: isSelected,
onTap: (label) {
context.read<SosBloc>().add(
SelectOptionEvent(
selectedOption: fromRoom.id!,
),
);
roomIdSelected = fromRoom.id!;
},
),
if (index < _bloc.roomsList.length - 1) ...[
const SizedBox(height: 10),
const Divider(
color: ColorsManager.dividerColor,
),
const SizedBox(height: 10),
],
],
);
},
),
),
],
),
);
},
),
),
);
}
}
class CircularCheckbox extends StatefulWidget {
final bool value;
final ValueChanged<bool?> onChanged;
CircularCheckbox({required this.value, required this.onChanged});
@override
_CircularCheckboxState createState() => _CircularCheckboxState();
}
class _CircularCheckboxState extends State<CircularCheckbox> {
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
widget.onChanged(!widget.value);
},
child: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: widget.value
? ColorsManager.primaryColorWithOpacity.withOpacity(0.01)
: Colors.grey,
width: 2.0,
),
color: widget.value
? ColorsManager.primaryColorWithOpacity
: Colors.transparent,
),
width: 24.0,
height: 24.0,
child: widget.value
? const Icon(
Icons.check,
color: Colors.white,
size: 16.0,
)
: null,
),
);
}
}
Widget _buildCheckboxOption({
required String label,
required bool isSelected,
required Function(String) onTap,
}) {
return Padding(
padding: const EdgeInsets.only(bottom: 10, top: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
BodyMedium(
text: label,
style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w400),
),
CircularCheckbox(
value: isSelected,
onChanged: (bool? value) {
if (value == true) {
onTap(label);
}
},
),
],
),
);
}

View File

@ -1,105 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_event.dart';
import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_state.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/menu/view/widgets/manage_home/home_settings.dart';
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/utils/helpers/custom_page_route.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class ShareSosPage extends StatelessWidget {
final DeviceModel? device;
const ShareSosPage({super.key, this.device});
@override
Widget build(BuildContext context) {
var spaces = HomeCubit.getInstance().spaces;
return DefaultScaffold(
title: 'Share Device',
child: BlocProvider(
create: (context) =>
SosBloc(sosId: device?.uuid ?? '')..add(const SosInitial()),
child: BlocBuilder<SosBloc, SosState>(
builder: (context, state) {
final sensor = BlocProvider.of<SosBloc>(context);
return state is SosLoadingState
? const Center(
child: DefaultContainer(
width: 50,
height: 50,
child: CircularProgressIndicator()),
)
: RefreshIndicator(
onRefresh: () async {
sensor.add(const SosInitial());
},
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: MediaQuery.of(context).size.height * 0.05,
),
const BodyLarge(
text: 'Sharing Method Not Supported',
fontSize: 15,
fontWeight: FontWeight.w400,
fontColor: ColorsManager.blackColor,
),
const BodyMedium(
text:
'Currently, you cannot use the specified method to share Bluetooth mesh devices Zigbee devices, infrared devices, Bluetooth Beacon Devices, and certain Bluetooth LE devices with other users.',
fontSize: 14,
fontWeight: FontWeight.w400,
fontColor: ColorsManager.secondaryTextColor,
),
const SizedBox(
height: 10,
),
const BodyLarge(
text: 'Recommended Sharing Method',
fontSize: 15,
fontWeight: FontWeight.w400,
fontColor: ColorsManager.blackColor,
),
const BodyMedium(
text:
'If the recipient is a home member or a reliable user, tap Me > Home Management > Add Member and add the recipient to your home. Then, devices in the home can be shared with the recipient in bulk.',
fontSize: 14,
fontWeight: FontWeight.w400,
fontColor: ColorsManager.secondaryTextColor,
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.15,
),
Center(
child: SizedBox(
width: 250,
child: DefaultButton(
backgroundColor: ColorsManager.blueColor1,
borderRadius: 50,
onPressed: () {
Navigator.of(context).push(CustomPageRoute(
builder: (context) => HomeSettingsView(
space: spaces!.first,
)));
},
child: const Text('Add Home Member')),
),
)
],
));
},
),
),
);
}
}

View File

@ -1,141 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_event.dart';
import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_state.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class SosInfoPage extends StatelessWidget {
final DeviceModel? device;
const SosInfoPage({super.key, this.device});
@override
Widget build(BuildContext context) {
return DefaultScaffold(
title: 'Device Information',
child: BlocProvider(
create: (context) => SosBloc(sosId: device?.uuid ?? '')
..add(const SosInitial())
..add(SosInitialDeviseInfo()),
child: BlocBuilder<SosBloc, SosState>(
builder: (context, state) {
final _bloc = BlocProvider.of<SosBloc>(context);
return state is SosLoadingState
? const Center(
child: DefaultContainer(
width: 50,
height: 50,
child: CircularProgressIndicator()),
)
: RefreshIndicator(
onRefresh: () async {
_bloc.add(const SosInitial());
},
child: DefaultContainer(
child: Padding(
padding: const EdgeInsets.only(left: 5, right: 5),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
const BodyLarge(
text: 'Virtual ID',
fontSize: 15,
fontWeight: FontWeight.w400,
fontColor: ColorsManager.blackColor,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(
width:
MediaQuery.of(context).size.width * 0.61,
child: BodySmall(
text: _bloc.deviceInfo.productUuid,
fontColor: ColorsManager.primaryTextColor,
),
),
InkWell(
onTap: () {
Clipboard.setData(
ClipboardData(
text: _bloc.deviceInfo.productUuid,
),
);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("Copied to Clipboard"),
),
);
},
child: const Row(
children: [
Icon(
Icons.copy,
color: ColorsManager.blueColor,
),
BodyMedium(
text: 'Copy',
fontColor: ColorsManager.blueColor,
),
],
),
)
],
),
const Divider(
color: ColorsManager.dividerColor,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const BodyLarge(
text: 'MAC',
fontSize: 15,
fontWeight: FontWeight.w400,
fontColor: ColorsManager.blackColor,
),
BodySmall(
text: _bloc.deviceInfo.macAddress,
fontColor: ColorsManager.primaryTextColor,
),
],
),
const Divider(
color: ColorsManager.dividerColor,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const BodyLarge(
text: 'Time Zone',
fontSize: 15,
fontWeight: FontWeight.w400,
fontColor: ColorsManager.blackColor,
),
BodySmall(
text: _bloc.deviceInfo.timeZone,
fontColor: ColorsManager.primaryTextColor,
),
],
),
]),
)));
},
),
),
);
}
}

View File

@ -1,184 +0,0 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_event.dart';
import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_state.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/devices/model/sos_model.dart';
import 'package:syncrow_app/features/devices/view/widgets/sos/sos_setting/location_setting.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class SosProfilePage extends StatelessWidget {
final DeviceModel? device;
const SosProfilePage({super.key, this.device});
@override
Widget build(BuildContext context) {
var spaces = HomeCubit.getInstance().spaces;
return DefaultScaffold(
title: 'Device Settings',
leading: IconButton(
onPressed: () {
Navigator.of(context).pop(true);
},
icon: const Icon(Icons.arrow_back_ios)),
child: BlocProvider(
create: (context) => SosBloc(sosId: device?.uuid ?? '')
..add(const SosInitial())
..add(SosInitialDeviseInfo()),
child: BlocBuilder<SosBloc, SosState>(
builder: (context, state) {
final _bloc = BlocProvider.of<SosBloc>(context);
SosModel model =
SosModel(batteryPercentage: 0, sosContactState: '');
if (state is LoadingNewSate) {
model = state.sosSensor;
} else if (state is UpdateState) {
model = state.sensor;
}
return state is SosLoadingState
? const Center(
child: DefaultContainer(
width: 50,
height: 50,
child: CircularProgressIndicator()),
)
: RefreshIndicator(
onRefresh: () async {
_bloc.add(const SosInitial());
},
child: ListView(
children: [
CircleAvatar(
radius: 60,
backgroundColor: Colors.white.withOpacity(0),
child: CircleAvatar(
radius: 55,
backgroundColor: ColorsManager.graysColor,
child: ClipOval(
child: Center(
child: SvgPicture.asset(
Assets.sosHomeIcon,
fit: BoxFit.fitHeight,
height: 100,
),
),
),
),
),
const SizedBox(
height: 10,
),
SizedBox(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
IntrinsicWidth(
child: ConstrainedBox(
constraints:
const BoxConstraints(maxWidth: 200),
child: TextFormField(
maxLength: 30,
style: const TextStyle(
color: Colors.black,
),
textAlign: TextAlign.center,
focusNode: _bloc.focusNode,
controller: _bloc.nameController,
enabled: _bloc.editName,
onEditingComplete: () {
_bloc.add(SaveNameEvent());
},
decoration: const InputDecoration(
hintText: "Your Name",
border: InputBorder.none,
fillColor: Colors.white10,
counterText: '',
),
),
),
),
const SizedBox(width: 5),
InkWell(
onTap: () {
_bloc.add(const ChangeNameEvent(value: true));
},
child: const Padding(
padding: EdgeInsets.symmetric(horizontal: 10),
child: Icon(
Icons.edit_outlined,
size: 20,
color: ColorsManager.textPrimaryColor,
),
),
),
],
),
),
const SizedBox(height: 20),
const BodyMedium(
text: 'Smart Device Information',
fontWeight: FontWeight.w700,
fontSize: 12,
fontColor: ColorsManager.grayColor,
),
const SizedBox(height: 7),
DefaultContainer(
padding: const EdgeInsets.all(20),
child: InkWell(
onTap: () async {
bool val = await Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => LocationSosPage(
space: spaces!.first,
deviceId: device?.uuid ?? '',
)),
);
if (val == true) {
_bloc.add(SosInitialDeviseInfo());
}
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const SizedBox(
child: Text('Location'),
),
Row(
children: [
SizedBox(
child: BodyMedium(
text: _bloc
.deviceInfo.subspace.subspaceName,
fontColor: ColorsManager.textGray,
),
),
const Icon(
Icons.arrow_forward_ios,
size: 15,
color: ColorsManager.textGray,
),
],
)
],
),
),
)
],
),
);
},
),
),
);
}
}

View File

@ -1,353 +0,0 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:percent_indicator/linear_percent_indicator.dart';
import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_event.dart';
import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_state.dart';
import 'package:syncrow_app/features/devices/view/widgets/sos/sos_setting/sos_update_note.dart';
import 'package:syncrow_app/features/shared_widgets/default_button.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class SosUpdatePage extends StatelessWidget {
const SosUpdatePage({super.key});
@override
Widget build(BuildContext context) {
return DefaultScaffold(
title: 'Device Update',
child: BlocProvider(
create: (context) => SosBloc(sosId: '')..add(const SosInitial()),
child: BlocBuilder<SosBloc, SosState>(
builder: (context, state) {
final _bloc = BlocProvider.of<SosBloc>(context);
return state is SosLoadingState
? const Center(
child: DefaultContainer(
width: 50,
height: 50,
child: CircularProgressIndicator()),
)
: RefreshIndicator(
onRefresh: () async {},
child: Column(
children: [
// SizedBox(
// height: MediaQuery.of(context).size.height * 0.15,
// ),
DefaultContainer(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 50,
child: ListTile(
contentPadding: EdgeInsets.zero,
leading: SizedBox(
width: 200,
child: Row(
children: [
Container(
padding: const EdgeInsets.all(10),
decoration: const BoxDecoration(
color:
ColorsManager.primaryColor,
borderRadius: BorderRadius.all(
Radius.circular(50))),
child: SvgPicture.asset(
Assets.checkUpdateIcon,
fit: BoxFit.fill,
height: 25,
),
),
const SizedBox(
width: 10,
),
InkWell(
onTap: () {},
child: const BodyMedium(
text: 'Automatic Update',
fontWeight: FontWeight.normal,
),
),
],
),
),
trailing: Container(
width: 100,
child: Row(
mainAxisAlignment:
MainAxisAlignment.end,
children: [
BodyMedium(
text: _bloc.enableUpdate
? 'true'
: 'Off',
fontColor: ColorsManager.textGray,
),
Transform.scale(
scale: .8,
child: CupertinoSwitch(
value: _bloc.enableUpdate,
onChanged: (value) {
_bloc.add(ToggleUpdateEvent(
isUpdateEnabled: value));
},
applyTheme: true,
),
),
],
),
)
),
),
],
),
),
const SizedBox(
height: 10,
),
const UpdateSosContainerWithProgressBar(
sosDescription:
'Connectivity Issue Resolved Fixed a bug that caused the SOS button to disconnect from the app intermittently.',
sosVersion: 'SOS v2.0.5',
),
// const UpdatedContainer(
// sosVersion: 'SOS v1.0.13',
// sosDescription: 'SOS is up to date',
// ),
// const NewUpdateContainer(
// sosVersion: 'SOS v2.0.5',
// sosDescription:
// 'Connectivity Issue Resolved Fixed a bug that caused the SOS button to disconnect from the app intermittently.',
// ),
const SizedBox(
height: 15,
),
],
));
},
),
),
);
}
}
class UpdatedContainer extends StatelessWidget {
final String? sosVersion;
final String? sosDescription;
const UpdatedContainer({
this.sosVersion,
this.sosDescription,
super.key,
});
@override
Widget build(BuildContext context) {
return DefaultContainer(
height: MediaQuery.of(context).size.height * 0.35,
child: Padding(
padding: const EdgeInsets.all(25),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SvgPicture.asset(
Assets.emptyUpdateIcon,
fit: BoxFit.fill,
),
BodyMedium(
text: sosVersion!,
fontColor: ColorsManager.primaryTextColor,
),
BodyMedium(
text: sosDescription!,
fontColor: ColorsManager.blackColor,
),
],
),
],
),
),
);
}
}
class NewUpdateContainer extends StatelessWidget {
final String? sosVersion;
final String? sosDescription;
const NewUpdateContainer({
this.sosVersion,
this.sosDescription,
super.key,
});
@override
Widget build(BuildContext context) {
return DefaultContainer(
height: MediaQuery.of(context).size.height * 0.50,
child: Padding(
padding: const EdgeInsets.all(25),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SvgPicture.asset(
Assets.emptyUpdateIcon,
fit: BoxFit.fill,
),
const BodyMedium(
text: 'New Update Available Now!',
fontColor: ColorsManager.blueColor,
),
BodyMedium(
text: sosVersion!,
fontColor: ColorsManager.primaryTextColor,
),
Container(
width: MediaQuery.of(context).size.width * 0.7,
child: BodyMedium(
text: sosDescription!,
fontColor: ColorsManager.textPrimaryColor,
textAlign: TextAlign.center,
),
),
SizedBox(
width: MediaQuery.of(context).size.width * 0.6,
child: DefaultButton(
borderRadius: 25,
backgroundColor: ColorsManager.blueColor1,
height: 150,
onPressed: () {
showDialog(
context: context,
builder: (context) {
return SosUpdateNote(
cancelTab: () {
Navigator.of(context).pop();
},
confirmTab: () {
Navigator.of(context).pop();
},
);
},
);
},
child: const BodyMedium(
text: 'Update Now',
fontColor: Colors.white,
fontSize: 16,
fontWeight: FontWeight.w700,
textAlign: TextAlign.center,
),
),
)
],
),
],
),
),
);
}
}
class UpdateSosContainerWithProgressBar extends StatelessWidget {
final String? sosVersion;
final String? sosDescription;
const UpdateSosContainerWithProgressBar({
this.sosVersion,
this.sosDescription,
super.key,
});
@override
Widget build(BuildContext context) {
return Column(
children: [
DefaultContainer(
height: MediaQuery.of(context).size.height * 0.50,
child: Padding(
padding: const EdgeInsets.all(25),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SvgPicture.asset(
Assets.emptyUpdateIcon,
fit: BoxFit.fill,
),
const BodyMedium(
text: 'New Update Available Now!',
fontColor: ColorsManager.blueColor,
),
BodyMedium(
text: sosVersion!,
fontColor: ColorsManager.primaryTextColor,
),
SizedBox(
width: MediaQuery.of(context).size.width * 0.7,
child: BodyMedium(
text: sosDescription!,
fontColor: ColorsManager.textPrimaryColor,
textAlign: TextAlign.center,
),
),
LinearPercentIndicator(
barRadius: Radius.circular(10),
width: 170.0,
animation: true,
animationDuration: 1000,
lineHeight: 5.0,
percent: 0.2,
linearStrokeCap: LinearStrokeCap.butt,
progressColor: ColorsManager.blueColor1,
),
SizedBox(
width: MediaQuery.of(context).size.width * 0.7,
child: const BodyMedium(
text: 'Downloading Update please be patient',
fontColor: ColorsManager.textPrimaryColor,
textAlign: TextAlign.center,
),
),
],
),
],
),
),
),
SizedBox(
width: MediaQuery.of(context).size.width * 0.7,
child: const BodyMedium(
text:
'Please keep the power of the device connected during the upgrade process.',
fontColor: ColorsManager.textPrimaryColor,
textAlign: TextAlign.center,
),
),
],
);
}
}

View File

@ -1,118 +0,0 @@
import 'package:flutter/material.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_large.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class UpdateInfoDialog extends StatelessWidget {
final Function()? cancelTab;
final Function()? confirmTab;
const UpdateInfoDialog({
super.key,
required this.cancelTab,
required this.confirmTab,
});
@override
Widget build(BuildContext context) {
return AlertDialog(
contentPadding: EdgeInsets.zero,
content: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const SizedBox(
height: 10,
),
BodyLarge(
text: 'Update Available',
fontWeight: FontWeight.w700,
fontColor: ColorsManager.switchButton.withOpacity(0.6),
fontSize: 16,
),
const Padding(
padding: EdgeInsets.only(left: 15, right: 15),
child: Divider(
color: ColorsManager.textGray,
),
),
const Padding(
padding: EdgeInsets.only(left: 15, right: 20, top: 15, bottom: 20),
child: Column(
children: [
Center(
child: Text(
'An update is available for your device. Version 2.1.0 includes new features and important fixes to enhance performance and security.',
textAlign: TextAlign.center,
)),
],
),
),
Row(
children: [
Expanded(
child: Container(
decoration: const BoxDecoration(
border: Border(
right: BorderSide(
color: ColorsManager.textGray,
width: 0.5,
),
top: BorderSide(
color: ColorsManager.textGray,
width: 1.0,
),
)),
child: SizedBox(
child: InkWell(
onTap: cancelTab,
child: const Padding(
padding: const EdgeInsets.only(top: 15, bottom: 15),
child: Center(
child: Text(
'Remind me later',
style: TextStyle(
color: ColorsManager.textGray,
fontSize: 14,
fontWeight: FontWeight.w400),
),
),
),
),
),
),
),
Expanded(
child: Container(
decoration: const BoxDecoration(
border: Border(
left: BorderSide(
color: ColorsManager.textGray,
width: 0.5,
),
top: BorderSide(
color: ColorsManager.textGray,
width: 1.0,
),
)),
child: InkWell(
onTap: confirmTab,
child: Padding(
padding: const EdgeInsets.only(top: 15, bottom: 15),
child: Center(
child: Text(
'Update Now',
style: TextStyle(
color:
ColorsManager.switchButton.withOpacity(0.6),
fontSize: 14,
fontWeight: FontWeight.w400),
),
),
)),
))
],
)
],
),
);
}
}

View File

@ -1,377 +1,377 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_bloc.dart';
import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_event.dart';
import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_state.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/features/devices/model/sos_model.dart';
import 'package:syncrow_app/features/devices/view/widgets/sos/sos_setting/sos_profile_page.dart';
import 'package:syncrow_app/features/devices/view/widgets/sos/sos_setting/faq_sos_page.dart';
import 'package:syncrow_app/features/devices/view/widgets/sos/sos_setting/share_sos_page.dart';
import 'package:syncrow_app/features/devices/view/widgets/sos/sos_setting/sos_info_page.dart';
import 'package:syncrow_app/features/devices/view/widgets/sos/sos_setting/sos_update_page.dart';
import 'package:syncrow_app/features/devices/view/widgets/sos/sos_setting/update_dialog_sos.dart';
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
import 'package:syncrow_app/features/shared_widgets/delete_device_dialogs.dart';
import 'package:syncrow_app/features/shared_widgets/setting_widget.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
import 'package:syncrow_app/generated/assets.dart';
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
// import 'package:flutter/material.dart';
// import 'package:flutter_bloc/flutter_bloc.dart';
// import 'package:flutter_svg/flutter_svg.dart';
// import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_bloc.dart';
// import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_event.dart';
// import 'package:syncrow_app/features/devices/bloc/sos_bloc/sos_state.dart';
// import 'package:syncrow_app/features/devices/model/device_model.dart';
// import 'package:syncrow_app/features/devices/model/sos_model.dart';
// import 'package:syncrow_app/features/devices/view/widgets/sos/sos_setting/sos_profile_page.dart';
// import 'package:syncrow_app/features/devices/view/widgets/sos/sos_setting/faq_sos_page.dart';
// import 'package:syncrow_app/features/devices/view/widgets/sos/sos_setting/share_sos_page.dart';
// import 'package:syncrow_app/features/devices/view/widgets/sos/sos_setting/sos_info_page.dart';
// import 'package:syncrow_app/features/devices/view/widgets/sos/sos_setting/sos_update_page.dart';
// import 'package:syncrow_app/features/devices/view/widgets/sos/sos_setting/update_dialog_sos.dart';
// import 'package:syncrow_app/features/shared_widgets/default_container.dart';
// import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
// import 'package:syncrow_app/features/shared_widgets/delete_device_dialogs.dart';
// import 'package:syncrow_app/features/shared_widgets/setting_widget.dart';
// import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
// import 'package:syncrow_app/features/shared_widgets/text_widgets/body_small.dart';
// import 'package:syncrow_app/generated/assets.dart';
// import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
class SosSettings extends StatelessWidget {
final DeviceModel? device;
const SosSettings({
super.key,
this.device,
});
// class SosSettings extends StatelessWidget {
// final DeviceModel? device;
// const SosSettings({
// super.key,
// this.device,
// });
@override
Widget build(BuildContext context) {
return DefaultScaffold(
title: 'Device Settings',
child: BlocProvider(
create: (context) => SosBloc(sosId: device?.uuid ?? '')
..add(const SosInitial())
..add(SosInitialDeviseInfo()),
child: BlocBuilder<SosBloc, SosState>(
builder: (context, state) {
final _bloc = BlocProvider.of<SosBloc>(context);
SosModel model =
SosModel(batteryPercentage: 0, sosContactState: 'normal');
if (state is LoadingNewSate) {
model = state.sosSensor;
} else if (state is UpdateState) {
model = state.sensor;
}
return state is SosLoadingState
? const Center(
child: DefaultContainer(
width: 50,
height: 50,
child: CircularProgressIndicator()),
)
: ListView(
children: [
Padding(
padding: const EdgeInsets.symmetric(
vertical: 10,
),
child: InkWell(
onTap: () async {
bool val = await Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => SosProfilePage(
device: device,
),
),
);
if (val == true) {
_bloc.add(SosInitialDeviseInfo());
_bloc.add(const SosInitial());
}
},
child: Stack(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SizedBox(height: 20),
DefaultContainer(
borderRadius: const BorderRadius.all(
Radius.circular(30)),
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Padding(
padding:
const EdgeInsets.only(left: 90),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
BodyMedium(
text: _bloc.deviceInfo.name,
fontWeight: FontWeight.bold,
),
const SizedBox(
height: 5,
),
BodySmall(
text: _bloc.deviceInfo
.subspace.subspaceName),
],
),
const Icon(
Icons.edit_outlined,
color: ColorsManager.grayColor,
),
],
),
),
),
),
],
),
Positioned(
top: 0,
left: 20,
child: CircleAvatar(
radius: 40,
backgroundColor: Colors.white,
child: CircleAvatar(
radius: 40,
backgroundColor:
Colors.white.withOpacity(0),
child: ClipOval(
child: SvgPicture.asset(
Assets.sosHomeIcon,
fit: BoxFit.contain,
height: 80,
),
)),
),
),
],
),
),
),
const SizedBox(height: 20),
const BodyMedium(
text: 'Device Management',
fontWeight: FontWeight.w700,
fontSize: 12,
fontColor: ColorsManager.grayColor,
),
DefaultContainer(
child: SettingWidget(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
SosInfoPage(device: device!)),
);
},
text: 'Device Information',
icon: Assets.infoIcon,
),
),
const SizedBox(height: 20),
const BodyMedium(
text: 'Device Offline Notification',
fontWeight: FontWeight.w700,
fontSize: 12,
fontColor: ColorsManager.grayColor,
),
DefaultContainer(
child: Column(
children: [
SettingWidget(
value: _bloc.enableAlarm,
onChanged: (p0) {
context
.read<SosBloc>()
.add(ToggleEnableAlarmEvent(p0));
},
isNotification: true,
onTap: () {},
text: 'Offline Notification',
icon: Assets.notificationIcon,
),
],
),
),
const SizedBox(height: 20),
const BodyMedium(
text: 'Others',
fontWeight: FontWeight.w700,
fontSize: 12,
fontColor: ColorsManager.grayColor,
),
const SizedBox(height: 5),
DefaultContainer(
child: Column(
children: [
SettingWidget(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
ShareSosPage(device: device!)),
);
},
text: 'Share Device',
icon: Assets.shareIcon,
),
const Divider(
color: ColorsManager.dividerColor,
),
SettingWidget(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
FaqSosPage(device: device!)),
);
},
text: 'Device FAQ',
icon: Assets.faqIcon,
),
const Divider(
color: ColorsManager.dividerColor,
),
SettingWidget(
onTapUpdate: () {
showDialog(
context: context,
builder: (context) {
return UpdateInfoDialog(
cancelTab: () {
Navigator.of(context).pop();
},
confirmTab: () {
Navigator.of(context).pop();
},
);
},
);
},
isUpdate: true,
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) =>
const SosUpdatePage()),
);
},
text: 'Device Update',
icon: Assets.updateIcon,
),
],
),
),
const SizedBox(height: 20),
InkWell(
onTap: () {
showModalBottomSheet(
context: context,
builder: (BuildContext context) {
return Container(
height: 200,
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const BodyMedium(
text: 'Remove Device',
fontWeight: FontWeight.w700,
fontSize: 16,
fontColor: ColorsManager.red,
),
const SizedBox(height: 10),
const SizedBox(
width: 250,
child: Divider(
color: ColorsManager.dividerColor,
),
),
const SizedBox(height: 10),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
InkWell(
onTap: () {
showDialog(
context: context,
builder: (context) {
return DisconnectDeviceDialog(
cancelTab: () {
Navigator.of(context).pop();
},
confirmTab: () {
Navigator.of(context).pop();
},
);
},
);
},
child: const BodyMedium(
text: 'Disconnect Device',
fontWeight: FontWeight.w400,
fontSize: 15,
fontColor:
ColorsManager.textPrimaryColor,
),
),
const Icon(
Icons.keyboard_arrow_right,
color: ColorsManager.textGray,
)
],
),
const SizedBox(height: 20),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
InkWell(
onTap: () {
showDialog(
context: context,
builder: (context) {
return DisconnectWipeData(
cancelTab: () {
Navigator.of(context).pop();
},
confirmTab: () {
_bloc.add(
DeleteDeviceEvent());
},
);
},
);
},
child: const BodyMedium(
text:
'Disconnect Device and Wipe Data',
fontWeight: FontWeight.w400,
fontSize: 15,
fontColor:
ColorsManager.textPrimaryColor,
),
),
const Icon(
Icons.keyboard_arrow_right,
color: ColorsManager.textGray,
)
],
),
],
),
);
},
);
},
child: const Center(
child: BodyMedium(
text: 'Remove Device',
fontWeight: FontWeight.w400,
fontSize: 15,
fontColor: ColorsManager.red,
),
),
),
],
);
},
),
),
);
}
}
// @override
// Widget build(BuildContext context) {
// return DefaultScaffold(
// title: 'Device Settings',
// child: BlocProvider(
// create: (context) => SosBloc(sosId: device?.uuid ?? '')
// ..add(const SosInitial())
// ..add(SosInitialDeviseInfo()),
// child: BlocBuilder<SosBloc, SosState>(
// builder: (context, state) {
// final _bloc = BlocProvider.of<SosBloc>(context);
// SosModel model =
// SosModel(batteryPercentage: 0, sosContactState: 'normal');
// if (state is LoadingNewSate) {
// model = state.sosSensor;
// } else if (state is UpdateState) {
// model = state.sensor;
// }
// return state is SosLoadingState
// ? const Center(
// child: DefaultContainer(
// width: 50,
// height: 50,
// child: CircularProgressIndicator()),
// )
// : ListView(
// children: [
// Padding(
// padding: const EdgeInsets.symmetric(
// vertical: 10,
// ),
// child: InkWell(
// onTap: () async {
// bool val = await Navigator.of(context).push(
// MaterialPageRoute(
// builder: (context) => SosProfilePage(
// device: device,
// ),
// ),
// );
// if (val == true) {
// _bloc.add(SosInitialDeviseInfo());
// _bloc.add(const SosInitial());
// }
// },
// child: Stack(
// children: [
// Column(
// crossAxisAlignment: CrossAxisAlignment.stretch,
// children: [
// const SizedBox(height: 20),
// DefaultContainer(
// borderRadius: const BorderRadius.all(
// Radius.circular(30)),
// child: Padding(
// padding: const EdgeInsets.all(10.0),
// child: Padding(
// padding:
// const EdgeInsets.only(left: 90),
// child: Row(
// mainAxisAlignment:
// MainAxisAlignment.spaceBetween,
// children: [
// Column(
// crossAxisAlignment:
// CrossAxisAlignment.start,
// children: [
// BodyMedium(
// text: _bloc.deviceInfo.name,
// fontWeight: FontWeight.bold,
// ),
// const SizedBox(
// height: 5,
// ),
// BodySmall(
// text: _bloc.deviceInfo
// .subspace.subspaceName),
// ],
// ),
// const Icon(
// Icons.edit_outlined,
// color: ColorsManager.grayColor,
// ),
// ],
// ),
// ),
// ),
// ),
// ],
// ),
// Positioned(
// top: 0,
// left: 20,
// child: CircleAvatar(
// radius: 40,
// backgroundColor: Colors.white,
// child: CircleAvatar(
// radius: 40,
// backgroundColor:
// Colors.white.withOpacity(0),
// child: ClipOval(
// child: SvgPicture.asset(
// Assets.sosHomeIcon,
// fit: BoxFit.contain,
// height: 80,
// ),
// )),
// ),
// ),
// ],
// ),
// ),
// ),
// const SizedBox(height: 20),
// const BodyMedium(
// text: 'Device Management',
// fontWeight: FontWeight.w700,
// fontSize: 12,
// fontColor: ColorsManager.grayColor,
// ),
// DefaultContainer(
// child: SettingWidget(
// onTap: () {
// Navigator.of(context).push(
// MaterialPageRoute(
// builder: (context) =>
// SosInfoPage(device: device!)),
// );
// },
// text: 'Device Information',
// icon: Assets.infoIcon,
// ),
// ),
// const SizedBox(height: 20),
// const BodyMedium(
// text: 'Device Offline Notification',
// fontWeight: FontWeight.w700,
// fontSize: 12,
// fontColor: ColorsManager.grayColor,
// ),
// DefaultContainer(
// child: Column(
// children: [
// SettingWidget(
// value: _bloc.enableAlarm,
// onChanged: (p0) {
// context
// .read<SosBloc>()
// .add(ToggleEnableAlarmEvent(p0));
// },
// isNotification: true,
// onTap: () {},
// text: 'Offline Notification',
// icon: Assets.notificationIcon,
// ),
// ],
// ),
// ),
// const SizedBox(height: 20),
// const BodyMedium(
// text: 'Others',
// fontWeight: FontWeight.w700,
// fontSize: 12,
// fontColor: ColorsManager.grayColor,
// ),
// const SizedBox(height: 5),
// DefaultContainer(
// child: Column(
// children: [
// SettingWidget(
// onTap: () {
// Navigator.of(context).push(
// MaterialPageRoute(
// builder: (context) =>
// ShareSosPage(device: device!)),
// );
// },
// text: 'Share Device',
// icon: Assets.shareIcon,
// ),
// const Divider(
// color: ColorsManager.dividerColor,
// ),
// SettingWidget(
// onTap: () {
// Navigator.of(context).push(
// MaterialPageRoute(
// builder: (context) =>
// FaqSosPage(device: device!)),
// );
// },
// text: 'Device FAQ',
// icon: Assets.faqIcon,
// ),
// const Divider(
// color: ColorsManager.dividerColor,
// ),
// SettingWidget(
// onTapUpdate: () {
// showDialog(
// context: context,
// builder: (context) {
// return UpdateInfoDialog(
// cancelTab: () {
// Navigator.of(context).pop();
// },
// confirmTab: () {
// Navigator.of(context).pop();
// },
// );
// },
// );
// },
// isUpdate: true,
// onTap: () {
// Navigator.of(context).push(
// MaterialPageRoute(
// builder: (context) =>
// const SosUpdatePage()),
// );
// },
// text: 'Device Update',
// icon: Assets.updateIcon,
// ),
// ],
// ),
// ),
// const SizedBox(height: 20),
// InkWell(
// onTap: () {
// showModalBottomSheet(
// context: context,
// builder: (BuildContext context) {
// return Container(
// height: 200,
// padding: const EdgeInsets.all(16.0),
// child: Column(
// mainAxisSize: MainAxisSize.min,
// children: [
// const BodyMedium(
// text: 'Remove Device',
// fontWeight: FontWeight.w700,
// fontSize: 16,
// fontColor: ColorsManager.red,
// ),
// const SizedBox(height: 10),
// const SizedBox(
// width: 250,
// child: Divider(
// color: ColorsManager.dividerColor,
// ),
// ),
// const SizedBox(height: 10),
// Row(
// mainAxisAlignment:
// MainAxisAlignment.spaceBetween,
// children: [
// InkWell(
// onTap: () {
// showDialog(
// context: context,
// builder: (context) {
// return DisconnectDeviceDialog(
// cancelTab: () {
// Navigator.of(context).pop();
// },
// confirmTab: () {
// Navigator.of(context).pop();
// },
// );
// },
// );
// },
// child: const BodyMedium(
// text: 'Disconnect Device',
// fontWeight: FontWeight.w400,
// fontSize: 15,
// fontColor:
// ColorsManager.textPrimaryColor,
// ),
// ),
// const Icon(
// Icons.keyboard_arrow_right,
// color: ColorsManager.textGray,
// )
// ],
// ),
// const SizedBox(height: 20),
// Row(
// mainAxisAlignment:
// MainAxisAlignment.spaceBetween,
// children: [
// InkWell(
// onTap: () {
// showDialog(
// context: context,
// builder: (context) {
// return DisconnectWipeData(
// cancelTab: () {
// Navigator.of(context).pop();
// },
// confirmTab: () {
// _bloc.add(
// DeleteDeviceEvent());
// },
// );
// },
// );
// },
// child: const BodyMedium(
// text:
// 'Disconnect Device and Wipe Data',
// fontWeight: FontWeight.w400,
// fontSize: 15,
// fontColor:
// ColorsManager.textPrimaryColor,
// ),
// ),
// const Icon(
// Icons.keyboard_arrow_right,
// color: ColorsManager.textGray,
// )
// ],
// ),
// ],
// ),
// );
// },
// );
// },
// child: const Center(
// child: BodyMedium(
// text: 'Remove Device',
// fontWeight: FontWeight.w400,
// fontSize: 15,
// fontColor: ColorsManager.red,
// ),
// ),
// ),
// ],
// );
// },
// ),
// ),
// );
// }
// }

View File

@ -218,7 +218,6 @@ abstract class ApiEndpoints {
static const String fourSceneByName =
'/device/{deviceUuid}/scenes?switchName={switchName}';
static const String resetDevice =
'/factory/reset/{deviceUuid}';
static const String resetDevice = '/factory/reset/{deviceUuid}';
static const String unAssignScenesDevice = '/factory/reset/{deviceUuid}';
}