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

feat: setting icon #21

Merged
merged 3 commits into from
Jan 31, 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/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/Theme.Packie">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/java/org/care/packie/feature/PackingNavContract.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.care.packie.feature

import android.net.Uri

object PackingNavContract {
const val ROUTE = "packing"

Expand All @@ -17,4 +19,16 @@ object PackingNavContract {
} ?: "$BASE_ROUTE/{$CATEGORY_ARGUMENT}"
}
}

object Url {
private const val PRIVACY_POLICY_URL = "https://2zerozu.notion.site/ccb6d3ff81f742ba9152d31de8a62ab1?pvs=4"
private const val TERMS_URL = "https://2zerozu.notion.site/abbe8debe4f14d19b4a62b3f8db459bb?pvs=4"
private const val CONTACT_US_URL = "https://walla.my/packie"
private const val DEVELOPER_INFO_URL = "https://2zerozu.notion.site/a14c462a913f42029f8b05c596f5441b?pvs=4"

val privacyPolicyUri = Uri.parse(PRIVACY_POLICY_URL)
val termsUri = Uri.parse(TERMS_URL)
val contactUsUri = Uri.parse(CONTACT_US_URL)
val developerInfoUri = Uri.parse(DEVELOPER_INFO_URL)
}
}
30 changes: 29 additions & 1 deletion app/src/main/java/org/care/packie/feature/PackingNavGraph.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.care.packie.feature

import android.content.Context
import android.content.Intent
import android.net.Uri
import android.widget.Toast
import androidx.activity.compose.BackHandler
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableLongStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.LocalContext
Expand Down Expand Up @@ -50,11 +52,37 @@ private fun NavGraphBuilder.categoryComposable(
navController.navigate(
route = PackingNavContract.Stuffs.getRoute(category)
)
},
onClickPrivacyPolicy = {
context.startActionViewActivity(
webUri = PackingNavContract.Url.privacyPolicyUri
)
},
onClickContactUs = {
context.startActionViewActivity(
webUri = PackingNavContract.Url.contactUsUri
)
},
onClickTerms = {
context.startActionViewActivity(
webUri = PackingNavContract.Url.termsUri
)
},
onClickDeveloperInfo = {
context.startActionViewActivity(
webUri = PackingNavContract.Url.developerInfoUri
)
}
)
}
}

private fun Context.startActionViewActivity(webUri: Uri) {
Intent(Intent.ACTION_VIEW, webUri).also {
startActivity(it)
}
}

