Что за ошибка?  FATAL EXCEPTION: main
                                                                                                    Process: today.maxi.mobile.dev, PID: 5276
                                                                                                    java.lang.IllegalStateException: Fragment's view can't be accessed. Fragment isn't added
                                                                                                    	at by.kirich1409.viewbindingdelegate.LifecycleViewBindingProperty.getValue(ViewBindingProperty.kt:87)
                                                                                                    	at by.kirich1409.viewbindingdelegate.FragmentViewBindingProperty.getValue(FragmentViewBindings.kt:63)
                                                                                                    	at by.kirich1409.viewbindingdelegate.FragmentViewBindingProperty.getValue(FragmentViewBindings.kt:52)
                                                                                                    	at ru.maxi.mobile.feature.achievements.container.AchievementsContainerFragment.getViewBinding(AchievementsContainerFragment.kt:30)
                                                                                                    	at ru.maxi.mobile.feature.achievements.container.AchievementsContainerFragment.<init>(AchievementsContainerFragment.kt:58)
                                                                                                    	at ru.maxi.mobile.feature.achievements.AchievementsScreens.ContainerScreen$lambda$0(AchievementsScreens.kt:33)
                                                                                                    	at ru.maxi.mobile.feature.achievements.AchievementsScreens.$r8$lambda$qhwQsInW2CurpWvxwMf93ywAPxY(Unknown Source:0)
                                                                                                    	at ru.maxi.mobile.feature.achievements.AchievementsScreens$$ExternalSyntheticLambda1.create(D8$$SyntheticClass:0)
                                                                                                    	at ru.maxi.mobile.core.navigation.FragmentScreenWithArgs$Companion$invoke$1.createFragment(FragmentScreenWithArgs.kt:22)
                                                                                                    	at com.github.terrakok.cicerone.androidx.AppNavigator.commitNewFragmentScreen(AppNavigator.kt:106)
                                                                                                    	at com.github.terrakok.cicerone.androidx.AppNavigator.forward(AppNavigator.kt:66)
                                                                                                    	at ru.maxi.mobile.core.navigation.AppNavigator.forward(AppNavigator.kt:63)
                                                                                                    	at com.github.terrakok.cicerone.androidx.AppNavigator.applyCommand(AppNavigator.kt:53)
                                                                                                    	at com.github.terrakok.cicerone.androidx.AppNavigator.applyCommands(AppNavigator.kt:32)
                                                                                                    	at com.github.terrakok.cicerone.CommandBuffer.executeCommands$lambda-1(CommandBuffer.kt:32)
                                                                                                    	at com.github.terrakok.cicerone.CommandBuffer.$r8$lambda$oYjEPDAg39fvTlY-vhXZ13GaS30(Unknown Source:0)
                                                                                                    	at com.github.terrakok.cicerone.CommandBuffer$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
                                                                                                    	at android.os.Handler.handleCallback(Handler.java:900)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:103)
                                                                                                    	at android.os.Looper.loop(Looper.java:219)
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:8349)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)package ru.maxi.mobile.feature.achievements.container

import android.os.Bundle
import android.view.View
import androidx.annotation.IdRes
import androidx.core.content.ContextCompat
import androidx.fragment.app.viewModels
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import androidx.viewpager2.widget.ViewPager2
import by.kirich1409.viewbindingdelegate.viewBinding
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch
import ru.maxi.mobile.R
import ru.maxi.mobile.base.ui.MvvmBaseFragment
import ru.maxi.mobile.databinding.FragmentAchievementsContainerBinding
import ru.maxi.mobile.feature.achievements.AchievementsScreens
import ru.maxi.mobile.feature.achievements.container.model.AchievementsTabPage
import ru.maxi.mobile.feature.achievements.container.model.AchievementsViewState
import ru.maxi.mobile.uikit.utils.lifecycleAwareLazy
import ru.maxi.mobile.uikit.R as UIKitR

/**
 * [Fragment] контейнера экранов достижений
 */
