Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/546 apply the correct icon for floormap #620

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.droidkaigi.confsched2023.main

import androidx.annotation.DrawableRes
import androidx.compose.animation.EnterTransition
import androidx.compose.animation.ExitTransition
import androidx.compose.animation.core.FastOutLinearInEasing
Expand All @@ -16,7 +17,6 @@ import androidx.compose.material.icons.filled.Approval
import androidx.compose.material.icons.filled.CalendarMonth
import androidx.compose.material.icons.filled.Group
import androidx.compose.material.icons.filled.Info
import androidx.compose.material.icons.filled.Map
import androidx.compose.material.icons.outlined.Approval
import androidx.compose.material.icons.outlined.CalendarMonth
import androidx.compose.material.icons.outlined.Group
Expand All @@ -37,6 +37,7 @@ import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import io.github.droidkaigi.confsched2023.feature.main.R
import io.github.droidkaigi.confsched2023.main.component.KaigiBottomBar
import io.github.droidkaigi.confsched2023.main.strings.MainStrings
import io.github.droidkaigi.confsched2023.ui.SnackbarMessageEffect
Expand Down Expand Up @@ -84,40 +85,45 @@ fun MainScreen(
)
}

sealed class IconRepresentation {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implement the selectedIcon of MainScreenTab to make it work with drawable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

data class Vector(val imageVector: ImageVector) : IconRepresentation()
data class Drawable(@DrawableRes val drawableId: Int) : IconRepresentation()
}

enum class MainScreenTab(
val icon: ImageVector,
val selectedIcon: ImageVector,
val selectedIcon: IconRepresentation,
val label: String,
val contentDescription: String,
val testTag: String = "mainScreenTab:$label",
) {
Timetable(
icon = Icons.Outlined.CalendarMonth,
selectedIcon = Icons.Filled.CalendarMonth,
selectedIcon = IconRepresentation.Vector(Icons.Filled.CalendarMonth),
label = MainStrings.Timetable.asString(),
contentDescription = MainStrings.Timetable.asString(),
),
FloorMap(
icon = Icons.Outlined.Map,
selectedIcon = Icons.Filled.Map,
selectedIcon = IconRepresentation.Drawable(drawableId = R.drawable.icon_map_fill),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Icons.Filled.Map did not align with the Figma design, I added the map_fill SVG to display.

label = MainStrings.FloorMap.asString(),
contentDescription = MainStrings.FloorMap.asString(),
),
Badges(
icon = Icons.Outlined.Approval,
selectedIcon = Icons.Filled.Approval,
selectedIcon = IconRepresentation.Vector(Icons.Filled.Approval),
label = MainStrings.Badges.asString(),
contentDescription = MainStrings.Badges.asString(),
),
About(
icon = Icons.Outlined.Info,
selectedIcon = Icons.Filled.Info,
selectedIcon = IconRepresentation.Vector(Icons.Filled.Info),
label = MainStrings.About.asString(),
contentDescription = MainStrings.About.asString(),
),
Contributor(
icon = Icons.Outlined.Group,
selectedIcon = Icons.Filled.Group,
selectedIcon = IconRepresentation.Vector(Icons.Filled.Group),
label = MainStrings.Contributors.asString(),
contentDescription = MainStrings.Contributors.asString(),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextOverflow
import io.github.droidkaigi.confsched2023.main.IconRepresentation.Drawable
import io.github.droidkaigi.confsched2023.main.IconRepresentation.Vector
import io.github.droidkaigi.confsched2023.main.MainScreenTab

@Composable
Expand All @@ -29,10 +32,24 @@ fun KaigiBottomBar(
selected = selected,
onClick = { onTabSelected(tab) },
icon = {
Icon(
imageVector = if (selected) tab.selectedIcon else tab.icon,
contentDescription = tab.contentDescription,
)
if (selected) {
when (val icon = tab.selectedIcon) {
is Drawable -> Icon(
painterResource(id = icon.drawableId),
contentDescription = tab.contentDescription,
)

is Vector -> Icon(
imageVector = icon.imageVector,
contentDescription = tab.contentDescription,
)
}
} else {
Icon(
imageVector = tab.icon,
contentDescription = tab.contentDescription,
)
}
},
label = {
Text(
Expand Down
9 changes: 9 additions & 0 deletions feature/main/src/main/res/drawable/icon_map_fill.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="#FF000000"
android:pathData="m600,840 l-240,-84 -186,72q-20,8 -37,-4.5T120,790v-560q0,-13 7.5,-23t20.5,-15l212,-72 240,84 186,-72q20,-8 37,4.5t17,33.5v560q0,13 -7.5,23T812,768l-212,72ZM560,742v-468l-160,-56v468l160,56Z"/>
</vector>