Skip to content

Commit

Permalink
feat: left-handed playback controls (zyrouge#700)
Browse files Browse the repository at this point in the history
  • Loading branch information
sevonj authored Dec 22, 2024
1 parent 4c6d8b5 commit d5f4f45
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 47 deletions.
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

0 comments on commit d5f4f45

Please sign in to comment.