Skip to content

Commit

Permalink
update to emptyview
Browse files Browse the repository at this point in the history
  • Loading branch information
Guri999 committed May 15, 2024
1 parent 17e6f00 commit 08facc9
Show file tree
Hide file tree
Showing 15 changed files with 196 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ android {
}
}
buildTypes {
release {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
Expand Down Expand Up @@ -71,6 +71,6 @@ dependencies {
implementation(libs.androidx.activity.compose)

//timber log찍는 library
implementation (libs.timber)
implementation(libs.timber)
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import com.guri.raffitcompose.domain.BookmarkEntity


interface BookmarkRepository {
suspend fun insert(bookmark: com.guri.raffitcompose.domain.BookmarkEntity)
suspend fun delete(bookmark: com.guri.raffitcompose.domain.BookmarkEntity)
suspend fun update(bookmark: com.guri.raffitcompose.domain.BookmarkEntity)
suspend fun findByBox(box: String): List<com.guri.raffitcompose.domain.BookmarkEntity>
suspend fun getAllBookmarks(): List<com.guri.raffitcompose.domain.BookmarkEntity>
suspend fun insert(bookmark: BookmarkEntity)
suspend fun delete(bookmark: BookmarkEntity)
suspend fun update(bookmark: BookmarkEntity)
suspend fun findByBox(box: String): List<BookmarkEntity>
suspend fun getAllBookmarks(): List<BookmarkEntity>
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package com.guri.raffitcompose.designsystem.component.category

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.guri.raffitcompose.designsystem.models.category.CategoryButton

@Composable
fun CategoryTab.Type(
modifier:Modifier = Modifier,
tabs: List<CategoryButton>,
) {
BaseCategoryItem(
modifier = modifier,
spacer = true,
categoryItems = tabs
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ fun ColumnScope.DialogContentWrapper(content: DialogContent) {
contentBottomPadding = Padding.xlarge,
)
) {

ListDialogContent(content)
}
ListDialogContent(content)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fun RaffitTheme(
SideEffect {
val window = (view.context as Activity).window
window.statusBarColor = colors.primary.toArgb()
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = !darkTheme
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,14 @@ val Typography = Typography(
val Typography.mainTitle: TextStyle
@Composable get() = displayLarge.copy(
fontStyle = FontStyle.Italic
)

val Typography.topComponentText: TextStyle
@Composable get() = bodyLarge.copy(
fontSize = 16.sp,
)
val Typography.topHeader: TextStyle
@Composable get() = headlineLarge.copy(
fontSize = 24.sp,
fontWeight = FontWeight.Bold
)
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
package com.guri.raffitcompose.presentation

import android.app.Activity
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.padding
import androidx.compose.material.BottomNavigation
import androidx.compose.material.BottomNavigationItem
import androidx.compose.material3.Surface
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.core.view.WindowCompat
import androidx.navigation.NavController
import androidx.navigation.NavDestination
import androidx.navigation.NavDestination.Companion.hierarchy
Expand All @@ -24,7 +31,9 @@ import com.guri.raffitcompose.designsystem.component.dialog.DialogPop
import com.guri.raffitcompose.designsystem.component.dialog.OneClick
import com.guri.raffitcompose.designsystem.models.dialog.DialogButton
import com.guri.raffitcompose.designsystem.models.dialog.DialogText
import com.guri.raffitcompose.designsystem.theme.Padding
import com.guri.raffitcompose.designsystem.theme.RaffitTheme
import com.guri.raffitcompose.designsystem.theme.scheme
import com.guri.raffitcompose.presentation.home.Home
import com.guri.raffitcompose.presentation.mybox.MyBox
import com.guri.raffitcompose.presentation.search.Search
Expand All @@ -34,6 +43,7 @@ fun RaffitApp(
appState: RaffitAppState = rememberRaffitAppState(),
) {
RaffitTheme {

if (appState.isOnline) {
Scaffold(
bottomBar = {
Expand Down Expand Up @@ -81,18 +91,36 @@ fun BottomBar(navController: NavController) {
)
val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentDestination = navBackStackEntry?.destination
val view = LocalView.current
val window = (view.context as Activity).window

when(currentDestination?.route) {
Screen.Home.route -> {
window.statusBarColor = MaterialTheme.scheme.primary.toArgb()
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = isSystemInDarkTheme()
}
Screen.Search.route, Screen.MyBox.route -> {
window.statusBarColor = MaterialTheme.scheme.onPrimary.toArgb()
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = !isSystemInDarkTheme()
}
}

if (currentDestination?.route == Screen.Home.route) return

BottomNavigation(
backgroundColor = Color.White
) {
screens.forEach { screen ->
AddItem(
screen = screen,
currentDestination = currentDestination,
navController = navController
)
Surface(
shadowElevation = Padding.xlarge
){
BottomNavigation(
modifier = Modifier,
backgroundColor = Color.White
) {
screens.forEach { screen ->
AddItem(
screen = screen,
currentDestination = currentDestination,
navController = navController
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
package com.guri.raffitcompose.presentation.mybox

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.staggeredgrid.LazyStaggeredGridItemScope
import androidx.compose.foundation.lazy.staggeredgrid.LazyVerticalStaggeredGrid
import androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridCells
import androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridItemSpan
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.sp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.guri.raffitcompose.designsystem.theme.Padding
import com.guri.raffitcompose.designsystem.theme.scheme
import com.guri.raffitcompose.designsystem.theme.topComponentText
import com.guri.raffitcompose.designsystem.theme.topHeader
import com.guri.raffitcompose.presentation.R
import com.guri.raffitcompose.presentation.UiState
import com.guri.raffitcompose.presentation.result.SearchModel
import com.guri.raffitcompose.presentation.result.itemResult
Expand All @@ -28,18 +35,46 @@ fun MyBox(
) {
val viewState by viewModel.state.collectAsStateWithLifecycle()

Scaffold {paddingValues ->
Scaffold(
topBar = { MyBoxTopBar() }
) {paddingValues ->
MyBox(
header = viewState.header,
searchItems = viewState.items,
modifier = Modifier.padding(paddingValues),
toggleBookmark = viewModel::deleteBookmark
)
}
}

@Composable
fun MyBoxTopBar(
folderName: String = "기본 폴더",
toggleEdit: () -> Unit = {}
) {
Box(
modifier = Modifier
.fillMaxWidth()
.padding(Padding.medium),
contentAlignment = Alignment.Center,
){
Text(
modifier = Modifier.align(Alignment.Center),
text = folderName,
style = MaterialTheme.typography.topHeader,
textAlign = TextAlign.Center
)
Text(
modifier = Modifier.align(Alignment.CenterEnd)
.padding(Padding.medium)
.clickable { toggleEdit() },
text = stringResource(R.string.edit),
style = MaterialTheme.typography.topComponentText,
)
}
}

@Composable
fun MyBox(
header: String,
searchItems: UiState<List<SearchModel>>,
modifier: Modifier = Modifier,
toggleBookmark: (SearchModel) -> Unit
Expand All @@ -48,11 +83,6 @@ fun MyBox(
modifier = modifier,
columns = StaggeredGridCells.Fixed(2)
) {
item(
span = StaggeredGridItemSpan.FullLine
) {
MyBoxTop(header)
}

if (searchItems is UiState.Success)
itemResult(searchItems = searchItems.data, toggleBookmark = toggleBookmark){}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@ class MyBoxViewModel @Inject constructor(
private fun setItems() {
viewModelScope.launch(Dispatchers.IO) {
_itemList.value = UiState.Success(
bookmarkRepository.getAllBookmarks().map { it.convert() }
bookmarkRepository.findByBox("default").map { it.convert() }
)
}
}

fun registerFolder(name: String) {

}

fun deleteBookmark(item: SearchModel) {
val currentItem = _itemList.value
if (currentItem is UiState.Success) {
Expand Down
Loading

0 comments on commit 08facc9

Please sign in to comment.