Allow feed name changes when adding subscriptions (#114)
This commit is contained in:
parent
056f641b13
commit
aafdb0a576
|
@ -25,10 +25,12 @@ import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.window.DialogProperties
|
import androidx.compose.ui.window.DialogProperties
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
import androidx.hilt.navigation.compose.hiltViewModel
|
||||||
import me.ash.reader.R
|
import me.ash.reader.R
|
||||||
|
import me.ash.reader.ui.component.RenameDialog
|
||||||
import me.ash.reader.ui.component.base.ClipboardTextField
|
import me.ash.reader.ui.component.base.ClipboardTextField
|
||||||
import me.ash.reader.ui.component.base.RYDialog
|
import me.ash.reader.ui.component.base.RYDialog
|
||||||
import me.ash.reader.ui.component.base.TextFieldDialog
|
import me.ash.reader.ui.component.base.TextFieldDialog
|
||||||
import me.ash.reader.ui.ext.collectAsStateValue
|
import me.ash.reader.ui.ext.collectAsStateValue
|
||||||
|
import me.ash.reader.ui.ext.roundClick
|
||||||
import me.ash.reader.ui.page.home.feeds.FeedOptionView
|
import me.ash.reader.ui.page.home.feeds.FeedOptionView
|
||||||
|
|
||||||
@OptIn(
|
@OptIn(
|
||||||
|
@ -76,6 +78,9 @@ fun SubscribeDialog(
|
||||||
},
|
},
|
||||||
title = {
|
title = {
|
||||||
Text(
|
Text(
|
||||||
|
modifier = Modifier.roundClick {
|
||||||
|
subscribeViewModel.showRenameDialog()
|
||||||
|
},
|
||||||
text = if (subscribeUiState.isSearchPage) {
|
text = if (subscribeUiState.isSearchPage) {
|
||||||
subscribeUiState.title
|
subscribeUiState.title
|
||||||
} else {
|
} else {
|
||||||
|
@ -185,6 +190,21 @@ fun SubscribeDialog(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
RenameDialog(
|
||||||
|
visible = subscribeUiState.renameDialogVisible,
|
||||||
|
value = subscribeUiState.newName,
|
||||||
|
onValueChange = {
|
||||||
|
subscribeViewModel.inputNewName(it)
|
||||||
|
},
|
||||||
|
onDismissRequest = {
|
||||||
|
subscribeViewModel.hideRenameDialog()
|
||||||
|
},
|
||||||
|
onConfirm = {
|
||||||
|
subscribeViewModel.renameFeed()
|
||||||
|
subscribeViewModel.hideRenameDialog()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
TextFieldDialog(
|
TextFieldDialog(
|
||||||
visible = subscribeUiState.newGroupDialogVisible,
|
visible = subscribeUiState.newGroupDialogVisible,
|
||||||
title = stringResource(R.string.create_new_group),
|
title = stringResource(R.string.create_new_group),
|
||||||
|
|
|
@ -189,6 +189,38 @@ class SubscribeViewModel @Inject constructor(
|
||||||
fun switchPage(isSearchPage: Boolean) {
|
fun switchPage(isSearchPage: Boolean) {
|
||||||
_subscribeUiState.update { it.copy(isSearchPage = isSearchPage) }
|
_subscribeUiState.update { it.copy(isSearchPage = isSearchPage) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun showRenameDialog() {
|
||||||
|
_subscribeUiState.update {
|
||||||
|
it.copy(
|
||||||
|
renameDialogVisible = true,
|
||||||
|
newName = _subscribeUiState.value.feed?.name ?: "",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun hideRenameDialog() {
|
||||||
|
_subscribeUiState.update {
|
||||||
|
it.copy(
|
||||||
|
renameDialogVisible = false,
|
||||||
|
newName = "",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun inputNewName(content: String) {
|
||||||
|
_subscribeUiState.update { it.copy(newName = content) }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun renameFeed() {
|
||||||
|
_subscribeUiState.value.feed?.let {
|
||||||
|
_subscribeUiState.update {
|
||||||
|
it.copy(
|
||||||
|
feed = it.feed?.copy(name = _subscribeUiState.value.newName),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class SubscribeUiState(
|
data class SubscribeUiState(
|
||||||
|
@ -206,4 +238,6 @@ data class SubscribeUiState(
|
||||||
val newGroupContent: String = "",
|
val newGroupContent: String = "",
|
||||||
val groups: Flow<List<Group>> = emptyFlow(),
|
val groups: Flow<List<Group>> = emptyFlow(),
|
||||||
val isSearchPage: Boolean = true,
|
val isSearchPage: Boolean = true,
|
||||||
|
val newName: String = "",
|
||||||
|
val renameDialogVisible: Boolean = false,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user