@AndroidEntryPoint
class AchievementsContainerFragment : MvvmBaseFragment(R.layout.fragment_achievements_container) {

    private val viewBinding by viewBinding(FragmentAchievementsContainerBinding::bind)

    private val viewModel by viewModels<AchievementsContainerViewModel>()

    private val pageAdapter by lifecycleAwareLazy {
        AchievementsTabAdapter(this)
    }

    private val pageChangeListener = object : ViewPager2.OnPageChangeCallback() {
        override fun onPageSelected(position: Int) {
            AchievementsScreens.ContainerTab.entries
                .getOrNull(position)
                ?.let(viewModel::updateCurrentTab)
        }
    }

    private val pageList: MutableList<AchievementsTabPage> = mutableListOf(
        AchievementsTabPage(AchievementsScreens.AchievementsInProgressScreen()),
        AchievementsTabPage(AchievementsScreens.AchievementsReceivedScreen()),
    )

    override val analyticsName: String? = null

    private var isFirstOpen = true

    private val backgroundObserver = BackgroundObserver(
        bgSource = BackgroundSource.FromDrawable(R.drawable.bg_achievements),
        hideToolbar = false,
        toolbarBlurView = viewBinding.toolbarBlurView,
    )

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        actionBarManager.setTitle(R.string.achievements_screen_title)
        actionBarManager.showBackButton()

        // with(viewBinding) {
        //     val topSystemViewsHeight = actionBarManager.getHeight(withSystemBarsInset = true)
        //
        //     toolbarBlurView.updateLayoutParams { height = topSystemViewsHeight }
        //     toolbarBlurView.translationY = -topSystemViewsHeight.toFloat()
        // }

        with(viewBinding) {
            tabsContainer.registerOnPageChangeCallback(pageChangeListener)
            tabsContainer.adapter = pageAdapter
            pageAdapter.pages = pageList
            tabsButtonContainer.setOnButtonCheckedListener { buttonId ->
                AchievementsScreens.ContainerTab.entries
                    .find { it.buttonId == buttonId }
                    ?.let(viewModel::updateCurrentTab)

                updateButtonTextColor(buttonId)
            }
        }
        backgroundObserver.attachTo(viewLifecycleOwner)
        with(viewLifecycleOwner) {
            // backgroundObserver.attachTo(this)
            lifecycleScope.launch {
                repeatOnLifecycle(Lifecycle.State.STARTED) {
                    launch { viewModel.viewState.collect(::onViewStateChange) }
                }
            }
        }
    }

    override fun onDestroyView() {
        super.onDestroyView()
        viewBinding.tabsContainer.unregisterOnPageChangeCallback(pageChangeListener)
    }

    private fun onViewStateChange(state: AchievementsViewState) {
        with(viewBinding) {
            tabsButtonContainer.check(state.currentTab.buttonId)
            tabsContainer.setCurrentItem(state.currentTab.ordinal, !isFirstOpen)
        }
        isFirstOpen = false
    }

    private fun updateButtonTextColor(checkedButtonId: Int) {
        with(viewBinding) {
            inProgressTab.setTextColor(ContextCompat.getColor(requireContext(), UIKitR.color.white))
            receivedTab.setTextColor(ContextCompat.getColor(requireContext(), UIKitR.color.white))

            when (checkedButtonId) {
                R.id.in_progress_tab -> inProgressTab.setTextColor(
                    ContextCompat.getColor(
                        requireContext(),
                        UIKitR.color.text_color_on_surface_high,
                    ),
                )

                R.id.received_tab -> receivedTab.setTextColor(
                    ContextCompat.getColor(
                        requireContext(),
                        UIKitR.color.text_color_on_surface_high,
                    ),
                )
            }
        }
    }
}

@get:IdRes
private val AchievementsScreens.ContainerTab.buttonId: Int
    get() = when (this) {
        AchievementsScreens.ContainerTab.IN_PROGRESS_TAB -> R.id.in_progress_tab
        AchievementsScreens.ContainerTab.RECEIVED_TAB -> R.id.received_tab
    }