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 durationM = Duration(milliseconds: 200);
|
||||||
static const Duration durationML = Duration(milliseconds: 250);
|
static const Duration durationML = Duration(milliseconds: 250);
|
||||||
static const Duration durationL = Duration(milliseconds: 300);
|
static const Duration durationL = Duration(milliseconds: 300);
|
||||||
|
static const Duration switchDuration = Duration(milliseconds: 100);
|
||||||
|
|
||||||
static const double enabledOpacity = 1.0;
|
static const double enabledOpacity = 1.0;
|
||||||
static const double disabledOpacity = 0.38;
|
static const double disabledOpacity = 0.38;
|
||||||
|
|
|
@ -10,10 +10,9 @@ class CameraViewPlaceholder extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Card(
|
return Card(
|
||||||
|
color: error != null ? null : Colors.black,
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(Dimens.borderRadiusM)),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(Dimens.borderRadiusM)),
|
||||||
child: Center(
|
child: Center(child: error != null ? const Icon(Icons.no_photography) : null),
|
||||||
child: error != null ? const Icon(Icons.no_photography) : const CircularProgressIndicator(),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,18 +110,18 @@ class _CameraViewBuilder extends StatelessWidget {
|
||||||
return AspectRatio(
|
return AspectRatio(
|
||||||
aspectRatio: PlatformConfig.cameraPreviewAspectRatio,
|
aspectRatio: PlatformConfig.cameraPreviewAspectRatio,
|
||||||
child: BlocBuilder<CameraContainerBloc, CameraContainerState>(
|
child: BlocBuilder<CameraContainerBloc, CameraContainerState>(
|
||||||
buildWhen: (previous, current) =>
|
buildWhen: (previous, current) => current is! CameraActiveState,
|
||||||
current is CameraLoadingState ||
|
builder: (context, state) => Center(
|
||||||
current is CameraInitializedState ||
|
child: AnimatedSwitcher(
|
||||||
current is CameraErrorState,
|
duration: Dimens.durationM,
|
||||||
builder: (context, state) {
|
child: switch (state) {
|
||||||
if (state is CameraInitializedState) {
|
CameraInitializedState() => CameraView(controller: state.controller),
|
||||||
return Center(child: CameraView(controller: state.controller));
|
CameraErrorState() => CameraViewPlaceholder(error: state.error),
|
||||||
} else {
|
_ => const CameraViewPlaceholder(error: null),
|
||||||
return CameraViewPlaceholder(error: state is CameraErrorState ? state.error : null);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,11 +161,11 @@ class _CameraControlsBuilder extends StatelessWidget {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
child = const SizedBox.shrink();
|
child = const Column(children: [Expanded(child: SizedBox.shrink())],);
|
||||||
}
|
}
|
||||||
|
|
||||||
return AnimatedSwitcher(
|
return AnimatedSwitcher(
|
||||||
duration: Dimens.durationS,
|
duration: Dimens.switchDuration,
|
||||||
child: child,
|
child: child,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -12,10 +12,11 @@ class ExposurePairsList extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (exposurePairs.isEmpty) {
|
return AnimatedSwitcher(
|
||||||
return const EmptyExposurePairsList();
|
duration: Dimens.switchDuration,
|
||||||
}
|
child: exposurePairs.isEmpty
|
||||||
return Stack(
|
? const EmptyExposurePairsList()
|
||||||
|
: Stack(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
children: [
|
children: [
|
||||||
Positioned.fill(
|
Positioned.fill(
|
||||||
|
@ -76,6 +77,7 @@ class ExposurePairsList extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,12 +72,15 @@ class _ReadingValueBuilder extends StatelessWidget {
|
||||||
softWrap: false,
|
softWrap: false,
|
||||||
),
|
),
|
||||||
const SizedBox(height: Dimens.grid4),
|
const SizedBox(height: Dimens.grid4),
|
||||||
Text(
|
AnimatedSwitcher(
|
||||||
|
duration: Dimens.switchDuration,
|
||||||
|
child: Text(
|
||||||
reading.value,
|
reading.value,
|
||||||
style: textTheme.titleMedium?.copyWith(color: textColor),
|
style: textTheme.titleMedium?.copyWith(color: textColor),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
softWrap: false,
|
softWrap: false,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue