setting to control swipe to refresh
This commit is contained in:
+7
@@ -242,6 +242,12 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Activit
|
||||
view = view,
|
||||
)
|
||||
|
||||
// Apply pull-to-refresh setting
|
||||
binding.swipeToRefresh.isEnabled = GlobalComponents.pullToRefreshEnabled
|
||||
GlobalComponents.onPullToRefreshEnabledChanged = { enabled ->
|
||||
_binding?.swipeToRefresh?.isEnabled = enabled
|
||||
}
|
||||
|
||||
shareResourceFeature.set(
|
||||
ShareResourceFeature(
|
||||
context = components.profileApplicationContext,
|
||||
@@ -549,6 +555,7 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Activit
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
|
||||
GlobalComponents.onPullToRefreshEnabledChanged = null
|
||||
components.engineView?.setActivityContext(null)
|
||||
_binding = null
|
||||
}
|
||||
|
||||
+9
@@ -36,6 +36,15 @@ object GlobalComponents {
|
||||
val components: Components?
|
||||
get() = _components
|
||||
|
||||
// Pull-to-refresh setting
|
||||
var pullToRefreshEnabled: Boolean = true
|
||||
set(value) {
|
||||
field = value
|
||||
onPullToRefreshEnabledChanged?.invoke(value)
|
||||
}
|
||||
|
||||
var onPullToRefreshEnabledChanged: ((Boolean) -> Unit)? = null
|
||||
|
||||
@DelicateCoroutinesApi
|
||||
private fun restoreBrowserState(newComponents: Components) =
|
||||
GlobalScope.launch(Dispatchers.Main) {
|
||||
|
||||
+4
-1
@@ -6,7 +6,6 @@
|
||||
|
||||
package eu.weblibre.flutter_mozilla_components.api
|
||||
|
||||
import eu.weblibre.flutter_mozilla_components.EngineProvider
|
||||
import eu.weblibre.flutter_mozilla_components.GlobalComponents
|
||||
import eu.weblibre.flutter_mozilla_components.pigeons.ColorScheme
|
||||
import eu.weblibre.flutter_mozilla_components.pigeons.CookieBannerHandlingMode
|
||||
@@ -243,4 +242,8 @@ class GeckoEngineSettingsApiImpl : GeckoEngineSettingsApi {
|
||||
components.useCases.sessionUseCases.reload()
|
||||
}
|
||||
}
|
||||
|
||||
override fun setPullToRefreshEnabled(enabled: Boolean) {
|
||||
GlobalComponents.pullToRefreshEnabled = enabled
|
||||
}
|
||||
}
|
||||
|
||||
+19
@@ -3504,6 +3504,7 @@ interface GeckoBrowserApi {
|
||||
interface GeckoEngineSettingsApi {
|
||||
fun setDefaultSettings(settings: GeckoEngineSettings)
|
||||
fun updateRuntimeSettings(settings: GeckoEngineSettings)
|
||||
fun setPullToRefreshEnabled(enabled: Boolean)
|
||||
|
||||
companion object {
|
||||
/** The codec used by GeckoEngineSettingsApi. */
|
||||
@@ -3550,6 +3551,24 @@ interface GeckoEngineSettingsApi {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
run {
|
||||
val channel = BasicMessageChannel<Any?>(binaryMessenger, "dev.flutter.pigeon.flutter_mozilla_components.GeckoEngineSettingsApi.setPullToRefreshEnabled$separatedMessageChannelSuffix", codec)
|
||||
if (api != null) {
|
||||
channel.setMessageHandler { message, reply ->
|
||||
val args = message as List<Any?>
|
||||
val enabledArg = args[0] as Boolean
|
||||
val wrapped: List<Any?> = try {
|
||||
api.setPullToRefreshEnabled(enabledArg)
|
||||
listOf(null)
|
||||
} catch (exception: Throwable) {
|
||||
GeckoPigeonUtils.wrapError(exception)
|
||||
}
|
||||
reply.reply(wrapped)
|
||||
}
|
||||
} else {
|
||||
channel.setMessageHandler(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user