Skip to content

Commit

Permalink
- Using LanguageUtils for language functionality
Browse files Browse the repository at this point in the history
- Refactoring code
  • Loading branch information
muradnajafli committed Mar 18, 2024
1 parent 9f79678 commit 8c75ea3
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.muradnajafli.newscatcher.presentation.detail.components
package com.muradnajafli.newscatcher.presentation.common

import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import coil.compose.AsyncImage
import com.muradnajafli.newscatcher.domain.model.Article
import com.muradnajafli.newscatcher.presentation.detail.components.ArticleTextContent
import com.muradnajafli.newscatcher.presentation.detail.components.MoreButton
import com.muradnajafli.newscatcher.presentation.detail.components.NavigateBackButton
import com.muradnajafli.newscatcher.presentation.common.NavigateBackButton

@Composable
fun DetailsScreen(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.muradnajafli.newscatcher.presentation.detail.components.NavigateBackButton
import com.muradnajafli.newscatcher.presentation.common.NavigateBackButton

@Composable
fun DropdownScreen(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.muradnajafli.newscatcher.presentation.home

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
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.material3.Text
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -56,6 +58,8 @@ fun HomeScreen(
)
}

Spacer(modifier = Modifier.height(16.dp))

SearchPanel(
searchText = searchState.searchText,
onSearchChange = searchState.onSearchChange,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ 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.lazy.itemsIndexed
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
Expand All @@ -38,21 +38,22 @@ fun ImageSlider(
onClick: (Article) -> Unit
) {
LazyRow(
modifier = Modifier.fillMaxWidth()
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp)
) {
items(newsImages) { item ->
val isFirst = item == newsImages.first()
val isLast = item == newsImages.last()

Spacer(
modifier = Modifier
.width(if (isFirst || isLast) 16.dp else 8.dp))
itemsIndexed(newsImages) { index, article ->
if (article != null) {

if (item != null) {
HomeImageItem(
article = item,
article = article,
onClick = onClick
)

if (index != newsImages.lastIndex) {
Spacer(modifier = Modifier.width(8.dp))
}

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
Expand All @@ -20,6 +22,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.unit.dp
import com.muradnajafli.newscatcher.R
import com.muradnajafli.newscatcher.domain.model.Article
Expand All @@ -41,6 +44,7 @@ fun SearchPanel(
focusedTextColor = Color.Black,
unfocusedTextColor = Color.Black
)

TextField(
value = searchText,
onValueChange = onSearchChange,
Expand All @@ -58,7 +62,15 @@ fun SearchPanel(
RoundedCornerShape(16.dp)
),
colors = textFieldColors,
singleLine = true
singleLine = true,
keyboardOptions = KeyboardOptions.Default.copy(
imeAction = ImeAction.Search
),
keyboardActions = KeyboardActions(
onSearch = {
onSearchChange(searchText)
}
)
)

Spacer(modifier = Modifier.height(16.dp))
Expand Down

0 comments on commit 8c75ea3

Please sign in to comment.