mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-27 03:57:54 +00:00
issue fixes
This commit is contained in:
@@ -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()),
|
||||
child: BlocBuilder<SosBloc, SosState>(
|
||||
builder: (context, state) {
|
||||
final sensor = 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
|
||||
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);
|
||||
// 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 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()),
|
||||
width: 50,
|
||||
height: 50,
|
||||
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,
|
||||
@@ -129,9 +139,10 @@ class SosScreen extends StatelessWidget {
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
SosRecordsScreen(
|
||||
sosId: device!.uuid!)),
|
||||
builder: (context) =>
|
||||
SosRecordsScreen(
|
||||
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()),
|
||||
builder: (context) =>
|
||||
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,15 +212,15 @@ class SosScreen extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -64,9 +64,13 @@ class SosInfoPage extends StatelessWidget {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
BodySmall(
|
||||
text: _bloc.deviceInfo.productUuid,
|
||||
fontColor: ColorsManager.primaryTextColor,
|
||||
SizedBox(
|
||||
width:
|
||||
MediaQuery.of(context).size.width * 0.61,
|
||||
child: BodySmall(
|
||||
text: _bloc.deviceInfo.productUuid,
|
||||
fontColor: ColorsManager.primaryTextColor,
|
||||
),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
|
||||
@@ -64,20 +64,11 @@ 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: SvgPicture.asset(
|
||||
Assets.fourSceneIcon,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
],
|
||||
child: Center(
|
||||
child: SvgPicture.asset(
|
||||
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