1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-09-19 15:11:42 +02:00

Move web state to separate folder

This commit is contained in:
Allan Wang 2023-06-19 21:09:34 -07:00
parent abbbae4b7f
commit 2794a104e8
No known key found for this signature in database
GPG Key ID: C93E3F9C679D7A56
9 changed files with 37 additions and 35 deletions

View File

@ -21,9 +21,9 @@ import android.webkit.ConsoleMessage
import android.webkit.WebChromeClient
import android.webkit.WebView
import com.google.common.flogger.FluentLogger
import com.pitchedapps.frost.web.FrostWebStore
import com.pitchedapps.frost.web.UpdateProgressAction
import com.pitchedapps.frost.web.UpdateTitleAction
import com.pitchedapps.frost.web.state.FrostWebStore
import com.pitchedapps.frost.web.state.UpdateProgressAction
import com.pitchedapps.frost.web.state.UpdateTitleAction
import javax.inject.Inject
/** The default chrome client */

View File

@ -30,9 +30,9 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.viewinterop.AndroidView
import androidx.core.view.children
import com.pitchedapps.frost.web.FrostWebState
import com.pitchedapps.frost.web.FrostWebStore
import com.pitchedapps.frost.web.ResponseAction
import com.pitchedapps.frost.web.state.FrostWebState
import com.pitchedapps.frost.web.state.FrostWebStore
import com.pitchedapps.frost.web.state.ResponseAction
import com.pitchedapps.frost.webview.FrostWebScoped
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow

View File

@ -26,10 +26,10 @@ import com.pitchedapps.frost.facebook.FACEBOOK_BASE_COM
import com.pitchedapps.frost.facebook.WWW_FACEBOOK_COM
import com.pitchedapps.frost.facebook.isExplicitIntent
import com.pitchedapps.frost.web.FrostWebHelper
import com.pitchedapps.frost.web.FrostWebStore
import com.pitchedapps.frost.web.UpdateNavigationAction
import com.pitchedapps.frost.web.UpdateProgressAction
import com.pitchedapps.frost.web.UpdateTitleAction
import com.pitchedapps.frost.web.state.FrostWebStore
import com.pitchedapps.frost.web.state.UpdateNavigationAction
import com.pitchedapps.frost.web.state.UpdateProgressAction
import com.pitchedapps.frost.web.state.UpdateTitleAction
import java.io.ByteArrayInputStream
import javax.inject.Inject

View File

@ -14,17 +14,17 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pitchedapps.frost.web
package com.pitchedapps.frost.web.state
import com.google.common.flogger.FluentLogger
import mozilla.components.lib.state.Middleware
import mozilla.components.lib.state.MiddlewareContext
class FrostLoggerMiddleware(private val tag: String) : Middleware<FrostWebState, FrostAction> {
class FrostLoggerMiddleware(private val tag: String) : Middleware<FrostWebState, FrostWebAction> {
override fun invoke(
context: MiddlewareContext<FrostWebState, FrostAction>,
next: (FrostAction) -> Unit,
action: FrostAction
context: MiddlewareContext<FrostWebState, FrostWebAction>,
next: (FrostWebAction) -> Unit,
action: FrostWebAction
) {
logger.atInfo().log("FrostWebAction-%s: %s - %s", tag, action::class.simpleName, action)
next(action)

View File

@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pitchedapps.frost.web
package com.pitchedapps.frost.web.state
import mozilla.components.lib.state.Action
@ -24,27 +24,29 @@ import mozilla.components.lib.state.Action
*
* For firefox example
*/
sealed interface FrostAction : Action
sealed interface FrostWebAction : Action
/**
* [FrostAction] dispatched to indicate that the store is initialized and ready to use. This action
* is dispatched automatically before any other action is processed. Its main purpose is to trigger
* initialization logic in middlewares. The action itself has no effect on the [FrostWebState].
* [FrostWebAction] dispatched to indicate that the store is initialized and ready to use. This
* action is dispatched automatically before any other action is processed. Its main purpose is to
* trigger initialization logic in middlewares. The action itself has no effect on the
* [FrostWebState].
*/
object InitAction : FrostAction
object InitAction : FrostWebAction
/** Action indicating current url state. */
data class UpdateUrlAction(val url: String) : FrostAction
data class UpdateUrlAction(val url: String) : FrostWebAction
/** Action indicating current title state. */
data class UpdateTitleAction(val title: String?) : FrostAction
data class UpdateTitleAction(val title: String?) : FrostWebAction
data class UpdateNavigationAction(val canGoBack: Boolean, val canGoForward: Boolean) : FrostAction
data class UpdateNavigationAction(val canGoBack: Boolean, val canGoForward: Boolean) :
FrostWebAction
data class UpdateProgressAction(val progress: Int) : FrostAction
data class UpdateProgressAction(val progress: Int) : FrostWebAction
/** Action triggered by user, leading to transient state changes. */
sealed interface UserAction : FrostAction {
sealed interface UserAction : FrostWebAction {
/** Action to load new url. */
data class LoadUrlAction(val url: String) : UserAction
@ -55,7 +57,7 @@ sealed interface UserAction : FrostAction {
}
/** Response triggered by webview, indicating [UserAction] fulfillment. */
sealed interface ResponseAction : FrostAction {
sealed interface ResponseAction : FrostWebAction {
data class LoadUrlResponseAction(val url: String) : ResponseAction

View File

@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pitchedapps.frost.web
package com.pitchedapps.frost.web.state
/**
* See
@ -23,7 +23,7 @@ package com.pitchedapps.frost.web
* For firefox example
*/
internal object FrostWebReducer {
fun reduce(state: FrostWebState, action: FrostAction): FrostWebState {
fun reduce(state: FrostWebState, action: FrostWebAction): FrostWebState {
return when (action) {
is InitAction -> state
is UpdateUrlAction -> state.copy(url = action.url)

View File

@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pitchedapps.frost.web
package com.pitchedapps.frost.web.state
import mozilla.components.lib.state.State

View File

@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.pitchedapps.frost.web
package com.pitchedapps.frost.web.state
import com.pitchedapps.frost.facebook.FB_URL_BASE
import mozilla.components.lib.state.Middleware
@ -29,9 +29,9 @@ import mozilla.components.lib.state.Store
class FrostWebStore(
tag: String,
initialState: FrostWebState = FrostWebState(),
middleware: List<Middleware<FrostWebState, FrostAction>> = emptyList(),
middleware: List<Middleware<FrostWebState, FrostWebAction>> = emptyList(),
) :
Store<FrostWebState, FrostAction>(
Store<FrostWebState, FrostWebAction>(
initialState,
FrostWebReducer::reduce,
middleware,

View File

@ -17,8 +17,8 @@
package com.pitchedapps.frost.webview
import com.pitchedapps.frost.compose.webview.FrostWebCompose
import com.pitchedapps.frost.web.FrostLoggerMiddleware
import com.pitchedapps.frost.web.FrostWebStore
import com.pitchedapps.frost.web.state.FrostLoggerMiddleware
import com.pitchedapps.frost.web.state.FrostWebStore
import dagger.BindsInstance
import dagger.Module
import dagger.Provides