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.ComponentActivity
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import androidx.compose.animation.*
|
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.animation.core.tween
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.material3.*
|
import androidx.compose.material3.*
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.unit.IntOffset
|
||||||
import chat.revolt.screens.about.AboutScreen
|
import chat.revolt.screens.about.AboutScreen
|
||||||
import chat.revolt.screens.about.AttributionScreen
|
import chat.revolt.screens.about.AttributionScreen
|
||||||
import chat.revolt.screens.about.PlaceholderScreen
|
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)
|
@OptIn(ExperimentalAnimationApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun AppEntrypoint() {
|
fun AppEntrypoint() {
|
||||||
|
|
@ -50,26 +56,26 @@ fun AppEntrypoint() {
|
||||||
enterTransition = {
|
enterTransition = {
|
||||||
slideIntoContainer(
|
slideIntoContainer(
|
||||||
AnimatedContentScope.SlideDirection.Left,
|
AnimatedContentScope.SlideDirection.Left,
|
||||||
animationSpec = tween(400)
|
animationSpec = RevoltTweenInt
|
||||||
) + fadeIn(animationSpec = tween(400))
|
) + fadeIn(animationSpec = RevoltTweenFloat)
|
||||||
},
|
},
|
||||||
exitTransition = {
|
exitTransition = {
|
||||||
slideOutOfContainer(
|
slideOutOfContainer(
|
||||||
AnimatedContentScope.SlideDirection.Left,
|
AnimatedContentScope.SlideDirection.Left,
|
||||||
animationSpec = tween(400)
|
animationSpec = RevoltTweenInt
|
||||||
) + fadeOut(animationSpec = tween(400))
|
) + fadeOut(animationSpec = RevoltTweenFloat)
|
||||||
},
|
},
|
||||||
popEnterTransition = {
|
popEnterTransition = {
|
||||||
slideIntoContainer(
|
slideIntoContainer(
|
||||||
AnimatedContentScope.SlideDirection.Right,
|
AnimatedContentScope.SlideDirection.Right,
|
||||||
animationSpec = tween(400)
|
animationSpec = RevoltTweenInt
|
||||||
) + fadeIn(animationSpec = tween(400))
|
) + fadeIn(animationSpec = RevoltTweenFloat)
|
||||||
},
|
},
|
||||||
popExitTransition = {
|
popExitTransition = {
|
||||||
slideOutOfContainer(
|
slideOutOfContainer(
|
||||||
AnimatedContentScope.SlideDirection.Right,
|
AnimatedContentScope.SlideDirection.Right,
|
||||||
animationSpec = tween(400)
|
animationSpec = RevoltTweenInt
|
||||||
) + fadeOut(animationSpec = tween(400))
|
) + fadeOut(animationSpec = RevoltTweenFloat)
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
composable("login/greeting") { GreeterScreen(navController) }
|
composable("login/greeting") { GreeterScreen(navController) }
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,9 @@ fun CollapsibleCard(
|
||||||
|
|
||||||
Card(
|
Card(
|
||||||
modifier = modifier.padding(10.dp),
|
modifier = modifier.padding(10.dp),
|
||||||
shape = MaterialTheme.shapes.small
|
shape = MaterialTheme.shapes.large
|
||||||
) {
|
) {
|
||||||
Column() {
|
Column {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.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.layout.*
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
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.Button
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
|
|
@ -22,9 +24,9 @@ import androidx.lifecycle.viewModelScope
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import chat.revolt.api.REVOLT_FILES
|
import chat.revolt.api.REVOLT_FILES
|
||||||
import chat.revolt.api.RevoltAPI
|
import chat.revolt.api.RevoltAPI
|
||||||
import chat.revolt.components.generic.CollapsibleCard
|
|
||||||
import chat.revolt.components.generic.FormTextField
|
import chat.revolt.components.generic.FormTextField
|
||||||
import chat.revolt.components.generic.RemoteImage
|
import chat.revolt.components.generic.RemoteImage
|
||||||
|
import chat.revolt.components.screens.home.LinkOnHome
|
||||||
import chat.revolt.persistence.KVStorage
|
import chat.revolt.persistence.KVStorage
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
@ -101,17 +103,18 @@ fun HomeScreen(navController: NavController, viewModel: HomeScreenViewModel = hi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CollapsibleCard(title = "Send a message") {
|
Column() {
|
||||||
Column() {
|
FormTextField(
|
||||||
FormTextField(
|
value = viewModel.messageContent,
|
||||||
value = viewModel.messageContent,
|
label = "Content",
|
||||||
label = "Content",
|
modifier = Modifier.fillMaxWidth(),
|
||||||
onChange = viewModel::setMessageContent
|
onChange = viewModel::setMessageContent
|
||||||
)
|
)
|
||||||
Button(onClick = { viewModel.sendMessage() }) {
|
LinkOnHome(
|
||||||
Text(text = "Send")
|
heading = "Send",
|
||||||
}
|
icon = Icons.Filled.Send,
|
||||||
}
|
onClick = viewModel::sendMessage
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Button(
|
Button(
|
||||||
|
|
@ -130,5 +133,4 @@ fun HomeScreen(navController: NavController, viewModel: HomeScreenViewModel = hi
|
||||||
Text("Logout")
|
Text("Logout")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue