Skip to content

Commit

Permalink
Add icons to locations drawer
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry-Hiles committed Dec 25, 2023
1 parent f5738f7 commit 841447c
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,26 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.Delete
import androidx.compose.material.icons.filled.LocationOn
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import cafe.adriel.voyager.navigator.LocalNavigator
import com.henryhiles.qweather.R
import com.henryhiles.qweather.presentation.screen.LocationPickerScreen
import com.henryhiles.qweather.presentation.screenmodel.LocationPreferenceManager
import org.koin.androidx.compose.get
import org.koin.compose.koinInject

@Composable
fun LocationsDrawer(
drawerState: DrawerState,
onClose: () -> Unit,
children: @Composable () -> Unit
) {
val locationPreferenceManager: LocationPreferenceManager = get()
val locationPreferenceManager: LocationPreferenceManager = koinInject()
val navigator = LocalNavigator.current?.parent

ModalNavigationDrawer(
Expand All @@ -42,7 +44,15 @@ fun LocationsDrawer(
locations.forEachIndexed { index, data ->
val selected = index == locationPreferenceManager.selectedIndex
NavigationDrawerItem(
label = { Text(text = data.location) },
label = { Text(text = data.location, overflow = TextOverflow.Ellipsis, maxLines = 1) },
icon = {
Icon(
imageVector = Icons.Default.LocationOn,
contentDescription = stringResource(
id = R.string.location
)
)
},
selected = selected,
onClick = {
onClose()
Expand Down

0 comments on commit 841447c

Please sign in to comment.