mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-23 16:00:41 +00:00
fixed camera screen layout
This commit is contained in:
parent
f23979975b
commit
c88a767d1a
3 changed files with 80 additions and 18 deletions
|
@ -21,6 +21,10 @@ class Dimens {
|
||||||
static const Duration durationML = Duration(milliseconds: 250);
|
static const Duration durationML = Duration(milliseconds: 250);
|
||||||
static const Duration durationL = Duration(milliseconds: 300);
|
static const Duration durationL = Duration(milliseconds: 300);
|
||||||
|
|
||||||
|
// TopBar
|
||||||
|
/// Probably this is a bad practice, but with text size locked, the height is always 212
|
||||||
|
static const double readingContainerHeight = 212;
|
||||||
|
|
||||||
// `CenteredSlider`
|
// `CenteredSlider`
|
||||||
static const double cameraSliderTrackHeight = grid4;
|
static const double cameraSliderTrackHeight = grid4;
|
||||||
static const double cameraSliderTrackRadius = cameraSliderTrackHeight / 2;
|
static const double cameraSliderTrackRadius = cameraSliderTrackHeight / 2;
|
||||||
|
|
|
@ -38,6 +38,9 @@ class CameraContainer extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final topBarOverflow = Dimens.readingContainerHeight -
|
||||||
|
((MediaQuery.of(context).size.width - Dimens.grid8 - 2 * Dimens.paddingM) / 2) /
|
||||||
|
PlatformConfig.cameraPreviewAspectRatio;
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
MeteringTopBar(
|
MeteringTopBar(
|
||||||
|
@ -49,11 +52,17 @@ class CameraContainer extends StatelessWidget {
|
||||||
onIsoChanged: onIsoChanged,
|
onIsoChanged: onIsoChanged,
|
||||||
onNdChanged: onNdChanged,
|
onNdChanged: onNdChanged,
|
||||||
),
|
),
|
||||||
|
appendixHeight: topBarOverflow,
|
||||||
|
preview: const _CameraViewBuilder(),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: Dimens.paddingM),
|
padding: const EdgeInsets.symmetric(horizontal: Dimens.paddingM),
|
||||||
child: ExposurePairsList(exposurePairs),
|
child: _MiddleContentWrapper(
|
||||||
|
topBarOverflow: topBarOverflow,
|
||||||
|
leftContent: ExposurePairsList(exposurePairs),
|
||||||
|
rightContent: const _CameraControlsBuilder(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -85,23 +94,66 @@ class _CameraControlsBuilder extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<CameraContainerBloc, CameraContainerState>(
|
return Padding(
|
||||||
builder: (context, state) => AnimatedSwitcher(
|
padding: const EdgeInsets.symmetric(vertical: Dimens.paddingM),
|
||||||
duration: Dimens.durationS,
|
child: BlocBuilder<CameraContainerBloc, CameraContainerState>(
|
||||||
child: state is CameraActiveState
|
builder: (context, state) => AnimatedSwitcher(
|
||||||
? CameraControls(
|
duration: Dimens.durationS,
|
||||||
exposureOffsetRange: state.exposureOffsetRange,
|
child: state is CameraActiveState
|
||||||
exposureOffsetValue: state.currentExposureOffset,
|
? CameraControls(
|
||||||
onExposureOffsetChanged: (value) {
|
exposureOffsetRange: state.exposureOffsetRange,
|
||||||
context.read<CameraContainerBloc>().add(ExposureOffsetChangedEvent(value));
|
exposureOffsetValue: state.currentExposureOffset,
|
||||||
},
|
onExposureOffsetChanged: (value) {
|
||||||
zoomRange: state.zoomRange,
|
context.read<CameraContainerBloc>().add(ExposureOffsetChangedEvent(value));
|
||||||
zoomValue: state.currentZoom,
|
},
|
||||||
onZoomChanged: (value) {
|
zoomRange: state.zoomRange,
|
||||||
context.read<CameraContainerBloc>().add(ZoomChangedEvent(value));
|
zoomValue: state.currentZoom,
|
||||||
},
|
onZoomChanged: (value) {
|
||||||
)
|
context.read<CameraContainerBloc>().add(ZoomChangedEvent(value));
|
||||||
: const SizedBox.shrink(),
|
},
|
||||||
|
)
|
||||||
|
: const SizedBox.shrink(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,11 +68,17 @@ class _ReadingValueBuilder extends StatelessWidget {
|
||||||
Text(
|
Text(
|
||||||
reading.label,
|
reading.label,
|
||||||
style: textTheme.labelMedium?.copyWith(color: textColor),
|
style: textTheme.labelMedium?.copyWith(color: textColor),
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.visible,
|
||||||
|
softWrap: false,
|
||||||
),
|
),
|
||||||
const SizedBox(height: Dimens.grid4),
|
const SizedBox(height: Dimens.grid4),
|
||||||
Text(
|
Text(
|
||||||
reading.value,
|
reading.value,
|
||||||
style: textTheme.titleMedium?.copyWith(color: textColor),
|
style: textTheme.titleMedium?.copyWith(color: textColor),
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.visible,
|
||||||
|
softWrap: false,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue