issue fixes

This commit is contained in:
mohammad
2024-11-24 17:04:29 +03:00
parent b365f7e347
commit efe68ecb1a
14 changed files with 332 additions and 269 deletions

View File

@ -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 {
),
],
),
)
),
],
),
),
],
),
);
},
),
),
);
},
),
);
}