mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-08-26 07:19:39 +00:00
issue fixes
This commit is contained in:
@ -47,6 +47,7 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
||||
on<FetchRoomsEvent>(_fetchRoomsAndDevices);
|
||||
on<SixSceneInitialQuestion>(_onSixSceneInitial);
|
||||
on<DeleteDeviceEvent>(deleteDevice);
|
||||
on<ToggleEnableAlarmEvent>(_toggleLowBattery);
|
||||
}
|
||||
|
||||
final TextEditingController nameController =
|
||||
@ -101,6 +102,19 @@ class SixSceneBloc extends Bloc<SixSceneEvent, SixSceneState> {
|
||||
),
|
||||
);
|
||||
|
||||
bool enableAlarm = false;
|
||||
|
||||
void _toggleLowBattery(
|
||||
ToggleEnableAlarmEvent event, Emitter<SixSceneState> emit) async {
|
||||
emit(LoadingNewSate(device: deviceStatus));
|
||||
try {
|
||||
enableAlarm = event.isLowBatteryEnabled;
|
||||
emit(UpdateState(device: deviceStatus));
|
||||
} catch (e) {
|
||||
emit(SixSceneFailedState(errorMessage: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
List<SubSpaceModel> roomsList = [];
|
||||
|
||||
void _fetchRoomsAndDevices(
|
||||
|
@ -48,6 +48,7 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
||||
on<GetSceneBySwitchName>(getSceneByName);
|
||||
on<SelectSceneEvent>(_selectScene);
|
||||
on<DeleteDeviceEvent>(deleteDevice);
|
||||
on<ToggleEnableAlarmEvent>(_toggleLowBattery);
|
||||
}
|
||||
|
||||
final TextEditingController nameController =
|
||||
@ -144,6 +145,7 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
||||
}
|
||||
|
||||
bool selecedScene = false;
|
||||
bool enableAlarm = false;
|
||||
|
||||
String _selectedOption = '';
|
||||
bool _hasSelectionChanged = false;
|
||||
@ -259,6 +261,18 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void _toggleLowBattery(
|
||||
ToggleEnableAlarmEvent event, Emitter<FourSceneState> emit) async {
|
||||
emit(LoadingNewSate(device: deviceStatus));
|
||||
try {
|
||||
enableAlarm = event.isLowBatteryEnabled;
|
||||
emit(UpdateState(device: deviceStatus));
|
||||
} catch (e) {
|
||||
emit(FourSceneFailedState(errorMessage: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
// void _controlDevice(
|
||||
// ControlDeviceScene event, Emitter<FourSceneState> emit) async {
|
||||
// emit(FourSceneLoadingState());
|
||||
@ -320,7 +334,7 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
||||
ToggleNotificationEvent event, Emitter<FourSceneState> emit) async {
|
||||
emit(LoadingNewSate(device: deviceStatus));
|
||||
try {
|
||||
closingReminder = event.isClosingEnabled;
|
||||
enableAlarm = event.isClosingEnabled;
|
||||
emit(UpdateState(device: deviceStatus));
|
||||
// API call to update the state, if necessary
|
||||
// await DevicesAPI.controlDevice(
|
||||
@ -483,6 +497,7 @@ class FourSceneBloc extends Bloc<FourSceneEvent, FourSceneState> {
|
||||
}
|
||||
emit(UpdateStateList(groupDevices: groupDevices, devices: devices));
|
||||
}
|
||||
|
||||
void _assignDevice(
|
||||
AssignRoomEvent event, Emitter<FourSceneState> emit) async {
|
||||
try {
|
||||
|
@ -38,12 +38,13 @@ class SosBloc extends Bloc<SosEvent, SosState> {
|
||||
on<SaveSelectionEvent>(_onSaveSelection);
|
||||
on<AssignRoomEvent>(_assignDevice);
|
||||
on<SosInitialDeviseInfo>(fetchDeviceInfo);
|
||||
on<SaveNameEvent>(saveName);
|
||||
// on<UnassignRoomEvent>(_unassignDevice);
|
||||
// on<ToggleWaterLeakAlarmEvent>(_toggleWaterLeakAlarm);
|
||||
}
|
||||
|
||||
final TextEditingController nameController =
|
||||
TextEditingController(text: '${'firstName'}');
|
||||
TextEditingController(text: deviceName);
|
||||
bool isSaving = false;
|
||||
bool editName = false;
|
||||
final FocusNode focusNode = FocusNode();
|
||||
@ -52,7 +53,7 @@ class SosBloc extends Bloc<SosEvent, SosState> {
|
||||
bool closingReminder = false;
|
||||
bool waterAlarm = false;
|
||||
SosModel deviceStatus =
|
||||
SosModel(sosContactState: 'normal', batteryPercentage: 0);
|
||||
SosModel(sosContactState: 'sos', batteryPercentage: 0);
|
||||
|
||||
void _fetchStatus(SosInitial event, Emitter<SosState> emit) async {
|
||||
emit(SosLoadingState());
|
||||
@ -156,16 +157,6 @@ class SosBloc extends Bloc<SosEvent, SosState> {
|
||||
try {
|
||||
closingReminder = event.isClosingReminderEnabled;
|
||||
emit(UpdateState(sensor: deviceStatus));
|
||||
|
||||
// API call to update the state, if necessary
|
||||
// await DevicesAPI.controlDevice(
|
||||
// DeviceControlModel(
|
||||
// deviceId: sosId,
|
||||
// code: 'closing_reminder',
|
||||
// value: closingReminder,
|
||||
// ),
|
||||
// sosId,
|
||||
// );
|
||||
} catch (e) {
|
||||
emit(SosFailedState(errorMessage: e.toString()));
|
||||
}
|
||||
|
@ -71,10 +71,14 @@ class SixSceneInfoPage extends StatelessWidget {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
BodySmall(
|
||||
SizedBox(
|
||||
width:
|
||||
MediaQuery.of(context).size.width * 0.61,
|
||||
child: BodySmall(
|
||||
text: _bloc.deviceInfo.productUuid,
|
||||
fontColor: ColorsManager.primaryTextColor,
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Clipboard.setData(
|
||||
|
@ -194,7 +194,12 @@ class SixSceneSettings extends StatelessWidget {
|
||||
child: Column(
|
||||
children: [
|
||||
SettingWidget(
|
||||
onChanged: (p0) {},
|
||||
value: _bloc.enableAlarm,
|
||||
onChanged: (p0) {
|
||||
context
|
||||
.read<SixSceneBloc>()
|
||||
.add(ToggleEnableAlarmEvent(p0));
|
||||
},
|
||||
isNotification: true,
|
||||
onTap: () {},
|
||||
text: 'Offline Notification',
|
||||
@ -430,6 +435,7 @@ class SixSceneSettings extends StatelessWidget {
|
||||
class SettingWidget extends StatelessWidget {
|
||||
final String? text;
|
||||
final bool? isUpdate;
|
||||
final bool? value;
|
||||
final bool? isNotification;
|
||||
final String? icon;
|
||||
final Function()? onTap;
|
||||
@ -440,6 +446,7 @@ class SettingWidget extends StatelessWidget {
|
||||
this.text,
|
||||
this.icon,
|
||||
this.onTap,
|
||||
this.value,
|
||||
this.isUpdate,
|
||||
this.onChanged,
|
||||
this.isNotification = false,
|
||||
@ -502,7 +509,7 @@ class SettingWidget extends StatelessWidget {
|
||||
: Transform.scale(
|
||||
scale: .8,
|
||||
child: CupertinoSwitch(
|
||||
value: true,
|
||||
value: value!,
|
||||
onChanged: onChanged,
|
||||
applyTheme: true,
|
||||
),
|
||||
|
@ -24,22 +24,7 @@ class SixSceneScreen extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DefaultScaffold(
|
||||
title: '6 Scene Switch',
|
||||
actions: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SixSceneSettings(device: device!)),
|
||||
);
|
||||
},
|
||||
child: SvgPicture.asset(Assets.assetsIconsSettings)),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
)
|
||||
],
|
||||
child: BlocProvider(
|
||||
return BlocProvider(
|
||||
create: (context) => SixSceneBloc(sixSceneId: device?.uuid ?? '')
|
||||
..add(const SixSceneInitial())
|
||||
..add(const SixSceneInitialInfo())
|
||||
@ -47,6 +32,7 @@ class SixSceneScreen extends StatelessWidget {
|
||||
child: BlocBuilder<SixSceneBloc, SixSceneState>(
|
||||
builder: (context, state) {
|
||||
final _bloc = BlocProvider.of<SixSceneBloc>(context);
|
||||
|
||||
SixSceneModel model = SixSceneModel(
|
||||
scene_1: '',
|
||||
scene_2: '',
|
||||
@ -55,19 +41,37 @@ class SixSceneScreen extends StatelessWidget {
|
||||
scene_5: '',
|
||||
scene_6: '',
|
||||
scene_id_group_id: '',
|
||||
switch_backlight: '');
|
||||
switch_backlight: '',
|
||||
);
|
||||
|
||||
if (state is LoadingNewSate) {
|
||||
model = state.device;
|
||||
} else if (state is UpdateState) {
|
||||
model = state.device;
|
||||
}
|
||||
return state is SixSceneLoadingState
|
||||
|
||||
return DefaultScaffold(
|
||||
title: _bloc.deviceInfo.subspace.subspaceName,
|
||||
actions: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SixSceneSettings(device: device!),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: SvgPicture.asset(Assets.assetsIconsSettings),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
],
|
||||
child: state is SixSceneLoadingState
|
||||
? const Center(
|
||||
child: DefaultContainer(
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: CircularProgressIndicator()),
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
)
|
||||
: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
@ -86,28 +90,22 @@ class SixSceneScreen extends StatelessWidget {
|
||||
switch4Title: model.scene_4,
|
||||
switch5Title: model.scene_5,
|
||||
switch6Title: model.scene_6,
|
||||
switch1Down:
|
||||
_bloc.deviceStatus.switch_backlight == true
|
||||
switch1Down: _bloc.deviceStatus.switch_backlight
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
switch1Up:
|
||||
_bloc.deviceStatus.switch_backlight == true
|
||||
switch1Up: _bloc.deviceStatus.switch_backlight
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
switch2Down:
|
||||
_bloc.deviceStatus.switch_backlight == true
|
||||
switch2Down: _bloc.deviceStatus.switch_backlight
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
switch2Up:
|
||||
_bloc.deviceStatus.switch_backlight == true
|
||||
switch2Up: _bloc.deviceStatus.switch_backlight
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
switch3Up:
|
||||
_bloc.deviceStatus.switch_backlight == true
|
||||
switch3Up: _bloc.deviceStatus.switch_backlight
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
switch3Down:
|
||||
_bloc.deviceStatus.switch_backlight == true
|
||||
switch3Down: _bloc.deviceStatus.switch_backlight
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
onSwitch3DownTap: () {
|
||||
@ -136,7 +134,6 @@ class SixSceneScreen extends StatelessWidget {
|
||||
child: DefaultContainer(
|
||||
onTap: () {
|
||||
_bloc.add(ChangeSwitchStatusEvent());
|
||||
|
||||
},
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
@ -146,13 +143,13 @@ class SixSceneScreen extends StatelessWidget {
|
||||
children: [
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
maxHeight: 46, maxWidth: 50),
|
||||
maxHeight: 46,
|
||||
maxWidth: 50,
|
||||
),
|
||||
child: SvgPicture.asset(
|
||||
Assets.backlightIcon),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
const Flexible(
|
||||
child: FittedBox(
|
||||
child: BodySmall(
|
||||
@ -165,9 +162,7 @@ class SixSceneScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: DefaultContainer(
|
||||
onTap: () async {
|
||||
@ -189,10 +184,10 @@ class SixSceneScreen extends StatelessWidget {
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
SixSelectSceneFourPage(
|
||||
deviceId:
|
||||
device!.uuid,
|
||||
deviceId: device!.uuid,
|
||||
switchSelected: v,
|
||||
)),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
@ -214,13 +209,13 @@ class SixSceneScreen extends StatelessWidget {
|
||||
children: [
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
maxHeight: 46, maxWidth: 50),
|
||||
maxHeight: 46,
|
||||
maxWidth: 50,
|
||||
),
|
||||
child: SvgPicture.asset(
|
||||
Assets.addSceneIcon),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
const Flexible(
|
||||
child: FittedBox(
|
||||
child: BodySmall(
|
||||
@ -235,16 +230,16 @@ class SixSceneScreen extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -24,22 +24,7 @@ class FourSceneScreen extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DefaultScaffold(
|
||||
title: '4 Scene Switch',
|
||||
actions: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => FourSceneSettings(device: device!)),
|
||||
);
|
||||
},
|
||||
child: SvgPicture.asset(Assets.assetsIconsSettings)),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
)
|
||||
],
|
||||
child: BlocProvider(
|
||||
return BlocProvider(
|
||||
create: (context) => FourSceneBloc(fourSceneId: device?.uuid ?? '')
|
||||
..add(const FourSceneInitial())
|
||||
..add(const FourSceneInitialInfo())
|
||||
@ -47,24 +32,44 @@ class FourSceneScreen extends StatelessWidget {
|
||||
child: BlocBuilder<FourSceneBloc, FourSceneState>(
|
||||
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: '');
|
||||
switch_backlight: '',
|
||||
);
|
||||
|
||||
if (state is LoadingNewSate) {
|
||||
model = state.device;
|
||||
} else if (state is UpdateState) {
|
||||
model = state.device;
|
||||
}
|
||||
return state is FourSceneLoadingState
|
||||
|
||||
return DefaultScaffold(
|
||||
title: _bloc.deviceInfo.name,
|
||||
actions: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => FourSceneSettings(device: device!),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: SvgPicture.asset(Assets.assetsIconsSettings),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
],
|
||||
child: state is FourSceneLoadingState
|
||||
? const Center(
|
||||
child: DefaultContainer(
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: CircularProgressIndicator()),
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
)
|
||||
: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
@ -81,20 +86,16 @@ class FourSceneScreen extends StatelessWidget {
|
||||
title2: model.scene_2,
|
||||
title3: model.scene_3,
|
||||
title4: model.scene_4,
|
||||
switch1:
|
||||
_bloc.deviceStatus.switch_backlight == true
|
||||
switch1: _bloc.deviceStatus.switch_backlight
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
switch2:
|
||||
_bloc.deviceStatus.switch_backlight == true
|
||||
switch2: _bloc.deviceStatus.switch_backlight
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
switch3:
|
||||
_bloc.deviceStatus.switch_backlight == true
|
||||
switch3: _bloc.deviceStatus.switch_backlight
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
switch4:
|
||||
_bloc.deviceStatus.switch_backlight == true
|
||||
switch4: _bloc.deviceStatus.switch_backlight
|
||||
? Assets.switchOn
|
||||
: Assets.switchOff,
|
||||
onSwitch1UpTap: () {
|
||||
@ -126,13 +127,13 @@ class FourSceneScreen extends StatelessWidget {
|
||||
children: [
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
maxHeight: 46, maxWidth: 50),
|
||||
maxHeight: 46,
|
||||
maxWidth: 50,
|
||||
),
|
||||
child: SvgPicture.asset(
|
||||
Assets.backlightIcon),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
const Flexible(
|
||||
child: FittedBox(
|
||||
child: BodySmall(
|
||||
@ -145,9 +146,7 @@ class FourSceneScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: DefaultContainer(
|
||||
onTap: () async {
|
||||
@ -162,13 +161,17 @@ class FourSceneScreen extends StatelessWidget {
|
||||
cancelTab: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
confirmTab: (switchSelected) async {
|
||||
confirmTab:
|
||||
(switchSelected) async {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
FourSelectSceneFourPage(
|
||||
switchSelected:switchSelected,
|
||||
deviceId: device!.uuid)),
|
||||
switchSelected:
|
||||
switchSelected,
|
||||
deviceId: device!.uuid,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
@ -190,13 +193,13 @@ class FourSceneScreen extends StatelessWidget {
|
||||
children: [
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
maxHeight: 46, maxWidth: 50),
|
||||
maxHeight: 46,
|
||||
maxWidth: 50,
|
||||
),
|
||||
child: SvgPicture.asset(
|
||||
Assets.addSceneIcon),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
const Flexible(
|
||||
child: FittedBox(
|
||||
child: BodySmall(
|
||||
@ -211,19 +214,16 @@ class FourSceneScreen extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//MohaM&&&uba1
|
@ -69,10 +69,14 @@ class FourSceneInfoPage extends StatelessWidget {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
BodySmall(
|
||||
Container(
|
||||
width:
|
||||
MediaQuery.of(context).size.width * 0.61,
|
||||
child: BodySmall(
|
||||
text: _bloc.deviceInfo.productUuid,
|
||||
fontColor: ColorsManager.primaryTextColor,
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Clipboard.setData(
|
||||
|
@ -144,6 +144,7 @@ class FourSceneProfilePage extends StatelessWidget {
|
||||
fontSize: 12,
|
||||
fontColor: ColorsManager.grayColor,
|
||||
),
|
||||
const SizedBox(height: 7),
|
||||
DefaultContainer(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: InkWell(
|
||||
|
@ -207,7 +207,12 @@ class FourSceneSettings extends StatelessWidget {
|
||||
child: Column(
|
||||
children: [
|
||||
SettingWidget(
|
||||
onChanged: (p0) {},
|
||||
value: _bloc.enableAlarm,
|
||||
onChanged: (p0) {
|
||||
context
|
||||
.read<FourSceneBloc>()
|
||||
.add(ToggleEnableAlarmEvent(p0));
|
||||
},
|
||||
isNotification: true,
|
||||
onTap: () {},
|
||||
text: 'Offline Notification',
|
||||
@ -444,6 +449,7 @@ class FourSceneSettings extends StatelessWidget {
|
||||
class SettingWidget extends StatelessWidget {
|
||||
final String? text;
|
||||
final bool? isUpdate;
|
||||
final bool? value;
|
||||
final bool? isNotification;
|
||||
final String? icon;
|
||||
final Function()? onTap;
|
||||
@ -453,6 +459,7 @@ class SettingWidget extends StatelessWidget {
|
||||
{super.key,
|
||||
this.text,
|
||||
this.icon,
|
||||
this.value,
|
||||
this.onTap,
|
||||
this.isUpdate,
|
||||
this.onChanged,
|
||||
@ -516,7 +523,7 @@ class SettingWidget extends StatelessWidget {
|
||||
: Transform.scale(
|
||||
scale: .8,
|
||||
child: CupertinoSwitch(
|
||||
value: true,
|
||||
value: value!,
|
||||
onChanged: onChanged,
|
||||
applyTheme: true,
|
||||
),
|
||||
|
@ -18,45 +18,51 @@ import 'package:syncrow_app/generated/assets.dart';
|
||||
class SosScreen extends StatelessWidget {
|
||||
final DeviceModel? device;
|
||||
|
||||
|
||||
const SosScreen({super.key, this.device});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DefaultScaffold(
|
||||
title: 'SOS',
|
||||
actions: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SosSettings(device: device!)),
|
||||
);
|
||||
},
|
||||
child: SvgPicture.asset(Assets.assetsIconsSettings)),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
)
|
||||
],
|
||||
child: BlocProvider(
|
||||
create: (context) =>
|
||||
SosBloc(sosId: device?.uuid ?? '')..add(const SosInitial()),
|
||||
return BlocProvider(
|
||||
create: (context) => SosBloc(sosId: device?.uuid ?? '')
|
||||
..add(const SosInitial())
|
||||
..add(SosInitialDeviseInfo()),
|
||||
child: BlocBuilder<SosBloc, SosState>(
|
||||
builder: (context, state) {
|
||||
final sensor = BlocProvider.of<SosBloc>(context);
|
||||
SosModel model =
|
||||
SosModel(batteryPercentage: 0, sosContactState: 'normal');
|
||||
// Default SOS model in case no state is loaded
|
||||
SosModel model = SosModel(
|
||||
batteryPercentage: 0,
|
||||
sosContactState: '',
|
||||
);
|
||||
// Update the model based on the state
|
||||
if (state is LoadingNewSate) {
|
||||
model = state.sosSensor;
|
||||
} else if (state is UpdateState) {
|
||||
model = state.sensor;
|
||||
}
|
||||
return state is SosLoadingState
|
||||
|
||||
return DefaultScaffold(
|
||||
title: sensor.deviceInfo.name,
|
||||
actions: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SosSettings(device: device!),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: SvgPicture.asset(Assets.assetsIconsSettings),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
],
|
||||
child: state is SosLoadingState
|
||||
? const Center(
|
||||
child: DefaultContainer(
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: CircularProgressIndicator()),
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
)
|
||||
: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
@ -69,14 +75,17 @@ class SosScreen extends StatelessWidget {
|
||||
child: Column(
|
||||
children: [
|
||||
BatteryBar(
|
||||
batteryPercentage: model.batteryPercentage,
|
||||
batteryPercentage:
|
||||
sensor.deviceStatus.batteryPercentage,
|
||||
),
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: InkWell(
|
||||
overlayColor: WidgetStateProperty.all(
|
||||
overlayColor: MaterialStateProperty.all(
|
||||
Colors.transparent),
|
||||
onTap: () {},
|
||||
onTap: () {
|
||||
// Add functionality for the main SOS button here
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment:
|
||||
@ -111,7 +120,8 @@ class SosScreen extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
child: SvgPicture.asset(
|
||||
model.sosContactState == 'normal'
|
||||
sensor.deviceStatus.sosContactState !=
|
||||
'sos'
|
||||
? Assets.redSos
|
||||
: Assets.greenSos,
|
||||
fit: BoxFit.fill,
|
||||
@ -131,7 +141,8 @@ class SosScreen extends StatelessWidget {
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
SosRecordsScreen(
|
||||
sosId: device!.uuid!)),
|
||||
sosId: device!.uuid!),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
@ -142,13 +153,13 @@ class SosScreen extends StatelessWidget {
|
||||
children: [
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
maxHeight: 46, maxWidth: 50),
|
||||
maxHeight: 46,
|
||||
maxWidth: 50,
|
||||
),
|
||||
child: SvgPicture.asset(
|
||||
Assets.doorRecordsIcon),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
const Flexible(
|
||||
child: FittedBox(
|
||||
child: BodySmall(
|
||||
@ -161,16 +172,15 @@ class SosScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: DefaultContainer(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const AlarmManagementPage()),
|
||||
const AlarmManagementPage(),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
@ -181,13 +191,13 @@ class SosScreen extends StatelessWidget {
|
||||
children: [
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
maxHeight: 46, maxWidth: 50),
|
||||
maxHeight: 46,
|
||||
maxWidth: 50,
|
||||
),
|
||||
child: SvgPicture.asset(Assets
|
||||
.doorNotificationSetting),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
const Flexible(
|
||||
child: FittedBox(
|
||||
child: BodySmall(
|
||||
@ -202,16 +212,16 @@ class SosScreen extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -64,10 +64,14 @@ class SosInfoPage extends StatelessWidget {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
BodySmall(
|
||||
SizedBox(
|
||||
width:
|
||||
MediaQuery.of(context).size.width * 0.61,
|
||||
child: BodySmall(
|
||||
text: _bloc.deviceInfo.productUuid,
|
||||
fontColor: ColorsManager.primaryTextColor,
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Clipboard.setData(
|
||||
|
@ -64,21 +64,12 @@ class SosProfilePage extends StatelessWidget {
|
||||
radius: 55,
|
||||
backgroundColor: ColorsManager.graysColor,
|
||||
child: ClipOval(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Center(
|
||||
child: Center(
|
||||
child: SvgPicture.asset(
|
||||
Assets.fourSceneIcon,
|
||||
Assets.sosProfileIcon,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -139,6 +130,7 @@ class SosProfilePage extends StatelessWidget {
|
||||
fontSize: 12,
|
||||
fontColor: ColorsManager.grayColor,
|
||||
),
|
||||
const SizedBox(height: 7),
|
||||
DefaultContainer(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: InkWell(
|
||||
|
@ -7,7 +7,6 @@ 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/model/subspace_model.dart';
|
||||
import 'package:syncrow_app/features/devices/view/widgets/sos/sos_setting/delete_dialog.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';
|
||||
@ -62,14 +61,18 @@ class SosSettings extends StatelessWidget {
|
||||
vertical: 10,
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
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: [
|
||||
@ -93,8 +96,8 @@ class SosSettings extends StatelessWidget {
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
const BodyMedium(
|
||||
text: 'SOS',
|
||||
BodyMedium(
|
||||
text: _bloc.deviceInfo.name,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
const SizedBox(
|
||||
@ -169,7 +172,21 @@ class SosSettings extends StatelessWidget {
|
||||
child: Column(
|
||||
children: [
|
||||
SettingWidget(
|
||||
onChanged: (p0) {},
|
||||
value: _bloc.enableAlarm,
|
||||
onChanged: (p0) {
|
||||
context
|
||||
.read<SosBloc>()
|
||||
.add(ToggleEnableAlarmEvent(p0));
|
||||
// Transform.scale(
|
||||
// scale: .8,
|
||||
// child: CupertinoSwitch(
|
||||
// value: _bloc.enableAlarm,
|
||||
// onChanged: (value) {
|
||||
|
||||
// },
|
||||
// applyTheme: true,
|
||||
// )),
|
||||
},
|
||||
isNotification: true,
|
||||
onTap: () {},
|
||||
text: 'Offline Notification',
|
||||
@ -400,6 +417,7 @@ class SosSettings extends StatelessWidget {
|
||||
class SettingWidget extends StatelessWidget {
|
||||
final String? text;
|
||||
final bool? isUpdate;
|
||||
final bool? value;
|
||||
final bool? isNotification;
|
||||
final String? icon;
|
||||
final Function()? onTap;
|
||||
@ -409,6 +427,7 @@ class SettingWidget extends StatelessWidget {
|
||||
{super.key,
|
||||
this.text,
|
||||
this.icon,
|
||||
this.value,
|
||||
this.onTap,
|
||||
this.isUpdate,
|
||||
this.onChanged,
|
||||
@ -472,7 +491,7 @@ class SettingWidget extends StatelessWidget {
|
||||
: Transform.scale(
|
||||
scale: .8,
|
||||
child: CupertinoSwitch(
|
||||
value: true,
|
||||
value: value!,
|
||||
onChanged: onChanged,
|
||||
applyTheme: true,
|
||||
),
|
||||
|
Reference in New Issue
Block a user