Skip to content

Commit

Permalink
[#44] 게시판 화면 흐름 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
ayz1070 committed Apr 16, 2024
1 parent ae94ff0 commit a19a908
Show file tree
Hide file tree
Showing 38 changed files with 667 additions and 247 deletions.
3 changes: 3 additions & 0 deletions MungNolZa/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ dependencies {
implementation("androidx.activity:activity:1.8.2")
implementation("com.google.android.gms:play-services-maps:18.2.0")
implementation("androidx.coordinatorlayout:coordinatorlayout:1.2.0")
implementation("androidx.datastore:datastore-core:1.0.0")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
Expand Down Expand Up @@ -89,4 +90,6 @@ dependencies {
implementation("com.google.android.gms:play-services-maps:18.2.0")
implementation("com.google.android.gms:play-services-location:21.2.0")

implementation("androidx.datastore:datastore-preferences:1.0.0")

}
1 change: 1 addition & 0 deletions MungNolZa/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".util.App"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package kr.co.lion.mungnolza.data.repository

import android.content.Context
import android.net.Uri
import android.widget.ImageView
import kr.co.lion.mungnolza.model.BoardModel


Expand All @@ -11,8 +13,10 @@ interface BoardRepository {

suspend fun deleteBoard(boardModel: BoardModel)

suspend fun getBoardImageListPath(boardModel: BoardModel):Uri?

suspend fun updateBoard(boardModel:BoardModel, isRemoveImage:Boolean)

suspend fun getBoardImageUri(boardIdx:Int,imageFilePath: String):Uri?

suspend fun getBoardImageUriList(boardModel:BoardModel): MutableList<Uri?>
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package kr.co.lion.mungnolza.data.repository

import android.content.Context
import android.net.Uri
import android.util.Log
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.google.firebase.Firebase
import com.google.firebase.firestore.Query
import com.google.firebase.firestore.firestore
Expand Down Expand Up @@ -70,18 +73,25 @@ class BoardRepositoryImpl() : BoardRepository {
// 삭제가 아닌 BoardState 변경
}

override suspend fun getBoardImageListPath(boardModel: BoardModel):Uri?{
override suspend fun getBoardImageUri(boardIdx:Int,imageFilePath: String):Uri?{
var response:Uri? = null
val path = "board/${boardModel.boardIdx}/${boardModel.boardImagePathList}"
val path = "board/${boardIdx}/${imageFilePath}"
try{
response = storage.child(path).downloadUrl.await()
}catch (e:Exception){
Log.e("FirebaseResult",
"Error Get BoardImageListPath : ${storage.child(path)}")
}
return response

}

override suspend fun getBoardImageUriList(boardModel:BoardModel): MutableList<Uri?> {
var imageUriList:MutableList<Uri?> = mutableListOf()

boardModel.boardImagePathList.forEach {
imageUriList.add(getBoardImageUri(boardModel.boardIdx,it!!)!!)
}
return imageUriList
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package kr.co.lion.mungnolza.datasource

import android.content.Context
import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.booleanPreferencesKey
import androidx.datastore.preferences.core.edit
import androidx.datastore.preferences.core.stringPreferencesKey
import androidx.datastore.preferences.preferencesDataStore
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
import kr.co.lion.mungnolza.util.App


object MainDataStore {
private fun getContext(): Context = App.context()

private val mDataStore: DataStore<Preferences>
get() = getContext().dataStore

private val Context.dataStore : DataStore<Preferences> by preferencesDataStore("user_pref")
private val FIRST_FLAG = booleanPreferencesKey("FIRST_FLAG")
private val USER_NUMBER = stringPreferencesKey("USER_NUMBER")

suspend fun setupFirstData(){
mDataStore.edit { pref ->
pref[FIRST_FLAG] = true
}
}

suspend fun getFirstFlag(): Boolean{
var currentValue = false

mDataStore.edit { pref->
currentValue = pref[FIRST_FLAG] ?: false
}

return currentValue
}

suspend fun setUserNumber(uniqueNumber: String){
mDataStore.edit { pref->
pref[USER_NUMBER] = uniqueNumber
}
}

fun getUserNumber(): Flow<String> {
return mDataStore.data.map { preferences ->
preferences[USER_NUMBER] ?: ""
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package kr.co.lion.mungnolza.model

import android.net.Uri
import java.net.URI

data class BoardAddUerInfoModel (
val contentData: BoardModel,
val writerNickName: String,
val imgUri: Uri
val imgUri: URI
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package kr.co.lion.mungnolza.model

import android.os.Parcelable
import kotlinx.parcelize.Parcelize
import kotlinx.parcelize.RawValue
import java.net.URI

@Parcelize
data class PetImgModel (
val petInfo: @RawValue PetModel,
val imgUrl: URI
): Parcelable
29 changes: 29 additions & 0 deletions MungNolZa/app/src/main/java/kr/co/lion/mungnolza/model/PetModel.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package kr.co.lion.mungnolza.model

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class PetModel (
val ownerIdx: String,
val petName: String,
val petBreed: String,
val petGender: String,
val petWeight: String,
val petAge: String,
val isNeutering: Boolean,
val petSignificant: String,
val imgName: String
): Parcelable {
constructor(): this(
ownerIdx = "",
petName = "",
petBreed = "",
petGender = "",
petWeight = "",
petAge = "",
isNeutering = true,
petSignificant = "",
imgName = ""
)
}
24 changes: 14 additions & 10 deletions MungNolZa/app/src/main/java/kr/co/lion/mungnolza/model/UserModel.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package kr.co.lion.mungnolza.model

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class UserModel(
var uniqueNumber: String,
var userNickname: String,
var userName: String,
var userEmail: String,
var userPhone: String,
var userAddress: String,
var userProfileImgPath: String,
var userAgeRange : String,
var userGender: String
){
val uniqueNumber: String,
val userNickname: String,
val userName: String,
val userEmail: String,
val userPhone: String,
val userAddress: String,
val userProfileImgPath: String,
val userAgeRange : String,
val userGender: String
): Parcelable {
constructor(): this(
uniqueNumber = "",
userNickname = "",
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package kr.co.lion.mungnolza.repository.freeboard

import java.net.URI
import kr.co.lion.mungnolza.model.BoardModel

interface FreeBoardRepository {
suspend fun fetchAllBoardData(): List<BoardModel>
suspend fun fetchAllBoardImage(boardIdx: String, imgName: String): URI?
}
Loading

0 comments on commit a19a908

Please sign in to comment.