mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-10 18:10:44 +09:00
When navigating to a document via search-screen, open this new document without passing by dashboard-screen (#844)
This commit is contained in:
parent
080a310540
commit
be8dd22bd0
8 changed files with 37 additions and 19 deletions
|
@ -14,6 +14,7 @@
|
|||
|
||||
### Fixes & tech 🚒
|
||||
|
||||
* When navigating to a document via search-screen, open this new document without passing by dashboard-screen (#830)
|
||||
* Inconsistent logic when adding markup in certain corner cases (#509)
|
||||
* If you change checkbox's text color and then check off this checkbox, its text color always becomes black whereas it should have the color that you've set before (#785)
|
||||
|
||||
|
|
|
@ -81,6 +81,17 @@ class Navigator : AppNavigation {
|
|||
)
|
||||
}
|
||||
|
||||
override fun launchDocument(id: String) {
|
||||
navController?.navigate(
|
||||
R.id.pageScreen,
|
||||
bundleOf(PageFragment.ID_KEY to id),
|
||||
navOptions {
|
||||
popUpTo = R.id.desktopScreen
|
||||
launchSingleTop = true
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
override fun openKeychainScreen() {
|
||||
navController?.navigate(R.id.action_open_keychain)
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ abstract class NavigationFragment(
|
|||
is Command.ConfirmPinCodeScreen -> navigation.confirmPinCode(command.code)
|
||||
is Command.OpenProfile -> navigation.openProfile()
|
||||
is Command.OpenPage -> navigation.openDocument(command.id, command.editorSettings)
|
||||
is Command.LaunchDocument -> navigation.launchDocument(command.id)
|
||||
is Command.OpenDatabaseViewAddView -> navigation.openDatabaseViewAddView()
|
||||
is Command.OpenEditDatabase -> navigation.openEditDatabase()
|
||||
is Command.OpenKeychainScreen -> navigation.openKeychainScreen()
|
||||
|
|
|
@ -4,7 +4,7 @@ import android.os.Bundle
|
|||
import android.view.View
|
||||
import android.widget.EditText
|
||||
import androidx.core.widget.doAfterTextChanged
|
||||
import androidx.lifecycle.ViewModelProviders
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.agileburo.anytype.R
|
||||
import com.agileburo.anytype.core_ui.features.navigation.PageLinksAdapter
|
||||
|
@ -23,13 +23,16 @@ class PageSearchFragment : ViewStateFragment<PageSearchView>(R.layout.fragment_p
|
|||
@Inject
|
||||
lateinit var factory: PageSearchViewModelFactory
|
||||
|
||||
lateinit var clearSearchText: View
|
||||
lateinit var filterInputField: EditText
|
||||
private lateinit var clearSearchText: View
|
||||
private lateinit var filterInputField: EditText
|
||||
|
||||
private val vm by lazy {
|
||||
ViewModelProviders
|
||||
.of(this, factory)
|
||||
.get(PageSearchViewModel::class.java)
|
||||
private val vm by viewModels<PageSearchViewModel> { factory }
|
||||
|
||||
private val searchAdapter by lazy {
|
||||
PageLinksAdapter(
|
||||
data = emptyList(),
|
||||
onClick = vm::onOpenPageClicked
|
||||
)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
|
@ -65,11 +68,7 @@ class PageSearchFragment : ViewStateFragment<PageSearchView>(R.layout.fragment_p
|
|||
}
|
||||
}
|
||||
recyclerView.layoutManager = LinearLayoutManager(requireContext())
|
||||
recyclerView.adapter =
|
||||
PageLinksAdapter(
|
||||
data = mutableListOf(),
|
||||
onClick = vm::onOpenPageClicked
|
||||
)
|
||||
recyclerView.adapter = searchAdapter
|
||||
vm.onGetPageList(searchText = "")
|
||||
}
|
||||
PageSearchView.Loading -> {
|
||||
|
@ -81,7 +80,7 @@ class PageSearchFragment : ViewStateFragment<PageSearchView>(R.layout.fragment_p
|
|||
progressBar.invisible()
|
||||
tvScreenStateMessage.invisible()
|
||||
recyclerView.visible()
|
||||
(recyclerView.adapter as PageLinksAdapter).updateLinks(state.pages)
|
||||
searchAdapter.updateLinks(state.pages)
|
||||
}
|
||||
PageSearchView.EmptyPages -> {
|
||||
progressBar.invisible()
|
||||
|
|
|
@ -14,13 +14,12 @@ import kotlinx.android.synthetic.main.item_page_link.view.*
|
|||
import timber.log.Timber
|
||||
|
||||
class PageLinksAdapter(
|
||||
private val data: MutableList<PageLinkView>,
|
||||
private var data: List<PageLinkView>,
|
||||
private val onClick: (String) -> Unit
|
||||
) : RecyclerView.Adapter<PageLinksAdapter.PageLinkHolder>() {
|
||||
|
||||
fun updateLinks(links: List<PageLinkView>) {
|
||||
data.clear()
|
||||
data.addAll(links)
|
||||
data = links
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,10 @@ interface AppNavigation {
|
|||
fun chooseAccount()
|
||||
fun workspace()
|
||||
fun openProfile()
|
||||
|
||||
fun openDocument(id: String, editorSettings: EditorSettings?)
|
||||
fun launchDocument(id: String)
|
||||
|
||||
fun startDesktopFromSplash()
|
||||
fun startDesktopFromLogin()
|
||||
fun startSplashFromDesktop()
|
||||
|
@ -55,7 +58,10 @@ interface AppNavigation {
|
|||
object SelectAccountScreen : Command()
|
||||
object EnterKeyChainScreen : Command()
|
||||
object WorkspaceScreen : Command()
|
||||
|
||||
data class OpenPage(val id: String, val editorSettings: EditorSettings? = null) : Command()
|
||||
data class LaunchDocument(val id: String) : Command()
|
||||
|
||||
object OpenProfile : Command()
|
||||
object OpenKeychainScreen : Command()
|
||||
object OpenPinCodeScreen : Command()
|
||||
|
|
|
@ -26,6 +26,7 @@ class PageSearchViewModel(
|
|||
MutableLiveData()
|
||||
|
||||
fun onViewCreated() {
|
||||
links.clear()
|
||||
stateData.postValue(PageSearchView.Init)
|
||||
}
|
||||
|
||||
|
@ -66,6 +67,6 @@ class PageSearchViewModel(
|
|||
}
|
||||
|
||||
fun onOpenPageClicked(pageId: String) {
|
||||
navigate(EventWrapper(AppNavigation.Command.ExitToDesktopAndOpenPage(pageId = pageId)))
|
||||
navigate(EventWrapper(AppNavigation.Command.LaunchDocument(id = pageId)))
|
||||
}
|
||||
}
|
|
@ -477,7 +477,7 @@ class BlockReadModeTest : PageViewModelTest() {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `should show error after action menu is closed by action item move to`() {
|
||||
fun `should not show error after action menu is closed by action item move to`() {
|
||||
|
||||
val paragraphs = blocks
|
||||
stubObserveEvents(flow)
|
||||
|
@ -501,6 +501,6 @@ class BlockReadModeTest : PageViewModelTest() {
|
|||
|
||||
val testObserver = vm.error.test()
|
||||
|
||||
testObserver.assertValue("Move To not implemented")
|
||||
testObserver.assertNoValue()
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue