-
Notifications
You must be signed in to change notification settings - Fork 506
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework Duplicate Dialog and Allow Migration (#492)
* (Mostly) Working Manga screen migration via duplicate dialog * Fully working migrate from Browse Search * Small tweaks for Antsy * Update app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/BrowseSourceScreenModel.kt * Update app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreen.kt --------- Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
- Loading branch information
Showing
7 changed files
with
155 additions
and
44 deletions.
There are no files selected for viewing
139 changes: 103 additions & 36 deletions
139
app/src/main/java/eu/kanade/presentation/manga/DuplicateMangaDialog.kt
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 |
---|---|---|
@@ -1,59 +1,126 @@ | ||
package eu.kanade.presentation.manga | ||
|
||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.FlowRow | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.material3.AlertDialog | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.sizeIn | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.outlined.Add | ||
import androidx.compose.material.icons.outlined.Book | ||
import androidx.compose.material.icons.outlined.SwapVert | ||
import androidx.compose.material3.HorizontalDivider | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.OutlinedButton | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TextButton | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import eu.kanade.presentation.components.AdaptiveSheet | ||
import eu.kanade.presentation.components.TabbedDialogPaddings | ||
import eu.kanade.presentation.more.settings.LocalPreferenceMinHeight | ||
import eu.kanade.presentation.more.settings.widget.TextPreferenceWidget | ||
import tachiyomi.i18n.MR | ||
import tachiyomi.presentation.core.components.material.padding | ||
import tachiyomi.presentation.core.i18n.stringResource | ||
|
||
@Composable | ||
fun DuplicateMangaDialog( | ||
onDismissRequest: () -> Unit, | ||
onConfirm: () -> Unit, | ||
onOpenManga: () -> Unit, | ||
onMigrate: () -> Unit, | ||
modifier: Modifier = Modifier, | ||
) { | ||
AlertDialog( | ||
val minHeight = LocalPreferenceMinHeight.current | ||
|
||
AdaptiveSheet( | ||
modifier = modifier, | ||
onDismissRequest = onDismissRequest, | ||
title = { | ||
Text(text = stringResource(MR.strings.are_you_sure)) | ||
}, | ||
text = { | ||
Text(text = stringResource(MR.strings.confirm_add_duplicate_manga)) | ||
}, | ||
confirmButton = { | ||
FlowRow( | ||
horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.extraSmall), | ||
) { | ||
TextButton( | ||
onClick = { | ||
onDismissRequest() | ||
onOpenManga() | ||
}, | ||
) { | ||
Text(text = stringResource(MR.strings.action_show_manga)) | ||
} | ||
) { | ||
Column( | ||
modifier = Modifier | ||
.padding( | ||
vertical = TabbedDialogPaddings.Vertical, | ||
horizontal = TabbedDialogPaddings.Horizontal, | ||
) | ||
.fillMaxWidth(), | ||
) { | ||
Text( | ||
modifier = Modifier.padding(TitlePadding), | ||
text = stringResource(MR.strings.are_you_sure), | ||
style = MaterialTheme.typography.headlineMedium, | ||
) | ||
|
||
Spacer(modifier = Modifier.weight(1f)) | ||
Text( | ||
text = stringResource(MR.strings.confirm_add_duplicate_manga), | ||
style = MaterialTheme.typography.bodyMedium, | ||
) | ||
|
||
TextButton(onClick = onDismissRequest) { | ||
Text(text = stringResource(MR.strings.action_cancel)) | ||
} | ||
TextButton( | ||
onClick = { | ||
onDismissRequest() | ||
onConfirm() | ||
}, | ||
) { | ||
Text(text = stringResource(MR.strings.action_add)) | ||
Spacer(Modifier.height(PaddingSize)) | ||
|
||
TextPreferenceWidget( | ||
title = stringResource(MR.strings.action_show_manga), | ||
icon = Icons.Outlined.Book, | ||
onPreferenceClick = { | ||
onDismissRequest() | ||
onOpenManga() | ||
}, | ||
) | ||
|
||
HorizontalDivider() | ||
|
||
TextPreferenceWidget( | ||
title = stringResource(MR.strings.action_migrate_duplicate), | ||
icon = Icons.Outlined.SwapVert, | ||
onPreferenceClick = { | ||
onDismissRequest() | ||
onMigrate() | ||
}, | ||
) | ||
|
||
HorizontalDivider() | ||
|
||
TextPreferenceWidget( | ||
title = stringResource(MR.strings.action_add_anyway), | ||
icon = Icons.Outlined.Add, | ||
onPreferenceClick = { | ||
onDismissRequest() | ||
onConfirm() | ||
}, | ||
) | ||
|
||
Row( | ||
modifier = Modifier | ||
.sizeIn(minHeight = minHeight) | ||
.clickable { onDismissRequest.invoke() } | ||
.padding(ButtonPadding) | ||
.fillMaxWidth(), | ||
verticalAlignment = Alignment.CenterVertically, | ||
horizontalArrangement = Arrangement.Center, | ||
) { | ||
OutlinedButton(onClick = onDismissRequest, modifier = Modifier.fillMaxWidth()) { | ||
Text( | ||
modifier = Modifier | ||
.padding(vertical = 8.dp), | ||
text = stringResource(MR.strings.action_cancel), | ||
color = MaterialTheme.colorScheme.primary, | ||
style = MaterialTheme.typography.titleLarge, | ||
fontSize = 16.sp, | ||
) | ||
} | ||
} | ||
}, | ||
) | ||
} | ||
} | ||
} | ||
|
||
private val PaddingSize = 16.dp | ||
|
||
private val ButtonPadding = PaddingValues(top = 16.dp, bottom = 16.dp) | ||
private val TitlePadding = PaddingValues(bottom = 16.dp, top = 8.dp) |
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
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