-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
1,155 additions
and
354 deletions.
There are no files selected for viewing
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
117 changes: 117 additions & 0 deletions
117
app/src/main/java/com/wafflestudio/snutt2/components/compose/EditTextFieldValue.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,117 @@ | ||
package com.wafflestudio.snutt2.components.compose | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.text.BasicTextField | ||
import androidx.compose.foundation.text.KeyboardActions | ||
import androidx.compose.foundation.text.KeyboardOptions | ||
import androidx.compose.foundation.text.selection.LocalTextSelectionColors | ||
import androidx.compose.foundation.text.selection.TextSelectionColors | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.CompositionLocalProvider | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.focus.onFocusChanged | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.graphics.SolidColor | ||
import androidx.compose.ui.platform.LocalFocusManager | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.text.input.TextFieldValue | ||
import androidx.compose.ui.text.input.VisualTransformation | ||
import androidx.compose.ui.unit.Dp | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import com.wafflestudio.snutt2.ui.SNUTTColors | ||
import com.wafflestudio.snutt2.ui.SNUTTTypography | ||
|
||
@Composable | ||
fun EditTextFieldValue( | ||
modifier: Modifier = Modifier, | ||
leadingIcon: @Composable (() -> Unit) = {}, | ||
trailingIcon: @Composable (() -> Unit) = {}, | ||
keyboardOptions: KeyboardOptions = KeyboardOptions(), | ||
keyboardActions: KeyboardActions = KeyboardActions(), | ||
singleLine: Boolean = false, | ||
enabled: Boolean = true, | ||
visualTransformation: VisualTransformation = VisualTransformation.None, | ||
value: TextFieldValue, | ||
onValueChange: (TextFieldValue) -> Unit, | ||
hint: String? = null, | ||
hintTextColor: Color = SNUTTColors.EditTextHint, | ||
hintTextStyle: TextStyle = SNUTTTypography.body1.copy(fontSize = 15.sp), | ||
underlineEnabled: Boolean = true, | ||
underlineColor: Color = SNUTTColors.Gray200, | ||
underlineColorFocused: Color = SNUTTColors.Black900, | ||
underlineWidth: Dp = 1.dp, | ||
clearFocusFlag: Boolean = false, | ||
textStyle: TextStyle = SNUTTTypography.subtitle1.copy(color = SNUTTColors.Black900), | ||
) { | ||
val focusManager = LocalFocusManager.current | ||
LaunchedEffect(clearFocusFlag) { | ||
if (clearFocusFlag) focusManager.clearFocus() | ||
} | ||
|
||
var isFocused by remember { mutableStateOf(false) } | ||
val customTextSelectionColors = TextSelectionColors( | ||
handleColor = SNUTTColors.Black900, | ||
backgroundColor = SNUTTColors.Black300, | ||
) | ||
CompositionLocalProvider( | ||
LocalTextSelectionColors provides customTextSelectionColors, | ||
) { | ||
BasicTextField( | ||
modifier = modifier | ||
.onFocusChanged { isFocused = it.isFocused }, | ||
keyboardOptions = keyboardOptions, | ||
keyboardActions = keyboardActions, | ||
value = value, | ||
textStyle = textStyle, | ||
enabled = enabled, | ||
onValueChange = onValueChange, | ||
singleLine = singleLine, | ||
visualTransformation = visualTransformation, | ||
cursorBrush = SolidColor(SNUTTColors.Black900), | ||
decorationBox = { | ||
Column { | ||
Row(modifier = Modifier.fillMaxWidth()) { | ||
leadingIcon() | ||
Box( | ||
modifier = Modifier.weight(1f), | ||
) { | ||
it() | ||
if (value.text.isEmpty()) { | ||
hint?.let { | ||
Text( | ||
text = it, | ||
style = hintTextStyle.copy(color = hintTextColor), | ||
) | ||
} | ||
} | ||
} | ||
trailingIcon() | ||
} | ||
|
||
if (underlineEnabled) { | ||
Box( | ||
modifier = Modifier | ||
.padding(top = 8.dp) | ||
.background(if (isFocused) underlineColorFocused else underlineColor) | ||
.fillMaxWidth() | ||
.height(underlineWidth), | ||
) | ||
} | ||
} | ||
}, | ||
) | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
app/src/main/java/com/wafflestudio/snutt2/components/compose/IOSStyleTopBar.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,78 @@ | ||
package com.wafflestudio.snutt2.components.compose | ||
|
||
import androidx.compose.animation.AnimatedContent | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.drawWithCache | ||
import androidx.compose.ui.geometry.Offset | ||
import androidx.compose.ui.graphics.ColorFilter | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import com.wafflestudio.snutt2.ui.SNUTTColors | ||
import com.wafflestudio.snutt2.ui.SNUTTTypography | ||
|
||
@Composable | ||
fun IOSStyleTopBar( | ||
modifier: Modifier = Modifier, | ||
title: String, | ||
backButtonText: String, | ||
onBack: () -> Unit, | ||
) { | ||
Box( | ||
modifier = modifier | ||
.fillMaxWidth() | ||
.background(color = SNUTTColors.White900) | ||
.height(40.dp) | ||
.drawWithCache { | ||
onDrawWithContent { | ||
drawLine( | ||
color = SNUTTColors.EditTextHint, | ||
start = Offset(0f, this.size.height), end = Offset(this.size.width, this.size.height), | ||
strokeWidth = 0.5.dp.toPx(), | ||
) | ||
drawContent() | ||
} | ||
} | ||
.padding(horizontal = 5.dp), | ||
contentAlignment = Alignment.CenterStart, | ||
) { | ||
Row( | ||
modifier = Modifier.clicks(1000L) { onBack() }, | ||
verticalAlignment = Alignment.CenterVertically, | ||
) { | ||
ArrowBackIcon( | ||
colorFilter = ColorFilter.tint(SNUTTColors.Black900), | ||
) | ||
AnimatedContent(backButtonText, label = "") { | ||
Text( | ||
text = it, | ||
style = SNUTTTypography.button, | ||
) | ||
} | ||
} | ||
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { | ||
Text( | ||
text = title, | ||
style = SNUTTTypography.h3, | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun IOSStyleTopBarPreview() { | ||
IOSStyleTopBar( | ||
title = "비밀번호 재설정", | ||
backButtonText = "로그인", | ||
) { } | ||
} |
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
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
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
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
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
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
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
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
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
Oops, something went wrong.