Added some RepaintBoundary

This commit is contained in:
Vadim 2023-08-12 12:33:21 +02:00
parent 4917ee8aef
commit deb1ac3282
5 changed files with 119 additions and 95 deletions

View file

@ -49,32 +49,34 @@ class _MeteringMeasureButtonState extends State<MeteringMeasureButton> {
_isPressed = false;
});
},
child: SizedBox.fromSize(
size: const Size.square(Dimens.grid72),
child: Stack(
children: [
Center(
child: AnimatedScale(
duration: Dimens.durationS,
scale: _isPressed ? 0.9 : 1.0,
child: FilledCircle(
color: Theme.of(context).colorScheme.onSurface,
size: Dimens.grid72 - Dimens.grid8,
child: Center(
child: widget.ev != null ? _EvValueText(ev: widget.ev!) : null,
child: RepaintBoundary(
child: SizedBox.fromSize(
size: const Size.square(Dimens.grid72),
child: Stack(
children: [
Center(
child: AnimatedScale(
duration: Dimens.durationS,
scale: _isPressed ? 0.9 : 1.0,
child: FilledCircle(
color: Theme.of(context).colorScheme.onSurface,
size: Dimens.grid72 - Dimens.grid8,
child: Center(
child: widget.ev != null ? _EvValueText(ev: widget.ev!) : null,
),
),
),
),
),
Positioned.fill(
child: CircularProgressIndicator(
/// This key is needed to make indicator start from the same point every time
key: ValueKey(widget.isMetering),
color: Theme.of(context).colorScheme.onSurface,
value: widget.isMetering ? null : 1,
Positioned.fill(
child: CircularProgressIndicator(
/// This key is needed to make indicator start from the same point every time
key: ValueKey(widget.isMetering),
color: Theme.of(context).colorScheme.onSurface,
value: widget.isMetering ? null : 1,
),
),
),
],
],
),
),
),
);

View file

@ -37,16 +37,12 @@ class MeteringBottomControls extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
if (onSwitchEvSourceType != null)
Expanded(
child: Center(
child: IconButton(
onPressed: onSwitchEvSourceType,
icon: Icon(
context.listen<EvSourceType>() != EvSourceType.camera
? Icons.camera_rear
: Icons.wb_incandescent,
),
),
_SideIcon(
onPressed: onSwitchEvSourceType!,
icon: Icon(
context.listen<EvSourceType>() != EvSourceType.camera
? Icons.camera_rear
: Icons.wb_incandescent,
),
)
else
@ -56,13 +52,9 @@ class MeteringBottomControls extends StatelessWidget {
isMetering: isMetering,
onTap: onMeasure,
),
Expanded(
child: Center(
child: IconButton(
onPressed: onSettings,
icon: const Icon(Icons.settings),
),
),
_SideIcon(
onPressed: onSettings,
icon: const Icon(Icons.settings),
),
],
),
@ -72,3 +64,27 @@ class MeteringBottomControls extends StatelessWidget {
);
}
}
class _SideIcon extends StatelessWidget {
final Icon icon;
final VoidCallback onPressed;
const _SideIcon({
required this.icon,
required this.onPressed,
});
@override
Widget build(BuildContext context) {
return Expanded(
child: Center(
child: RepaintBoundary(
child: IconButton(
onPressed: onPressed,
icon: icon,
),
),
),
);
}
}

View file

@ -25,22 +25,24 @@ class CameraControls extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
children: [
Expanded(
child: ExposureOffsetSlider(
range: exposureOffsetRange,
value: exposureOffsetValue,
onChanged: onExposureOffsetChanged,
return RepaintBoundary(
child: Column(
children: [
Expanded(
child: ExposureOffsetSlider(
range: exposureOffsetRange,
value: exposureOffsetValue,
onChanged: onExposureOffsetChanged,
),
),
),
const SizedBox(height: Dimens.grid24),
ZoomSlider(
range: zoomRange,
value: zoomValue,
onChanged: onZoomChanged,
),
],
const SizedBox(height: Dimens.grid24),
ZoomSlider(
range: zoomRange,
value: zoomValue,
onChanged: onZoomChanged,
),
],
),
);
}
}

View file

@ -22,39 +22,41 @@ class CameraPreview extends StatefulWidget {
class _CameraPreviewState extends State<CameraPreview> {
@override
Widget build(BuildContext context) {
return AspectRatio(
aspectRatio: PlatformConfig.cameraPreviewAspectRatio,
child: Center(
child: Stack(
children: [
const CameraViewPlaceholder(error: null),
AnimatedSwitcher(
duration: Dimens.switchDuration,
child: widget.controller != null
? ValueListenableBuilder<CameraValue>(
valueListenable: widget.controller!,
builder: (_, __, ___) => widget.controller!.value.isInitialized
? Stack(
alignment: Alignment.bottomCenter,
children: [
CameraView(controller: widget.controller!),
if (MeteringScreenLayout.featureOf(
context,
MeteringScreenLayoutFeature.histogram,
))
Positioned(
left: Dimens.grid8,
right: Dimens.grid8,
bottom: Dimens.grid16,
child: CameraHistogram(controller: widget.controller!),
),
],
)
: const SizedBox.shrink(),
)
: CameraViewPlaceholder(error: widget.error),
),
],
return RepaintBoundary(
child: AspectRatio(
aspectRatio: PlatformConfig.cameraPreviewAspectRatio,
child: Center(
child: Stack(
children: [
const CameraViewPlaceholder(error: null),
AnimatedSwitcher(
duration: Dimens.switchDuration,
child: widget.controller != null
? ValueListenableBuilder<CameraValue>(
valueListenable: widget.controller!,
builder: (_, __, ___) => widget.controller!.value.isInitialized
? Stack(
alignment: Alignment.bottomCenter,
children: [
CameraView(controller: widget.controller!),
if (MeteringScreenLayout.featureOf(
context,
MeteringScreenLayoutFeature.histogram,
))
Positioned(
left: Dimens.grid8,
right: Dimens.grid8,
bottom: Dimens.grid16,
child: CameraHistogram(controller: widget.controller!),
),
],
)
: const SizedBox.shrink(),
)
: CameraViewPlaceholder(error: widget.error),
),
],
),
),
),
);

View file

@ -72,14 +72,16 @@ class _ReadingValueBuilder extends StatelessWidget {
softWrap: false,
),
const SizedBox(height: Dimens.grid4),
AnimatedSwitcher(
duration: Dimens.switchDuration,
child: Text(
reading.value,
style: textTheme.titleMedium?.copyWith(color: textColor),
maxLines: 1,
overflow: TextOverflow.ellipsis,
softWrap: false,
RepaintBoundary(
child: AnimatedSwitcher(
duration: Dimens.switchDuration,
child: Text(
reading.value,
style: textTheme.titleMedium?.copyWith(color: textColor),
maxLines: 1,
overflow: TextOverflow.ellipsis,
softWrap: false,
),
),
)
],