Skip to content

Commit

Permalink
feat: 로그인 수정 (#59) (KAN-135)
Browse files Browse the repository at this point in the history
  • Loading branch information
0114chan committed Nov 6, 2024
1 parent f16b05e commit 21b7d54
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 48 deletions.
1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

137 changes: 90 additions & 47 deletions app/src/main/java/com/example/mhnfe/ui/screens/auth/LoginScreen.kt
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
package com.example.mhnfe.ui.screens.auth

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.*
import androidx.compose.material3.Checkbox
import androidx.compose.material3.CheckboxDefaults
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.material3.Scaffold

import com.example.mhnfe.R
import com.example.mhnfe.ui.components.MainTextBox
import com.example.mhnfe.ui.components.SubTopBar
import com.example.mhnfe.ui.components.middleButton
import com.example.mhnfe.ui.theme.mainBlack
import com.example.mhnfe.ui.theme.mainGray
import com.example.mhnfe.ui.theme.mainYellow
import com.example.mhnfe.ui.theme.mainGray3

@Composable
fun LoginScreen(
modifier: Modifier = Modifier,
onBackClick: () -> Unit,
onLoginClick: () -> Unit
) {
val focusManager = LocalFocusManager.current
var isAutoLogin by remember { mutableStateOf(false) }

Scaffold(
modifier = Modifier
.statusBarsPadding()
.navigationBarsPadding(),
modifier = modifier,
topBar = {
SubTopBar(
text = "로그인",
Expand All @@ -38,63 +43,101 @@ fun LoginScreen(
}
) { paddingValues ->
Column(
modifier = Modifier
.fillMaxSize()
modifier = modifier
.padding(paddingValues)
.padding(horizontal = 20.dp)
.padding(top = 20.dp),
verticalArrangement = Arrangement.spacedBy(16.dp),
horizontalAlignment = Alignment.CenterHorizontally // 중앙 정렬 추가
.fillMaxSize()
.padding(horizontal = 34.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.SpaceBetween // 최상위 Column에 SpaceBetween 적용
) {
// 입력 필드들
// 상단부 (로고)
Column(
modifier = Modifier.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(16.dp)
horizontalAlignment = Alignment.CenterHorizontally
) {
MainTextBox(
focusManager = focusManager,
hintText = "아이디"
)
Spacer(modifier = Modifier.height(40.dp))

MainTextBox(
focusManager = focusManager,
hintText = "비밀번호"
// 로고 이미지
Image(
painter = painterResource(id = R.drawable.logo2),
contentDescription = "로고",
modifier = Modifier.size(250.dp),
contentScale = ContentScale.Fit
)

// 자동 로그인 체크박스
Row(
modifier = Modifier.padding(vertical = 4.dp),
verticalAlignment = Alignment.CenterVertically
Spacer(modifier = Modifier.height(60.dp))

// 입력 필드들과 자동로그인을 포함하는 Column
Column(
modifier = Modifier.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(16.dp),
horizontalAlignment = Alignment.Start
) {
Checkbox(
checked = isAutoLogin,
onCheckedChange = { isAutoLogin = it },
colors = CheckboxDefaults.colors(checkedColor = mainYellow)
MainTextBox(
focusManager = focusManager,
hintText = "아이디"
)

MainTextBox(
focusManager = focusManager,
hintText = "비밀번호"
)
Text("자동로그인")

// 자동 로그인 체크박스
Row( // Column을 Row로 변경
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.offset((-12).dp)
) {
Checkbox(
checked = isAutoLogin,
onCheckedChange = { isAutoLogin = it },
colors = CheckboxDefaults.colors(checkedColor = mainYellow)
)
Text(
text = "자동로그인",
color = mainGray
)
}
}
}

Spacer(modifier = Modifier.weight(1f))

// 로그인 버튼
middleButton(
text = "로그인",
onClick = onLoginClick,
modifier = Modifier.align(Alignment.CenterHorizontally)
)

// 비밀번호 찾기 텍스트
Text(
text = "비밀번호를 잊어버리셨나요?",
// 하단부 버튼과 텍스트를 포함하는 Column
Column(
modifier = Modifier
.padding(vertical = 16.dp), // fillMaxWidth 제거
textAlign = TextAlign.Center,
color = mainGray
)
.fillMaxWidth()
.padding(bottom = 20.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
// 로그인 버튼
middleButton(
text = "로그인",
onClick = onLoginClick,
modifier = Modifier.fillMaxWidth()
)

// 비밀번호 찾기 텍스트
Text(
text = "비밀번호를 잊어버리셨나요?",
textAlign = TextAlign.Center,
color = mainGray,

// 하단 여백
Spacer(modifier = Modifier.height(20.dp))
)
}
}
}
}

@Preview(
name = "Login Screen",
showBackground = true,
showSystemUi = true,
device = "spec:width=411dp,height=891dp"
)
@Composable
fun LoginScreenPreview() {
LoginScreen(
onBackClick = {},
onLoginClick = {}
)
}
Binary file added app/src/main/res/drawable/logo2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 21b7d54

Please sign in to comment.