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

Feat: Left-handed playback controls #700

Merged
merged 2 commits into from
Dec 22, 2024
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
5 changes: 4 additions & 1 deletion .phrasey/schema.toml
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,10 @@ name = "Codec"
name = "ControlsLayout"

[[keys]]
name = "Default"
name = "CompactLeft"

[[keys]]
name = "CompactRight"

[[keys]]
name = "Traditional"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ class Settings(private val symphony: Symphony) {
val nowPlayingControlsLayout = EnumEntry(
"now_playing_controls_layout",
enumEntries<NowPlayingControlsLayout>(),
NowPlayingControlsLayout.Default,
NowPlayingControlsLayout.CompactLeft,
)
val showUpdateToast = BooleanEntry("show_update_toast", true)
val fontScale = FloatEntry("font_scale", 1f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ object NowPlayingDefaults {
}

enum class NowPlayingControlsLayout {
Default,
CompactLeft,
CompactRight,
Traditional,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,48 +163,16 @@ fun NowPlayingBodyContent(context: ViewContext, data: NowPlayingData) {
}
Spacer(modifier = Modifier.height(defaultHorizontalPadding + 8.dp))
when (controlsLayout) {
NowPlayingControlsLayout.Default -> Row(
modifier = Modifier.padding(defaultHorizontalPadding, 0.dp),
horizontalArrangement = Arrangement.spacedBy(12.dp),
) {
NowPlayingPlayPauseButton(
context,
data = data,
style = NowPlayingControlButtonStyle(
color = NowPlayingControlButtonColor.Primary,
),
)
NowPlayingSkipPreviousButton(
context,
data = data,
style = NowPlayingControlButtonStyle(
color = NowPlayingControlButtonColor.Surface,
),
)
if (enableSeekControls) {
NowPlayingFastRewindButton(
context,
data = data,
style = NowPlayingControlButtonStyle(
color = NowPlayingControlButtonColor.Surface,
),
)
NowPlayingFastForwardButton(
context,
data = data,
style = NowPlayingControlButtonStyle(
color = NowPlayingControlButtonColor.Surface,
),
)
}
NowPlayingSkipNextButton(
context,
data = data,
style = NowPlayingControlButtonStyle(
color = NowPlayingControlButtonColor.Surface,
),
)
}
NowPlayingControlsLayout.CompactLeft -> NowPlayingCompactControls(
context,
data = data
)

NowPlayingControlsLayout.CompactRight -> NowPlayingCompactControls(
context,
data = data,
modifier = Modifier.align(Alignment.End)
)

NowPlayingControlsLayout.Traditional -> NowPlayingTraditionalControls(
context,
Expand All @@ -218,6 +186,56 @@ fun NowPlayingBodyContent(context: ViewContext, data: NowPlayingData) {
}
}

@Composable
fun NowPlayingCompactControls(
context: ViewContext,
data: NowPlayingData,
modifier: Modifier = Modifier,
) {
Row(
modifier = modifier.padding(defaultHorizontalPadding, 0.dp),
horizontalArrangement = Arrangement.spacedBy(12.dp),
) {
NowPlayingPlayPauseButton(
context,
data = data,
style = NowPlayingControlButtonStyle(
color = NowPlayingControlButtonColor.Primary,
),
)
NowPlayingSkipPreviousButton(
context,
data = data,
style = NowPlayingControlButtonStyle(
color = NowPlayingControlButtonColor.Surface,
),
)
if (data.enableSeekControls) {
NowPlayingFastRewindButton(
context,
data = data,
style = NowPlayingControlButtonStyle(
color = NowPlayingControlButtonColor.Surface,
),
)
NowPlayingFastForwardButton(
context,
data = data,
style = NowPlayingControlButtonStyle(
color = NowPlayingControlButtonColor.Surface,
),
)
}
NowPlayingSkipNextButton(
context,
data = data,
style = NowPlayingControlButtonStyle(
color = NowPlayingControlButtonColor.Surface,
),
)
}
}

@Composable
fun NowPlayingTraditionalControls(context: ViewContext, data: NowPlayingData) {
Row(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ fun NowPlayingSettingsView(context: ViewContext) {
}

fun NowPlayingControlsLayout.label(context: ViewContext) = when (this) {
NowPlayingControlsLayout.Default -> context.symphony.t.Default
NowPlayingControlsLayout.CompactLeft -> context.symphony.t.CompactLeft
NowPlayingControlsLayout.CompactRight -> context.symphony.t.CompactRight
NowPlayingControlsLayout.Traditional -> context.symphony.t.Traditional
}

Expand Down
3 changes: 2 additions & 1 deletion i18n/en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ ShowSeekControls = "Show seek controls"
Font = "Font"
Codec = "Codec"
ControlsLayout = "Controls layout"
Default = "Default"
CompactLeft = "Compact (left)"
CompactRight = "Compact (right)"
Traditional = "Traditional"
Enabled = "Enabled"
Disabled = "Disabled"
Expand Down