Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ dependencies {
implementation(project(":feature:home"))
implementation(project(":feature:create"))
implementation(project(":feature:profile"))
implementation(project(":feature:setting"))
implementation(project(":feature:detail"))
implementation(project(":feature:friend"))
implementation(project(":feature:management"))
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/com/idiotfrogs/memoryseal/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import com.idiotfrogs.navigation.Routes
import com.idiotfrogs.preview.PreviewRoute
import com.idiotfrogs.profile.editprofile.EditProfileRoute
import com.idiotfrogs.profile.profile.ProfileRoute
import com.idiotfrogs.setting.SettingRoute
import com.idiotfrogs.splash.SplashRoute
import dagger.hilt.android.AndroidEntryPoint

Expand Down Expand Up @@ -136,7 +135,6 @@ class MainActivity : ComponentActivity() {
entry<Routes.Create> { CreateRoute() }
entry<Routes.Profile> { ProfileRoute() }
entry<Routes.EditProfile> { EditProfileRoute() }
entry<Routes.Setting> { SettingRoute() }
entry<Routes.Detail> { DetailRoute(capsuleId = it.id) }
entry<Routes.Message> { MessageRoute(capsuleId = it.id) }
entry<Routes.Preview> { PreviewRoute(capsuleId = it.id) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import kotlin.math.min
import kotlin.math.roundToInt
import kotlin.math.sin

enum class DrawType { TOP, BOTTOM, START, END, ALL }
enum class DrawType { TOP, BOTTOM, START, END, ALL, TOP_SIDES }
enum class WavyAlign { INNER, OUTER }

fun Modifier.wavyStroke(
Expand Down Expand Up @@ -102,6 +102,16 @@ fun Modifier.wavyStroke(
seed = seed + size.width.roundToInt() + size.height.roundToInt() * 1_000_003L,
)
}
DrawType.TOP_SIDES -> {
makeTopSidesWavyPath(
rect = rect,
cornerRadius = radius,
spacing = spacingPx,
amplitude = ampPx,
seed = seed + size.width.roundToInt() +
size.height.roundToInt() * 1_000_003L,
)
}
}

val fillPath = if (drawType == DrawType.ALL) {
Expand Down Expand Up @@ -130,6 +140,10 @@ fun Modifier.wavyStroke(
lineTo(0f, 0f)
lineTo(size.width, 0f)
}
DrawType.TOP_SIDES -> {
lineTo(rect.right, size.height)
lineTo(rect.left, size.height)
}
}
close()
}
Expand Down Expand Up @@ -366,5 +380,89 @@ private fun makeSingleAxisWavyPath(
}
}

private fun makeTopSidesWavyPath(
rect: Rect,
cornerRadius: Float,
spacing: Float,
amplitude: Float,
seed: Long,
): Path {
val wavyData = mutableListOf<WavyData>()

fun line(from: Offset, to: Offset, normal: Offset) {
val dx = to.x - from.x
val dy = to.y - from.y
val length = hypot(dx, dy)
val count = max(1, (length / spacing).toInt())

repeat(count) { i ->
val t = i / count.toFloat()
wavyData += WavyData(
point = Offset(from.x + dx * t, from.y + dy * t),
normal = normal,
)
}
}

fun arc(center: Offset, radius: Float, start: Float, end: Float) {
val count = max(1, (abs(end - start) * radius / spacing).toInt())

repeat(count) { i ->
val t = i / count.toFloat()
val angle = start + (end - start) * t
wavyData += WavyData(
point = Offset(
center.x + cos(angle) * radius,
center.y + sin(angle) * radius,
),
normal = Offset(cos(angle), sin(angle)),
)
}
}

line(
Offset(rect.left, rect.bottom - cornerRadius),
Offset(rect.left, rect.top + cornerRadius),
Offset(-1f, 0f)
)
arc(
Offset(rect.left + cornerRadius, rect.top + cornerRadius),
cornerRadius, PI.toFloat(), PI.toFloat() * 1.5f
)
line(
Offset(rect.left + cornerRadius, rect.top),
Offset(rect.right - cornerRadius, rect.top),
Offset(0f, -1f)
)
arc(
Offset(rect.right - cornerRadius, rect.top + cornerRadius),
cornerRadius, -PI.toFloat() / 2f, 0f
)
line(
Offset(rect.right, rect.top + cornerRadius),
Offset(rect.right, rect.bottom - cornerRadius),
Offset(1f, 0f)
)

var nextSeed = seed
val points = wavyData.map {
nextSeed = nextSeed * 6364136223846793005L + 1442695040888963407L
val random = ((nextSeed ushr 1) % 2000L) / 1000f - 1f
val offset = random * amplitude
it.point + it.normal * offset
}

return Path().apply {
if (points.isEmpty()) return@apply

moveTo(points.first().x, points.first().y)
points.zipWithNext { current, next ->
val mid = midpoint(current, next)
quadraticTo(current.x, current.y, mid.x, mid.y)
}
lineTo(points.last().x, points.last().y)
}
}

private fun midpoint(a: Offset, b: Offset): Offset =
Offset((a.x + b.x) / 2f, (a.y + b.y) / 2f)
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ sealed interface Routes: NavKey {
@Serializable
data object EditProfile : Routes
@Serializable
data object Setting : Routes
@Serializable
data class Friend(val id: Long) : Routes
@Serializable
data class Detail(val id: Long) : Routes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package com.idiotfrogs.profile.component

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
Expand All @@ -23,15 +22,13 @@ import com.idiotfrogs.resource.R
fun ProfileHeader(
modifier: Modifier = Modifier,
onBack: () -> Unit,
onSetting: () -> Unit
) {
Row(
Box(
modifier = modifier
.fillMaxWidth()
.background(MSTheme.color.white)
.padding(horizontal = 20.dp, vertical = 16.dp),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
contentAlignment = Alignment.CenterStart,
) {
Image(
modifier = Modifier
Expand All @@ -41,18 +38,12 @@ fun ProfileHeader(
contentDescription = "chevron_left",
)
MSText(
modifier = Modifier.align(Alignment.Center),
text = "ํ”„๋กœํ•„",
fontWeight = FontWeight.Bold,
fontSize = 20.dp,
color = MSTheme.color.greyG5
)
Image(
modifier = Modifier
.size(24.dp)
.noRippleClickable(onClick = onSetting),
painter = painterResource(R.drawable.ic_setting),
contentDescription = "์„ค์ •"
)
}
}

Expand All @@ -61,6 +52,5 @@ fun ProfileHeader(
private fun ProfileHeaderPreview() {
ProfileHeader(
onBack = {},
onSetting = {}
)
}
Loading
Loading