Skip to content

Commit

Permalink
Display token instead of logging
Browse files Browse the repository at this point in the history
  • Loading branch information
nrobi144 committed Jan 7, 2022
1 parent db5cb9a commit 517656c
Showing 1 changed file with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material.Text
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import energy.octopus.octopusenergy.teslauth.TeslAuth

const val TAG = "tesla_auth_test"
Expand All @@ -13,11 +24,23 @@ class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
TeslAuth(onSuccess = {
Log.i(TAG, "Got auth token $it")
}, onError = {
Log.i(TAG, "Got error $it")
})
var message by remember { mutableStateOf<String?>(null) }
if (message == null) {
TeslAuth(onSuccess = {
message = it.toString()
}, onError = {
message = it.toString()
})
} else {
Box(Modifier.padding(16.dp)) {
Text(
message ?: "",
Modifier
.wrapContentSize()
.align(Alignment.Center)
)
}
}
}
}
}

0 comments on commit 517656c

Please sign in to comment.