Skip to content

Commit

Permalink
Merge branch 'develop' into feat/#12-빌드속도_빠르게
Browse files Browse the repository at this point in the history
  • Loading branch information
rhkrwngud445 authored Mar 2, 2024
2 parents 551cfe1 + 18f1c62 commit 670a6e5
Show file tree
Hide file tree
Showing 93 changed files with 1,349 additions and 257 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[*.{kt,kts}]
ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true
ktlint_function_naming_ignore_when_annotated_with = Composable, Test
3 changes: 3 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
## 관련 이슈번호

<br/> close #

## 작업 사항

<br/>

## 기타 사항

<br/>
9 changes: 8 additions & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

Expand All @@ -32,8 +32,15 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Access Google Client Id
env:
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
run: |
echo "GOOGLE_CLIENT_ID=\"$GOOGLE_CLIENT_ID\"" >> local.properties
- name: Run test
run: ./gradlew test --parallel

- name: Run ktlint
run: ./gradlew ktlintCheck

10 changes: 10 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,13 @@ android {
}
}

dependencies {
implementation(libs.androidx.core.splashscreen)
implementation(project(":feature:login"))
implementation(project(":core:interceptor"))
implementation(project(":core:data"))
implementation(project(":core:network"))
implementation(project(":core:datastore"))
implementation(project(":core:domain"))
implementation(project(":core:designsystem"))
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.withpeace.withpeace

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

import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.*
import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
Expand Down
11 changes: 7 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
xmlns:tools="http://schemas.android.com/tools"
package="com.withpeace.withpeace">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".WithPeaceApplication"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:usesCleartextTraffic="true"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
Expand All @@ -16,8 +20,7 @@
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.Withpeace">
android:theme="@style/Theme.Withpeace.Starting">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand All @@ -26,4 +29,4 @@
</activity>
</application>

</manifest>
</manifest>
60 changes: 29 additions & 31 deletions app/src/main/java/com/withpeace/withpeace/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,48 +1,46 @@
package com.withpeace.withpeace

import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.withpeace.withpeace.ui.theme.WithpeaceTheme
import androidx.activity.viewModels
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import com.withpeace.withpeace.core.designsystem.theme.WithpeaceTheme
import com.withpeace.withpeace.feature.login.navigation.LOGIN_ROUTE
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

@AndroidEntryPoint
class MainActivity : ComponentActivity() {
private val viewModel by viewModels<MainViewModel>()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val splashScreen = installSplashScreen()
splashScreen.setKeepOnScreenCondition { true }
lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.STARTED){
viewModel.isLogin.collect { isLogin ->
if(isLogin) {
Log.d("covy","Main 화면으로 이동")
} else {
composeStart(LOGIN_ROUTE)
}
delay(2000L)
splashScreen.setKeepOnScreenCondition { false }
}
}
}
}
private fun ComponentActivity.composeStart(startDestination: String) {
setContent {
WithpeaceTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
Greeting("Android")
}
WithpeaceApp(startDestination = startDestination)
}
}
}
}

@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
Text(
text = "Hello $name!",
modifier = modifier
)
}

@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
WithpeaceTheme {
Greeting("Android")
}
}
31 changes: 31 additions & 0 deletions app/src/main/java/com/withpeace/withpeace/MainViewModel.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.withpeace.withpeace

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.withpeace.withpeace.core.domain.repository.TokenRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.flow.firstOrNull
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class MainViewModel @Inject constructor(
private val tokenRepository: TokenRepository
) : ViewModel() {
private val _isLogin: MutableSharedFlow<Boolean> = MutableSharedFlow()
val isLogin = _isLogin.asSharedFlow()

init {
viewModelScope.launch {
val token = tokenRepository.getAccessToken().firstOrNull()
if(token==null) {
_isLogin.emit(false)
} else {
_isLogin.emit(true)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import android.app.Application
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class WithPeaceApplication: Application() {
class WithPeaceApplication : Application() {
}
34 changes: 34 additions & 0 deletions app/src/main/java/com/withpeace/withpeace/WithpeaceApp.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.withpeace.withpeace

import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import com.withpeace.withpeace.navigation.WithpeaceNavHost
import kotlinx.coroutines.launch


@Composable
fun WithpeaceApp(
startDestination: String
) {
val snackBarHostState = remember { SnackbarHostState() }
val coroutineScope = rememberCoroutineScope()
fun showSnackBar(message: String) = coroutineScope.launch {
snackBarHostState.showSnackbar(message)
}

Scaffold(
modifier = Modifier.fillMaxSize(),
snackbarHost = { SnackbarHost(snackBarHostState) },
) {
WithpeaceNavHost(
onShowSnackBar = ::showSnackBar,
)
it
}
}
26 changes: 26 additions & 0 deletions app/src/main/java/com/withpeace/withpeace/navigation/NavHost.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.withpeace.withpeace.navigation

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.rememberNavController
import com.withpeace.withpeace.feature.login.navigation.LOGIN_ROUTE
import com.withpeace.withpeace.feature.login.navigation.loginNavGraph


@Composable
fun WithpeaceNavHost(
modifier: Modifier = Modifier,
navController: NavHostController = rememberNavController(),
startDestination: String = LOGIN_ROUTE,
onShowSnackBar: (message: String) -> Unit,
) {
NavHost(
modifier = modifier,
navController = navController,
startDestination = startDestination,
) {
loginNavGraph(onShowSnackBar = onShowSnackBar)
}
}
11 changes: 0 additions & 11 deletions app/src/main/java/com/withpeace/withpeace/ui/theme/Color.kt

This file was deleted.

70 changes: 0 additions & 70 deletions app/src/main/java/com/withpeace/withpeace/ui/theme/Theme.kt

This file was deleted.

Loading

0 comments on commit 670a6e5

Please sign in to comment.