feat: various M3 related tweaks

This commit is contained in:
Infi 2023-02-20 03:52:18 +01:00
parent 14a4a4fec0
commit 5cf0943e26
7 changed files with 75 additions and 23 deletions

View File

@ -161,6 +161,9 @@ object RealtimeSocket {
RevoltAPI.channelCache[channelUpdateFrame.id] =
existing.mergeWithPartial(channelUpdateFrame.data)
}
"Authenticated" -> {
// No effect
}
else -> {
Log.i("RealtimeSocket", "Unknown frame: $rawFrame")
}

View File

@ -5,6 +5,7 @@ import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
@ -87,7 +88,8 @@ fun MessageField(
unfocusedIndicatorColor = Color.Transparent,
disabledIndicatorColor = Color.Transparent,
errorIndicatorColor = Color.Transparent,
placeholderColor = Color.Gray
placeholderColor = Color.Gray,
containerColor = MaterialTheme.colorScheme.surfaceColorAtElevation(1.dp)
),
contentPadding = PaddingValues(16.dp),
leadingIcon = {
@ -126,7 +128,11 @@ fun MessageField(
.padding(4.dp)
)
}
}
},
shape = RoundedCornerShape(
topStart = 16.dp,
topEnd = 16.dp
)
)
}
)

View File

@ -33,10 +33,10 @@ enum class Presence {
fun presenceFromStatus(status: String): Presence {
return when (status) {
"online" -> Presence.Online
"idle" -> Presence.Idle
"dnd" -> Presence.Dnd
"focus" -> Presence.Focus
"Online" -> Presence.Online
"Idle" -> Presence.Idle
"Busy" -> Presence.Dnd
"Focus" -> Presence.Focus
else -> Presence.Offline
}
}

View File

@ -126,12 +126,6 @@ fun DoubleDrawer(
modifier = Modifier
.fillMaxHeight()
.fillMaxWidth(drawerWeight)
.clip(
RoundedCornerShape(
topEnd = 16.dp,
bottomEnd = 16.dp
)
)
.align(Alignment.CenterStart)
.offset {
IntOffset(
@ -140,15 +134,18 @@ fun DoubleDrawer(
)
},
) {
startPanel()
Box(
modifier = Modifier
.fillMaxSize()
.clip(RoundedCornerShape(topEnd = 16.dp, bottomEnd = 16.dp))
) {
startPanel()
}
}
Box(
modifier = Modifier
.fillMaxSize()
.clip(
RoundedCornerShape(contentCornerRadius)
)
.align(Alignment.Center)
.offset {
IntOffset(
@ -157,7 +154,13 @@ fun DoubleDrawer(
)
},
) {
content()
Box(
modifier = Modifier
.fillMaxSize()
.clip(RoundedCornerShape(contentCornerRadius))
) {
content()
}
}
Box(
@ -178,7 +181,13 @@ fun DoubleDrawer(
)
},
) {
endPanel()
Box(
modifier = Modifier
.fillMaxSize()
.clip(RoundedCornerShape(topStart = 16.dp, bottomStart = 16.dp))
) {
endPanel()
}
}
}
}

View File

@ -20,7 +20,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.lifecycle.ViewModel
@ -96,7 +95,11 @@ fun ChatRouterScreen(topNav: NavController, viewModel: ChatRouterViewModel = vie
val navController = rememberNavController(bottomSheetNavigator)
val navBackStackEntry by navController.currentBackStackEntryAsState()
ModalBottomSheetLayout(bottomSheetNavigator = bottomSheetNavigator) {
ModalBottomSheetLayout(
sheetShape = RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp),
sheetBackgroundColor = MaterialTheme.colorScheme.surface,
bottomSheetNavigator = bottomSheetNavigator,
) {
Column {
AnimatedVisibility(visible = RealtimeSocket.disconnectionState != DisconnectionState.Connected) {
DisconnectedNotice(
@ -178,7 +181,7 @@ fun ChatRouterScreen(topNav: NavController, viewModel: ChatRouterViewModel = vie
Surface(
tonalElevation = 1.dp,
modifier = Modifier
.padding(vertical = 4.dp)
.padding(start = 4.dp, top = 8.dp, bottom = 8.dp)
.clip(RoundedCornerShape(16.dp))
) {
Column(
@ -215,7 +218,7 @@ fun ChatRouterScreen(topNav: NavController, viewModel: ChatRouterViewModel = vie
Text(
text = server?.name
?: stringResource(R.string.unknown),
fontWeight = FontWeight.Black,
style = MaterialTheme.typography.labelLarge,
fontSize = 24.sp,
modifier = Modifier.padding(16.dp)
)

View File

@ -11,12 +11,14 @@ import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.KeyboardArrowDown
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
@ -402,7 +404,13 @@ fun ChannelScreen(
navController.navigate("channel/${channel.id}/info")
}
.fillMaxWidth()
.background(MaterialTheme.colorScheme.surface)
.clip(
RoundedCornerShape(
bottomStart = 16.dp,
bottomEnd = 16.dp
)
)
.background(MaterialTheme.colorScheme.surfaceColorAtElevation(1.dp))
.padding(16.dp),
verticalAlignment = Alignment.CenterVertically
) {

View File

@ -1,10 +1,19 @@
package chat.revolt.screens.chat.views
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.Settings
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.ViewModel
import androidx.navigation.NavController
@ -33,6 +42,7 @@ class HomeScreenViewModel @Inject constructor(
fun HomeScreen(navController: NavController, viewModel: HomeScreenViewModel = hiltViewModel()) {
Column {
PageHeader(text = stringResource(id = R.string.home))
LinkOnHome(
heading = stringResource(id = R.string.logout),
icon = Icons.Default.Close,
@ -44,5 +54,18 @@ fun HomeScreen(navController: NavController, viewModel: HomeScreenViewModel = hi
}
}
})
LinkOnHome(
heading = stringResource(id = R.string.settings),
icon = Icons.Default.Settings,
onClick = {
navController.navigate("settings")
})
Text(buildAnnotatedString {
withStyle(style = SpanStyle(fontWeight = FontWeight.Bold)) {
append("Note: ")
}
append("Settings are accessible from the top left status icon in the drawer. The link here is temporary until a tutorial is in place.")
}, modifier = Modifier.padding(16.dp))
}
}