2022-10-24 20:25:38 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2022-10-29 18:02:45 +00:00
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
2022-12-18 09:03:41 +00:00
|
|
|
import 'package:lightmeter/data/models/photography_values/photography_value.dart';
|
2022-10-29 18:02:45 +00:00
|
|
|
import 'package:lightmeter/res/dimens.dart';
|
2022-10-24 20:25:38 +00:00
|
|
|
|
2022-12-18 09:03:41 +00:00
|
|
|
import 'components/bottom_controls/widget_bottom_controls.dart';
|
2022-12-21 19:31:22 +00:00
|
|
|
import 'components/camera/widget_exposure_slider.dart';
|
|
|
|
import 'components/camera/widget_zoom_camera.dart';
|
2022-12-18 09:03:41 +00:00
|
|
|
import 'components/exposure_pairs_list/widget_list_exposure_pairs.dart';
|
|
|
|
import 'components/topbar/widget_topbar.dart';
|
2022-12-14 17:33:38 +00:00
|
|
|
import 'bloc_metering.dart';
|
|
|
|
import 'event_metering.dart';
|
|
|
|
import 'state_metering.dart';
|
2022-10-24 20:25:38 +00:00
|
|
|
|
2022-11-26 18:14:51 +00:00
|
|
|
class MeteringScreen extends StatefulWidget {
|
2022-12-11 14:09:10 +00:00
|
|
|
const MeteringScreen({super.key});
|
2022-10-24 20:25:38 +00:00
|
|
|
|
2022-11-26 18:14:51 +00:00
|
|
|
@override
|
|
|
|
State<MeteringScreen> createState() => _MeteringScreenState();
|
|
|
|
}
|
|
|
|
|
2022-11-26 19:29:00 +00:00
|
|
|
class _MeteringScreenState extends State<MeteringScreen> {
|
2023-01-20 19:31:35 +00:00
|
|
|
double topBarOverflow = 0.0;
|
|
|
|
|
2023-01-26 15:03:48 +00:00
|
|
|
MeteringBloc get _bloc => context.read<MeteringBloc>();
|
|
|
|
|
2022-12-11 14:04:08 +00:00
|
|
|
@override
|
|
|
|
void didChangeDependencies() {
|
|
|
|
super.didChangeDependencies();
|
2023-01-26 15:03:48 +00:00
|
|
|
_bloc.add(StopTypeChangedEvent(context.watch<StopType>()));
|
2022-12-11 14:04:08 +00:00
|
|
|
}
|
|
|
|
|
2022-10-24 20:25:38 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
backgroundColor: Theme.of(context).colorScheme.background,
|
2022-10-29 18:02:45 +00:00
|
|
|
body: BlocBuilder<MeteringBloc, MeteringState>(
|
2023-01-26 15:03:48 +00:00
|
|
|
builder: (context, state) => Column(
|
|
|
|
children: [
|
|
|
|
MeteringTopBar(
|
|
|
|
fastest: state.fastest,
|
|
|
|
slowest: state.slowest,
|
|
|
|
ev: state.ev,
|
|
|
|
iso: state.iso,
|
|
|
|
nd: state.nd,
|
|
|
|
onIsoChanged: (value) => _bloc.add(IsoChangedEvent(value)),
|
|
|
|
onNdChanged: (value) => _bloc.add(NdChangedEvent(value)),
|
|
|
|
onCutoutLayout: (value) => topBarOverflow = value,
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: Dimens.paddingM),
|
|
|
|
child: _MiddleContentWrapper(
|
|
|
|
topBarOverflow: topBarOverflow,
|
|
|
|
leftContent: ExposurePairsList(state.exposurePairs),
|
|
|
|
rightContent: Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: Dimens.paddingM),
|
|
|
|
child: Column(
|
|
|
|
children: const [
|
|
|
|
Expanded(child: CameraExposureSlider()),
|
|
|
|
SizedBox(height: Dimens.grid24),
|
|
|
|
CameraZoomSlider(),
|
|
|
|
],
|
2022-11-26 18:14:51 +00:00
|
|
|
),
|
2022-10-29 18:02:45 +00:00
|
|
|
),
|
2023-01-26 15:03:48 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
MeteringBottomControls(
|
|
|
|
onMeasure: () => _bloc.add(const MeasureEvent()),
|
|
|
|
onSettings: () => Navigator.pushNamed(context, 'settings'),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _MiddleContentWrapper extends StatelessWidget {
|
|
|
|
final double topBarOverflow;
|
|
|
|
final Widget leftContent;
|
|
|
|
final Widget rightContent;
|
|
|
|
|
|
|
|
const _MiddleContentWrapper({
|
|
|
|
required this.topBarOverflow,
|
|
|
|
required this.leftContent,
|
|
|
|
required this.rightContent,
|
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return LayoutBuilder(
|
|
|
|
builder: (context, constraints) => OverflowBox(
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
maxHeight: constraints.maxHeight + topBarOverflow.abs(),
|
|
|
|
maxWidth: constraints.maxWidth,
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.only(top: topBarOverflow >= 0 ? topBarOverflow : 0),
|
|
|
|
child: leftContent,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(width: Dimens.grid8),
|
|
|
|
Expanded(
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.only(top: topBarOverflow <= 0 ? -topBarOverflow : 0),
|
|
|
|
child: rightContent,
|
2022-10-29 18:02:45 +00:00
|
|
|
),
|
2023-01-26 15:03:48 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-10-24 20:25:38 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|