This file contains hidden or 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
private enum class EvenSplitElements { | |
Left, | |
Right | |
} | |
@Composable | |
fun EvenSplitDuo( | |
modifier: Modifier = Modifier, | |
leftContent: @Composable () -> Unit, | |
rightContent: @Composable () -> Unit, |
This file contains hidden or 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
@Composable | |
fun EqualSizeTiles( | |
modifier: Modifier = Modifier, | |
content: @Composable () -> Unit, | |
) { | |
Layout( | |
content = content, | |
modifier = modifier, | |
) { measurables, constraints -> | |
layoutTiles( |
This file contains hidden or 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
enum class AppTheme { | |
MODE_DAY, | |
MODE_NIGHT, | |
MODE_AUTO; | |
companion object { | |
fun fromOrdinal(ordinal: Int) = values()[ordinal] | |
} | |
} |
This file contains hidden or 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
interface UserSettings { | |
val themeStream: StateFlow<AppTheme> | |
var theme: AppTheme | |
} | |
class UserSettingsImpl @Inject constructor( | |
@ApplicationContext context: Context | |
) : UserSettings { | |
override val themeStream: MutableStateFlow<AppTheme> |
This file contains hidden or 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
data class RadioButtonItem( | |
val id: Int, | |
val title: String, | |
) | |
@Composable | |
private fun RadioGroupItem( | |
item: RadioButtonItem, | |
selected: Boolean, | |
onClick: ((Int) -> Unit)?, |
This file contains hidden or 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
@Composable | |
fun RadioGroup( | |
items: Iterable<RadioButtonItem>, | |
selected: Int, | |
onItemSelect: ((Int) -> Unit)?, | |
modifier: Modifier = Modifier, | |
) { | |
Column( | |
modifier = modifier.selectableGroup() | |
) { |
This file contains hidden or 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
@AndroidEntryPoint | |
class MainActivity : ComponentActivity() { | |
@Inject | |
lateinit var userSettings: UserSettings | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContent { | |
val theme = userSettings.themeStream.collectAsState() |
This file contains hidden or 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
@Composable | |
fun InfoLabels( | |
modifier: Modifier = Modifier, | |
content: @Composable () -> Unit, | |
) { | |
// 1 | |
Layout( | |
content = content, | |
modifier = modifier, | |
) { measurables, constraints -> |
This file contains hidden or 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
enum class InfoAlignment { | |
Top, | |
Center, | |
Bottom, | |
} |
This file contains hidden or 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
// 1 | |
interface InfoLabelsScope { | |
@Stable | |
// 2 | |
fun Modifier.align(alignment: InfoAlignment) = this.then( | |
// 3 | |
InfoLabelsData( | |
alignment = alignment, | |
) | |
) |