1 /*
2 * Copyright 2024 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package com.android.photopicker.core.selection
18
19 import androidx.compose.runtime.staticCompositionLocalOf
20 import com.android.photopicker.data.model.Media
21
22 /**
23 * Provider for fetching [Selection] inside of composables. [staticCompositionLocalOf] is used here
24 * because the actual selection object is unlikely to change or be reassigned, and there are
25 * performance benefits for not having to keep track of consumers to apply recompositions. The
26 * drawback is that the content this CompositionLocal wraps will be recalculated if the value is
27 * changed. Since it's not expected for the Selection reference to be updated (this is being
28 * provided by the ActivityRetainedComponent), and is injected via Hilt, this value should be very
29 * stable.
30 */
<lambda>null31 val LocalSelection = staticCompositionLocalOf<Selection<Media>> { error("No Selection provided") }
32