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.features.navigationbar
18 
19 import androidx.compose.runtime.Composable
20 import androidx.compose.ui.Modifier
21 import com.android.photopicker.core.configuration.PhotopickerConfiguration
22 import com.android.photopicker.core.events.RegisteredEventClass
23 import com.android.photopicker.core.features.FeatureManager
24 import com.android.photopicker.core.features.FeatureRegistration
25 import com.android.photopicker.core.features.FeatureToken
26 import com.android.photopicker.core.features.Location
27 import com.android.photopicker.core.features.LocationParams
28 import com.android.photopicker.core.features.PhotopickerUiFeature
29 import com.android.photopicker.core.features.Priority
30 
31 /** Feature class for the Photopicker's navigation bar. */
32 class NavigationBarFeature : PhotopickerUiFeature {
33 
34     companion object Registration : FeatureRegistration {
35         override val TAG: String = "PhotopickerNavigationBarFeature"
36 
isEnablednull37         override fun isEnabled(config: PhotopickerConfiguration) = true
38 
39         override fun build(featureManager: FeatureManager) = NavigationBarFeature()
40     }
41 
42     override fun registerLocations(): List<Pair<Location, Int>> {
43         return listOf(Pair(Location.NAVIGATION_BAR, Priority.HIGH.priority))
44     }
45 
46     override val token = FeatureToken.NAVIGATION_BAR.token
47 
48     /** Events consumed by the selection bar */
49     override val eventsConsumed = setOf<RegisteredEventClass>()
50 
51     /** Events produced by the selection bar */
52     override val eventsProduced = setOf<RegisteredEventClass>()
53 
54     @Composable
composenull55     override fun compose(location: Location, modifier: Modifier, params: LocationParams) {
56         when (location) {
57             Location.NAVIGATION_BAR -> NavigationBar(modifier)
58             else -> {}
59         }
60     }
61 }
62