mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 11:38:51 +01:00
Hide drawer once item is clicked
This commit is contained in:
@@ -5,6 +5,8 @@ import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.ActionBarDrawerToggle
|
||||
import android.support.v7.widget.LinearLayoutManager
|
||||
import android.view.Gravity
|
||||
import com.jakewharton.rxbinding2.support.v4.widget.drawerOpen
|
||||
import com.jakewharton.rxbinding2.view.clicks
|
||||
import com.karumi.dexter.Dexter
|
||||
import com.karumi.dexter.MultiplePermissionsReport
|
||||
@@ -27,6 +29,7 @@ class ConversationsActivity : QkActivity<ConversationsViewModel, ConversationsSt
|
||||
|
||||
override val viewModelClass = ConversationsViewModel::class
|
||||
override val composeIntent by lazy { compose.clicks() }
|
||||
override val drawerOpenIntent by lazy { drawerLayout.drawerOpen(Gravity.START) }
|
||||
override val archivedIntent by lazy { archived.clicks() }
|
||||
override val scheduledIntent by lazy { scheduled.clicks() }
|
||||
override val blockedIntent by lazy { blocked.clicks() }
|
||||
@@ -57,6 +60,9 @@ class ConversationsActivity : QkActivity<ConversationsViewModel, ConversationsSt
|
||||
if (conversationList.adapter == null && state.conversations?.isValid == true) {
|
||||
conversationList.adapter = ConversationsAdapter(state.conversations)
|
||||
}
|
||||
|
||||
if (drawerLayout.isDrawerOpen(Gravity.START) && !state.drawerOpen) drawerLayout.closeDrawer(Gravity.START)
|
||||
else if (!drawerLayout.isDrawerVisible(Gravity.START) && state.drawerOpen) drawerLayout.openDrawer(Gravity.START)
|
||||
}
|
||||
|
||||
private fun requestPermissions() {
|
||||
|
||||
@@ -5,5 +5,6 @@ import io.realm.OrderedRealmCollection
|
||||
|
||||
data class ConversationsState(
|
||||
val conversations: OrderedRealmCollection<Message>? = null,
|
||||
val refreshing: Boolean = false
|
||||
val refreshing: Boolean = false,
|
||||
val drawerOpen: Boolean = false
|
||||
)
|
||||
@@ -6,6 +6,7 @@ import io.reactivex.Observable
|
||||
interface ConversationsView : QkView<ConversationsState> {
|
||||
|
||||
val composeIntent: Observable<Unit>
|
||||
val drawerOpenIntent: Observable<Boolean>
|
||||
val archivedIntent: Observable<Unit>
|
||||
val scheduledIntent: Observable<Unit>
|
||||
val blockedIntent: Observable<Unit>
|
||||
|
||||
+24
-5
@@ -32,11 +32,30 @@ class ConversationsViewModel : QkViewModel<ConversationsView, ConversationsState
|
||||
override fun bindIntents(view: ConversationsView) {
|
||||
super.bindIntents(view)
|
||||
|
||||
intents += view.composeIntent.subscribe()
|
||||
intents += view.archivedIntent.subscribe()
|
||||
intents += view.scheduledIntent.subscribe()
|
||||
intents += view.blockedIntent.subscribe()
|
||||
intents += view.settingsIntent.subscribe { navigator.showSettings() }
|
||||
intents += view.composeIntent.subscribe {
|
||||
newState { it.copy(drawerOpen = false) }
|
||||
}
|
||||
|
||||
intents += view.drawerOpenIntent.filter { it }.subscribe {
|
||||
newState { it.copy(drawerOpen = true) }
|
||||
}
|
||||
|
||||
intents += view.archivedIntent.subscribe {
|
||||
newState { it.copy(drawerOpen = false) }
|
||||
}
|
||||
|
||||
intents += view.scheduledIntent.subscribe {
|
||||
newState { it.copy(drawerOpen = false) }
|
||||
}
|
||||
|
||||
intents += view.blockedIntent.subscribe {
|
||||
newState { it.copy(drawerOpen = false) }
|
||||
}
|
||||
|
||||
intents += view.settingsIntent.subscribe {
|
||||
navigator.showSettings()
|
||||
newState { it.copy(drawerOpen = false) }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user