Skip to content

Commit

Permalink
mod: #6 문자열 strings로 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyobeen-Park committed May 2, 2024
1 parent a37de9d commit 698bd4a
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 66 deletions.
32 changes: 16 additions & 16 deletions app/src/main/java/com/sopt/now/compose/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,29 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.sopt.now.compose.ui.theme.NOWSOPTAndroidTheme

class HomeActivity: ComponentActivity() {
class HomeActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
NOWSOPTAndroidTheme {
Surface (
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
){

) {
HomeScreen()
}
}
}
}

data class BottomNavigationItem (
val Icon : ImageVector,
val label : String
data class BottomNavigationItem(
val Icon: ImageVector,
val label: String
)

@OptIn(ExperimentalMaterial3Api::class)
Expand All @@ -73,42 +73,43 @@ class HomeActivity: ComponentActivity() {
)
)

Scaffold (
Scaffold(
topBar = {
TopAppBar(
colors = topAppBarColors(
containerColor = MaterialTheme.colorScheme.primaryContainer,
titleContentColor = MaterialTheme.colorScheme.primary
),
title = {
Text("NOW SOPT ANDROID")
Text(stringResource(id = R.string.app_name))
}
)
},
bottomBar = {
NavigationBar {
items.forEachIndexed {index, item ->
items.forEachIndexed { index, item ->
NavigationBarItem(
icon = { Icon(item.Icon, contentDescription = item.label)},
label = { Text(item.label)},
selected = selectedItem == index ,
icon = { Icon(item.Icon, contentDescription = item.label) },
label = { Text(item.label) },
selected = selectedItem == index,
onClick = { selectedItem = index }
)
}
}
}
) { innerPadding ->
Column (
Column(
modifier = Modifier
.padding(innerPadding)
.padding(horizontal = 30.dp),
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
when(selectedItem) {
when (selectedItem) {
0 -> HomeFragment(
intent.getStringExtra("nickname"),
intent.getStringExtra("mbti")
)

1 -> SearchFragment()
2 -> MypageFragment(
intent.getStringExtra("id"),
Expand All @@ -122,5 +123,4 @@ class HomeActivity: ComponentActivity() {
}



}
43 changes: 23 additions & 20 deletions app/src/main/java/com/sopt/now/compose/LoginActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight.Companion.Bold
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.PasswordVisualTransformation
Expand All @@ -43,7 +44,7 @@ class LoginActivity : ComponentActivity() {
super.onCreate(savedInstanceState)
setContent {
NOWSOPTAndroidTheme {
Surface (
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
Expand All @@ -60,29 +61,29 @@ class LoginActivity : ComponentActivity() {
}

@Composable
fun Login(signupId : String?, signupPw : String?, nickname : String?, mbti : String?) {
fun Login(signupId: String?, signupPw: String?, nickname: String?, mbti: String?) {
val context = LocalContext.current
var id by remember { mutableStateOf("") }
var pw by remember { mutableStateOf("") }

var shouldShowPassword by remember {
mutableStateOf(false)
}
val passwordResource : (Boolean) -> Int = {
if(it) {
val passwordResource: (Boolean) -> Int = {
if (it) {
R.drawable.ic_baseline_visibility_white_24
} else {
R.drawable.ic_baseline_visibility_off_white_24
}
}

Column (
Column(
modifier = Modifier
.padding(horizontal = 70.dp)
.fillMaxWidth()
) {
Text(
text = "Welcome To SOPT",
text = stringResource(id = R.string.tv_login_title),
fontSize = 30.sp,
fontWeight = Bold,
textAlign = TextAlign.Center,
Expand All @@ -91,7 +92,7 @@ fun Login(signupId : String?, signupPw : String?, nickname : String?, mbti : Str
.padding(top = 70.dp)
)
Text(
text = "ID",
text = stringResource(id = R.string.tv_login_id),
fontSize = 20.sp,
fontWeight = Bold,
textAlign = TextAlign.Start,
Expand All @@ -107,10 +108,10 @@ fun Login(signupId : String?, signupPw : String?, nickname : String?, mbti : Str
modifier = Modifier
.fillMaxWidth()
.padding(top = 10.dp),
label = {Text("아이디를 입력해주세요")}
label = { Text(stringResource(id = R.string.et_login_id_hint)) }
)
Text(
text = "비밀번호",
text = stringResource(id = R.string.tv_login_pw),
fontSize = 20.sp,
fontWeight = Bold,
textAlign = TextAlign.Start,
Expand All @@ -128,23 +129,25 @@ fun Login(signupId : String?, signupPw : String?, nickname : String?, mbti : Str
.padding(top = 10.dp),
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password),
visualTransformation = if (shouldShowPassword) VisualTransformation.None
else PasswordVisualTransformation(),
label = {Text("비밀번호를 입력해주세요")},
else PasswordVisualTransformation(),
label = { Text(stringResource(id = R.string.et_login_pw_hint)) },
trailingIcon = {
IconButton(onClick = {
shouldShowPassword = !shouldShowPassword
}) {
Icon(painter = painterResource(
id = passwordResource(shouldShowPassword)),
Icon(
painter = painterResource(
id = passwordResource(shouldShowPassword)
),
contentDescription = null
)
}
}
)
Button(
onClick = {
if(id == signupId && pw == signupPw) {
Toast.makeText(context, "로그인에 성공했습니다.", Toast.LENGTH_SHORT).show()
if (id == signupId && pw == signupPw) {
Toast.makeText(context, R.string.login_success, Toast.LENGTH_SHORT).show()
Intent(context, HomeActivity::class.java).apply {
putExtra("id", id)
putExtra("pw", pw)
Expand All @@ -154,7 +157,7 @@ fun Login(signupId : String?, signupPw : String?, nickname : String?, mbti : Str
}

} else {
Toast.makeText(context, "아이디와 비밀번호가 일치하지 않습니다.", Toast.LENGTH_SHORT).show()
Toast.makeText(context, R.string.login_fail, Toast.LENGTH_SHORT).show()
}
},
colors = ButtonDefaults.buttonColors(
Expand All @@ -164,7 +167,7 @@ fun Login(signupId : String?, signupPw : String?, nickname : String?, mbti : Str
.fillMaxWidth()
.padding(top = 20.dp)
) {
Text(text = "로그인")
Text(text = stringResource(id = R.string.btn_login))
}
Button(
onClick = {
Expand All @@ -175,13 +178,13 @@ fun Login(signupId : String?, signupPw : String?, nickname : String?, mbti : Str
containerColor = Color.Transparent
),
modifier = Modifier.align(Alignment.End)
) {
Text(text = "회원가입하기", color = Color.Black)
) {
Text(text = stringResource(id = R.string.btn_signup), color = Color.Black)
}
}
}

@Preview (showBackground = true)
@Preview(showBackground = true)
@Composable
fun LoginPreview() {
Login(null, null, null, null)
Expand Down
13 changes: 7 additions & 6 deletions app/src/main/java/com/sopt/now/compose/MypageFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

@Composable
fun MypageFragment(id : String ?= "", pw : String ?= "", nickname : String ?= "", mbti : String ?= "") {
Column (
fun MypageFragment(id: String? = "", pw: String? = "", nickname: String? = "", mbti: String? = "") {
Column(
modifier = Modifier
.padding(horizontal = 40.dp)
.fillMaxWidth(),
Expand All @@ -46,14 +47,14 @@ fun MypageFragment(id : String ?= "", pw : String ?= "", nickname : String ?= ""
modifier = Modifier.padding(top = 30.dp)
)
}
Row (
Row(
modifier = Modifier
.fillMaxWidth()
.padding(top = 40.dp),
horizontalArrangement = Arrangement.Start
) {
Text(
text = "ID : ",
text = stringResource(id = R.string.tv_mypage_id),
fontSize = 30.sp,
fontWeight = FontWeight.Bold,
textAlign = TextAlign.Start
Expand All @@ -67,14 +68,14 @@ fun MypageFragment(id : String ?= "", pw : String ?= "", nickname : String ?= ""
)
}
}
Row (
Row(
modifier = Modifier
.fillMaxWidth()
.padding(top = 15.dp),
horizontalArrangement = Arrangement.Start
) {
Text(
text = "MBTI : ",
text = stringResource(id = R.string.tv_mypage_mbti),
fontSize = 30.sp,
fontWeight = FontWeight.Bold,
textAlign = TextAlign.Start
Expand Down
Loading

0 comments on commit 698bd4a

Please sign in to comment.