Skip to content

Commit

Permalink
Redesign onboarding
Browse files Browse the repository at this point in the history
  • Loading branch information
greenart7c3 committed Nov 25, 2024
1 parent 50e6b35 commit 151f77c
Show file tree
Hide file tree
Showing 12 changed files with 1,035 additions and 461 deletions.
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,6 @@ dependencies {
implementation libs.coil.svg
// enables network for coil
implementation libs.coil.okhttp

implementation libs.storage
}
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
</queries>

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:largeHeap="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import androidx.compose.ui.window.DialogProperties
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.compose.rememberNavController
import com.anggrayudi.storage.SimpleStorageHelper
import com.greenart7c3.nostrsigner.service.Biometrics
import com.greenart7c3.nostrsigner.service.IntentUtils
import com.greenart7c3.nostrsigner.ui.AccountScreen
Expand All @@ -56,6 +57,7 @@ fun Intent.isLaunchFromHistory(): Boolean =

class MainActivity : AppCompatActivity() {
private lateinit var mainViewModel: MainViewModel
private val storageHelper = SimpleStorageHelper(this@MainActivity)

override fun onCreate(savedInstanceState: Bundle?) {
installSplashScreen()
Expand Down Expand Up @@ -232,7 +234,7 @@ class MainActivity : AppCompatActivity() {
}
}

AccountScreen(accountStateViewModel, intent, packageName, appName, mainViewModel.intents, navController)
AccountScreen(accountStateViewModel, intent, packageName, appName, mainViewModel.intents, navController, storageHelper)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.NavHostController
import androidx.navigation.compose.rememberNavController
import com.anggrayudi.storage.SimpleStorageHelper
import com.greenart7c3.nostrsigner.BuildConfig
import com.greenart7c3.nostrsigner.LocalPreferences
import com.greenart7c3.nostrsigner.NostrSigner
Expand All @@ -59,6 +61,7 @@ fun AccountScreen(
appName: String?,
flow: MutableStateFlow<List<IntentData>>,
navController: NavHostController,
storageHelper: SimpleStorageHelper,
) {
val accountState by accountStateViewModel.accountContent.collectAsState()
val intents by flow.collectAsState(initial = emptyList())
Expand All @@ -72,7 +75,8 @@ fun AccountScreen(
) { state ->
when (state) {
is AccountState.LoggedOff -> {
MainLoginPage(accountStateViewModel)
val newNavController = rememberNavController()
MainLoginPage(accountStateViewModel, storageHelper, newNavController)
}
is AccountState.LoggedIn -> {
LaunchedEffect(intent, intents) {
Expand Down Expand Up @@ -133,6 +137,7 @@ fun AccountScreen(
localRoute,
database,
navController,
storageHelper,
onRemoveIntentData = {
val oldIntents = intents.toMutableList()
oldIntents.remove(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,13 @@ class AccountStateViewModel(npub: String?) : ViewModel() {
proxyPort: Int,
signPolicy: Int,
seedWords: Set<String>,
name: String,
) {
val key = seedWords.joinToString(separator = " ") { it }
val keyPair = KeyPair(privKey = CryptoUtils.privateKeyFromMnemonic(key))
val account = Account(
NostrSignerInternal(keyPair),
name = "",
name = name,
useProxy = useProxy,
proxyPort = proxyPort,
language = null,
Expand Down
Loading

0 comments on commit 151f77c

Please sign in to comment.