mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-21 23:10: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,17 +110,17 @@ 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,70 +12,72 @@ class ExposurePairsList extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (exposurePairs.isEmpty) {
|
||||
return const EmptyExposurePairsList();
|
||||
}
|
||||
return Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: ListView.builder(
|
||||
key: ValueKey(exposurePairs.hashCode),
|
||||
padding: const EdgeInsets.symmetric(vertical: Dimens.paddingL),
|
||||
itemCount: exposurePairs.length,
|
||||
itemBuilder: (_, index) => Stack(
|
||||
return AnimatedSwitcher(
|
||||
duration: Dimens.switchDuration,
|
||||
child: exposurePairs.isEmpty
|
||||
? const EmptyExposurePairsList()
|
||||
: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: ExposurePairsListItem(
|
||||
exposurePairs[index].aperture,
|
||||
tickOnTheLeft: false,
|
||||
Positioned.fill(
|
||||
child: ListView.builder(
|
||||
key: ValueKey(exposurePairs.hashCode),
|
||||
padding: const EdgeInsets.symmetric(vertical: Dimens.paddingL),
|
||||
itemCount: exposurePairs.length,
|
||||
itemBuilder: (_, index) => Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: ExposurePairsListItem(
|
||||
exposurePairs[index].aperture,
|
||||
tickOnTheLeft: false,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: ExposurePairsListItem(
|
||||
exposurePairs[index].shutterSpeed,
|
||||
tickOnTheLeft: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: ExposurePairsListItem(
|
||||
exposurePairs[index].shutterSpeed,
|
||||
tickOnTheLeft: true,
|
||||
Positioned(
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) => Align(
|
||||
alignment: index == 0
|
||||
? Alignment.bottomCenter
|
||||
: (index == exposurePairs.length - 1
|
||||
? Alignment.topCenter
|
||||
: Alignment.center),
|
||||
child: SizedBox(
|
||||
height: index == 0 || index == exposurePairs.length - 1
|
||||
? constraints.maxHeight / 2
|
||||
: constraints.maxHeight,
|
||||
child: ColoredBox(
|
||||
color: Theme.of(context).colorScheme.onBackground,
|
||||
child: const SizedBox(width: 1),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Positioned(
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) => Align(
|
||||
alignment: index == 0
|
||||
? Alignment.bottomCenter
|
||||
: (index == exposurePairs.length - 1
|
||||
? Alignment.topCenter
|
||||
: Alignment.center),
|
||||
child: SizedBox(
|
||||
height: index == 0 || index == exposurePairs.length - 1
|
||||
? constraints.maxHeight / 2
|
||||
: constraints.maxHeight,
|
||||
child: ColoredBox(
|
||||
color: Theme.of(context).colorScheme.onBackground,
|
||||
child: const SizedBox(width: 1),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,12 +72,15 @@ class _ReadingValueBuilder extends StatelessWidget {
|
|||
softWrap: false,
|
||||
),
|
||||
const SizedBox(height: Dimens.grid4),
|
||||
Text(
|
||||
reading.value,
|
||||
style: textTheme.titleMedium?.copyWith(color: textColor),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
softWrap: false,
|
||||
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