-
Notifications
You must be signed in to change notification settings - Fork 0
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
테마 마켓 추가 #383
Merged
eastshine2741
merged 37 commits into
develop
from
eastshine2741/add-custom-theme-market
Feb 22, 2025
+450
−24
Merged
테마 마켓 추가 #383
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
c01338d
ThemeDto의 필드를 nullable로 수정
eastshine2741 5b26aaf
GtCurrentTableThemeUseCase 생성
eastshine2741 812b80a
ThemeDetailViewModel init {} 함수분리
eastshine2741 db22d6c
ThemeDetailViewModel.isNewTheme의 backing field 제거
eastshine2741 8e1b8e3
null check용 depth 제거
eastshine2741 e073af3
시간표 색상 새로고침 조건문 단순화
eastshine2741 c337ea9
도메인모델 v2 추가
eastshine2741 2247639
비즈니스 로직 리팩토링
eastshine2741 c77b904
v2 도메인 모델으로 대체
eastshine2741 36331b7
ThemeDetailPage 리팩토링
eastshine2741 48a75d0
UiState Error, Loading 대응
eastshine2741 c7ad540
isEditable 조건 오타 수정 & SNUTT 외 테마 색상 옮겨오기
eastshine2741 b23ad10
ThemeColorRow 애니메이션 버그 수정
eastshine2741 71dd5b6
isEditable 조건 오타 수정 2
eastshine2741 09f76cc
누락된 private 추가
eastshine2741 fd29300
ThemeDetail Preview 몇 개 추가
eastshine2741 4540741
ThemeListViewModel 로직 개선
eastshine2741 405cf21
ThemeConfigScreen 리팩토링
eastshine2741 2f91a1a
ThemeListViewModel -> ThemeConfigViewModel 이름 수정
eastshine2741 1129f1d
누락된 private 추가
eastshine2741 05a8a5e
ThemeConfig Preview 몇 개 추가
eastshine2741 ee00ec4
lint
eastshine2741 4a8a70b
ThemeConfigViewModel의 StateFlow가 backing field 가지도록 수정
eastshine2741 186e59b
네이밍 수정
eastshine2741 0a2fb22
담은 테마 따로 보여주기
eastshine2741 95f7019
더보기 탭 테마마켓 진입점 생성
eastshine2741 3b8730f
ThemeMarketScreen 추가
eastshine2741 328bf87
테마마켓 웹뷰 추가
eastshine2741 eb42341
담은 테마가 없으면 담은 테마 UI 보여주지 않도록 수정
eastshine2741 b4a27dd
lint
eastshine2741 3918fed
웹뷰 Loading, Error 대응
eastshine2741 92587c5
테마마켓용 string resource 생성
eastshine2741 e33312b
LoadState.InitialLoading 삭제
eastshine2741 078d637
Merge branch 'develop' into eastshine2741/add-custom-theme-market
eastshine2741 186a994
웹뷰 영역이 전체를 채우도록 수정
eastshine2741 65a4181
담은 테마에 3dot 아이콘, 바텀시트 추가
eastshine2741 d7dec71
Merge branch 'develop' into eastshine2741/add-custom-theme-market
eastshine2741 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 2 additions & 3 deletions
5
app/src/main/java/com/wafflestudio/snutt2/lib/android/webview/LoadState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
package com.wafflestudio.snutt2.lib.android.webview | ||
|
||
sealed class LoadState { | ||
object Success : LoadState() | ||
object Error : LoadState() | ||
data object Success : LoadState() | ||
data object Error : LoadState() | ||
data class Loading(val progress: Int) : LoadState() | ||
data class InitialLoading(val progress: Int) : LoadState() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
app/src/main/java/com/wafflestudio/snutt2/lib/android/webview/ThemeMarketWebViewContainer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package com.wafflestudio.snutt2.lib.android.webview | ||
|
||
import android.content.Context | ||
import android.graphics.Bitmap | ||
import android.os.Build | ||
import android.webkit.CookieManager | ||
import android.webkit.WebChromeClient | ||
import android.webkit.WebResourceError | ||
import android.webkit.WebResourceRequest | ||
import android.webkit.WebView | ||
import android.webkit.WebViewClient | ||
import androidx.compose.runtime.MutableState | ||
import androidx.compose.runtime.mutableStateOf | ||
import com.wafflestudio.snutt2.BuildConfig | ||
import com.wafflestudio.snutt2.R | ||
import kotlinx.coroutines.flow.StateFlow | ||
import kotlinx.coroutines.flow.filterNotNull | ||
import kotlinx.coroutines.flow.first | ||
import java.net.URL | ||
|
||
class ThemeMarketWebViewContainer( | ||
private val context: Context, | ||
private val accessToken: StateFlow<String?>, | ||
private val isDarkMode: Boolean, | ||
) : WebViewContainer { | ||
val loadState: MutableState<LoadState> = mutableStateOf(LoadState.Loading(0)) | ||
|
||
override val webView: WebView = WebView(context).apply { | ||
if (BuildConfig.DEBUG) { | ||
WebView.setWebContentsDebuggingEnabled(true) | ||
} | ||
this.webViewClient = object : WebViewClient() { | ||
override fun onPageFinished(view: WebView?, url: String?) { | ||
if (loadState.value != LoadState.Error) { | ||
loadState.value = LoadState.Success | ||
} | ||
} | ||
|
||
override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) { | ||
loadState.value = LoadState.Loading(0) | ||
} | ||
|
||
override fun onReceivedError( | ||
view: WebView?, | ||
request: WebResourceRequest?, | ||
error: WebResourceError?, | ||
) { | ||
loadState.value = LoadState.Error | ||
} | ||
} | ||
this.webChromeClient = object : WebChromeClient() { | ||
override fun onProgressChanged(view: WebView?, newProgress: Int) { | ||
when (loadState.value) { | ||
is LoadState.Loading -> LoadState.Loading(newProgress) | ||
else -> null | ||
}?.let { | ||
loadState.value = it | ||
} | ||
} | ||
} | ||
this.settings.javaScriptEnabled = true | ||
} | ||
|
||
override suspend fun openPage(url: String?) { | ||
val accessToken = accessToken.filterNotNull().first() | ||
val themeMarketUrl = url ?: THEME_MARKET_URL | ||
val urlHost = URL(themeMarketUrl).host | ||
|
||
setCookies(urlHost, accessToken) | ||
webView.loadUrl(themeMarketUrl) | ||
} | ||
|
||
private fun setCookies(host: String, accessToken: String) { | ||
CookieManager.getInstance().apply { | ||
setCookie( | ||
host, | ||
"x-access-apikey=${context.getString(R.string.api_key)}", | ||
) | ||
setCookie( | ||
host, | ||
"x-access-token=$accessToken", | ||
) | ||
setCookie( | ||
host, | ||
"x-os-type=android", | ||
) | ||
setCookie( | ||
host, | ||
"x-os-version=${Build.VERSION.SDK_INT}", | ||
) | ||
setCookie( | ||
host, | ||
"x-app-version=${BuildConfig.VERSION_NAME}", | ||
) | ||
setCookie( | ||
host, | ||
"x-app-type=${if (BuildConfig.DEBUG) "debug" else "release"}", | ||
) | ||
setCookie( | ||
host, | ||
"theme=${ | ||
if (isDarkMode) { | ||
"dark" | ||
} else { | ||
"light" | ||
} | ||
}", | ||
) | ||
}.flush() | ||
} | ||
|
||
companion object { | ||
private val THEME_MARKET_URL = "https://snutt-theme-market-dev.wafflestudio.com/download" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
흐음 혹시 이
MarketCustomThemeMoreActionBottomSheet
랑MyCustomThemeMoreActionBottomSheet
잘 합치는건 별로인가..?굳이 무리한 합치기이면 필요 없긴 한데 약간 중복 느낌도 있어서
+) 으음 전체적으로 따로따로 있구나 굳이 합칠필요 없는것 같기도
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
마자 공용 함수로 합치면 MarketCustomTheme에는 필요없는 콜백을 MarketCustomTheme이 받게 되는 게 싫어서 분리했어