Skip to content

Commit

Permalink
Merge pull request #4 from Team-ReMind/feat/setting_architecture
Browse files Browse the repository at this point in the history
Feat/setting architecture
  • Loading branch information
seunghee17 authored May 3, 2024
2 parents d20e2b5 + c1f64a1 commit e67de00
Show file tree
Hide file tree
Showing 48 changed files with 1,236 additions and 222 deletions.
15 changes: 15 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,19 @@ dependencies {
implementation(platform("com.google.firebase:firebase-bom:32.8.1"))
implementation("com.google.firebase:firebase-analytics")
implementation ("com.google.firebase:firebase-messaging:23.2.1")

//navigation
implementation("androidx.navigation:navigation-compose:2.4.2")

//ted permission
implementation("io.github.ParkSangGwon:tedpermission-normal:3.3.0")
implementation("io.github.ParkSangGwon:tedpermission-coroutine:3.3.0")

//data store
implementation( "androidx.datastore:datastore-preferences:1.1.0")

//splash screen api
implementation( "androidx.core:core-splashscreen:1.0.1")


}
15 changes: 8 additions & 7 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,27 @@

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission
android:name="android.permission.POST_NOTIFICATIONS"
android:minSdkVersion="33"/>

<application
android:name=".core.di.App"
android:name=".app.App"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.ReMind"
android:theme="@style/Theme.SplashScreenAPI"
tools:targetApi="31" >

<activity
android:name=".MainActivity"
android:name=".app.MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.ReMind" >
android:theme="@style/Theme.SplashScreen.SplashScreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand All @@ -33,17 +36,15 @@
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="oauth"
android:scheme="${kakaoKey}" />
</intent-filter>
</activity>
<service
android:name="com.example.remind.FirebaseMessageService"
android:name="com.example.remind.app.FirebaseMessageService"
android:enabled="true"
android:exported="true">
<intent-filter>
Expand Down
61 changes: 0 additions & 61 deletions app/src/main/java/com/example/remind/MainActivity.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.remind.core.di
package com.example.remind.app
import com.example.remind.BuildConfig
import android.app.Application
import com.kakao.sdk.common.KakaoSdk
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.example.remind
package com.example.remind.app

import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.util.Log
import androidx.core.app.NotificationCompat
import com.example.remind.R
import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage

Expand Down
34 changes: 34 additions & 0 deletions app/src/main/java/com/example/remind/app/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.example.remind.app

import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import com.example.remind.core.designsystem.theme.RemindTheme
import com.google.firebase.Firebase
import dagger.hilt.android.AndroidEntryPoint
import com.google.firebase.messaging.messaging

@AndroidEntryPoint
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
installSplashScreen()
setContent {
RemindTheme {
RemindNavHost()
}
}
//곧 지워질 코드
Firebase.messaging.token.addOnCompleteListener { task ->
if(!task.isSuccessful) {
Log.e("tagg", "failed")
} else {
val token = task.result
Log.d("taag", "$token")
}
}
}
}

31 changes: 31 additions & 0 deletions app/src/main/java/com/example/remind/app/RemindNavHost.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.example.remind.app

import androidx.compose.runtime.Composable
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.navigation
import androidx.navigation.compose.rememberNavController
import com.example.remind.feature.screens.patience.FirstScreen
import com.example.remind.feature.screens.patience.FourthScreen
import com.example.remind.feature.screens.patience.PatienceScreen
import com.example.remind.feature.screens.patience.SecondScreen
import com.example.remind.feature.screens.patience.ThirdScreen
import com.example.remind.feature.screens.register.RegisterGraph

@Composable
fun RemindNavHost() {
val navHostController = rememberNavController()
NavHost(
navController = navHostController,
startDestination = Screens.Register.route
) {
RegisterGraph(navHostController)


composable(route = Screens.Patience.route) {
PatienceScreen()
}

}
}

21 changes: 21 additions & 0 deletions app/src/main/java/com/example/remind/app/Screens.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.example.remind.app

sealed class Screens(val route: String) {
object Register: Screens("register") {
object Login: Screens("login")
object SelectType: Screens("selecttype")
}

object Doctor: Screens("doctor") {
object PatienceRegister: Screens("PatienceRegister")
}
object Center: Screens("center") {
object PatienceRegister: Screens("PatienceRegister")
}
object Patience: Screens("patience") {
object Fitst: Screens("FirstScreen")
object Second: Screens("SecondScreen")
object Third: Screens("ThirdScreen")
object Fourth: Screens("FourthScreen")
}
}
64 changes: 64 additions & 0 deletions app/src/main/java/com/example/remind/core/base/BaseViewModel.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.example.remind.core.base

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.receiveAsFlow
import kotlinx.coroutines.launch


interface UiState
interface UiEvent
interface UiEffect
abstract class BaseViewModel<Event: UiEvent, State: UiState, Effect: UiEffect>(
initialState: State
): ViewModel() {
private val _uiState: MutableStateFlow<State> = MutableStateFlow(initialState)
val currentState: State
get() = _uiState.value
val uiState = _uiState.asStateFlow()

private val _event: MutableSharedFlow<Event> = MutableSharedFlow()
val event = _event.asSharedFlow()

private val _effect: Channel<Effect> = Channel()
val effect = _effect.receiveAsFlow()

fun setEvent(event: Event) {
val newEvent = event
viewModelScope.launch {
_event.emit(newEvent)
}
}

fun setEffect(builder: () -> Effect) {
val effectValue = builder()
viewModelScope.launch {
_effect.send(effectValue)
}
}

protected fun setState(reduce: State.() -> State) {
val newState = currentState.reduce()
_uiState.value = newState
}

init {
subscribeEvents()
}

private fun subscribeEvents() {
viewModelScope.launch {
event.collect {
handleEvent(it)
}
}
}

abstract fun handleEvent(event: Event)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.example.remind.core.common.component

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
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.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.example.remind.R
import com.example.remind.core.designsystem.theme.RemindColors
import com.example.remind.core.designsystem.theme.RemindTheme
import com.example.remind.data.model.response.ListData

@Composable
fun BasicListItem(name: String, index: String) {
Row(
modifier = Modifier
.background(Color.White)
.fillMaxWidth()
.padding(start = 11.dp, end = 9.dp, top = 10.dp, bottom = 9.dp),
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = index,
color = RemindTheme.colors.text,
style = RemindTheme.typography.b3Medium
)
Text(
modifier = Modifier
.padding(start = 30.dp),
text = name,
color = RemindTheme.colors.text,
style = RemindTheme.typography.b3Medium
)
Spacer(Modifier.weight(1f))
Text(
text = "관리",
color = Color.Black,
style = RemindTheme.typography.b3Medium
)
Image(
painter = painterResource(id = R.drawable.ic_listitem),
contentDescription = null
)
}
}

@Preview
@Composable
fun ListItemPreview() {
BasicListItem("송승희", "01")
}
Loading

0 comments on commit e67de00

Please sign in to comment.