private fun NavGraphBuilder.stuffsComposable(
navController: NavController
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ import org.care.packie.R
import org.care.packie.ui.DoneDialogType
import org.care.packie.ui.TextFieldDialogType
import org.care.packie.ui.component.category.Category
import org.care.packie.ui.component.category.SettingPopupMenu
import org.care.packie.ui.component.common.PackieButton
import org.care.packie.ui.component.dialog.DoneDialog
import org.care.packie.ui.component.dialog.TextFieldDialog
import org.care.packie.ui.theme.PackieDesignSystem
import org.care.packie.ui.theme.PackieTheme

private const val MIN_CATEGORY_SIZE = 5
// private const val MIN_CATEGORY_SIZE = 4
private const val MIN_SPACER_SIZE = 4
private const val MAX_SPACER_SIZE = 80

Expand All @@ -50,9 +51,13 @@ fun CategoryScreen(
onClickEditCategory: (String, String) -> Unit = { _, _ -> },
onClickDeleteCategory: (String) -> Unit = {},
onClickCategory: (String) -> Unit = {},
onClickPrivacyPolicy: () -> Unit = {},
onClickTerms: () -> Unit = {},
onClickContactUs: () -> Unit = {},
onClickDeveloperInfo: () -> Unit = {}
) {
val state = rememberCollapsingToolbarScaffoldState()
val isCollapseEnabled = categories.size >= MIN_CATEGORY_SIZE
//val isCollapseEnabled = categories.size >= MIN_CATEGORY_SIZE
val toolbarStateProgress = state.toolbarState.progress
var categoryName by remember { mutableStateOf("") }
var dialogType by remember { mutableStateOf(TextFieldDialogType.ADD_CATEGORY) }
Expand All @@ -61,16 +66,28 @@ fun CategoryScreen(
val context = LocalContext.current

Column {
Box(
modifier = Modifier
.padding(top = 8.dp, end = 8.dp)
.align(Alignment.End)
) {
SettingPopupMenu(
onClickPrivacyPolicy = onClickPrivacyPolicy,
onClickTerms = onClickTerms,
onClickContactUs = onClickContactUs,
onClickDeveloperInfo = onClickDeveloperInfo
)
}
CollapsingToolbarScaffold(
modifier = Modifier.weight(1f),
state = state,
enabled = isCollapseEnabled,
//enabled = isCollapseEnabled,
scrollStrategy = ScrollStrategy.ExitUntilCollapsed,
toolbar = {
Box(
modifier = Modifier
.fillMaxWidth()
.height(130.dp)
.height(80.dp)
.pin()
)
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ import org.care.packie.utils.ui.LoadingScreen
@Composable
fun CategoryScreenRoot(
viewModel: CategoryViewModel = hiltViewModel(),
navigateToStuff: (String) -> Unit = {}
navigateToStuff: (String) -> Unit = {},
onClickPrivacyPolicy: () -> Unit = {},
onClickTerms: () -> Unit = {},
onClickContactUs: () -> Unit = {},
onClickDeveloperInfo: () -> Unit = {}
) {
val state by viewModel.uiState.collectAsState()

Expand All @@ -40,7 +44,11 @@ fun CategoryScreenRoot(
onClickAddCategory = viewModel::addCategory,
onClickEditCategory = viewModel::editCategory,
onClickDeleteCategory = viewModel::removeCategory,
onClickCategory = { navigateToStuff(it) },
onClickCategory = navigateToStuff,
onClickPrivacyPolicy = onClickPrivacyPolicy,
onClickTerms = onClickTerms,
onClickContactUs = onClickContactUs,
onClickDeveloperInfo = onClickDeveloperInfo
)

LoadingScreen(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package org.care.packie.ui.component.category

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
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.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import org.care.packie.R
import org.care.packie.ui.theme.PackieDesignSystem

@Composable
fun SettingPopupMenu(
onClickPrivacyPolicy: () -> Unit,
onClickTerms: () -> Unit,
onClickContactUs: () -> Unit,
onClickDeveloperInfo: () -> Unit,
) {
var isPopupOpen by remember { mutableStateOf(false) }

Box(
modifier = Modifier.clickable { isPopupOpen = true }
) {
Icon(
painter = painterResource(id = R.drawable.ic_setting), // 설정 아이콘에 해당하는 리소스를 넣어주세요
contentDescription = null,
tint = PackieDesignSystem.colors.white, // 아이콘 색상을 설정하세요
modifier = Modifier.padding(16.dp)
)

DropdownMenu(
expanded = isPopupOpen,
onDismissRequest = { isPopupOpen = false }
) {
DropdownMenuItem(
onClick = {
isPopupOpen = false
onClickPrivacyPolicy()
},
text = {
Text(
text = "개인정보 보호 정책",
style = PackieDesignSystem.typography.content
)
}
)

DropdownMenuItem(
onClick = {
isPopupOpen = false
onClickTerms()
},
text = {
Text(
text = "서비스 이용 약관",
style = PackieDesignSystem.typography.content
)
}
)

DropdownMenuItem(
onClick = {
isPopupOpen = false
onClickContactUs()
},
text = {
Text(
text = "문의하기",
style = PackieDesignSystem.typography.content
)
}
)

DropdownMenuItem(
onClick = {
isPopupOpen = false
onClickDeveloperInfo()
},
text = {
Text(
text = "개발자 정보",
style = PackieDesignSystem.typography.content
)
}
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fun TextFieldDialog(
confirm = type.confirm,
onDismiss = onDismiss,
onConfirmation = {
onConfirmation(textFieldValue.text)
onConfirmation(textFieldValue.text.replace("\n", ""))
},
isConfirmButtonEnabled = isConfirmButtonEnabled.value
)
Expand Down Expand Up @@ -131,8 +131,10 @@ fun TextFieldDialogTextField(
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(
onDone = {
onConfirmation(textFieldValue.text)
keyboardController?.hide()
if (textFieldValue.text.isNotEmpty()) {
onConfirmation(textFieldValue.text.replace("\n", ""))
keyboardController?.hide()
}
}
),
cursorBrush = SolidColor(PackieDesignSystem.colors.purple),
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/res/drawable/ic_setting.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<group>
<clip-path
android:pathData="M0,0h24v24h-24z"/>
<path
android:pathData="M19.14,12.94C19.18,12.64 19.2,12.33 19.2,12C19.2,11.68 19.18,11.36 19.13,11.06L21.16,9.48C21.34,9.34 21.39,9.07 21.28,8.87L19.36,5.55C19.24,5.33 18.99,5.26 18.77,5.33L16.38,6.29C15.88,5.91 15.35,5.59 14.76,5.35L14.4,2.81C14.36,2.57 14.16,2.4 13.92,2.4H10.08C9.84,2.4 9.65,2.57 9.61,2.81L9.25,5.35C8.66,5.59 8.12,5.92 7.63,6.29L5.24,5.33C5.02,5.25 4.77,5.33 4.65,5.55L2.74,8.87C2.62,9.08 2.66,9.34 2.86,9.48L4.89,11.06C4.84,11.36 4.8,11.69 4.8,12C4.8,12.31 4.82,12.64 4.87,12.94L2.84,14.52C2.66,14.66 2.61,14.93 2.72,15.13L4.64,18.45C4.76,18.67 5.01,18.74 5.23,18.67L7.62,17.71C8.12,18.09 8.65,18.41 9.24,18.65L9.6,21.19C9.65,21.43 9.84,21.6 10.08,21.6H13.92C14.16,21.6 14.36,21.43 14.39,21.19L14.75,18.65C15.34,18.41 15.88,18.09 16.37,17.71L18.76,18.67C18.98,18.75 19.23,18.67 19.35,18.45L21.27,15.13C21.39,14.91 21.34,14.66 21.15,14.52L19.14,12.94ZM12,15.6C10.02,15.6 8.4,13.98 8.4,12C8.4,10.02 10.02,8.4 12,8.4C13.98,8.4 15.6,10.02 15.6,12C15.6,13.98 13.98,15.6 12,15.6Z"
android:fillColor="#323232"/>
</group>
</vector>