-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
883481c
commit 0c7d641
Showing
4 changed files
with
111 additions
and
87 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
app/src/main/java/com/dosei/game/blocks/ui/component/ResetIcon.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.dosei.game.blocks.ui.component | ||
|
||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.Refresh | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.scale | ||
import androidx.compose.ui.res.stringResource | ||
import com.dosei.game.blocks.R | ||
|
||
@Composable | ||
fun ResetIcon() { | ||
Icon( | ||
modifier = Modifier.scale(scaleX = -1f, scaleY = 1f), | ||
imageVector = Icons.Default.Refresh, | ||
contentDescription = stringResource(R.string.action_reset) | ||
) | ||
} |
53 changes: 53 additions & 0 deletions
53
app/src/main/java/com/dosei/game/blocks/ui/component/TopBar.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.dosei.game.blocks.ui.component | ||
|
||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.IconButton | ||
import androidx.compose.material3.RichTooltipBox | ||
import androidx.compose.material3.RichTooltipState | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TopAppBar | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.rememberCoroutineScope | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.res.stringResource | ||
import com.dosei.game.blocks.R | ||
import com.dosei.game.blocks.ui.component.ResetIcon | ||
import kotlinx.coroutines.launch | ||
|
||
@Composable | ||
@OptIn(ExperimentalMaterial3Api::class) | ||
fun TopBar(onReset: () -> Unit) { | ||
val scope = rememberCoroutineScope() | ||
val helpState = remember { RichTooltipState() } | ||
TopAppBar( | ||
title = { Text(text = stringResource(id = R.string.app_name)) }, | ||
actions = { | ||
IconButton(onClick = onReset) { | ||
ResetIcon() | ||
} | ||
RichTooltipBox( | ||
modifier = Modifier, | ||
tooltipState = helpState, | ||
title = { Text(stringResource(R.string.help)) }, | ||
text = { Text(stringResource(R.string.gameplay_help)) }, | ||
action = { | ||
Button( | ||
onClick = { scope.launch { helpState.dismiss() } }, | ||
content = { Text(text = stringResource(R.string.understood)) } | ||
) | ||
} | ||
) { | ||
IconButton(onClick = { scope.launch { helpState.show() } }) { | ||
Icon( | ||
painter = painterResource(id = R.drawable.baseline_help_outline_24), | ||
contentDescription = stringResource(R.string.help) | ||
) | ||
} | ||
} | ||
} | ||
) | ||
} |