Skip to content

Commit 517a609

Browse files
committed
🔧 updated Lrc Correct dialog
1 parent 27b8656 commit 517a609

File tree

2 files changed

+122
-74
lines changed

2 files changed

+122
-74
lines changed

app/src/main/java/com/shub39/rush/presentation/lyrics/component/LrcCorrectDialog.kt

Lines changed: 114 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ import androidx.compose.foundation.layout.padding
2626
import androidx.compose.foundation.layout.size
2727
import androidx.compose.foundation.lazy.LazyColumn
2828
import androidx.compose.foundation.lazy.itemsIndexed
29+
import androidx.compose.foundation.shape.RoundedCornerShape
2930
import androidx.compose.material3.Button
3031
import androidx.compose.material3.Card
3132
import androidx.compose.material3.CardDefaults
3233
import androidx.compose.material3.CircularProgressIndicator
3334
import androidx.compose.material3.ExperimentalMaterial3Api
34-
import androidx.compose.material3.HorizontalDivider
3535
import androidx.compose.material3.Icon
3636
import androidx.compose.material3.MaterialTheme
3737
import androidx.compose.material3.OutlinedTextField
@@ -43,15 +43,21 @@ import androidx.compose.runtime.remember
4343
import androidx.compose.runtime.setValue
4444
import androidx.compose.ui.Alignment
4545
import androidx.compose.ui.Modifier
46+
import androidx.compose.ui.draw.clip
4647
import androidx.compose.ui.graphics.StrokeCap
4748
import androidx.compose.ui.res.painterResource
4849
import androidx.compose.ui.res.stringResource
4950
import androidx.compose.ui.text.font.FontWeight
5051
import androidx.compose.ui.text.style.TextOverflow
52+
import androidx.compose.ui.tooling.preview.Preview
5153
import androidx.compose.ui.unit.dp
5254
import com.shub39.rush.R
55+
import com.shub39.rush.domain.dataclasses.Theme
56+
import com.shub39.rush.domain.enums.AppTheme
5357
import com.shub39.rush.domain.interfaces.CorrectionSearchResult
5458
import com.shub39.rush.presentation.components.RushDialog
59+
import com.shub39.rush.presentation.components.RushTheme
60+
import com.shub39.rush.presentation.lyrics.LrcCorrect
5561
import com.shub39.rush.presentation.lyrics.LyricsPageAction
5662
import com.shub39.rush.presentation.lyrics.LyricsPageState
5763
import com.shub39.rush.presentation.lyrics.LyricsState
@@ -74,7 +80,6 @@ fun LrcCorrectDialog(
7480
) {
7581
Column(
7682
modifier = Modifier.fillMaxWidth().padding(top = 32.dp),
77-
horizontalAlignment = Alignment.CenterHorizontally,
7883
verticalArrangement = Arrangement.spacedBy(8.dp),
7984
) {
8085
Text(
@@ -127,75 +132,121 @@ fun LrcCorrectDialog(
127132
}
128133
}
129134

130-
Column {
131-
HorizontalDivider()
132-
LazyColumn(
133-
verticalArrangement = Arrangement.spacedBy(4.dp),
134-
contentPadding = PaddingValues(16.dp),
135-
) {
136-
itemsIndexed(state.lrcCorrect.searchResults) { _, result ->
137-
Card(
138-
onClick = {
139-
(state.lyricsState as? LyricsState.Loaded)?.song?.id?.let {
140-
action(LyricsPageAction.OnUpdateSongLyrics(it, result))
141-
}
142-
action(LyricsPageAction.OnLyricsCorrect(false))
143-
},
144-
colors = CardDefaults.elevatedCardColors(),
145-
shape = MaterialTheme.shapes.extraLarge,
146-
) {
147-
Column(modifier = Modifier.fillMaxWidth().padding(16.dp)) {
148-
Row(
149-
verticalAlignment = Alignment.CenterVertically,
150-
horizontalArrangement = Arrangement.spacedBy(4.dp),
151-
) {
152-
Icon(
153-
painter =
154-
painterResource(
155-
if (
156-
result
157-
is
158-
CorrectionSearchResult.PlainLyricsSearchResult
159-
) {
160-
R.drawable.quote
161-
} else R.drawable.sync
162-
),
163-
modifier = Modifier.size(20.dp),
164-
contentDescription = null,
165-
)
166-
167-
Text(
168-
text =
169-
stringResource(
170-
when (result) {
171-
is CorrectionSearchResult.LineSyncedLyricsSearchResult ->
172-
R.string.line_synced_lyrics
173-
is CorrectionSearchResult.PlainLyricsSearchResult ->
174-
R.string.plain_lyrics
175-
is CorrectionSearchResult.SyllableSyncedLyricsSearchResult ->
176-
R.string.syllable_synced_lyrics
177-
}
178-
),
179-
style = MaterialTheme.typography.labelLarge,
180-
)
181-
}
182-
183-
Text(
184-
text = result.title,
185-
maxLines = 1,
186-
overflow = TextOverflow.Ellipsis,
135+
LazyColumn(
136+
verticalArrangement = Arrangement.spacedBy(2.dp),
137+
contentPadding = PaddingValues(top = 16.dp, bottom = 60.dp),
138+
modifier =
139+
Modifier.padding(horizontal = 16.dp)
140+
.clip(RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp)),
141+
) {
142+
itemsIndexed(state.lrcCorrect.searchResults) { _, result ->
143+
Card(
144+
onClick = {
145+
(state.lyricsState as? LyricsState.Loaded)?.song?.id?.let {
146+
action(LyricsPageAction.OnUpdateSongLyrics(it, result))
147+
}
148+
action(LyricsPageAction.OnLyricsCorrect(false))
149+
},
150+
colors =
151+
CardDefaults.cardColors(
152+
containerColor = MaterialTheme.colorScheme.surfaceContainerHigh
153+
),
154+
shape = MaterialTheme.shapes.large,
155+
) {
156+
Column(modifier = Modifier.fillMaxWidth().padding(16.dp)) {
157+
Row(
158+
verticalAlignment = Alignment.CenterVertically,
159+
horizontalArrangement = Arrangement.spacedBy(4.dp),
160+
) {
161+
Icon(
162+
painter =
163+
painterResource(
164+
if (
165+
result
166+
is
167+
CorrectionSearchResult.PlainLyricsSearchResult
168+
) {
169+
R.drawable.quote
170+
} else R.drawable.sync
171+
),
172+
modifier = Modifier.size(14.dp),
173+
contentDescription = null,
187174
)
175+
188176
Text(
189-
text = result.artist,
190-
style = MaterialTheme.typography.bodySmall,
191-
maxLines = 1,
192-
overflow = TextOverflow.Ellipsis,
177+
text =
178+
stringResource(
179+
when (result) {
180+
is CorrectionSearchResult.LineSyncedLyricsSearchResult ->
181+
R.string.line_synced_lyrics
182+
183+
is CorrectionSearchResult.PlainLyricsSearchResult ->
184+
R.string.plain_lyrics
185+
186+
is CorrectionSearchResult.SyllableSyncedLyricsSearchResult ->
187+
R.string.syllable_synced_lyrics
188+
}
189+
),
190+
style = MaterialTheme.typography.labelSmall,
193191
)
194192
}
193+
194+
Text(
195+
text = result.title,
196+
maxLines = 1,
197+
overflow = TextOverflow.Ellipsis,
198+
)
199+
Text(
200+
text = result.artist,
201+
style = MaterialTheme.typography.bodySmall,
202+
maxLines = 1,
203+
overflow = TextOverflow.Ellipsis,
204+
)
195205
}
196206
}
197207
}
198208
}
199209
}
200210
}
201211
}
212+
213+
@Preview
214+
@Composable
215+
private fun Preview() {
216+
RushTheme(theme = Theme(appTheme = AppTheme.DARK)) {
217+
LrcCorrectDialog(
218+
track = "Track Name",
219+
artist = "Artist Name",
220+
action = {},
221+
state =
222+
LyricsPageState(
223+
lrcCorrect =
224+
LrcCorrect(
225+
searchResults =
226+
(0..3).map {
227+
CorrectionSearchResult.PlainLyricsSearchResult(
228+
plainLyrics = "TODO()",
229+
title = "Song One",
230+
artist = "GABsdjhgva",
231+
)
232+
} +
233+
(0..3).map {
234+
CorrectionSearchResult.LineSyncedLyricsSearchResult(
235+
lineSyncedLyrics = "TODO",
236+
plainLyrics = "TODO",
237+
title = "Synced Song",
238+
artist = "Sync Joe",
239+
)
240+
} +
241+
(0..3).map {
242+
CorrectionSearchResult.SyllableSyncedLyricsSearchResult(
243+
syllableSyncedLyrics = "TODO()",
244+
title = "Syllable Search",
245+
artist = "ligma",
246+
)
247+
}
248+
)
249+
),
250+
)
251+
}
252+
}

app/src/main/java/com/shub39/rush/presentation/share/component/SharePageSheet.kt

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ fun SharePageSheet(
9494
modifier = modifier,
9595
) {
9696
LazyColumn(
97-
modifier = Modifier
98-
.fillMaxWidth()
99-
.padding(horizontal = 16.dp)
100-
.heightIn(max = 500.dp)
101-
.clip(RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp)),
97+
modifier =
98+
Modifier.fillMaxWidth()
99+
.padding(horizontal = 16.dp)
100+
.heightIn(max = 500.dp)
101+
.clip(RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp)),
102102
contentPadding = PaddingValues(top = 16.dp, bottom = 60.dp),
103103
verticalArrangement = Arrangement.spacedBy(2.dp),
104104
horizontalAlignment = Alignment.CenterHorizontally,
@@ -202,8 +202,7 @@ fun SharePageSheet(
202202
labelProvider = {
203203
Box(
204204
modifier =
205-
Modifier
206-
.size(20.dp)
205+
Modifier.size(20.dp)
207206
.background(
208207
color = MaterialTheme.colorScheme.onSurface,
209208
shape = it.toShape(),
@@ -241,9 +240,7 @@ fun SharePageSheet(
241240
Text(
242241
text = "Show Rush Branding",
243242
maxLines = 1,
244-
modifier = Modifier
245-
.basicMarquee()
246-
.weight(1f),
243+
modifier = Modifier.basicMarquee().weight(1f),
247244
)
248245
},
249246
trailingContent = {
@@ -257,7 +254,7 @@ fun SharePageSheet(
257254
}
258255
},
259256
)
260-
}
257+
},
261258
)
262259
}
263260
}

0 commit comments

Comments
 (0)