mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2025-04-22 01:10:40 +00:00
Added some RepaintBoundary
This commit is contained in:
parent
4917ee8aef
commit
deb1ac3282
5 changed files with 119 additions and 95 deletions
|
@ -49,32 +49,34 @@ class _MeteringMeasureButtonState extends State<MeteringMeasureButton> {
|
||||||
_isPressed = false;
|
_isPressed = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: SizedBox.fromSize(
|
child: RepaintBoundary(
|
||||||
size: const Size.square(Dimens.grid72),
|
child: SizedBox.fromSize(
|
||||||
child: Stack(
|
size: const Size.square(Dimens.grid72),
|
||||||
children: [
|
child: Stack(
|
||||||
Center(
|
children: [
|
||||||
child: AnimatedScale(
|
Center(
|
||||||
duration: Dimens.durationS,
|
child: AnimatedScale(
|
||||||
scale: _isPressed ? 0.9 : 1.0,
|
duration: Dimens.durationS,
|
||||||
child: FilledCircle(
|
scale: _isPressed ? 0.9 : 1.0,
|
||||||
color: Theme.of(context).colorScheme.onSurface,
|
child: FilledCircle(
|
||||||
size: Dimens.grid72 - Dimens.grid8,
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
child: Center(
|
size: Dimens.grid72 - Dimens.grid8,
|
||||||
child: widget.ev != null ? _EvValueText(ev: widget.ev!) : null,
|
child: Center(
|
||||||
|
child: widget.ev != null ? _EvValueText(ev: widget.ev!) : null,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
Positioned.fill(
|
||||||
Positioned.fill(
|
child: CircularProgressIndicator(
|
||||||
child: CircularProgressIndicator(
|
/// This key is needed to make indicator start from the same point every time
|
||||||
/// This key is needed to make indicator start from the same point every time
|
key: ValueKey(widget.isMetering),
|
||||||
key: ValueKey(widget.isMetering),
|
color: Theme.of(context).colorScheme.onSurface,
|
||||||
color: Theme.of(context).colorScheme.onSurface,
|
value: widget.isMetering ? null : 1,
|
||||||
value: widget.isMetering ? null : 1,
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -37,16 +37,12 @@ class MeteringBottomControls extends StatelessWidget {
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
if (onSwitchEvSourceType != null)
|
if (onSwitchEvSourceType != null)
|
||||||
Expanded(
|
_SideIcon(
|
||||||
child: Center(
|
onPressed: onSwitchEvSourceType!,
|
||||||
child: IconButton(
|
icon: Icon(
|
||||||
onPressed: onSwitchEvSourceType,
|
context.listen<EvSourceType>() != EvSourceType.camera
|
||||||
icon: Icon(
|
? Icons.camera_rear
|
||||||
context.listen<EvSourceType>() != EvSourceType.camera
|
: Icons.wb_incandescent,
|
||||||
? Icons.camera_rear
|
|
||||||
: Icons.wb_incandescent,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
|
@ -56,13 +52,9 @@ class MeteringBottomControls extends StatelessWidget {
|
||||||
isMetering: isMetering,
|
isMetering: isMetering,
|
||||||
onTap: onMeasure,
|
onTap: onMeasure,
|
||||||
),
|
),
|
||||||
Expanded(
|
_SideIcon(
|
||||||
child: Center(
|
onPressed: onSettings,
|
||||||
child: IconButton(
|
icon: const Icon(Icons.settings),
|
||||||
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -25,22 +25,24 @@ class CameraControls extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
return RepaintBoundary(
|
||||||
children: [
|
child: Column(
|
||||||
Expanded(
|
children: [
|
||||||
child: ExposureOffsetSlider(
|
Expanded(
|
||||||
range: exposureOffsetRange,
|
child: ExposureOffsetSlider(
|
||||||
value: exposureOffsetValue,
|
range: exposureOffsetRange,
|
||||||
onChanged: onExposureOffsetChanged,
|
value: exposureOffsetValue,
|
||||||
|
onChanged: onExposureOffsetChanged,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: Dimens.grid24),
|
||||||
const SizedBox(height: Dimens.grid24),
|
ZoomSlider(
|
||||||
ZoomSlider(
|
range: zoomRange,
|
||||||
range: zoomRange,
|
value: zoomValue,
|
||||||
value: zoomValue,
|
onChanged: onZoomChanged,
|
||||||
onChanged: onZoomChanged,
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,39 +22,41 @@ class CameraPreview extends StatefulWidget {
|
||||||
class _CameraPreviewState extends State<CameraPreview> {
|
class _CameraPreviewState extends State<CameraPreview> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return AspectRatio(
|
return RepaintBoundary(
|
||||||
aspectRatio: PlatformConfig.cameraPreviewAspectRatio,
|
child: AspectRatio(
|
||||||
child: Center(
|
aspectRatio: PlatformConfig.cameraPreviewAspectRatio,
|
||||||
child: Stack(
|
child: Center(
|
||||||
children: [
|
child: Stack(
|
||||||
const CameraViewPlaceholder(error: null),
|
children: [
|
||||||
AnimatedSwitcher(
|
const CameraViewPlaceholder(error: null),
|
||||||
duration: Dimens.switchDuration,
|
AnimatedSwitcher(
|
||||||
child: widget.controller != null
|
duration: Dimens.switchDuration,
|
||||||
? ValueListenableBuilder<CameraValue>(
|
child: widget.controller != null
|
||||||
valueListenable: widget.controller!,
|
? ValueListenableBuilder<CameraValue>(
|
||||||
builder: (_, __, ___) => widget.controller!.value.isInitialized
|
valueListenable: widget.controller!,
|
||||||
? Stack(
|
builder: (_, __, ___) => widget.controller!.value.isInitialized
|
||||||
alignment: Alignment.bottomCenter,
|
? Stack(
|
||||||
children: [
|
alignment: Alignment.bottomCenter,
|
||||||
CameraView(controller: widget.controller!),
|
children: [
|
||||||
if (MeteringScreenLayout.featureOf(
|
CameraView(controller: widget.controller!),
|
||||||
context,
|
if (MeteringScreenLayout.featureOf(
|
||||||
MeteringScreenLayoutFeature.histogram,
|
context,
|
||||||
))
|
MeteringScreenLayoutFeature.histogram,
|
||||||
Positioned(
|
))
|
||||||
left: Dimens.grid8,
|
Positioned(
|
||||||
right: Dimens.grid8,
|
left: Dimens.grid8,
|
||||||
bottom: Dimens.grid16,
|
right: Dimens.grid8,
|
||||||
child: CameraHistogram(controller: widget.controller!),
|
bottom: Dimens.grid16,
|
||||||
),
|
child: CameraHistogram(controller: widget.controller!),
|
||||||
],
|
),
|
||||||
)
|
],
|
||||||
: const SizedBox.shrink(),
|
)
|
||||||
)
|
: const SizedBox.shrink(),
|
||||||
: CameraViewPlaceholder(error: widget.error),
|
)
|
||||||
),
|
: CameraViewPlaceholder(error: widget.error),
|
||||||
],
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -72,14 +72,16 @@ class _ReadingValueBuilder extends StatelessWidget {
|
||||||
softWrap: false,
|
softWrap: false,
|
||||||
),
|
),
|
||||||
const SizedBox(height: Dimens.grid4),
|
const SizedBox(height: Dimens.grid4),
|
||||||
AnimatedSwitcher(
|
RepaintBoundary(
|
||||||
duration: Dimens.switchDuration,
|
child: AnimatedSwitcher(
|
||||||
child: Text(
|
duration: Dimens.switchDuration,
|
||||||
reading.value,
|
child: Text(
|
||||||
style: textTheme.titleMedium?.copyWith(color: textColor),
|
reading.value,
|
||||||
maxLines: 1,
|
style: textTheme.titleMedium?.copyWith(color: textColor),
|
||||||
overflow: TextOverflow.ellipsis,
|
maxLines: 1,
|
||||||
softWrap: false,
|
overflow: TextOverflow.ellipsis,
|
||||||
|
softWrap: false,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue