use cranpose_core::{
CompositionLocal, composer_context::try_with_composer, compositionLocalWithComputedDefaultOf,
};
use cranpose_foundation::BringIntoViewSpec;
use crate::{UiModeType, local_configuration};
const TV_PIVOT: BringIntoViewSpec = BringIntoViewSpec::Pivot {
parent_fraction: 0.3,
child_fraction: 0.0,
};
pub fn local_bring_into_view_spec() -> CompositionLocal<BringIntoViewSpec> {
crate::environment_locals::cached_local(
|locals| &locals.bring_into_view_spec,
|| {
compositionLocalWithComputedDefaultOf(|scope| {
if scope.current_value(&local_configuration()).ui_mode_type
== UiModeType::Television
{
TV_PIVOT
} else {
BringIntoViewSpec::Default
}
})
},
)
}
pub(crate) fn current_bring_into_view_spec() -> BringIntoViewSpec {
try_with_composer(|_| local_bring_into_view_spec().current()).unwrap_or_default()
}