mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-24 16:30:40 +00:00
Added switch animations to MeteringScreen
This commit is contained in:
parent
6e1aaf5acf
commit
8a71c8db13
5 changed files with 82 additions and 77 deletions
|
@ -25,6 +25,7 @@ class Dimens {
|
|||
static const Duration durationM = Duration(milliseconds: 200);
|
||||
static const Duration durationML = Duration(milliseconds: 250);
|
||||
static const Duration durationL = Duration(milliseconds: 300);
|
||||
static const Duration switchDuration = Duration(milliseconds: 100);
|
||||
|
||||
static const double enabledOpacity = 1.0;
|
||||
static const double disabledOpacity = 0.38;
|
||||
|
|
|
@ -10,10 +10,9 @@ class CameraViewPlaceholder extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
color: error != null ? null : Colors.black,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(Dimens.borderRadiusM)),
|
||||
child: Center(
|
||||
child: error != null ? const Icon(Icons.no_photography) : const CircularProgressIndicator(),
|
||||
),
|
||||
child: Center(child: error != null ? const Icon(Icons.no_photography) : null),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,18 +110,18 @@ class _CameraViewBuilder extends StatelessWidget {
|
|||
return AspectRatio(
|
||||
aspectRatio: PlatformConfig.cameraPreviewAspectRatio,
|
||||
child: BlocBuilder<CameraContainerBloc, CameraContainerState>(
|
||||
buildWhen: (previous, current) =>
|
||||
current is CameraLoadingState ||
|
||||
current is CameraInitializedState ||
|
||||
current is CameraErrorState,
|
||||
builder: (context, state) {
|
||||
if (state is CameraInitializedState) {
|
||||
return Center(child: CameraView(controller: state.controller));
|
||||
} else {
|
||||
return CameraViewPlaceholder(error: state is CameraErrorState ? state.error : null);
|
||||
}
|
||||
buildWhen: (previous, current) => current is! CameraActiveState,
|
||||
builder: (context, state) => Center(
|
||||
child: AnimatedSwitcher(
|
||||
duration: Dimens.durationM,
|
||||
child: switch (state) {
|
||||
CameraInitializedState() => CameraView(controller: state.controller),
|
||||
CameraErrorState() => CameraViewPlaceholder(error: state.error),
|
||||
_ => const CameraViewPlaceholder(error: null),
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -161,11 +161,11 @@ class _CameraControlsBuilder extends StatelessWidget {
|
|||
},
|
||||
);
|
||||
} else {
|
||||
child = const SizedBox.shrink();
|
||||
child = const Column(children: [Expanded(child: SizedBox.shrink())],);
|
||||
}
|
||||
|
||||
return AnimatedSwitcher(
|
||||
duration: Dimens.durationS,
|
||||
duration: Dimens.switchDuration,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
|
|
|
@ -12,10 +12,11 @@ class ExposurePairsList extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (exposurePairs.isEmpty) {
|
||||
return const EmptyExposurePairsList();
|
||||
}
|
||||
return Stack(
|
||||
return AnimatedSwitcher(
|
||||
duration: Dimens.switchDuration,
|
||||
child: exposurePairs.isEmpty
|
||||
? const EmptyExposurePairsList()
|
||||
: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Positioned.fill(
|
||||
|
@ -76,6 +77,7 @@ class ExposurePairsList extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,12 +72,15 @@ class _ReadingValueBuilder extends StatelessWidget {
|
|||
softWrap: false,
|
||||
),
|
||||
const SizedBox(height: Dimens.grid4),
|
||||
Text(
|
||||
AnimatedSwitcher(
|
||||
duration: Dimens.switchDuration,
|
||||
child: Text(
|
||||
reading.value,
|
||||
style: textTheme.titleMedium?.copyWith(color: textColor),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
softWrap: false,
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue