Skip to content

Commit

Permalink
Merge pull request #31 from YAPP-Github/feature/tgyuu/PC-347
Browse files Browse the repository at this point in the history
[PC-347] 권한 얻는 기능 추가
  • Loading branch information
tgyuuAn authored Jan 12, 2025
2 parents b40ccda + c112ed0 commit 04ee10e
Show file tree
Hide file tree
Showing 17 changed files with 306 additions and 32 deletions.
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" tools:targetApi="33" />
<uses-permission android:name="android.permission.READ_CONTACTS" />

<application
android:name=".PieceApplication"
Expand Down
1 change: 1 addition & 0 deletions core/datasource/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
43 changes: 43 additions & 0 deletions core/datasource/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
}

android {
namespace = "com.puzzle.datasource"
compileSdk = 34

defaultConfig {
minSdk = 26

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "11"
}
}

dependencies {

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)
testImplementation(libs.junit4)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.test.espresso.core)
}
Empty file.
21 changes: 21 additions & 0 deletions core/datasource/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.puzzle.datasource

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.puzzle.datasource.test", appContext.packageName)
}
}
4 changes: 4 additions & 0 deletions core/datasource/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.puzzle.datasource

import org.junit.Test

import org.junit.Assert.*

/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package com.puzzle.designsystem.component

import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.animateIntOffsetAsState
import androidx.compose.animation.core.spring
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.SwitchDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import com.puzzle.designsystem.foundation.PieceTheme

@Composable
fun PieceToggle(
checked: Boolean,
onCheckedChange: () -> Unit,
modifier: Modifier = Modifier,
) {
val density = LocalDensity.current
val screenWidthPx = with(density) { 14.dp.toPx().toInt() }
val targetOffset = if (checked) {
IntOffset(screenWidthPx, 0)
} else {
IntOffset.Zero
}

val thumbXOffset by animateIntOffsetAsState(
targetValue = targetOffset,
animationSpec = spring(stiffness = Spring.StiffnessMedium),
label = "Thumb Animation",
)

Box(
contentAlignment = Alignment.CenterStart,
modifier = modifier
.size(width = 34.dp, height = 20.dp)
.clip(RoundedCornerShape(999.dp))
.background(if (checked) PieceTheme.colors.primaryDefault else PieceTheme.colors.light1)
.clickable { onCheckedChange() }
) {
Box(
modifier = Modifier
.padding(horizontal = 2.dp)
.graphicsLayer { translationX = thumbXOffset.x.toFloat() }
.size(SwitchDefaults.IconSize)
.clip(CircleShape)
.background(PieceTheme.colors.white),
)
}
}

@Preview
@Composable
fun PreviewPieceToggle() {
PieceTheme {
Column(
verticalArrangement = Arrangement.spacedBy(10.dp),
modifier = Modifier.padding(10.dp)
) {
PieceToggle(
checked = true,
onCheckedChange = {},
)

PieceToggle(
checked = false,
onCheckedChange = {},
)
}
}
}
8 changes: 7 additions & 1 deletion core/designsystem/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--Term-->
<!--SignUp-->
<string name="all_term_agree">약관 전체 동의</string>
<string name="next">다음</string>
<string name="agree">동의하기</string>
<string name="try_next">다음에 할래요</string>
<string name="avoid_acquaintances">아는 사람 차단하기</string>
<string name="generate_profile">프로필 생성하기</string>
<string name="avoid_acquaintances_description">연락처에 등록된 번호로 가입한 사용자는\n매칭 대상에서 제외되어, 개인정보가 보호됩니다.</string>
<string name="permission_camera">사진, 카메라 [필수]</string>
<string name="permission_camera_description">프로필 생성 시 사진 첨부를 위해 필요해요.</string>
<string name="permission_notification">알림 [선택]</string>
<string name="permission_notification_description">매칭 현황 등 중요 메시지 수신을 위해 필요해요.</string>
<string name="permission_contacts">연락처 [선택]</string>
<string name="permission_contacts_description">지인을 수집하기 위해 필요해요.</string>

<!--Matching-->
<string name="matching_title">Matching</string>
Expand Down
1 change: 1 addition & 0 deletions feature/auth/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ android {
dependencies {
implementation(projects.core.common)
implementation(libs.kakao.user)
implementation(libs.accompanist.permission)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.airbnb.mvrx.compose.collectAsState
Expand Down Expand Up @@ -51,7 +51,7 @@ private fun SignUpScreen(
onNextClick: () -> Unit,
navigate: (NavigationEvent) -> Unit,
) {
val (selectedTerm, setSelectedTerm) = remember { mutableStateOf<Term?>(null) }
val (selectedTerm, setSelectedTerm) = rememberSaveable { mutableStateOf<Term?>(null) }

Column(
modifier = Modifier
Expand Down Expand Up @@ -80,7 +80,6 @@ private fun SignUpScreen(
)

SignUpState.SignUpPage.AccessRightsPage -> AccessRightsPage(
agreeCameraPermission = true,
onBackClick = onBackClick,
onNextClick = onNextClick,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ data class SignUpState(
val termsCheckedInfo: Map<Int, Boolean> = emptyMap(),
val signUpPage: SignUpPage = SignUpPage.TermPage,
) : MavericksState {
val areAllTermsAgreed = terms.all { termsCheckedInfo.getOrDefault(it.id, false) }
val areAllTermsAgreed = terms.filter { it.required }
.all { termsCheckedInfo.getOrDefault(it.id, false) }

enum class SignUpPage {
TermPage,
Expand Down
Loading

0 comments on commit 04ee10e

Please sign in to comment.