2022-07-18 08:17:40 +06:00
|
|
|
package eu.kanade.presentation.components
|
|
|
|
|
2022-10-30 15:50:09 -04:00
|
|
|
import androidx.annotation.StringRes
|
2022-07-18 08:17:40 +06:00
|
|
|
import androidx.compose.foundation.background
|
2022-10-08 21:24:50 +07:00
|
|
|
import androidx.compose.foundation.layout.Column
|
2022-12-09 23:20:13 +07:00
|
|
|
import androidx.compose.foundation.layout.WindowInsets
|
|
|
|
import androidx.compose.foundation.layout.WindowInsetsSides
|
2022-07-18 08:17:40 +06:00
|
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
2022-12-09 23:20:13 +07:00
|
|
|
import androidx.compose.foundation.layout.only
|
2022-07-18 08:17:40 +06:00
|
|
|
import androidx.compose.foundation.layout.padding
|
2022-12-09 23:20:13 +07:00
|
|
|
import androidx.compose.foundation.layout.systemBars
|
|
|
|
import androidx.compose.foundation.layout.windowInsetsPadding
|
2022-07-18 08:17:40 +06:00
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
|
import androidx.compose.material3.Text
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
import androidx.compose.ui.res.stringResource
|
|
|
|
import androidx.compose.ui.text.style.TextAlign
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
import eu.kanade.tachiyomi.R
|
|
|
|
|
2022-10-30 15:50:09 -04:00
|
|
|
@Composable
|
|
|
|
fun WarningBanner(
|
|
|
|
@StringRes textRes: Int,
|
|
|
|
modifier: Modifier = Modifier,
|
|
|
|
) {
|
|
|
|
Text(
|
|
|
|
text = stringResource(textRes),
|
|
|
|
modifier = modifier
|
|
|
|
.fillMaxWidth()
|
|
|
|
.background(MaterialTheme.colorScheme.error)
|
|
|
|
.padding(16.dp),
|
|
|
|
color = MaterialTheme.colorScheme.onError,
|
|
|
|
style = MaterialTheme.typography.bodyMedium,
|
|
|
|
textAlign = TextAlign.Center,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-07-18 08:17:40 +06:00
|
|
|
@Composable
|
2022-10-08 21:24:50 +07:00
|
|
|
fun AppStateBanners(
|
2022-09-18 16:08:50 -04:00
|
|
|
downloadedOnlyMode: Boolean,
|
|
|
|
incognitoMode: Boolean,
|
2022-10-08 21:24:50 +07:00
|
|
|
modifier: Modifier = Modifier,
|
2022-09-18 16:08:50 -04:00
|
|
|
) {
|
2022-12-09 23:20:13 +07:00
|
|
|
val insets = WindowInsets.systemBars.only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal)
|
2022-10-08 21:24:50 +07:00
|
|
|
Column(modifier = modifier) {
|
|
|
|
if (downloadedOnlyMode) {
|
2022-12-09 23:20:13 +07:00
|
|
|
DownloadedOnlyModeBanner(
|
|
|
|
modifier = Modifier.windowInsetsPadding(insets),
|
|
|
|
)
|
2022-10-08 21:24:50 +07:00
|
|
|
}
|
|
|
|
if (incognitoMode) {
|
2022-12-09 23:20:13 +07:00
|
|
|
IncognitoModeBanner(
|
|
|
|
modifier = if (!downloadedOnlyMode) {
|
|
|
|
Modifier.windowInsetsPadding(insets)
|
|
|
|
} else {
|
|
|
|
Modifier
|
|
|
|
},
|
|
|
|
)
|
2022-10-08 21:24:50 +07:00
|
|
|
}
|
2022-09-18 16:08:50 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Composable
|
2022-12-09 23:20:13 +07:00
|
|
|
private fun DownloadedOnlyModeBanner(modifier: Modifier = Modifier) {
|
2022-07-18 08:17:40 +06:00
|
|
|
Text(
|
|
|
|
text = stringResource(R.string.label_downloaded_only),
|
|
|
|
modifier = Modifier
|
|
|
|
.background(color = MaterialTheme.colorScheme.tertiary)
|
|
|
|
.fillMaxWidth()
|
2022-12-09 23:20:13 +07:00
|
|
|
.padding(4.dp)
|
|
|
|
.then(modifier),
|
2022-07-18 08:17:40 +06:00
|
|
|
color = MaterialTheme.colorScheme.onTertiary,
|
|
|
|
textAlign = TextAlign.Center,
|
|
|
|
style = MaterialTheme.typography.labelMedium,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
@Composable
|
2022-12-09 23:20:13 +07:00
|
|
|
private fun IncognitoModeBanner(modifier: Modifier = Modifier) {
|
2022-07-18 08:17:40 +06:00
|
|
|
Text(
|
|
|
|
text = stringResource(R.string.pref_incognito_mode),
|
|
|
|
modifier = Modifier
|
|
|
|
.background(color = MaterialTheme.colorScheme.primary)
|
|
|
|
.fillMaxWidth()
|
2022-12-09 23:20:13 +07:00
|
|
|
.padding(4.dp)
|
|
|
|
.then(modifier),
|
2022-07-18 08:17:40 +06:00
|
|
|
color = MaterialTheme.colorScheme.onPrimary,
|
|
|
|
textAlign = TextAlign.Center,
|
|
|
|
style = MaterialTheme.typography.labelMedium,
|
|
|
|
)
|
|
|
|
}
|