|
|
@@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.PaddingValues
|
|
|
import androidx.compose.foundation.layout.Row
|
|
|
import androidx.compose.foundation.layout.fillMaxSize
|
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
+import androidx.compose.foundation.layout.navigationBarsPadding
|
|
|
import androidx.compose.foundation.layout.padding
|
|
|
import androidx.compose.foundation.layout.size
|
|
|
import androidx.compose.foundation.layout.width
|
|
|
@@ -14,12 +15,15 @@ import androidx.compose.foundation.lazy.LazyColumn
|
|
|
import androidx.compose.foundation.lazy.items
|
|
|
import androidx.compose.foundation.pager.HorizontalPager
|
|
|
import androidx.compose.foundation.pager.rememberPagerState
|
|
|
+import androidx.compose.foundation.rememberScrollState
|
|
|
+import androidx.compose.foundation.verticalScroll
|
|
|
import androidx.compose.material.icons.Icons
|
|
|
import androidx.compose.material.icons.automirrored.filled.FormatListBulleted
|
|
|
import androidx.compose.material.icons.automirrored.filled.Login
|
|
|
import androidx.compose.material.icons.filled.Check
|
|
|
import androidx.compose.material.icons.filled.CleaningServices
|
|
|
import androidx.compose.material.icons.filled.Dataset
|
|
|
+import androidx.compose.material.icons.filled.Done
|
|
|
import androidx.compose.material.icons.filled.Edit
|
|
|
import androidx.compose.material.icons.filled.History
|
|
|
import androidx.compose.material.icons.filled.Refresh
|
|
|
@@ -33,6 +37,7 @@ import androidx.compose.runtime.mutableStateOf
|
|
|
import androidx.compose.runtime.remember
|
|
|
import androidx.compose.runtime.rememberCoroutineScope
|
|
|
import androidx.compose.runtime.setValue
|
|
|
+import androidx.compose.runtime.Stable
|
|
|
import androidx.compose.ui.Alignment
|
|
|
import androidx.compose.ui.Modifier
|
|
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
|
|
@@ -47,7 +52,9 @@ import io.legado.app.ui.rss.read.title
|
|
|
import io.legado.app.ui.theme.LegadoTheme
|
|
|
import io.legado.app.ui.theme.adaptiveHorizontalPaddingTab
|
|
|
import io.legado.app.ui.widget.components.AppScaffold
|
|
|
+import io.legado.app.ui.widget.components.AppTextField
|
|
|
import io.legado.app.ui.widget.components.EmptyMessage
|
|
|
+import io.legado.app.ui.widget.components.button.series.MediumPlainButton
|
|
|
import io.legado.app.ui.widget.components.button.series.SmallPlainButton
|
|
|
import io.legado.app.ui.widget.components.button.series.SmallToggleButton
|
|
|
import io.legado.app.ui.widget.components.button.series.ToggleStyle
|
|
|
@@ -65,6 +72,13 @@ import io.legado.app.ui.widget.components.topbar.TopBarActionButton
|
|
|
import io.legado.app.ui.widget.components.topbar.TopBarNavigationButton
|
|
|
import kotlinx.coroutines.launch
|
|
|
|
|
|
+@Stable
|
|
|
+data class RssSourceVariableSheetState(
|
|
|
+ val title: String,
|
|
|
+ val variable: String,
|
|
|
+ val comment: String
|
|
|
+)
|
|
|
+
|
|
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
|
@Composable
|
|
|
fun RssSortScreen(
|
|
|
@@ -75,10 +89,13 @@ fun RssSortScreen(
|
|
|
redirectPolicy: RedirectPolicy,
|
|
|
showReadRecordSheet: Boolean,
|
|
|
readRecords: List<RssReadRecord>,
|
|
|
+ sourceVariableSheet: RssSourceVariableSheetState?,
|
|
|
onBackClick: () -> Unit,
|
|
|
onLogin: () -> Unit,
|
|
|
onRefreshSort: () -> Unit,
|
|
|
onSetSourceVariable: () -> Unit,
|
|
|
+ onDismissSourceVariable: () -> Unit,
|
|
|
+ onSaveSourceVariable: (String) -> Unit,
|
|
|
onEditSource: () -> Unit,
|
|
|
onSwitchLayout: () -> Unit,
|
|
|
onReadRecord: () -> Unit,
|
|
|
@@ -305,6 +322,12 @@ fun RssSortScreen(
|
|
|
onClear = onClearReadRecord,
|
|
|
onOpen = onOpenReadRecord
|
|
|
)
|
|
|
+
|
|
|
+ RssSourceVariableSheet(
|
|
|
+ state = sourceVariableSheet,
|
|
|
+ onDismissRequest = onDismissSourceVariable,
|
|
|
+ onSave = onSaveSourceVariable
|
|
|
+ )
|
|
|
}
|
|
|
|
|
|
@Composable
|
|
|
@@ -367,3 +390,48 @@ private fun RssReadRecordSheet(
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+@Composable
|
|
|
+private fun RssSourceVariableSheet(
|
|
|
+ state: RssSourceVariableSheetState?,
|
|
|
+ onDismissRequest: () -> Unit,
|
|
|
+ onSave: (String) -> Unit
|
|
|
+) {
|
|
|
+ var variable by remember(state) { mutableStateOf(state?.variable.orEmpty()) }
|
|
|
+
|
|
|
+ AppModalBottomSheet(
|
|
|
+ data = state,
|
|
|
+ onDismissRequest = onDismissRequest,
|
|
|
+ title = state?.title,
|
|
|
+ endAction = {
|
|
|
+ MediumPlainButton(
|
|
|
+ onClick = { onSave(variable) },
|
|
|
+ icon = Icons.Default.Done,
|
|
|
+ contentDescription = stringResource(R.string.ok)
|
|
|
+ )
|
|
|
+ }
|
|
|
+ ) { sheetState ->
|
|
|
+ Column(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxWidth()
|
|
|
+ .verticalScroll(rememberScrollState())
|
|
|
+ .navigationBarsPadding()
|
|
|
+ .padding(bottom = 32.dp)
|
|
|
+ ) {
|
|
|
+ AppText(
|
|
|
+ text = sheetState.comment,
|
|
|
+ style = LegadoTheme.typography.bodyMedium,
|
|
|
+ color = LegadoTheme.colorScheme.onSurfaceVariant,
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxWidth()
|
|
|
+ .padding(bottom = 12.dp)
|
|
|
+ )
|
|
|
+ AppTextField(
|
|
|
+ value = variable,
|
|
|
+ onValueChange = { variable = it },
|
|
|
+ modifier = Modifier.fillMaxWidth(),
|
|
|
+ minLines = 8
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|