feat: build basic UI skeleton
Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
parent
29b6e45cb2
commit
c3a4c5654a
|
|
@ -214,7 +214,11 @@ class MainActivityViewModel @Inject constructor(
|
|||
Log.d("MainActivity", "Onboarding state is complete, logging in")
|
||||
RevoltAPI.loginAs(token)
|
||||
RevoltAPI.setSessionId(id)
|
||||
startWithDestination("chat")
|
||||
if (Experiments.usePolar.isEnabled) {
|
||||
startWithDestination("main")
|
||||
} else {
|
||||
startWithDestination("chat")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("MainActivity", "Failed to login, could not log in", e)
|
||||
couldNotLogIn.emit(true)
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import androidx.compose.foundation.layout.Column
|
|||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.exclude
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
|
|
@ -31,8 +32,10 @@ import androidx.compose.material3.IconButton
|
|||
import androidx.compose.material3.LocalContentColor
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.ModalBottomSheet
|
||||
import androidx.compose.material3.NavigationBarDefaults
|
||||
import androidx.compose.material3.ProvideTextStyle
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.ScaffoldDefaults
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.rememberModalBottomSheetState
|
||||
import androidx.compose.runtime.Composable
|
||||
|
|
@ -64,7 +67,12 @@ import io.sentry.Sentry
|
|||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun OverviewScreen(navController: NavController, useDrawer: Boolean, onDrawerClicked: () -> Unit) {
|
||||
fun OverviewScreen(
|
||||
navController: NavController,
|
||||
useDrawer: Boolean,
|
||||
onDrawerClicked: () -> Unit,
|
||||
includePadding: Boolean = true
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
|
||||
var isLoading by rememberSaveable { mutableStateOf(true) }
|
||||
|
|
@ -119,6 +127,9 @@ fun OverviewScreen(navController: NavController, useDrawer: Boolean, onDrawerCli
|
|||
windowInsets = WindowInsets.zero
|
||||
)
|
||||
},
|
||||
contentWindowInsets = if (includePadding) ScaffoldDefaults.contentWindowInsets else ScaffoldDefaults.contentWindowInsets.exclude(
|
||||
NavigationBarDefaults.windowInsets
|
||||
)
|
||||
) { pv ->
|
||||
if (user == null && !isLoading) {
|
||||
NonIdealState(
|
||||
|
|
@ -138,8 +149,11 @@ fun OverviewScreen(navController: NavController, useDrawer: Boolean, onDrawerCli
|
|||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier
|
||||
.padding(pv)
|
||||
.padding(horizontal = 16.dp)
|
||||
.then(
|
||||
Modifier
|
||||
.padding(pv)
|
||||
.padding(horizontal = 16.dp)
|
||||
)
|
||||
) {
|
||||
AnimatedContent(targetState = isLoading, label = "isLoading") { loading ->
|
||||
Column(
|
||||
|
|
|
|||
|
|
@ -0,0 +1,109 @@
|
|||
package chat.revolt.screens.main
|
||||
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.NavigationBar
|
||||
import androidx.compose.material3.NavigationBarItem
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.navigation.NavController
|
||||
import chat.revolt.R
|
||||
import chat.revolt.screens.chat.views.OverviewScreen
|
||||
|
||||
enum class MainScreenTab {
|
||||
Communities,
|
||||
Conversations,
|
||||
Overview
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun MainScreen(navController: NavController) {
|
||||
var currentTab by rememberSaveable { mutableStateOf(MainScreenTab.Communities) }
|
||||
|
||||
Scaffold(
|
||||
bottomBar = {
|
||||
NavigationBar {
|
||||
NavigationBarItem(
|
||||
selected = currentTab == MainScreenTab.Communities,
|
||||
onClick = { currentTab = MainScreenTab.Communities },
|
||||
icon = {
|
||||
Icon(
|
||||
painter = painterResource(
|
||||
if (currentTab == MainScreenTab.Communities) {
|
||||
R.drawable.ic_account_group_24dp
|
||||
} else {
|
||||
R.drawable.ic_account_group_outline_24dp
|
||||
}
|
||||
),
|
||||
contentDescription = null,
|
||||
)
|
||||
},
|
||||
label = {
|
||||
Text("Communities")
|
||||
}
|
||||
)
|
||||
NavigationBarItem(
|
||||
selected = currentTab == MainScreenTab.Conversations,
|
||||
onClick = { currentTab = MainScreenTab.Conversations },
|
||||
icon = {
|
||||
Icon(
|
||||
painter = painterResource(
|
||||
if (currentTab == MainScreenTab.Conversations) {
|
||||
R.drawable.ic_forum_24dp
|
||||
} else {
|
||||
R.drawable.ic_forum_outline_24dp
|
||||
}
|
||||
),
|
||||
contentDescription = null,
|
||||
)
|
||||
},
|
||||
label = {
|
||||
Text("Conversations")
|
||||
}
|
||||
)
|
||||
NavigationBarItem(
|
||||
selected = currentTab == MainScreenTab.Overview,
|
||||
onClick = { currentTab = MainScreenTab.Overview },
|
||||
icon = {
|
||||
Icon(
|
||||
painter = painterResource(
|
||||
if (currentTab == MainScreenTab.Overview) {
|
||||
R.drawable.ic_creation_24dp
|
||||
} else {
|
||||
R.drawable.ic_creation_outline_24dp
|
||||
}
|
||||
),
|
||||
contentDescription = null,
|
||||
)
|
||||
},
|
||||
label = {
|
||||
Text("Overview")
|
||||
}
|
||||
)
|
||||
}
|
||||
},
|
||||
) { pv ->
|
||||
Box(Modifier.padding(pv)) {
|
||||
when (currentTab) {
|
||||
MainScreenTab.Communities -> {}
|
||||
MainScreenTab.Conversations -> {}
|
||||
MainScreenTab.Overview -> {
|
||||
OverviewScreen(
|
||||
navController,
|
||||
useDrawer = false,
|
||||
onDrawerClicked = {},
|
||||
includePadding = false
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:pathData="M12,5.5A3.5,3.5 0 0,1 15.5,9A3.5,3.5 0 0,1 12,12.5A3.5,3.5 0 0,1 8.5,9A3.5,3.5 0 0,1 12,5.5M5,8C5.56,8 6.08,8.15 6.53,8.42C6.38,9.85 6.8,11.27 7.66,12.38C7.16,13.34 6.16,14 5,14A3,3 0 0,1 2,11A3,3 0 0,1 5,8M19,8A3,3 0 0,1 22,11A3,3 0 0,1 19,14C17.84,14 16.84,13.34 16.34,12.38C17.2,11.27 17.62,9.85 17.47,8.42C17.92,8.15 18.44,8 19,8M5.5,18.25C5.5,16.18 8.41,14.5 12,14.5C15.59,14.5 18.5,16.18 18.5,18.25V20H5.5V18.25M0,20V18.5C0,17.11 1.89,15.94 4.45,15.6C3.86,16.28 3.5,17.22 3.5,18.25V20H0M24,20H20.5V18.25C20.5,17.22 20.14,16.28 19.55,15.6C22.11,15.94 24,17.11 24,18.5V20Z" />
|
||||
</vector>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:pathData="M12,5A3.5,3.5 0 0,0 8.5,8.5A3.5,3.5 0 0,0 12,12A3.5,3.5 0 0,0 15.5,8.5A3.5,3.5 0 0,0 12,5M12,7A1.5,1.5 0 0,1 13.5,8.5A1.5,1.5 0 0,1 12,10A1.5,1.5 0 0,1 10.5,8.5A1.5,1.5 0 0,1 12,7M5.5,8A2.5,2.5 0 0,0 3,10.5C3,11.44 3.53,12.25 4.29,12.68C4.65,12.88 5.06,13 5.5,13C5.94,13 6.35,12.88 6.71,12.68C7.08,12.47 7.39,12.17 7.62,11.81C6.89,10.86 6.5,9.7 6.5,8.5C6.5,8.41 6.5,8.31 6.5,8.22C6.2,8.08 5.86,8 5.5,8M18.5,8C18.14,8 17.8,8.08 17.5,8.22C17.5,8.31 17.5,8.41 17.5,8.5C17.5,9.7 17.11,10.86 16.38,11.81C16.5,12 16.63,12.15 16.78,12.3C16.94,12.45 17.1,12.58 17.29,12.68C17.65,12.88 18.06,13 18.5,13C18.94,13 19.35,12.88 19.71,12.68C20.47,12.25 21,11.44 21,10.5A2.5,2.5 0 0,0 18.5,8M12,14C9.66,14 5,15.17 5,17.5V19H19V17.5C19,15.17 14.34,14 12,14M4.71,14.55C2.78,14.78 0,15.76 0,17.5V19H3V17.07C3,16.06 3.69,15.22 4.71,14.55M19.29,14.55C20.31,15.22 21,16.06 21,17.07V19H24V17.5C24,15.76 21.22,14.78 19.29,14.55M12,16C13.53,16 15.24,16.5 16.23,17H7.77C8.76,16.5 10.47,16 12,16Z" />
|
||||
</vector>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:pathData="M9 4L11.5 9.5L17 12L11.5 14.5L9 20L6.5 14.5L1 12L6.5 9.5L9 4M9 8.83L8 11L5.83 12L8 13L9 15.17L10 13L12.17 12L10 11L9 8.83M19 9L17.74 6.26L15 5L17.74 3.75L19 1L20.25 3.75L23 5L20.25 6.26L19 9M19 23L17.74 20.26L15 19L17.74 17.75L19 15L20.25 17.75L23 19L20.25 20.26L19 23Z" />
|
||||
</vector>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:pathData="M17,12V3A1,1 0 0,0 16,2H3A1,1 0 0,0 2,3V17L6,13H16A1,1 0 0,0 17,12M21,6H19V15H6V17A1,1 0 0,0 7,18H18L22,22V7A1,1 0 0,0 21,6Z" />
|
||||
</vector>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#ffffff"
|
||||
android:pathData="M15,4V11H5.17L4,12.17V4H15M16,2H3A1,1 0 0,0 2,3V17L6,13H16A1,1 0 0,0 17,12V3A1,1 0 0,0 16,2M21,6H19V15H6V17A1,1 0 0,0 7,18H18L22,22V7A1,1 0 0,0 21,6Z" />
|
||||
</vector>
|
||||
Loading…
Reference in New Issue