This repository has been archived by the owner on Sep 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Google Services + небольшое изменение интерфейса
- Loading branch information
Showing
7 changed files
with
113 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// ignore_for_file: unused_import | ||
|
||
import 'dart:developer'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:temperature_viewer/logic/cubit/sensor_detail/sensor_detail_cubit.dart'; | ||
|
||
class SensorDetailView extends StatelessWidget { | ||
final int sensorId; | ||
|
||
final maxTempController = TextEditingController(); | ||
final minTempController = TextEditingController(); | ||
final sendDelayController = TextEditingController(); | ||
final updateDelayController = TextEditingController(); | ||
final labelController = TextEditingController(); | ||
|
||
SensorDetailView({required this.sensorId, Key? key}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: const Text('Настройка датчика'), | ||
), | ||
body: BlocBuilder<SensorDetailCubit, SensorDetailState>( | ||
builder: (context, state) { | ||
if (state is SensorDetailLoading) { | ||
if (state is SensorDetailInitialLoading) { | ||
BlocProvider.of<SensorDetailCubit>(context) | ||
.getSensorDetail(sensorId: sensorId); | ||
} | ||
|
||
return const Center( | ||
child: CircularProgressIndicator(), | ||
); | ||
} else if (state is SensorDetailFailure) { | ||
return const Center( | ||
child: Text('Не удалось получить данные'), | ||
); | ||
} else if (state is SensorDetailLoaded) { | ||
labelController.text = state.sensorDetail.label; | ||
minTempController.text = state.sensorDetail.minTemp.toString(); | ||
maxTempController.text = state.sensorDetail.maxTemp.toString(); | ||
sendDelayController.text = state.sensorDetail.sendDelay.toString(); | ||
updateDelayController.text = | ||
state.sensorDetail.updateDelay.toString(); | ||
|
||
return ListView( | ||
children: [ | ||
TextField( | ||
controller: labelController, | ||
decoration: | ||
const InputDecoration(labelText: 'Название датчика')), | ||
TextField( | ||
controller: minTempController, | ||
decoration: const InputDecoration( | ||
labelText: 'Минимальная температура')), | ||
TextField( | ||
controller: maxTempController, | ||
decoration: const InputDecoration( | ||
labelText: 'Максимальная температура')), | ||
TextField( | ||
controller: sendDelayController, | ||
decoration: const InputDecoration( | ||
labelText: 'Интервал отправки показаний')), | ||
TextField( | ||
controller: updateDelayController, | ||
decoration: const InputDecoration( | ||
labelText: 'Интервал проверки настроек')), | ||
ListTile( | ||
title: const Text('Сохранить'), | ||
leading: const Icon(Icons.save), | ||
onTap: () { | ||
context.read<SensorDetailCubit>().updateSensorDetail( | ||
sensorId: sensorId, | ||
label: labelController.text, | ||
minTemp: double.parse(minTempController.text), | ||
maxTemp: double.parse(maxTempController.text), | ||
sendDelay: int.parse(sendDelayController.text), | ||
updateDelay: int.parse(updateDelayController.text)); | ||
}, | ||
) | ||
], | ||
); | ||
} else { | ||
return const Text('???'); | ||
} | ||
}, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters