1 /* <lambda>null2 * 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 androidx.compose.integration.macrobenchmark.target.complexdifferenttypeslist 18 19 import androidx.compose.foundation.layout.fillMaxSize 20 import androidx.compose.foundation.lazy.LazyColumn 21 import androidx.compose.foundation.lazy.rememberLazyListState 22 import androidx.compose.integration.macrobenchmark.target.complexdifferenttypeslist.common.AdapterItemWrapper 23 import androidx.compose.integration.macrobenchmark.target.complexdifferenttypeslist.common.populate 24 import androidx.compose.integration.macrobenchmark.target.complexdifferenttypeslist.model.ui.SectionHeaderUiModel 25 import androidx.compose.integration.macrobenchmark.target.complexdifferenttypeslist.model.ui.SquadPlayerUiModel 26 import androidx.compose.integration.macrobenchmark.target.complexdifferenttypeslist.model.ui.SquadViewTopPlayersUiModel 27 import androidx.compose.integration.macrobenchmark.target.complexdifferenttypeslist.viewholder.SquadPlayer 28 import androidx.compose.integration.macrobenchmark.target.complexdifferenttypeslist.viewholder.SquadSectionHeader 29 import androidx.compose.integration.macrobenchmark.target.complexdifferenttypeslist.viewholder.SquadViewTopPlayers 30 import androidx.compose.integration.macrobenchmark.target.complexdifferenttypeslist.viewholder.SquadViewType 31 import androidx.compose.material.Surface 32 import androidx.compose.runtime.Composable 33 import androidx.compose.ui.Modifier 34 import androidx.compose.ui.semantics.contentDescription 35 import androidx.compose.ui.semantics.semantics 36 37 @Composable 38 fun SquadScreen(items: List<AdapterItemWrapper>) { 39 Surface { 40 LazyColumn( 41 state = rememberLazyListState(), 42 modifier = Modifier.fillMaxSize().semantics { contentDescription = "IamLazy" }, 43 ) { 44 populate<SquadViewType>( 45 listData = items, 46 factory = { viewType, data, _ -> 47 when (viewType) { 48 SquadViewType.VIEW_TOP_PLAYERS -> 49 SquadViewTopPlayers( 50 viewTopPlayersUiModel = data as SquadViewTopPlayersUiModel, 51 onClicked = { /*No-op.*/ } 52 ) 53 SquadViewType.POSITION_SECTION_HEADER -> 54 SquadSectionHeader( 55 uiModel = data as SectionHeaderUiModel, 56 ) 57 SquadViewType.COACH -> 58 SquadPlayer( 59 uiModel = data as SquadPlayerUiModel, 60 onPlayerClicked = { /* No-op. */ }, 61 ) 62 SquadViewType.PLAYER_ROW -> 63 SquadPlayer( 64 uiModel = data as SquadPlayerUiModel, 65 onPlayerClicked = { /*No-op.*/ }, 66 ) 67 } 68 } 69 ) 70 } 71 } 72 } 73