Skip to content

Commit

Permalink
Add data library as a submodule. Validator details screen state impro…
Browse files Browse the repository at this point in the history
…vements.
  • Loading branch information
kukabi committed Feb 20, 2024
1 parent 645c4f7 commit daab371
Show file tree
Hide file tree
Showing 11 changed files with 496 additions and 468 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
path = sceneview-android
url = https://github.com/helikon-labs/sceneview-android.git
branch = helikon-texture-view-v2.0.3
[submodule "subvt-data-android"]
path = subvt-data-android
url = https://github.com/helikon-labs/subvt-data-android.git
branch = main
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ dependencyResolutionManagement {
rootProject.name = "SubVT"
include(":subvt")
include(":sceneview-android:sceneview")
include(":subvt-data-android:subvt-data")
1 change: 1 addition & 0 deletions subvt-data-android
Submodule subvt-data-android added at c7677d
3 changes: 1 addition & 2 deletions subvt/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,13 @@ dependencies {
implementation("androidx.work:work-runtime-ktx:2.9.0")

// 3D
// implementation("io.github.sceneview:sceneview:2.0.3")
implementation(project(":sceneview-android:sceneview"))

// crypto
implementation("org.bouncycastle:bcprov-jdk15on:1.67")

// data
implementation("com.github.helikon-labs:subvt-data-android:0.24.5")
implementation(project(":subvt-data-android:subvt-data"))

// shadow fix
implementation("com.github.zed-alpha.shadow-gadgets:compose:2.2.0")
Expand Down
2 changes: 2 additions & 0 deletions subvt/src/main/java/io/helikon/subvt/ui/component/Snackbar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.ButtonDefaults
Expand Down Expand Up @@ -132,6 +133,7 @@ fun Snackbar(
verticalAlignment = Alignment.CenterVertically,
) {
Image(
modifier = Modifier.size(dimensionResource(id = R.dimen.snackbar_icon_size)),
painter = painterResource(id = R.drawable.snackbar_exclamation_icon),
contentDescription = stringResource(id = R.string.snackbar_exclamation_icon_description),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@ fun IntroductionScreen(
modifier = modifier,
state =
IntroductionScreenState(
isLoading = viewModel.createUserState == DataRequestState.Loading,
isLoading =
viewModel.createUserState == DataRequestState.Loading ||
viewModel.createUserState is DataRequestState.Success,
snackbarIsVisible = snackbarIsVisible,
),
onCreateUser = {
viewModel.createUser(context)
viewModel.createUser()
},
onSnackbarClick = {
snackbarIsVisible = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ class IntroductionViewModel
@ApplicationContext context: Context,
private val userPreferencesRepository: UserPreferencesRepository,
) : ViewModel() {
init {
SubVTData.reset(context)
}

var createUserState by mutableStateOf<DataRequestState<User>>(Idle)
private set
private val appService =
Expand All @@ -37,12 +41,11 @@ class IntroductionViewModel
"https://${BuildConfig.API_HOST}:${BuildConfig.APP_SERVICE_PORT}/",
)

fun createUser(context: Context) {
fun createUser() {
createUserState = Loading
viewModelScope.launch(Dispatchers.IO) {
val response =
try {
SubVTData.reset(context)
appService.createUser()
} catch (error: Throwable) {
createUserState = Error(error)
Expand Down
Loading

0 comments on commit daab371

Please sign in to comment.