feat: LinkOnHome component
This commit is contained in:
parent
234855b809
commit
851bbebd43
|
|
@ -4,11 +4,14 @@ import android.os.Bundle
|
|||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.animation.*
|
||||
import androidx.compose.animation.core.EaseInOutExpo
|
||||
import androidx.compose.animation.core.FiniteAnimationSpec
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.IntOffset
|
||||
import chat.revolt.screens.about.AboutScreen
|
||||
import chat.revolt.screens.about.AttributionScreen
|
||||
import chat.revolt.screens.about.PlaceholderScreen
|
||||
|
|
@ -39,6 +42,9 @@ class MainActivity : ComponentActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
val RevoltTweenInt: FiniteAnimationSpec<IntOffset> = tween(400, easing = EaseInOutExpo)
|
||||
val RevoltTweenFloat: FiniteAnimationSpec<Float> = tween(400, easing = EaseInOutExpo)
|
||||
|
||||
@OptIn(ExperimentalAnimationApi::class)
|
||||
@Composable
|
||||
fun AppEntrypoint() {
|
||||
|
|
@ -50,26 +56,26 @@ fun AppEntrypoint() {
|
|||
enterTransition = {
|
||||
slideIntoContainer(
|
||||
AnimatedContentScope.SlideDirection.Left,
|
||||
animationSpec = tween(400)
|
||||
) + fadeIn(animationSpec = tween(400))
|
||||
animationSpec = RevoltTweenInt
|
||||
) + fadeIn(animationSpec = RevoltTweenFloat)
|
||||
},
|
||||
exitTransition = {
|
||||
slideOutOfContainer(
|
||||
AnimatedContentScope.SlideDirection.Left,
|
||||
animationSpec = tween(400)
|
||||
) + fadeOut(animationSpec = tween(400))
|
||||
animationSpec = RevoltTweenInt
|
||||
) + fadeOut(animationSpec = RevoltTweenFloat)
|
||||
},
|
||||
popEnterTransition = {
|
||||
slideIntoContainer(
|
||||
AnimatedContentScope.SlideDirection.Right,
|
||||
animationSpec = tween(400)
|
||||
) + fadeIn(animationSpec = tween(400))
|
||||
animationSpec = RevoltTweenInt
|
||||
) + fadeIn(animationSpec = RevoltTweenFloat)
|
||||
},
|
||||
popExitTransition = {
|
||||
slideOutOfContainer(
|
||||
AnimatedContentScope.SlideDirection.Right,
|
||||
animationSpec = tween(400)
|
||||
) + fadeOut(animationSpec = tween(400))
|
||||
animationSpec = RevoltTweenInt
|
||||
) + fadeOut(animationSpec = RevoltTweenFloat)
|
||||
}
|
||||
) {
|
||||
composable("login/greeting") { GreeterScreen(navController) }
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ fun CollapsibleCard(
|
|||
|
||||
Card(
|
||||
modifier = modifier.padding(10.dp),
|
||||
shape = MaterialTheme.shapes.small
|
||||
shape = MaterialTheme.shapes.large
|
||||
) {
|
||||
Column() {
|
||||
Column {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
package chat.revolt.components.screens.home
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@Composable
|
||||
fun LinkOnHome(
|
||||
heading: String,
|
||||
icon: ImageVector,
|
||||
onClick: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
ElevatedButton(
|
||||
onClick = onClick,
|
||||
modifier = modifier
|
||||
.padding(10.dp)
|
||||
.fillMaxWidth()
|
||||
.clickable { onClick() },
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Icon(
|
||||
imageVector = icon,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.padding(10.dp)
|
||||
)
|
||||
Text(
|
||||
text = heading,
|
||||
style = MaterialTheme.typography.titleMedium.copy(
|
||||
fontWeight = FontWeight.Bold
|
||||
),
|
||||
modifier = Modifier.padding(5.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,8 @@ package chat.revolt.screens.chat
|
|||
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Send
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
|
|
@ -22,9 +24,9 @@ import androidx.lifecycle.viewModelScope
|
|||
import androidx.navigation.NavController
|
||||
import chat.revolt.api.REVOLT_FILES
|
||||
import chat.revolt.api.RevoltAPI
|
||||
import chat.revolt.components.generic.CollapsibleCard
|
||||
import chat.revolt.components.generic.FormTextField
|
||||
import chat.revolt.components.generic.RemoteImage
|
||||
import chat.revolt.components.screens.home.LinkOnHome
|
||||
import chat.revolt.persistence.KVStorage
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.launch
|
||||
|
|
@ -101,17 +103,18 @@ fun HomeScreen(navController: NavController, viewModel: HomeScreenViewModel = hi
|
|||
}
|
||||
}
|
||||
|
||||
CollapsibleCard(title = "Send a message") {
|
||||
Column() {
|
||||
FormTextField(
|
||||
value = viewModel.messageContent,
|
||||
label = "Content",
|
||||
onChange = viewModel::setMessageContent
|
||||
)
|
||||
Button(onClick = { viewModel.sendMessage() }) {
|
||||
Text(text = "Send")
|
||||
}
|
||||
}
|
||||
Column() {
|
||||
FormTextField(
|
||||
value = viewModel.messageContent,
|
||||
label = "Content",
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
onChange = viewModel::setMessageContent
|
||||
)
|
||||
LinkOnHome(
|
||||
heading = "Send",
|
||||
icon = Icons.Filled.Send,
|
||||
onClick = viewModel::sendMessage
|
||||
)
|
||||
}
|
||||
}
|
||||
Button(
|
||||
|
|
@ -130,5 +133,4 @@ fun HomeScreen(navController: NavController, viewModel: HomeScreenViewModel = hi
|
|||
Text("Logout")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue