Skip to content

Commit

Permalink
PERA-1357 :: Finalize Account Cache, Asset Cache and Polling (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsinsar authored Dec 26, 2024
1 parent 6c9fe8d commit f6d56f6
Show file tree
Hide file tree
Showing 107 changed files with 2,835 additions and 357 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@

package co.algorand.app.di

import com.algorand.common.foundation.network.GetIndexerInterceptorConfig
import com.algorand.common.foundation.network.IndexerInterceptorPluginConfig
import com.algorand.common.foundation.network.algod.AlgodInterceptorPluginConfig
import com.algorand.common.foundation.network.algod.GetAlgodInterceptorConfig
import com.algorand.common.foundation.network.indexer.GetIndexerInterceptorConfig
import com.algorand.common.foundation.network.indexer.IndexerInterceptorPluginConfig
import com.algorand.common.foundation.network.pera.GetPeraMobileInterceptorConfig
import com.algorand.common.foundation.network.pera.PeraMobileInterceptorPluginConfig
import com.algorand.common.foundation.network.pera.PeraMobileUserAgent
import org.koin.dsl.module

val accountInformationModule = module {
Expand All @@ -25,4 +30,29 @@ val accountInformationModule = module {
)
}
}
factory<GetPeraMobileInterceptorConfig> {
GetPeraMobileInterceptorConfig {
PeraMobileInterceptorPluginConfig(
baseUrl = "-",
apiKey = "-",
userAgent = PeraMobileUserAgent(
packageName = "-",
appVersion = "-",
appName = "-",
osVersion = "-",
deviceModel = "-",
languageTag = "-",
clientType = "-"
)
)
}
}
factory<GetAlgodInterceptorConfig> {
GetAlgodInterceptorConfig {
AlgodInterceptorPluginConfig(
baseUrl = "-",
apiKey = "-"
)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package co.algorand.app.di

import co.algorand.app.ui.screens.home.AccountsViewModel
import co.algorand.app.ui.AppViewModel
import co.algorand.app.ui.screens.accounts.AccountsViewModel
import co.algorand.app.ui.widgets.snackbar.SnackbarViewModel
import com.algorand.common.viewmodel.EventDelegate
import com.algorand.common.viewmodel.StateDelegate
Expand All @@ -9,5 +10,6 @@ import org.koin.dsl.module

val provideViewModelModules = module {
single { SnackbarViewModel(EventDelegate()) }
viewModel<AccountsViewModel> { AccountsViewModel(get(), get(), get(), get(), get(), StateDelegate()) }
viewModel<AccountsViewModel> { AccountsViewModel(get(), get(), get(), get(), get(), StateDelegate(), get()) }
viewModel<AppViewModel> { AppViewModel(get()) }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2022 Pera Wallet, LDA
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/

package co.algorand.app.ui

import androidx.lifecycle.Lifecycle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.algorand.common.cache.domain.usecase.InitializeAppCache
import kotlinx.coroutines.launch

class AppViewModel(
private val initializeAppCache: InitializeAppCache
) : ViewModel() {

fun initCache(lifecycle: Lifecycle) {
viewModelScope.launch {
initializeAppCache(lifecycle)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,36 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.lifecycle.compose.LocalLifecycleOwner
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import co.algorand.app.ui.AppViewModel
import co.algorand.app.ui.screens.CoreActionsBottomSheet
import co.algorand.app.ui.screens.PeraTypographyPreviewScreen
import co.algorand.app.ui.screens.PeraTypographyPreviewScreenNavigation
import co.algorand.app.ui.screens.QrScannerScreen
import co.algorand.app.ui.screens.QrScannerScreenNavigation
import com.algorand.common.ui.theme.PeraTheme
import org.koin.compose.viewmodel.koinViewModel

@Composable
fun AppNavigation() {
fun AppNavigation(
appViewModel: AppViewModel = koinViewModel()
) {
val navController = rememberNavController()
val snackbarHostState = remember { SnackbarHostState() }
val isBottomSheetVisible = remember { mutableStateOf(false) }

val lifecycleOwner = LocalLifecycleOwner.current
LaunchedEffect(Unit) {
appViewModel.initCache(lifecycleOwner.lifecycle)
}

Scaffold(
modifier = Modifier
.background(color = PeraTheme.colors.background)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import androidx.navigation.toRoute
import co.algorand.app.ui.screens.DiscoverScreen
import co.algorand.app.ui.screens.home.AccountsScreen
import co.algorand.app.ui.screens.accounts.AccountsScreen
import co.algorand.app.ui.screens.NftsScreen
import co.algorand.app.ui.screens.SettingsScreen
import co.algorand.app.ui.widgets.snackbar.SnackBarLayout
Expand Down
Loading

0 comments on commit f6d56f6

Please sign in to comment.