Skip to content

Commit

Permalink
refactor(android): rename compose preview functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Oppzippy committed Jul 5, 2023
1 parent 59b5d02 commit 402ec9f
Show file tree
Hide file tree
Showing 18 changed files with 83 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private fun HtmlText(text: String, modifier: Modifier = Modifier) {

@Preview(showBackground = true)
@Composable
private fun DefaultPreview() {
private fun PreviewAppInfo() {
OpenSCQ30Theme {
AppInfo(onBackClick = {})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fun DeviceList(

@Preview(showBackground = true)
@Composable
private fun DefaultPreview() {
private fun PreviewDeviceList() {
OpenSCQ30Theme {
val devices = ArrayList<BluetoothDevice>()
for (i in 1..100) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ fun DeviceListing(

@Preview(showBackground = true)
@Composable
private fun NoDevicesFoundPreview() {
private fun PreviewNoDevicesFound() {
OpenSCQ30Theme {
DeviceListing(listOf())
}
}

@Preview(showBackground = true)
@Composable
private fun DevicesPreview() {
private fun PreviewDeviceListing() {
OpenSCQ30Theme {
val devices = ArrayList<BluetoothDevice>()
for (i in 1..100) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fun NoDevicesFound(modifier: Modifier = Modifier) {

@Preview(showBackground = true)
@Composable
private fun DefaultPreview() {
private fun PreviewNoDevicesFound() {
OpenSCQ30Theme {
NoDevicesFound()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ fun DeviceSettings(

@Preview(showBackground = true)
@Composable
private fun DefaultPreview() {
private fun PreviewDeviceSettings() {
OpenSCQ30Theme {
DeviceSettings(
uiState = UiDeviceState.Connected(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fun Disconnected() {

@Preview(showBackground = true)
@Composable
private fun DefaultPreview() {
private fun PreviewDisconnected() {
OpenSCQ30Theme {
Disconnected()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fun Loading() {

@Preview(showBackground = true)
@Composable
private fun DefaultPreview() {
private fun PreviewLoading() {
OpenSCQ30Theme {
Loading()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private fun LabeledRadioButton(text: String, selected: Boolean, onClick: () -> U

@Preview(showBackground = true)
@Composable
private fun DefaultPreview() {
private fun PreviewSoundModeSettings() {
OpenSCQ30Theme {
SoundModeSettings(
ambientSoundMode = AmbientSoundMode.Normal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import com.oppzippy.openscq30.R
import com.oppzippy.openscq30.ui.equalizer.storage.CustomProfile
import com.oppzippy.openscq30.ui.theme.OpenSCQ30Theme

@Composable
fun CreateCustomProfileDialog(
Expand Down Expand Up @@ -57,3 +59,21 @@ fun CreateCustomProfileDialog(
)
}
}

@Preview(showBackground = true)
@Composable
private fun PreviewCreateCustomProfileDialog() {
OpenSCQ30Theme {
CreateCustomProfileDialog(
isOpen = true,
onDismiss = {},
onCreateCustomProfile = {},
existingProfiles = listOf(
CustomProfile(
"Test Profile",
listOf(1, 2, 3, 4, 5, 6, 7, 8),
),
),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package com.oppzippy.openscq30.ui.equalizer.composables

import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import com.oppzippy.openscq30.R
import com.oppzippy.openscq30.ui.equalizer.storage.CustomProfile
import com.oppzippy.openscq30.ui.theme.OpenSCQ30Theme

@Composable
fun CustomProfileSelection(
Expand All @@ -22,3 +24,16 @@ fun CustomProfileSelection(
onItemSelected = onProfileSelected,
)
}

@Preview(showBackground = true)
@Composable
private fun PreviewCustomProfileSelection() {
val selectedProfile = CustomProfile("Test Profile", listOf(0, 10, 20, 30, 40, 50, 60, 70))
OpenSCQ30Theme {
CustomProfileSelection(
selectedProfile = selectedProfile,
profiles = listOf(selectedProfile),
onProfileSelected = {},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import com.oppzippy.openscq30.R
import com.oppzippy.openscq30.ui.theme.OpenSCQ30Theme

@Composable
fun DeleteCustomProfileDialog(
Expand Down Expand Up @@ -39,3 +41,16 @@ fun DeleteCustomProfileDialog(
)
}
}

@Preview(showBackground = true)
@Composable
private fun PreviewDeleteCustomProfileDialog() {
OpenSCQ30Theme {
DeleteCustomProfileDialog(
isOpen = true,
profileName = "Test Profile",
onDelete = {},
onDismiss = {},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fun <T> Dropdown(

@Preview(showBackground = true)
@Composable
private fun DefaultPreview() {
private fun PreviewDropdown() {
OpenSCQ30Theme {
var value by remember { mutableStateOf(1) }
Dropdown(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fun Equalizer(

@Preview(showBackground = true)
@Composable
private fun DefaultPreview() {
private fun PreviewEqualizer() {
var values by remember { mutableStateOf(listOf<Byte>(0, 0, 0, 0, 0, 0, 0, 0)) }
OpenSCQ30Theme {
Equalizer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fun EqualizerLine(values: List<Byte>, width: Dp, height: Dp) {

@Preview(showBackground = true)
@Composable
private fun DefaultPreview() {
private fun PreviewEqualizerLine() {
val values by remember { mutableStateOf(listOf<Byte>(0, 10, 120, 0, -10, -120, 0, 0)) }
OpenSCQ30Theme {
EqualizerLine(values = values, width = 80.dp, height = 20.dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fun EqualizerSlider(

@Preview(showBackground = true)
@Composable
private fun DefaultPreview() {
private fun PreviewEqualizerSlider() {
OpenSCQ30Theme {
EqualizerSlider(hz = 100, value = 0, onValueChange = {}, text = "0", onTextChange = {})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fun PresetProfileSelection(

@Preview(showBackground = true)
@Composable
private fun DefaultPreview() {
private fun PreviewPresetProfileSelection() {
OpenSCQ30Theme {
var profile by remember { mutableStateOf(EqualizerProfile.Classical) }
PresetProfileSelection(value = profile, onProfileSelected = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fun ProfileSelectionRow(name: String, volumeAdjustments: List<Byte>?) {

@Preview(showBackground = true)
@Composable
private fun DefaultPreview() {
private fun PreviewProfileSelectionRow() {
OpenSCQ30Theme {
ProfileSelectionRow(
name = "Test Profile",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.oppzippy.openscq30.R
import com.oppzippy.openscq30.ui.equalizer.storage.CustomProfile
import com.oppzippy.openscq30.ui.theme.OpenSCQ30Theme

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand Down Expand Up @@ -71,3 +73,19 @@ fun ReplaceCustomProfileDialog(
}
}
}

@Preview(showBackground = true)
@Composable
private fun PreviewReplaceCustomProfileDialog() {
OpenSCQ30Theme {
ReplaceCustomProfileDialog(
isOpen = true,
profiles = listOf(
CustomProfile("Test Profile 1", listOf(0, -10, 20, 30, 40, 50, 60, 70)),
CustomProfile("Test Profile 2", listOf(-50, -20, 30, 40, 50, 60, 70, 80)),
),
onDismiss = {},
onProfileSelected = {},
)
}
}

0 comments on commit 402ec9f

Please sign in to comment.