Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/symbol selection #18

Merged
merged 28 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
868c704
:lipstick: Setup basic structure for symbol selection screen
sukchan-0811 Oct 28, 2023
82c2550
:lipstick: SymbolSearchBox and Symbol implement
JH747 Oct 28, 2023
93b7ecc
:truck: Add drawables fav_star, fav_star_selected
JH747 Oct 28, 2023
6c1566c
:lipstick: Symbol modified, fav_star_selected img file changed
JH747 Oct 28, 2023
996b7b7
:memo: annotation update on Symbol
JH747 Oct 28, 2023
f491b52
:lipstick: Refactor symbol search box
sukchan-0811 Oct 28, 2023
532ebcc
:sparkles: Declare data classes for symbol and category
sukchan-0811 Oct 28, 2023
9e7986f
:lipstick: Enhance symbol ui
sukchan-0811 Oct 28, 2023
cc96f54
:lipstick: Add CategoryUi
JH747 Oct 28, 2023
7d62926
:lipstick: Add SymbolSelectedBox but does not work properly
JH747 Oct 28, 2023
1289622
:memo: Update javadoc for symbol and category ui
sukchan-0811 Oct 29, 2023
15d6d46
:lipstick: Enhance symbol and category UI
sukchan-0811 Oct 29, 2023
411f2ae
:lipstick: Rename symbol selected box to selected symbol ui, enhance UI
sukchan-0811 Oct 29, 2023
921f688
:label: Change category field of symbols to categoryId
sukchan-0811 Oct 29, 2023
4b94283
:art: Removed unused import directives & javadoc
sukchan-0811 Oct 29, 2023
71d37f1
:sparkles: Implement selected symbols box
sukchan-0811 Oct 29, 2023
68fc7b0
:sparkles: Implement symbol selection screen
sukchan-0811 Oct 29, 2023
0259b19
:twisted_rightwards_arrows: Merge main into feat/symbol-selection
sukchan-0811 Oct 29, 2023
6224f2a
:fire: Remove onBackClick from symbol selection screen
sukchan-0811 Oct 29, 2023
572d7fd
:trucK: Replace speech buddy parrot
sukchan-0811 Oct 29, 2023
257f3bb
:lipstick: Adjust paddings in symbol selection screen
sukchan-0811 Oct 29, 2023
8d64e40
:art: Implement entry interface
sukchan-0811 Oct 30, 2023
8aaf730
:sparkles: Implement symbol selection view model
sukchan-0811 Oct 30, 2023
641ac13
:card_file_box: Modify symnbol and category ids to start from 1
sukchan-0811 Nov 1, 2023
522ce5d
:rewind: Re-add missing files
sukchan-0811 Nov 1, 2023
3bc31ea
:twisted_rightwards_arrows: Merge branch 'main' into feat/symbol-sele…
sukchan-0811 Nov 2, 2023
8571c12
:sparkles: Implement deselect selected symbols
sukchan-0811 Nov 2, 2023
ef0c6e0
:twisted_rightwards_arrows: Merge main into feat/symbol-selection
sukchan-0811 Nov 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.example.speechbuddy.compose.home

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
Expand All @@ -13,6 +16,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
Expand Down Expand Up @@ -82,14 +86,14 @@ fun HomeScreen() {
private fun BottomNavigationBar(
items: List<BottomNavItem>,
navController: NavController,
modifier: Modifier = Modifier,
onItemClick: (BottomNavItem) -> Unit
) {
val backStackEntry = navController.currentBackStackEntryAsState()

NavigationBar(
modifier = modifier,
containerColor = MaterialTheme.colorScheme.secondaryContainer
modifier = Modifier.height(100.dp),
containerColor = MaterialTheme.colorScheme.secondaryContainer,
windowInsets = WindowInsets(top = 20.dp)
) {
items.forEach { item ->
val selected = item.route == backStackEntry.value?.destination?.route
Expand All @@ -102,6 +106,7 @@ private fun BottomNavigationBar(
contentDescription = stringResource(id = item.nameResId)
)
},
modifier = Modifier.size(40.dp),
colors = NavigationBarItemDefaults.colors(
selectedIconColor = MaterialTheme.colorScheme.onPrimaryContainer,
unselectedIconColor = MaterialTheme.colorScheme.outline
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
Expand All @@ -25,11 +26,19 @@ fun LandingScreen(
onGuestClick: () -> Unit,
onLoginClick: () -> Unit,
) {
Surface(modifier = modifier.fillMaxSize(), color = MaterialTheme.colorScheme.primaryContainer) {
Image(
painter = painterResource(id = R.mipmap.ic_launcher_foreground),
contentDescription = stringResource(id = R.string.app_name),
)
Surface(
modifier = modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.primaryContainer
) {
Box(
modifier = Modifier.size(200.dp),
contentAlignment = Alignment.Center
) {
Image(
painter = painterResource(id = R.drawable.speechbuddy_parrot),
contentDescription = stringResource(id = R.string.app_name),
)
}
Box(
modifier = Modifier.padding(horizontal = 24.dp, vertical = 64.dp),
contentAlignment = Alignment.BottomCenter
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package com.example.speechbuddy.compose.symbolselection

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Clear
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.example.speechbuddy.R
import com.example.speechbuddy.domain.models.Symbol
import com.example.speechbuddy.ui.SpeechBuddyTheme
import com.example.speechbuddy.utils.Constants

@ExperimentalMaterial3Api
@Composable
fun SelectedSymbolUi(
symbol: Symbol,
modifier: Modifier = Modifier,
onClear: () -> Unit
) {
Card(
modifier = modifier.size(100.dp),
shape = RoundedCornerShape(10.dp),
colors = CardDefaults.cardColors(
containerColor = MaterialTheme.colorScheme.background
),
border = BorderStroke(width = 1.dp, color = MaterialTheme.colorScheme.onBackground)
) {
Box(contentAlignment = Alignment.TopEnd) {
IconButton(
onClick = onClear,
modifier = Modifier
.size(22.dp)
.padding(5.dp)
) {
Icon(
imageVector = Icons.Default.Clear,
contentDescription = stringResource(id = R.string.symbol_unselect)
)
}

Column(
modifier = Modifier.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally
) {
Image(
painter = painterResource(id = symbol.imageResId),
contentDescription = symbol.text,
modifier = Modifier.height(65.dp),
contentScale = ContentScale.FillHeight
)

Box(
modifier = Modifier
.fillMaxWidth()
.height(35.dp)
.background(color = MaterialTheme.colorScheme.secondaryContainer)
.padding(horizontal = 8.dp),
contentAlignment = Alignment.Center
) {
Text(
text = symbol.text,
textAlign = TextAlign.Center,
maxLines = Constants.MAXIMUM_LINES_FOR_SYMBOL_TEXT,
style = MaterialTheme.typography.labelSmall
)
}
}
}
}
}

@Preview(showBackground = true)
@ExperimentalMaterial3Api
@Composable
fun SelectedSymbolUiPreview() {
val previewSymbol = Symbol(
id = 1,
text = "119에 전화해주세요",
imageResId = R.drawable.symbol_1,
categoryId = 1,
isFavorite = true,
isMine = false
)

SpeechBuddyTheme {
SelectedSymbolUi(symbol = previewSymbol, onClear = {})
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package com.example.speechbuddy.compose.symbolselection

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.example.speechbuddy.R
import com.example.speechbuddy.domain.models.Symbol
import com.example.speechbuddy.ui.SpeechBuddyTheme

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SelectedSymbolsBox(
selectedSymbols: List<Symbol>,
onClear: (Symbol) -> Unit,
onClearAll: () -> Unit,
modifier: Modifier = Modifier
) {
Row(
modifier = modifier
.fillMaxWidth()
.height(120.dp)
.background(color = MaterialTheme.colorScheme.surface)
.border(
width = 1.dp,
color = MaterialTheme.colorScheme.surfaceVariant,
shape = RoundedCornerShape(10.dp)
)
) {
Box(
modifier = Modifier
.fillMaxWidth()
.weight(1f),
contentAlignment = Alignment.CenterStart
) {
LazyRow(
contentPadding = PaddingValues(10.dp),
horizontalArrangement = Arrangement.spacedBy(10.dp)
) {
items(selectedSymbols) { symbol ->
SelectedSymbolUi(symbol = symbol, onClear = { onClear(symbol) })
}
}
}

Box(
modifier = Modifier
.width(50.dp)
.background(color = MaterialTheme.colorScheme.background)
) {
Button(
onClick = onClearAll,
modifier = Modifier
.fillMaxSize()
.padding(6.dp),
enabled = selectedSymbols.isNotEmpty(),
shape = RoundedCornerShape(5.dp),
colors = ButtonDefaults.buttonColors(
containerColor = MaterialTheme.colorScheme.tertiary,
contentColor = MaterialTheme.colorScheme.onTertiary
),
contentPadding = PaddingValues(2.dp)
) {
Text(
text = stringResource(id = R.string.clear_all),
textAlign = TextAlign.Center,
style = MaterialTheme.typography.bodyMedium
)
}
}
}
}

@Preview
@Composable
fun SelectedSymbolsBoxPreview() {
val previewSymbol = Symbol(
id = 1,
text = "119에 전화해주세요",
imageResId = R.drawable.symbol_1,
categoryId = 1,
isFavorite = true,
isMine = false
)
val selectedSymbols = List(size = 10, init = { previewSymbol })

SpeechBuddyTheme {
SelectedSymbolsBox(selectedSymbols = selectedSymbols, onClear = {}, onClearAll = {})
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.example.speechbuddy.compose.symbolselection

import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Search
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.material3.TextFieldDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.example.speechbuddy.R
import com.example.speechbuddy.ui.SpeechBuddyTheme

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SymbolSearchTextField(
value: String,
onValueChange: (String) -> Unit,
modifier: Modifier = Modifier
) {
OutlinedTextField(
value = value,
onValueChange = onValueChange,
modifier = modifier
.fillMaxWidth()
.defaultMinSize(minHeight = 48.dp),
textStyle = MaterialTheme.typography.bodyMedium,
placeholder = { Text(text = stringResource(id = R.string.search_box_placeholder)) },
trailingIcon = {
Icon(
imageVector = Icons.Default.Search,
contentDescription = stringResource(id = R.string.search_box_placeholder)
)
},
singleLine = true,
shape = RoundedCornerShape(10.dp),
colors = TextFieldDefaults.outlinedTextFieldColors(
textColor = MaterialTheme.colorScheme.onSurface,
containerColor = MaterialTheme.colorScheme.surface,
focusedBorderColor = MaterialTheme.colorScheme.tertiary,
unfocusedBorderColor = MaterialTheme.colorScheme.surfaceVariant
)
)
}

@Preview(showBackground = true)
@Composable
fun SymbolSearchTextFieldPreview() {
SpeechBuddyTheme {
SymbolSearchTextField(
value = "검색어",
onValueChange = {}
)
}
}
Loading