mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-25 08:50:40 +00:00
c7ed4d332e
added `HapticsService` added haptics handling added `HapticsInteractor`
95 lines
3.2 KiB
Dart
95 lines
3.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:lightmeter/res/dimens.dart';
|
|
import 'package:lightmeter/screens/metering/ev_source/camera/bloc_camera.dart';
|
|
import 'package:lightmeter/screens/metering/ev_source/camera/event_camera.dart';
|
|
import 'package:lightmeter/screens/metering/ev_source/camera/state_camera.dart';
|
|
import 'package:lightmeter/utils/to_string_signed.dart';
|
|
|
|
import 'shared/widget_slider_camera.dart';
|
|
|
|
class CameraExposureSlider extends StatelessWidget {
|
|
const CameraExposureSlider({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocBuilder<CameraBloc, CameraState>(
|
|
builder: (context, state) {
|
|
if (state is CameraActiveState) {
|
|
return Column(
|
|
children: [
|
|
IconButton(
|
|
icon: const Icon(Icons.sync),
|
|
onPressed: state.currentExposureOffset != 0.0
|
|
? () => context.read<CameraBloc>().add(const ExposureOffsetResetEvent())
|
|
: null,
|
|
),
|
|
Expanded(
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: Dimens.grid8),
|
|
child: _Ruler(state.minExposureOffset, state.maxExposureOffset),
|
|
),
|
|
CameraSlider(
|
|
isVertical: true,
|
|
icon: const Icon(Icons.light_mode),
|
|
value: state.currentExposureOffset,
|
|
min: state.minExposureOffset,
|
|
max: state.maxExposureOffset,
|
|
onChanged: (value) {
|
|
context.read<CameraBloc>().add(ExposureOffsetChangedEvent(value));
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
return const SizedBox();
|
|
},
|
|
);
|
|
}
|
|
}
|
|
|
|
class _Ruler extends StatelessWidget {
|
|
final double min;
|
|
final double max;
|
|
|
|
const _Ruler(this.min, this.max);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: List.generate(
|
|
(max - min + 1).toInt(),
|
|
(index) {
|
|
final bool showValue = index % 2 == 0.0 || index == 0.0;
|
|
return Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: [
|
|
if (showValue)
|
|
Text(
|
|
(index + min).toStringSigned(),
|
|
style: Theme.of(context).textTheme.bodyLarge,
|
|
),
|
|
const SizedBox(width: Dimens.grid8),
|
|
ColoredBox(
|
|
color: Theme.of(context).colorScheme.onBackground,
|
|
child: SizedBox(
|
|
height: 1,
|
|
width: showValue ? Dimens.grid16 : Dimens.grid8,
|
|
),
|
|
),
|
|
const SizedBox(width: Dimens.grid8),
|
|
],
|
|
);
|
|
},
|
|
).reversed.toList(),
|
|
);
|
|
}
|
|
}
|