Skip to content

Commit

Permalink
refactor: issues fragments with tags
Browse files Browse the repository at this point in the history
  • Loading branch information
PratyushSingh07 committed Jan 5, 2024
1 parent b113736 commit 436f80e
Showing 8 changed files with 38 additions and 8 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

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

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

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

2 changes: 1 addition & 1 deletion .idea/misc.xml

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

Original file line number Diff line number Diff line change
@@ -9,14 +9,16 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import com.example.findissues.R

@Composable
fun IssueToolBar() {
TopAppBar(
title = {
Text(
text = "Issues",
text = stringResource(id = R.string.issues),
fontWeight = FontWeight.Medium,
color = Color.White,
style = MaterialTheme.typography.headlineSmall
28 changes: 24 additions & 4 deletions app/src/main/java/com/example/findissues/ui/issues/IssuesScreen.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.example.findissues.ui.issues

import android.util.Log
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi
@@ -10,27 +12,41 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.rememberScrollState
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshotFlow
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import com.example.core.ui.components.AppCard
import com.example.core.ui.components.AppCircularProgressBar
import com.example.core.ui.components.AppRowCard
import com.example.core.ui.components.Tag
import com.example.findissues.R
import com.example.findissues.models.issues.IssuesList
import com.example.findissues.utils.Browser

@OptIn(ExperimentalLayoutApi::class)
@Composable
fun IssuesScreen(
list: List<IssuesList>, isLoading: Boolean, viewModel: IssuesViewModel
) {
val context = LocalContext.current

Scaffold(topBar = { IssueToolBar() }) {
if (isLoading) {
AppCircularProgressBar()
@@ -42,8 +58,8 @@ fun IssuesScreen(
.padding(it)
) {
FlowRow(
horizontalArrangement = Arrangement.Start, modifier = Modifier.fillMaxWidth()

modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.Start
) {
viewModel.getTags().forEach { tag ->
Tag(tagText = tag, selected = tag == viewModel.tag) {
@@ -58,7 +74,7 @@ fun IssuesScreen(
modifier = Modifier.fillMaxSize()
) {
Text(
text = "Please select a valid tag",
text = stringResource(R.string.please_select_a_tag),
color = Color.White,
modifier = Modifier,
style = MaterialTheme.typography.headlineLarge
@@ -67,13 +83,17 @@ fun IssuesScreen(
}
} else {
LazyColumn(
modifier = Modifier.background(Color(0xFF0d1117))
modifier = Modifier.background(Color(0xFF0d1117)),
state = rememberLazyListState()
) {
items(list) { items ->
AppCard(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp)
.clickable(onClick = {
Browser(context).launch(items.html_url)
})
) {
AppRowCard(
modifier = Modifier
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ class IssuesViewModel @Inject constructor(
private val repository: DataRepository
) : ViewModel() {
private var issueLiveData = MutableStateFlow<IssuesUiState>(IssuesUiState.Loading)
private val tags = listOf("Kotlin", "Java", "Python")
private val tags = listOf("Kotlin", "Java", "Python","Rust","React.js","Go","Javascript","Node.js")
var tag = ""
private set

1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -7,5 +7,6 @@
<string name="pulls">Pull Requests</string>
<string name="statistics">Statistics</string>
<string name="profile">Profile</string>
<string name="please_select_a_tag">Please select a tag</string>

</resources>
2 changes: 1 addition & 1 deletion core/src/main/java/com/example/core/ui/components/Tag.kt
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ fun Tag(tagText: String, selected: Boolean, onclick: () -> Unit) {
BorderStroke(1.dp, Color(0xFF018786)), shape = RoundedCornerShape(100.dp)
)
.background(if (selected) Color(0xFF018786) else Color(0xFF0d1117))
.padding(10.dp)
.padding(8.dp)
) {
Text(
text = tagText,

0 comments on commit 436f80e

Please sign in to comment.