OXYGENHUB
# e845c208d516 oxygenhub-android / app / src / main / java / com / example / oxygenhub / MainActivity.kt
1.4 KiB · last changed Android: Add OxygenHub Authentication Login Screen 1 month ago source blame history raw
e0e4a1c4 Andy McCall ↶ 1
package com.example.oxygenhub
2
3
import android.os.Bundle
4
import androidx.activity.ComponentActivity
5
import androidx.activity.compose.setContent
6
import androidx.activity.enableEdgeToEdge
7
import androidx.compose.foundation.layout.fillMaxSize
8
import androidx.compose.foundation.layout.padding
9
import androidx.compose.material3.Scaffold
10
import androidx.compose.material3.Text
11
import androidx.compose.runtime.Composable
12
import androidx.compose.ui.Modifier
13
import androidx.compose.ui.tooling.preview.Preview
14
import com.example.oxygenhub.ui.theme.OxygenHubTheme
15
5edf011e Andy McCall ↶ 16
import uniffi.rust_core.oxygenGreeting
17
e845c208 Andy McCall ↶ 18
import com.example.oxygenhub.ui.LoginScreen
66127df3 Andy McCall ↶ 19
import com.example.oxygenhub.ui.MainScreen
e845c208 Andy McCall ↶ 20
import androidx.compose.runtime.*
66127df3 Andy McCall ↶ 21
e0e4a1c4 Andy McCall ↶ 22
class MainActivity : ComponentActivity() {
23
    override fun onCreate(savedInstanceState: Bundle?) {
24
        super.onCreate(savedInstanceState)
25
        enableEdgeToEdge()
26
        setContent {
27
            OxygenHubTheme {
e845c208 Andy McCall ↶ 28
                var isLoggedIn by remember { mutableStateOf(false) }
29
                
30
                if (isLoggedIn) {
31
                    MainScreen()
32
                } else {
33
                    LoginScreen(
34
                        onLoginSuccess = { isLoggedIn = true }
35
                    )
36
                }
e0e4a1c4 Andy McCall ↶ 37
            }
38
        }
39
    }
40
}
41
42
@Preview(showBackground = true)
43
@Composable
66127df3 Andy McCall ↶ 44
fun MainScreenPreview() {
e0e4a1c4 Andy McCall ↶ 45
    OxygenHubTheme {
66127df3 Andy McCall ↶ 46
        MainScreen()
e0e4a1c4 Andy McCall ↶ 47
    }
48
}