-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #118 from snuhcs-course/feat/android-my-emojis
Show my created&saved emoji list
- Loading branch information
Showing
4 changed files
with
180 additions
and
5 deletions.
There are no files selected for viewing
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
86 changes: 85 additions & 1 deletion
86
android/app/src/main/java/com/goliath/emojihub/views/components/CreatedEmojiListView.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,24 +1,108 @@ | ||
package com.goliath.emojihub.views.components | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.lazy.grid.GridCells | ||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid | ||
import androidx.compose.material.Button | ||
import androidx.compose.material.ButtonDefaults | ||
import androidx.compose.material.DropdownMenu | ||
import androidx.compose.material.DropdownMenuItem | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import androidx.paging.compose.collectAsLazyPagingItems | ||
import com.goliath.emojihub.LocalNavController | ||
import com.goliath.emojihub.NavigationDestination | ||
import com.goliath.emojihub.ui.theme.Color | ||
import com.goliath.emojihub.viewmodels.EmojiViewModel | ||
|
||
@Composable | ||
fun CreatedEmojiListView( | ||
|
||
emojiViewModel: EmojiViewModel | ||
) { | ||
val navController = LocalNavController.current | ||
|
||
val emojiList = emojiViewModel.myCreatedEmojiList.collectAsLazyPagingItems() | ||
|
||
var dropDownMenuExpanded by remember { mutableStateOf(false) } | ||
|
||
Column ( | ||
Modifier.background(Color.White) | ||
) { | ||
TopNavigationBar( | ||
title = "내가 만든 이모지", | ||
navigate = { navController.popBackStack() } | ||
) | ||
|
||
Column(Modifier.padding(horizontal = 16.dp)) { | ||
Spacer(Modifier.height(16.dp)) | ||
Row( | ||
modifier = Modifier.fillMaxWidth(), | ||
verticalAlignment = Alignment.CenterVertically | ||
) { | ||
Spacer(Modifier.weight(1f)) | ||
Column { | ||
Button( | ||
onClick = { dropDownMenuExpanded = true }, | ||
colors = ButtonDefaults.buttonColors( | ||
backgroundColor = Color.Black, | ||
contentColor = Color.White | ||
) | ||
) { | ||
Text(text = "Sort by", fontSize = 12.sp) | ||
} | ||
|
||
DropdownMenu( | ||
expanded = dropDownMenuExpanded, | ||
onDismissRequest = { dropDownMenuExpanded = false } | ||
) { | ||
DropdownMenuItem(onClick = { | ||
emojiViewModel.sortByDate = 1 | ||
emojiViewModel.fetchEmojiList() | ||
dropDownMenuExpanded = false | ||
}) { | ||
Text(text = "created date") | ||
} | ||
DropdownMenuItem(onClick = { | ||
emojiViewModel.sortByDate = 0 | ||
emojiViewModel.fetchEmojiList() | ||
dropDownMenuExpanded = false | ||
}) { | ||
Text(text = "save count") | ||
} | ||
} | ||
} | ||
} | ||
|
||
LazyVerticalGrid( | ||
columns = GridCells.Fixed(2), | ||
modifier = Modifier.padding(top = 18.dp), | ||
horizontalArrangement = Arrangement.spacedBy(4.dp), | ||
verticalArrangement = Arrangement.spacedBy(4.dp), | ||
) { | ||
items(emojiList.itemCount) { index -> | ||
emojiList[index]?.let{ | ||
EmojiCell(emoji = it, displayMode = EmojiCellDisplay.VERTICAL) { selectedEmoji -> | ||
emojiViewModel.currentEmoji = selectedEmoji | ||
navController.navigate(NavigationDestination.PlayEmojiVideo) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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
86 changes: 85 additions & 1 deletion
86
android/app/src/main/java/com/goliath/emojihub/views/components/SavedEmojiListView.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,24 +1,108 @@ | ||
package com.goliath.emojihub.views.components | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.lazy.grid.GridCells | ||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid | ||
import androidx.compose.material.Button | ||
import androidx.compose.material.ButtonDefaults | ||
import androidx.compose.material.DropdownMenu | ||
import androidx.compose.material.DropdownMenuItem | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import androidx.paging.compose.collectAsLazyPagingItems | ||
import com.goliath.emojihub.LocalNavController | ||
import com.goliath.emojihub.NavigationDestination | ||
import com.goliath.emojihub.ui.theme.Color | ||
import com.goliath.emojihub.viewmodels.EmojiViewModel | ||
|
||
@Composable | ||
fun SavedEmojiListView( | ||
|
||
emojiViewModel: EmojiViewModel | ||
) { | ||
val navController = LocalNavController.current | ||
|
||
val emojiList = emojiViewModel.mySavedEmojiList.collectAsLazyPagingItems() | ||
|
||
var dropDownMenuExpanded by remember { mutableStateOf(false) } | ||
|
||
Column ( | ||
Modifier.background(Color.White) | ||
) { | ||
TopNavigationBar( | ||
title = "저장된 이모지", | ||
navigate = { navController.popBackStack() } | ||
) | ||
|
||
Column(Modifier.padding(horizontal = 16.dp)) { | ||
Spacer(Modifier.height(16.dp)) | ||
Row( | ||
modifier = Modifier.fillMaxWidth(), | ||
verticalAlignment = Alignment.CenterVertically | ||
) { | ||
Spacer(Modifier.weight(1f)) | ||
Column { | ||
Button( | ||
onClick = { dropDownMenuExpanded = true }, | ||
colors = ButtonDefaults.buttonColors( | ||
backgroundColor = Color.Black, | ||
contentColor = Color.White | ||
) | ||
) { | ||
Text(text = "Sort by", fontSize = 12.sp) | ||
} | ||
|
||
DropdownMenu( | ||
expanded = dropDownMenuExpanded, | ||
onDismissRequest = { dropDownMenuExpanded = false } | ||
) { | ||
DropdownMenuItem(onClick = { | ||
emojiViewModel.sortByDate = 1 | ||
emojiViewModel.fetchEmojiList() | ||
dropDownMenuExpanded = false | ||
}) { | ||
Text(text = "created date") | ||
} | ||
DropdownMenuItem(onClick = { | ||
emojiViewModel.sortByDate = 0 | ||
emojiViewModel.fetchEmojiList() | ||
dropDownMenuExpanded = false | ||
}) { | ||
Text(text = "save count") | ||
} | ||
} | ||
} | ||
} | ||
|
||
LazyVerticalGrid( | ||
columns = GridCells.Fixed(2), | ||
modifier = Modifier.padding(top = 18.dp), | ||
horizontalArrangement = Arrangement.spacedBy(4.dp), | ||
verticalArrangement = Arrangement.spacedBy(4.dp), | ||
) { | ||
items(emojiList.itemCount) { index -> | ||
emojiList[index]?.let{ | ||
EmojiCell(emoji = it, displayMode = EmojiCellDisplay.VERTICAL) { selectedEmoji -> | ||
emojiViewModel.currentEmoji = selectedEmoji | ||
navController.navigate(NavigationDestination.PlayEmojiVideo) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |