-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature] Support selecting subtitle track
- Loading branch information
Showing
7 changed files
with
149 additions
and
14 deletions.
There are no files selected for viewing
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
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
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
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
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,55 @@ | ||
package com.skyd.anivu.ui.mpv | ||
|
||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.rounded.Check | ||
import androidx.compose.material3.DropdownMenu | ||
import androidx.compose.material3.DropdownMenuItem | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.MenuDefaults | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.unit.dp | ||
import com.skyd.anivu.R | ||
|
||
data class SubtitleTrackMenuState( | ||
val expanded: Boolean, | ||
val currentSubtitleTrack: MPVView.Track, | ||
val subtitleTrack: List<MPVView.Track>, | ||
) | ||
|
||
@Composable | ||
internal fun SubtitleTrackMenu( | ||
onDismissRequest: () -> Unit, | ||
subtitleTrackMenuState: () -> SubtitleTrackMenuState, | ||
onSubtitleTrackChanged: (MPVView.Track) -> Unit, | ||
) { | ||
val state = subtitleTrackMenuState() | ||
DropdownMenu( | ||
expanded = state.expanded, | ||
onDismissRequest = onDismissRequest, | ||
containerColor = ControllerLabelGray, | ||
shadowElevation = 0.dp, | ||
) { | ||
repeat(state.subtitleTrack.size) { index -> | ||
val track = state.subtitleTrack[index] | ||
DropdownMenuItem( | ||
text = { Text(track.name) }, | ||
onClick = { onSubtitleTrackChanged(track) }, | ||
leadingIcon = { | ||
if (state.currentSubtitleTrack.trackId == track.trackId) { | ||
Icon( | ||
imageVector = Icons.Rounded.Check, | ||
contentDescription = stringResource(id = R.string.item_selected) | ||
) | ||
} | ||
}, | ||
colors = MenuDefaults.itemColors().copy( | ||
textColor = Color.White, | ||
leadingIconColor = Color.White, | ||
) | ||
) | ||
} | ||
} | ||
} |
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
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