|
1 | 1 | package com.hoker.intra_example.presentation |
2 | 2 |
|
3 | 3 | import android.os.Bundle |
4 | | -import android.os.PersistableBundle |
| 4 | +import android.widget.Toast |
5 | 5 | import androidx.activity.compose.setContent |
6 | | -import androidx.compose.foundation.layout.fillMaxSize |
7 | | -import androidx.compose.material.MaterialTheme |
8 | | -import androidx.compose.material.Surface |
| 6 | +import androidx.compose.foundation.layout.Column |
| 7 | +import androidx.compose.foundation.layout.padding |
| 8 | +import androidx.compose.material.Text |
| 9 | +import androidx.compose.runtime.LaunchedEffect |
9 | 10 | import androidx.compose.ui.Modifier |
10 | 11 | import androidx.compose.ui.graphics.Color |
| 12 | +import androidx.compose.ui.platform.LocalContext |
| 13 | +import androidx.compose.ui.text.font.FontWeight |
| 14 | +import androidx.compose.ui.unit.dp |
| 15 | +import androidx.compose.ui.unit.sp |
| 16 | +import androidx.hilt.navigation.compose.hiltViewModel |
11 | 17 | import com.hoker.intra.domain.NfcActivity |
12 | | -import com.carbidecowboy.supra.presentation.scaffolds.SupraGyroScaffold |
| 18 | +import com.hoker.supra.presentation.scaffolds.SupraGyroScaffold |
13 | 19 | import dagger.hilt.android.AndroidEntryPoint |
| 20 | +import kotlinx.coroutines.flow.collectLatest |
14 | 21 |
|
15 | 22 | @AndroidEntryPoint |
16 | 23 | class IntraExampleActivity: NfcActivity() { |
17 | 24 |
|
18 | 25 | override fun onCreate(savedInstanceState: Bundle?) { |
19 | 26 | super.onCreate(savedInstanceState) |
20 | 27 | setContent { |
| 28 | + |
| 29 | + val viewModel: IntraExampleViewModel = hiltViewModel() |
| 30 | + val context = LocalContext.current |
| 31 | + |
| 32 | + LaunchedEffect(Unit) { |
| 33 | + viewModel.errorFlow.collectLatest { errorMessage -> |
| 34 | + Toast.makeText(context, errorMessage, Toast.LENGTH_SHORT).show() |
| 35 | + } |
| 36 | + } |
| 37 | + |
21 | 38 | SupraGyroScaffold( |
22 | | - borderColor = Color.Black, |
23 | | - backgroundColor = Color.DarkGray |
| 39 | + borderColor = Color.DarkGray, |
| 40 | + backgroundColor = Color.Black |
24 | 41 | ) { |
25 | | - |
| 42 | + Column( |
| 43 | + modifier = Modifier.padding(16.dp) |
| 44 | + ) { |
| 45 | + if (viewModel.jwtText == null) { |
| 46 | + Text( |
| 47 | + text = "Scan to get JWT", |
| 48 | + color = Color.White, |
| 49 | + fontSize = 24.sp, |
| 50 | + fontWeight = FontWeight.Bold |
| 51 | + ) |
| 52 | + } |
| 53 | + viewModel.jwtText?.let { jwt -> |
| 54 | + Text( |
| 55 | + text = "JWT:", |
| 56 | + color = Color.White, |
| 57 | + fontSize = 24.sp, |
| 58 | + fontWeight = FontWeight.Bold |
| 59 | + ) |
| 60 | + Text( |
| 61 | + text = jwt, |
| 62 | + color = Color.White, |
| 63 | + fontSize = 16.sp |
| 64 | + ) |
| 65 | + } |
| 66 | + } |
26 | 67 | } |
27 | 68 | } |
28 | 69 | } |
|
0 commit comments