Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into ui/#37-calendar-scrap
Browse files Browse the repository at this point in the history
# Conflicts:
#	core/src/main/res/values/strings.xml
  • Loading branch information
boiledEgg-s committed Jul 11, 2024
2 parents bb2d5da + ce20eb1 commit 40c8e0f
Show file tree
Hide file tree
Showing 68 changed files with 1,676 additions and 243 deletions.
1 change: 1 addition & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ dependencies {

// Compose Preview
debugImplementation(libs.compose.ui.tooling)
implementation(libs.androidx.ui.tooling.preview)

// Test Dependency
testImplementation(libs.junit)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.terning.feature.onboarding.signup.component
package com.terning.core.designsystem.component.bottomsheet

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
Expand All @@ -9,28 +9,35 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.items
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Text
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.terning.core.designsystem.component.bottomsheet.TerningBasicBottomSheet
import com.terning.core.R
import com.terning.core.designsystem.component.button.RoundButton
import com.terning.core.designsystem.theme.TerningTheme
import com.terning.core.extension.noRippleClickable
import com.terning.feature.R
import kotlinx.coroutines.launch

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SignUpBottomSheet(
modifier: Modifier = Modifier,
onDismiss: () -> Unit,
onStartDialog: () -> Unit
onSaveClick: () -> Unit
) {
val scope = rememberCoroutineScope()
val sheetState = rememberModalBottomSheetState()

TerningBasicBottomSheet(
content = {
Column {
Expand All @@ -50,13 +57,21 @@ fun SignUpBottomSheet(
paddingVertical = 19.dp,
cornerRadius = 10.dp,
text = R.string.sign_up_dialog_start,
onButtonClick = { onStartDialog() },
onButtonClick = {
scope.launch { sheetState.hide() }
.invokeOnCompletion {
if (!sheetState.isVisible) {
onSaveClick()
}
}
},
modifier = modifier.padding(horizontal = 24.dp)
)
Spacer(modifier = modifier.padding(bottom = 15.dp))
}
},
onDismissRequest = { onDismiss() }
onDismissRequest = { onDismiss() },
sheetState = sheetState
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.terning.core.designsystem.component.bottomsheet

import androidx.annotation.StringRes
import com.terning.core.R

enum class SortBy(@StringRes val type: Int) {
EARLIEST(R.string.sort_by_earliest),
SHORTEST(R.string.sort_by_shortest),
LONGEST(R.string.sort_by_longest),
SCRAP(R.string.sort_by_scrap),
VIEW_COUNT(R.string.sort_by_view_count),
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package com.terning.core.designsystem.component.bottomsheet

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Text
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.terning.core.R
import com.terning.core.designsystem.theme.Black
import com.terning.core.designsystem.theme.Grey200
import com.terning.core.designsystem.theme.Grey400
import com.terning.core.designsystem.theme.TerningMain
import com.terning.core.designsystem.theme.TerningTheme
import com.terning.core.extension.noRippleClickable
import kotlinx.coroutines.launch

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SortingBottomSheet(
onDismiss: () -> Unit,
currentSortBy: Int,
modifier: Modifier = Modifier,
newSortBy: MutableState<Int> = mutableStateOf(currentSortBy),
) {
val scope = rememberCoroutineScope()
val sheetState = rememberModalBottomSheetState()
var currentSortBy by remember { mutableStateOf(currentSortBy) }

TerningBasicBottomSheet(
content = {
Text(
text = stringResource(id = R.string.sort_bottom_sheet_title),
style = TerningTheme.typography.title2,
color = Black,
modifier = modifier
.padding(start = 27.dp, bottom = 16.dp)
)

HorizontalDivider(
thickness = 1.dp,
color = Grey200,
modifier = modifier.padding(horizontal = 24.dp)
)

LazyColumn(
modifier = modifier
.padding(top = 12.dp, bottom = 19.dp)
.padding(horizontal = 24.dp),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
items(sortByCount) { sortIndex ->
Text(
text = stringResource(id = SortBy.entries[sortIndex].type),
style = TerningTheme.typography.button3,
color = if (currentSortBy == sortIndex) TerningMain else Grey400,
textAlign = TextAlign.Start,
modifier = modifier
.fillMaxWidth()
.padding(start = 3.dp)
.padding(vertical = 12.dp)
.noRippleClickable {
newSortBy.value = sortIndex
scope
.launch { sheetState.hide() }
.invokeOnCompletion {
if (!sheetState.isVisible) {
onDismiss()
}
}
}
)
}
}
},
onDismissRequest = { onDismiss() },
sheetState = sheetState
)
}

private const val sortByCount = 5
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
package com.terning.core.designsystem.component.bottomsheet

import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.SheetState
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.terning.core.designsystem.theme.White

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun TerningBasicBottomSheet(
modifier: Modifier = Modifier,
content: @Composable () -> Unit,
onDismissRequest: () -> Unit
onDismissRequest: () -> Unit,
sheetState: SheetState = rememberModalBottomSheetState()
) {
val sheetState = rememberModalBottomSheetState()

ModalBottomSheet(
onDismissRequest = {
onDismissRequest()
},
sheetState = sheetState,
modifier = modifier.navigationBarsPadding()
containerColor = White,
) {
content()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.terning.core.designsystem.component.button

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.terning.core.R
import com.terning.core.designsystem.component.bottomsheet.SortBy
import com.terning.core.designsystem.theme.Black
import com.terning.core.designsystem.theme.TerningTheme
import com.terning.core.extension.noRippleClickable

@Composable
fun SortingButton(
sortBy: Int = 0,
modifier: Modifier = Modifier,
onCLick: () -> Unit,
) {
Row(
modifier = modifier
.noRippleClickable { onCLick() }
) {
Text(
text = stringResource(
id = SortBy.entries[sortBy].type
),
style = TerningTheme.typography.button3,
color = Black,
modifier = modifier
.padding(
top = 6.dp,
bottom = 5.dp,
start = 12.dp,
)
)
Image(
painter = painterResource(id = R.drawable.ic_down),
contentDescription = stringResource(id = R.string.sort_button_description),
modifier = modifier
.padding(vertical = 5.dp)
.padding(end = 2.dp)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.ripple.LocalRippleTheme
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
Expand All @@ -22,8 +21,8 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.terning.core.R
import com.terning.core.designsystem.theme.Black
import com.terning.core.designsystem.theme.Grey150
import com.terning.core.designsystem.theme.Grey350
import com.terning.core.designsystem.theme.TerningMain
import com.terning.core.designsystem.theme.TerningMain2
import com.terning.core.designsystem.theme.TerningPointTheme
Expand Down Expand Up @@ -55,7 +54,7 @@ fun TerningBasicButton(
containerColor = backgroundColor,
contentColor = White,
disabledContainerColor = Grey150,
disabledContentColor = Black
disabledContentColor = Grey350
),
shape = shape,
onClick = { onButtonClick() }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
package com.terning.core.designsystem.component.textfield

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import com.terning.core.designsystem.theme.Black
import com.terning.core.designsystem.theme.Grey300
import com.terning.core.designsystem.theme.Grey400
import com.terning.core.designsystem.theme.Grey500
import com.terning.core.designsystem.theme.TerningMain
import com.terning.core.designsystem.theme.TerningTheme

@Composable
fun NameTextField(
text: String,
value: String,
onValueChange: (String) -> Unit,
hint: String,
drawLineColor: Color,
helperMessage: String,
helperColor: Color,
helperIcon: Int? = null,
helperColor: Color = TerningMain,
) {
TerningBasicTextField(
value = text,
value = value,
onValueChange = onValueChange,
modifier = Modifier,
textStyle = TerningTheme.typography.detail1,
textColor = Black,
drawLineColor = Grey500,
drawLineColor = drawLineColor,
cursorBrush = SolidColor(Grey400),
hint = hint,
hintColor = Grey300,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.terning.core.designsystem.component.textfield

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.SolidColor
import com.terning.core.designsystem.theme.Grey300
import com.terning.core.designsystem.theme.Grey400
Expand All @@ -9,15 +10,19 @@ import com.terning.core.designsystem.theme.TerningTheme

@Composable
fun SearchTextField(
text: String,
onValueChange: (String) -> Unit,
text: String = "",
onValueChange: (String) -> Unit = {},
modifier: Modifier,
hint: String,
leftIcon: Int,
enabled: Boolean = true,
readOnly: Boolean = false,
onDoneAction: (() -> Unit)? = null,
) {
TerningBasicTextField(
value = text,
onValueChange = onValueChange,
modifier = modifier,
textStyle = TerningTheme.typography.button3,
textColor = Grey400,
cursorBrush = SolidColor(Grey300),
Expand All @@ -27,6 +32,9 @@ fun SearchTextField(
hintColor = Grey300,
leftIcon = leftIcon,
leftIconColor = TerningMain,
enabled = enabled,
readOnly = readOnly,
onDoneAction = onDoneAction,
helperColor = TerningMain
)
}
Loading

0 comments on commit 40c8e0f

Please sign in to comment.