Added switch animations to MeteringScreen

This commit is contained in:
Vadim 2023-08-04 16:17:40 +02:00
parent 6e1aaf5acf
commit 8a71c8db13
5 changed files with 82 additions and 77 deletions

View file

@ -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;

View file

@ -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),
);
}
}

View file

@ -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,
);
},

View file

@ -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 {
),
),
],
),
);
}
}

View file

@ -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,
),
)
],
);