Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

๐Ÿ”€ :: (#24) - publishing sign up #25

Merged
merged 22 commits into from
Jan 21, 2024
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: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ android {
dependencies {
implementation(project(":core:design-system"))
implementation(project(":feature:login"))
implementation(project(":feature:sign-up"))

implementation(libs.junit)
androidTestImplementation(libs.androidx.test.ext)
Expand Down
22 changes: 22 additions & 0 deletions app/src/main/java/com/goms/goms_android_v2/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.goms.goms_android_v2

import android.os.Bundle
import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.OnBackPressedCallback
import androidx.activity.compose.setContent
import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi
import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass
Expand All @@ -13,9 +15,18 @@ import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class MainActivity : ComponentActivity() {
private var doubleBackToExitPressedOnce = false
private var backPressedTimestamp = 0L
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
controlTheStackWhenBackPressed()
}
}

@OptIn(ExperimentalMaterial3WindowSizeClassApi::class)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
this.onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
setContent {
installSplashScreen()
CompositionLocalProvider {
Expand All @@ -25,4 +36,15 @@ class MainActivity : ComponentActivity() {
}
}
}

fun controlTheStackWhenBackPressed() {
val currentTime = System.currentTimeMillis()
if (doubleBackToExitPressedOnce && currentTime - backPressedTimestamp <= 2000) {
finishAffinity()
} else {
doubleBackToExitPressedOnce = true
backPressedTimestamp = currentTime
Toast.makeText(this, "'๋’ค๋กœ'๋ฒ„ํŠผ ํ•œ๋ฒˆ ๋” ๋ˆ„๋ฅด์‹œ๋ฉด ์ข…๋ฃŒ๋ฉ๋‹ˆ๋‹ค.", Toast.LENGTH_SHORT).show()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.compose.NavHost
import com.goms.goms_android_v2.ui.GomsAppState
import com.goms.login.navigation.emailLoginScreen
import com.goms.login.navigation.loginRoute
import com.goms.login.navigation.loginScreen
import com.goms.login.navigation.navigateToEmailLogin
import com.goms.login.navigation.navigateToLogin
import com.goms.login.navigation.navigateToNumberLogin
import com.goms.login.navigation.numberLoginScreen
import com.goms.sign_up.navigation.navigateToNumber
import com.goms.sign_up.navigation.navigateToPassword
import com.goms.sign_up.navigation.navigateToSignUp
import com.goms.sign_up.navigation.numberScreen
import com.goms.sign_up.navigation.passwordScreen
import com.goms.sign_up.navigation.signUpScreen

@Composable
fun GomsNavHost(
Expand All @@ -25,12 +26,18 @@ fun GomsNavHost(
modifier = modifier
) {
loginScreen(
onEmailLoginClick = navController::navigateToEmailLogin
onSignUpClick = navController::navigateToSignUp
)
emailLoginScreen(
onLoginClick = navController::navigateToLogin,
onNumberLoginClick = navController::navigateToNumberLogin
signUpScreen(
onBackClick = navController::popBackStack,
onNumberClick = navController::navigateToNumber
)
numberScreen(
onBackClick = navController::popBackStack,
onPasswordClick = navController::navigateToPassword
)
passwordScreen(
onBackClick = navController::popBackStack
)
numberLoginScreen()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package com.goms.design_system.component.bottomsheet

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.Text
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.goms.design_system.component.button.BottomSheetButton
import com.goms.design_system.component.modifier.gomsClickable
import com.goms.design_system.icon.CloseIcon
import com.goms.design_system.theme.GomsTheme

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SelectorBottomSheet(
modifier: Modifier,
title: String,
list: List<String>,
selected: String,
itemChange: (String) -> Unit,
closeSheet: () -> Unit
) {
var componentWidth by remember { mutableStateOf( 0.dp ) }
val density = LocalDensity.current

val sheetState = rememberModalBottomSheetState()

GomsTheme { colors, typography ->
ModalBottomSheet(
onDismissRequest = { closeSheet() },
sheetState = sheetState,
shape = RoundedCornerShape(topStart = 12.dp, topEnd = 12.dp),
containerColor = colors.G1
) {
Column(
modifier = modifier
.fillMaxWidth()
.padding(start = 20.dp, end = 20.dp, bottom = 16.dp)
.onGloballyPositioned {
componentWidth = with(density) {
it.size.width.toDp()
}
}
) {
Row(
modifier = Modifier
.fillMaxWidth()
.height(32.dp),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = title,
style = typography.titleSmall,
fontWeight = FontWeight.Bold,
color = colors.WHITE
)
CloseIcon(
modifier = Modifier.gomsClickable { closeSheet() },
tint = colors.WHITE
)
}
Spacer(modifier = Modifier.height(16.dp))
LazyRow(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(16.dp)
) {
items(list.size) {
BottomSheetButton(
modifier = Modifier.widthIn((componentWidth - 16.dp * list.lastIndex) / list.size),
text = list[it],
selected = selected == list[it]
) {
itemChange(list[it])
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.goms.design_system.component.button

import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.goms.design_system.component.modifier.gomsClickable
import com.goms.design_system.icon.BackIcon
import com.goms.design_system.theme.GomsTheme

@Composable
fun GomsBackButton(
modifier: Modifier = Modifier.height(48.dp),
onClick: () -> Unit,
) {
GomsTheme { colors, typography ->
Row(
modifier = modifier
.padding(start = 15.dp)
.gomsClickable { onClick() },
verticalAlignment = Alignment.CenterVertically
) {
BackIcon()
Spacer(modifier = Modifier.width(7.dp))
Text(
text = "๋Œ์•„๊ฐ€๊ธฐ",
style = typography.textMedium,
fontWeight = FontWeight.Normal,
color = colors.I5
)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.goms.design_system.component.button

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
Expand All @@ -9,11 +12,14 @@ import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.goms.design_system.component.modifier.gomsClickable
import com.goms.design_system.icon.GAuthIcon
import com.goms.design_system.theme.GomsTheme

Expand Down Expand Up @@ -87,6 +93,37 @@ fun AuthButton(
}
}

@Composable
fun BottomSheetButton(
modifier: Modifier = Modifier,
text: String,
selected: Boolean,
onClick: () -> Unit
) {
GomsTheme { colors, typography ->
Box(
modifier = modifier
.height(56.dp)
.clip(RoundedCornerShape(12.dp))
.background(if (selected) colors.P5.copy(0.25f) else colors.G1)
.border(
width = 1.dp,
color = if (selected) Color.Transparent else colors.WHITE.copy(0.15f),
shape = RoundedCornerShape(12.dp)
)
.gomsClickable { onClick() }
) {
Text(
modifier = Modifier.align(Alignment.Center),
text = text,
style = typography.buttonMedium,
fontWeight = FontWeight.SemiBold,
color = if (selected) colors.P5 else colors.G7
)
}
}
}

@Composable
@Preview(showBackground = true)
fun GomsButtonPreview() {
Expand All @@ -110,5 +147,15 @@ fun GomsButtonPreview() {
onClick = {}
)
AuthButton(modifier = Modifier.fillMaxWidth()) {}
BottomSheetButton(
modifier = Modifier.fillMaxWidth(),
text = "๋ฒ„ํŠผ",
selected = true,
) {}
BottomSheetButton(
modifier = Modifier.fillMaxWidth(),
text = "๋ฒ„ํŠผ",
selected = false,
) {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fun LinkText(
)
Text(
modifier = Modifier.padding(horizontal = 4.dp),
text = "๋˜๋Š”",
text = "์ฒ˜์Œ์ด๋ผ๋ฉด?",
style = typography.caption,
fontWeight = FontWeight.Normal,
color = colors.G4
Expand Down
Loading
Loading