Skip to content

Commit

Permalink
rename datastore
Browse files Browse the repository at this point in the history
  • Loading branch information
trbutler4 committed Dec 23, 2024
1 parent 4f93692 commit 63c41e5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import androidx.datastore.preferences.preferencesDataStore
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map

class DataStoreModule(private val context: Context) {
class WalletStoreModule(private val context: Context) {
companion object {
private val Context.dataStore: DataStore<Preferences> by preferencesDataStore("wallet_prefs")
private val HAS_ACCOUNT = booleanPreferencesKey("has_account")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.example.walletapp.BuildConfig
import com.example.walletapp.datastore.DataStoreModule
import com.example.walletapp.datastore.WalletStoreModule
import com.example.walletapp.ui.account.AddTokenScreen
import com.example.walletapp.ui.account.TokenViewModel
import com.example.walletapp.ui.account.WalletScreen
Expand Down Expand Up @@ -55,7 +54,7 @@ object Receive
fun WalletApp(tokenViewModel: TokenViewModel) {
val walletViewModel: WalletViewModel = viewModel()
val context = LocalContext.current
val dataStore = DataStoreModule(context)
val dataStore = WalletStoreModule(context)
val hasAccountState = dataStore.hasAccount.collectAsState(initial = null)
hasAccountState.value?.let { hasAccount ->
WalletappTheme {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ import androidx.compose.ui.unit.sp
import android.content.ClipboardManager
import android.content.ClipData
import android.widget.Toast
import androidx.compose.ui.graphics.painter.Painter
import androidx.core.graphics.toColorInt
import com.example.walletapp.R
import com.example.walletapp.datastore.DataStoreModule
import com.example.walletapp.datastore.WalletStoreModule
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -94,7 +93,7 @@ fun FinalizeAccountCreationScreen(
fun AccountInfoView(onContinue: () -> Unit) {
val context = LocalContext.current as Activity
val clipboardManager = LocalContext.current.getSystemService(ClipboardManager::class.java)
val dataStore = DataStoreModule(context)
val dataStore = WalletStoreModule(context)
var checked by remember { mutableStateOf(true) }
val accountName = "Starknet"
val privateKey = "q78ggh277ibckewjtnM"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.example.walletapp.ui.onboarding

import android.app.Activity
import android.content.Intent
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
Expand All @@ -13,7 +10,6 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
Expand All @@ -24,16 +20,12 @@ import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TextFieldDefaults
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.IconButton
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.SheetState
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.ArrowForward
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand All @@ -44,15 +36,13 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.core.graphics.toColorInt
import com.example.walletapp.R
import com.example.walletapp.datastore.DataStoreModule
import com.example.walletapp.datastore.WalletStoreModule
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -149,7 +139,7 @@ fun PrivateKeyView(modifier: Modifier = Modifier, onNext: () -> Unit) {
var openBottomSheet by remember { mutableStateOf(false) }
val sheetState = rememberModalBottomSheetState()
val context = (LocalContext.current as Activity)
val dataStore = DataStoreModule(context)
val dataStore = WalletStoreModule(context)

Column(
modifier = modifier
Expand Down Expand Up @@ -239,7 +229,7 @@ fun CreateNameView(modifier: Modifier = Modifier, onFinishAccountImport: () -> U
val borderColor = Color("#1B1B76".toColorInt())
var accountName by remember { mutableStateOf("") }
val context = (LocalContext.current as Activity)
val dataStore = DataStoreModule(context)
val dataStore = WalletStoreModule(context)

Column(
modifier = modifier
Expand Down

0 comments on commit 63c41e5

Please sign in to comment.