Commit 3f5b1e2
Changed files (4)
app
lib
bluetooth
components
app/lib/bluetooth/ble_read_cubit.dart
@@ -43,6 +43,7 @@ class BleReadCubit extends Cubit<BleReadState> {
final BluetoothDevice _device;
Future<void> _startRead() async {
+ Log.trace('_startRead');
// Query actual services supported by the device. While they must be
// rediscovered when a disconnect happens, this object is also recreated.
late final List<BluetoothService> allServices;
app/lib/components/bluetooth_input/device_selection.dart
@@ -27,14 +27,18 @@ class DeviceSelection extends StatelessWidget {
);
@override
- Widget build(BuildContext context) => InputCard(
- //title: Text('Available devices:'),
- child: ListView(
- children: [
- for (final dev in scanResults)
- _buildDeviceTile(context, dev),
- ]
- ),
- );
+ Widget build(BuildContext context) {
+ assert(scanResults.isNotEmpty);
+ return InputCard(
+ //title: Text('Available devices:'), TODO
+ child: ListView(
+ shrinkWrap: true,
+ children: [
+ for (final dev in scanResults)
+ _buildDeviceTile(context, dev),
+ ]
+ ),
+ );
+ }
}
app/lib/components/dialoges/add_measurement_dialoge.dart
@@ -281,6 +281,29 @@ class _AddEntryDialogeState extends State<AddEntryDialoge> {
child: ListView(
padding: const EdgeInsets.symmetric(horizontal: 8),
children: [
+ /* mock device selection
+ DeviceSelection(
+ scanResults: [
+ ScanResult(
+ device: BluetoothDevice(
+ remoteId: const DeviceIdentifier('xx:xx:xx:xx:xx:xx'),
+ ),
+ advertisementData: AdvertisementData(
+ advName: 'boso medicus CE6674',
+ txPowerLevel: 0,
+ appearance: null,
+ connectable: true,
+ manufacturerData: {},
+ serviceData: {},
+ serviceUuids: [Guid('1810')]
+ ),
+ rssi: -69,
+ timeStamp: DateTime.now(),
+ )
+ ],
+ onAccepted: (_) {},
+ ),
+ */
if (widget.settings.bleInput)
BluetoothInput(
settings: widget.settings,
app/lib/components/bluetooth_input.dart
@@ -8,6 +8,7 @@ import 'package:blood_pressure_app/components/bluetooth_input/device_selection.d
import 'package:blood_pressure_app/components/bluetooth_input/input_card.dart';
import 'package:blood_pressure_app/components/bluetooth_input/measurement_failure.dart';
import 'package:blood_pressure_app/components/bluetooth_input/measurement_success.dart';
+import 'package:blood_pressure_app/logging.dart';
import 'package:blood_pressure_app/model/blood_pressure/record.dart';
import 'package:blood_pressure_app/model/storage/storage.dart';
import 'package:flutter/material.dart';
@@ -71,35 +72,43 @@ class _BluetoothInputState extends State<BluetoothInput> {
);
return BlocBuilder<DeviceScanCubit, DeviceScanState>(
bloc: _deviceScanCubit,
- builder: (context, DeviceScanState state) => switch(state) {
- DeviceListLoading() => _buildMainCard(context,
- title: Text(AppLocalizations.of(context)!.scanningForDevices),
- child: const CircularProgressIndicator()),
- DeviceListAvailable() => DeviceSelection(
- scanResults: state.devices,
- onAccepted: (dev) => _deviceScanCubit!.acceptDevice(dev),
- ),
- SingleDeviceAvailable() => DeviceSelection(
- scanResults: [ state.device ],
- onAccepted: (dev) => _deviceScanCubit!.acceptDevice(dev),
- ),
- // distinction
- DeviceSelected() => BlocBuilder<BleReadCubit, BleReadState>(
- bloc: BleReadCubit(state.device),
- builder: (BuildContext context, BleReadState state) => switch (state) {
- BleReadInProgress() => _buildMainCard(context,
- child: const CircularProgressIndicator()),
- BleReadFailure() => MeasurementFailure(
- onTap: _returnToIdle,
- ),
- BleReadSuccess() => MeasurementSuccess(
- onTap: () {
- widget.onMeasurement(state.data);
- return _returnToIdle;
- }(),
- ),
- },
- ),
+ builder: (context, DeviceScanState state) {
+ Log.trace('_BluetoothInputState _deviceScanCubit: $state');
+ return switch(state) {
+ DeviceListLoading() => _buildMainCard(context,
+ title: Text(AppLocalizations.of(context)!.scanningForDevices),
+ child: const CircularProgressIndicator(),
+ ),
+ DeviceListAvailable() => DeviceSelection(
+ scanResults: state.devices,
+ onAccepted: (dev) => _deviceScanCubit!.acceptDevice(dev),
+ ),
+ SingleDeviceAvailable() => DeviceSelection(
+ scanResults: [ state.device ],
+ onAccepted: (dev) => _deviceScanCubit!.acceptDevice(dev),
+ ),
+ // distinction
+ DeviceSelected() => BlocBuilder<BleReadCubit, BleReadState>(
+ bloc: BleReadCubit(state.device),
+ builder: (BuildContext context, BleReadState state) {
+ Log.trace('_BluetoothInputState BleReadCubit: $state');
+ return switch (state) {
+ BleReadInProgress() => _buildMainCard(context,
+ child: const CircularProgressIndicator(),
+ ),
+ BleReadFailure() => MeasurementFailure(
+ onTap: _returnToIdle,
+ ),
+ BleReadSuccess() => MeasurementSuccess(
+ onTap: () {
+ widget.onMeasurement(state.data);
+ return _returnToIdle;
+ }(),
+ ),
+ };
+ },
+ ),
+ };
},
);
}