-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[Feature/#113] Apply profile card card screen design roughly
- Loading branch information
Showing
7 changed files
with
285 additions
and
20 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
...onMain/kotlin/io/github/droidkaigi/confsched/designsystem/theme/ProfileCardScreenTheme.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package io.github.droidkaigi.confsched.designsystem.theme | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.CompositionLocalProvider | ||
import androidx.compose.runtime.ProvidableCompositionLocal | ||
import androidx.compose.runtime.staticCompositionLocalOf | ||
import androidx.compose.ui.graphics.Color | ||
|
||
sealed interface ProfileCardScreenTheme { | ||
data object Default : ProfileCardScreenTheme { | ||
override val primaryColor = Color(0xFFB4FF79) | ||
override val containerColor = Color(0xFFC0FF8E) | ||
} | ||
|
||
data object Orange : ProfileCardScreenTheme { | ||
override val primaryColor = Color(0xFFFEB258) | ||
override val containerColor = Color(0xFFFFBB69) | ||
} | ||
|
||
data object Yellow : ProfileCardScreenTheme { | ||
override val primaryColor = Color(0xFFFCF65F) | ||
override val containerColor = Color(0xFFFFFA77) | ||
} | ||
|
||
data object Pink : ProfileCardScreenTheme { | ||
override val primaryColor = Color(0xFF6FD7F8) | ||
override val containerColor = Color(0xFFFFA0C9) | ||
} | ||
|
||
data object Blue : ProfileCardScreenTheme { | ||
override val primaryColor = Color(0xFFB4FF79) | ||
override val containerColor = Color(0xFF93E5FF) | ||
} | ||
|
||
data object White : ProfileCardScreenTheme { | ||
override val primaryColor = Color(0xFFF9F9F9) | ||
override val containerColor = Color.White | ||
} | ||
|
||
val primaryColor: Color | ||
val containerColor: Color | ||
|
||
companion object { | ||
fun ofOrNull(profileCardTheme: String): ProfileCardScreenTheme? { | ||
return when (profileCardTheme) { | ||
"Iguana" -> Default | ||
"Hedgehog" -> Orange | ||
"Giraffe" -> Yellow | ||
"Flamingo" -> Pink | ||
"Jellyfish" -> Blue | ||
else -> White | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Suppress("CompositionLocalAllowlist") | ||
val LocalProfileCardScreenTheme: ProvidableCompositionLocal<ProfileCardScreenTheme> = | ||
staticCompositionLocalOf<ProfileCardScreenTheme> { | ||
error("No RoomTheme provided") | ||
} | ||
|
||
@Composable | ||
fun ProvideProfileCardScreenTheme(profileCardTheme: String, content: @Composable () -> Unit) { | ||
val profileCardTheme = ProfileCardScreenTheme.ofOrNull(profileCardTheme) ?: ProfileCardScreenTheme.Default | ||
CompositionLocalProvider(LocalProfileCardScreenTheme provides profileCardTheme) { | ||
content() | ||
} | ||
} |
Binary file added
BIN
+17.8 KB
feature/profilecard/src/commonMain/composeResources/drawable/icon_qr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+311 Bytes
feature/profilecard/src/commonMain/composeResources/drawable/icon_share.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion
2
feature/profilecard/src/commonMain/composeResources/values-ja/strings.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="sample">!!Please remove this resource when you add string resource!!</string> | ||
<string name="profile_card">プロフィールカード</string> | ||
</resources> |
2 changes: 1 addition & 1 deletion
2
feature/profilecard/src/commonMain/composeResources/values/strings.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="sample">!!Please remove this resource when you add string resource!!</string> | ||
<string name="profile_card">Profile Card</string> | ||
</resources> |
136 changes: 136 additions & 0 deletions
136
.../profilecard/src/commonMain/kotlin/io/github/droidkaigi/confsched/profilecard/FlipCard.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
package io.github.droidkaigi.confsched.profilecard | ||
|
||
import androidx.compose.animation.core.FastOutSlowInEasing | ||
import androidx.compose.animation.core.animateFloatAsState | ||
import androidx.compose.animation.core.tween | ||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.shape.CircleShape | ||
import androidx.compose.material3.Card | ||
import androidx.compose.material3.CardDefaults | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.saveable.rememberSaveable | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.graphics.graphicsLayer | ||
import androidx.compose.ui.unit.dp | ||
import conference_app_2024.feature.profilecard.generated.resources.icon_qr | ||
import io.github.droidkaigi.confsched.designsystem.theme.LocalProfileCardScreenTheme | ||
import io.github.droidkaigi.confsched.designsystem.theme.ProvideProfileCardScreenTheme | ||
import io.github.droidkaigi.confsched.ui.rememberAsyncImagePainter | ||
import kotlinx.coroutines.delay | ||
import org.jetbrains.compose.resources.painterResource | ||
|
||
@Composable | ||
internal fun FlipCard( | ||
uiState: ProfileCardUiState.Card, | ||
modifier: Modifier = Modifier, | ||
isCreated: Boolean = false, | ||
) { | ||
var isFlipped by remember { mutableStateOf(false) } | ||
var isCreated by rememberSaveable { mutableStateOf(isCreated) } | ||
var initialRotation by remember { mutableStateOf(0f) } | ||
val rotation = animateFloatAsState( | ||
targetValue = if (isFlipped) 180f else initialRotation, | ||
animationSpec = tween( | ||
durationMillis = 400, | ||
easing = FastOutSlowInEasing, | ||
), | ||
) | ||
val targetRotation = animateFloatAsState( | ||
targetValue = 30f, | ||
animationSpec = tween( | ||
durationMillis = 400, | ||
easing = FastOutSlowInEasing, | ||
), | ||
).value | ||
val targetRotation2 = animateFloatAsState( | ||
targetValue = 0f, | ||
animationSpec = tween( | ||
durationMillis = 400, | ||
easing = FastOutSlowInEasing, | ||
), | ||
).value | ||
|
||
LaunchedEffect(Unit) { | ||
if (isCreated) { | ||
initialRotation = targetRotation | ||
delay(400) | ||
initialRotation = targetRotation2 | ||
isCreated = false | ||
} | ||
} | ||
|
||
ProvideProfileCardScreenTheme(uiState.theme.toString()) { | ||
Card( | ||
modifier = modifier | ||
.size(width = 300.dp, height = 380.dp) | ||
.clickable { isFlipped = !isFlipped } | ||
.graphicsLayer { | ||
rotationY = rotation.value | ||
cameraDistance = 12f * density | ||
}, | ||
colors = CardDefaults.cardColors(containerColor = LocalProfileCardScreenTheme.current.containerColor), | ||
elevation = CardDefaults.cardElevation(10.dp), | ||
) { | ||
if (isFlipped) { // Back | ||
Column( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.graphicsLayer { | ||
rotationY = 180f | ||
}, | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
verticalArrangement = Arrangement.Center, | ||
) { | ||
Image( | ||
painter = painterResource(ProfileCardRes.drawable.icon_qr), | ||
contentDescription = null, | ||
modifier = Modifier.size(160.dp), | ||
) | ||
} | ||
} else { // Front | ||
Column( | ||
modifier = Modifier.fillMaxSize(), | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
verticalArrangement = Arrangement.Center, | ||
) { | ||
Image( | ||
painter = rememberAsyncImagePainter(uiState.image ?: ""), | ||
contentDescription = null, | ||
modifier = Modifier | ||
.clip(CircleShape) | ||
.size(120.dp), | ||
) | ||
Spacer(Modifier.height(12.dp)) | ||
Text( | ||
text = uiState.occupation ?: "", | ||
style = MaterialTheme.typography.titleMedium, | ||
color = Color.Black, | ||
) | ||
Spacer(Modifier.height(2.dp)) | ||
Text( | ||
text = uiState.nickname, | ||
style = MaterialTheme.typography.headlineSmall, | ||
color = Color.Black, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters