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

마이페이지 > 설정 화면 UI 변경 사항 및 기능 구현 #91

Merged
merged 5 commits into from
Nov 17, 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
2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
id("org.jetbrains.kotlin.android")
id("kotlin-kapt")
id("com.google.firebase.crashlytics")
id("com.google.android.gms.oss-licenses-plugin")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 이런게 있구나

}

android {
Expand Down Expand Up @@ -53,6 +54,7 @@ dependencies {
implementation(project(":data"))

implementation(libs.bundles.android.base)
implementation(libs.play.services.oss.licenses)

val composeBom = platform("androidx.compose:compose-bom:2024.05.00")
implementation(composeBom)
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
android:theme="@style/AppTheme" />
<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesActivity"
android:theme="@style/AppTheme" />
<service
android:name="androidx.work.impl.foreground.SystemForegroundService"
android:foregroundServiceType="location"
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/values/style.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:statusBarColor">@android:color/white</item>
<item name="android:windowLightStatusBar">true</item>
</style>
</resources>
10 changes: 10 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.google.android.gms:oss-licenses-plugin:0.10.6")
}
}

plugins {
id("com.android.application") version "7.4.2" apply false
id("com.android.library") version "7.4.2" apply false
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ android-material = "1.8.0"
junit = "4.13.2"
androidx-test-junit = "1.1.5"
espresso-core = "3.5.1"
play-services-oss-licenses = "17.1.0"

[libraries]
androidx-navigation-fragment-ktx = { module = "androidx.navigation:navigation-fragment-ktx", version.ref = "androidx-navigation" }
Expand All @@ -34,6 +35,7 @@ hilt = { module = "com.google.dagger:hilt-android", version.ref = "hilt" }
hilt-complier = { module = "com.google.dagger:hilt-android-compiler", version.ref = "hilt" }

javax-inject = { module = "javax.inject:javax.inject", version.ref = "javax-inject" }
play-services-oss-licenses = { group = "com.google.android.gms", name = "play-services-oss-licenses", version.ref = "play-services-oss-licenses" }

[bundles]
navigation = ["androidx-navigation-fragment-ktx", "androidx-navigation-ui-ktx", "androidx-navigation-dynamic-features-fragment"]
Expand Down
1 change: 1 addition & 0 deletions presentation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ dependencies {
implementation(project(":domain"))

implementation(libs.bundles.android.base)
implementation(libs.play.services.oss.licenses)

val composeBom = platform("androidx.compose:compose-bom:2024.05.00")
implementation(composeBom)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.whyranoid.presentation.reusable

import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.whyranoid.presentation.R
import com.whyranoid.presentation.theme.WalkieColor
import com.whyranoid.presentation.theme.WalkieTheme
import com.whyranoid.presentation.theme.WalkieTypography

@Composable
fun MenuItem(
@StringRes text: Int,
subInfo: String?= null,
@DrawableRes icon: Int? = null,
onClick: () -> Unit = {}
) {
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 12.dp)
.padding(horizontal = 20.dp)
.clickable(onClick = onClick)
) {
if (icon != null) {
Icon(
painter = painterResource(id = icon),
contentDescription = null,
modifier = Modifier.size(22.dp)
)

Spacer(modifier = Modifier.width(8.dp))
}

Text(
text = stringResource(id = text),
style = WalkieTypography.Body1_Normal
)

if (subInfo != null) {
Spacer(modifier = Modifier.width(10.dp))

Text(
text = subInfo,
style = WalkieTypography.Body1_Normal,
color = WalkieColor.Primary,
textAlign = TextAlign.End,
modifier = Modifier.weight(1f),
)
}
}
}

@Preview
@Composable
private fun MenuItemPreview() {
WalkieTheme {
MenuItem(
text = R.string.version_info,
subInfo = "1.0.0",
icon = R.drawable.ic_mobile
)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.whyranoid.presentation.screens

import android.util.Log
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeDrawingPadding
Expand Down Expand Up @@ -253,6 +254,14 @@ fun AppScreenContent(
}
)
}

composable(
route = Screen.WebViewScreen.route,
arguments = Screen.WebViewScreen.arguments,
) {
val url = it.arguments?.getString("url")
WebViewScreen(url = url)
}
}

val isLoading = ApiResponseDialog.isLoading.collectAsStateWithLifecycle()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import androidx.navigation.NamedNavArgument
import androidx.navigation.NavType
import androidx.navigation.navArgument
import com.whyranoid.presentation.R
import java.net.URLEncoder
import java.nio.charset.StandardCharsets

sealed class Screen(
val route: String,
Expand Down Expand Up @@ -143,6 +145,21 @@ sealed class Screen(
fun route(uid: Long, postId: Long) = "userPostsScreen/$uid/$postId"
}

object WebViewScreen : Screen(
route = "webViewScreen/{$URL}",
arguments = listOf(
navArgument(URL) {
type = NavType.StringType
nullable = true
}
),
) {
fun createRoute(url: String): String {
val encodedUrl = URLEncoder.encode(url, StandardCharsets.UTF_8.toString())
return route.replace("{$URL}", encodedUrl)
}
}

companion object {
val bottomNavigationItems = listOf(Running, Community, ChallengeMainScreen, MyPage)

Expand All @@ -151,5 +168,6 @@ sealed class Screen(
const val IS_FOLLOWING_ARGUMENT = "isFollowing"
const val PAGE_NO = "pageNo"
const val POST_ID = "postId"
const val URL = "url"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.whyranoid.presentation.screens

import android.annotation.SuppressLint
import android.graphics.Color
import android.view.ViewGroup
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.viewinterop.AndroidView

@SuppressLint("SetJavaScriptEnabled")
@Composable
fun WebViewScreen(
url: String?,
) {
Box(modifier = Modifier.fillMaxSize()) {
AndroidView(
factory = { context ->
WebView(context).apply {
setBackgroundColor(Color.TRANSPARENT)
layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
webViewClient = WebViewClient()
settings.apply {
javaScriptEnabled = true
loadWithOverviewMode = true
useWideViewPort = true
domStorageEnabled = true
setSupportZoom(false)
}
}
},
update = { webView ->
webView.loadUrl(url ?: "")
}
)
}
}
Loading
Loading