Skip to content

Commit

Permalink
#7 세팅 - base url 숨기기
Browse files Browse the repository at this point in the history
  • Loading branch information
MinseoSONG committed Nov 13, 2024
1 parent a8f4e83 commit 4c4a341
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 32 deletions.
8 changes: 8 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import java.util.Properties

plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.compose)
}

val properties = Properties().apply{
load(project.rootProject.file("local.properties").inputStream())
}

android {
namespace = "org.sopt.and"
compileSdk = 35
Expand All @@ -16,6 +22,7 @@ android {
versionName = "1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
buildConfigField("String","BASE_URL", properties["base.url"].toString())
}

buildTypes {
Expand All @@ -36,6 +43,7 @@ android {
}
buildFeatures {
compose = true
buildConfig = true
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/sopt/and/component/BuyTextButton.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import org.sopt.and.R
@Composable
fun BuyTextButton(
labelText: String,
onClick: ()->Unit
onClick: () -> Unit
) {
Column {
Text(
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/sopt/and/component/MyPageItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fun MyPageItem(
.padding(bottom = 80.dp)
.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally
){
) {
Image(
painter = icon,
contentDescription = "",
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/java/org/sopt/and/component/bar/BottomBar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavHostController
import org.sopt.and.navigate.Routes
import org.sopt.and.navigate.ScreenTab

@Composable
Expand Down Expand Up @@ -55,8 +54,8 @@ fun BottomBar(

BottomTab(
onClick = {
navController.navigate(tab.route){
popUpTo(tab.route){
navController.navigate(tab.route) {
popUpTo(tab.route) {
inclusive = true
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/sopt/and/component/bar/TopBar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fun TopBar(modifier: Modifier = Modifier) {
modifier = Modifier.width(100.dp)
)

Row{
Row {
Image(
painter = painterResource(R.drawable.outline_cast_connected_24),
contentDescription = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fun IDTextField(
onValueChange: (String) -> Unit,
placeholder: String,
modifier: Modifier = Modifier
){
) {
TextField(
value = value,
onValueChange = onValueChange,
Expand Down
31 changes: 25 additions & 6 deletions app/src/main/java/org/sopt/and/navigate/NavGraph.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import androidx.navigation.compose.composable
import androidx.navigation.compose.currentBackStackEntryAsState
import org.sopt.and.component.bar.BottomBar
import org.sopt.and.ui.home.HomeScreen
import org.sopt.and.ui.home.HomeViewModel
import org.sopt.and.ui.my.MyScreen
import org.sopt.and.ui.search.SearchScreen
import org.sopt.and.ui.signin.SignInScreen
Expand All @@ -25,7 +24,7 @@ import org.sopt.and.ui.signup.SignUpScreen
import org.sopt.and.ui.signup.SignUpViewModel

@Composable
fun NavGraph(navController: NavHostController){
fun NavGraph(navController: NavHostController) {
val signUpViewModel: SignUpViewModel = viewModel()
val signInViewModel: SignInViewModel = viewModel()

Expand All @@ -37,7 +36,12 @@ fun NavGraph(navController: NavHostController){
val selectedScreen = ScreenTab.entries.find { it.route == currentRoute }
if (selectedScreen != null) {
BottomBar(selected = selectedScreen, navController = navController)
}else if (currentRoute in listOf(Routes.Home.route, Routes.My.route, Routes.Search.route)) {
} else if (currentRoute in listOf(
Routes.Home.route,
Routes.My.route,
Routes.Search.route
)
) {
BottomBar(selected = null, navController = navController)
}
}
Expand All @@ -49,9 +53,24 @@ fun NavGraph(navController: NavHostController){
.padding(paddingValues)
) {
NavHost(navController = navController, startDestination = Routes.SignIn.route) {
composable(Routes.SignIn.route) { SignInScreen(navController, signInViewModel = signInViewModel) }
composable(Routes.SignUp.route) { SignUpScreen(navController, signUpViewModel = signUpViewModel) }
composable(Routes.My.route) { MyScreen(navController, signInViewModel = signInViewModel) }
composable(Routes.SignIn.route) {
SignInScreen(
navController,
signInViewModel = signInViewModel
)
}
composable(Routes.SignUp.route) {
SignUpScreen(
navController,
signUpViewModel = signUpViewModel
)
}
composable(Routes.My.route) {
MyScreen(
navController,
signInViewModel = signInViewModel
)
}
composable(Routes.Search.route) { SearchScreen(navController) }
composable(Routes.Home.route) { HomeScreen(navController) }
}
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/java/org/sopt/and/ui/my/MyScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
Expand All @@ -25,7 +24,6 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.navigation.NavHostController
import org.sopt.and.R
import org.sopt.and.component.bar.BottomBar
import org.sopt.and.component.BuyTextButton
import org.sopt.and.component.MyPageItem
import org.sopt.and.ui.signin.SignInViewModel
Expand All @@ -39,7 +37,7 @@ fun MyScreen(

Column(
modifier = Modifier.fillMaxSize()
){
) {
Column(
modifier = Modifier
.background(Color.DarkGray)
Expand Down
3 changes: 0 additions & 3 deletions app/src/main/java/org/sopt/and/ui/search/SearchScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ package org.sopt.and.ui.search
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.navigation.NavHostController
import org.sopt.and.component.bar.BottomBar

@Composable
fun SearchScreen(
Expand Down
21 changes: 13 additions & 8 deletions app/src/main/java/org/sopt/and/ui/signup/SignUpScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fun SignUpScreen(

Column(
modifier = modifier
){
) {
Box(
modifier = Modifier
.fillMaxSize()
Expand All @@ -58,7 +58,7 @@ fun SignUpScreen(
modifier = Modifier
.padding(20.dp)
.align(Alignment.TopStart)
){
) {
Text(
text = stringResource(R.string.signup_text),
color = Color.Gray
Expand All @@ -67,7 +67,7 @@ fun SignUpScreen(

IDTextField(
value = userId,
onValueChange = {userId = it},
onValueChange = { userId = it },
modifier = Modifier.fillMaxWidth(),
placeholder = context.getString(R.string.signup_id)
)
Expand Down Expand Up @@ -95,15 +95,20 @@ fun SignUpScreen(
modifier = Modifier
.fillMaxWidth()
.align(Alignment.BottomCenter)
){
) {
Button(
onClick = {
if (signUpViewModel.isAbleEmail(userId) && signUpViewModel.isAblePassword(userPassWord)){
if (signUpViewModel.isAbleEmail(userId) && signUpViewModel.isAblePassword(
userPassWord
)
) {
signUpViewModel.saveUserInfo(userId, userPassWord)
navController.popBackStack()
Toast.makeText(context, (R.string.signup_success),Toast.LENGTH_SHORT).show()
}else{
Toast.makeText(context, (R.string.signup_fail),Toast.LENGTH_SHORT).show()
Toast.makeText(context, (R.string.signup_success), Toast.LENGTH_SHORT)
.show()
} else {
Toast.makeText(context, (R.string.signup_fail), Toast.LENGTH_SHORT)
.show()
}
},
modifier = Modifier
Expand Down
5 changes: 0 additions & 5 deletions app/src/main/java/org/sopt/and/ui/signup/SignUpViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ package org.sopt.and.ui.signup

import android.content.Context
import android.content.SharedPreferences
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import org.sopt.and.model.UserInfo


class SignUpViewModel: ViewModel() {
Expand All @@ -15,7 +11,6 @@ class SignUpViewModel: ViewModel() {
val PASSWORD_REGEX = Regex("^(?=.*[A-Za-z])(?=.*\\d)(?=.*[@\$!%*?&])[A-Za-z\\d@\$!%*?&]{$PASSWORD_MIN_LENGTH,$PASSWORD_MAX_LENGTH}\$")

var sharedPreferences: SharedPreferences? = null
var userInfo by mutableStateOf(UserInfo("",""))

fun initializePreferences(context: Context){
sharedPreferences = context.getSharedPreferences("user_prefs", Context.MODE_PRIVATE)
Expand Down

0 comments on commit 4c4a341

Please sign in to comment.