Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Garneg committed Mar 4, 2024
2 parents 50f4b3b + 6315d62 commit 3645be6
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .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 app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ android {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion "1.5.3"
kotlinCompilerExtensionVersion "1.5.10"
}
packagingOptions {
resources {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ class DownloadOfflineArticleWorker(
}
return Result.failure()
}
withContext(Dispatchers.Main) {
Toast.makeText(applicationContext, "Статья скачивается.", Toast.LENGTH_SHORT).show()
}
withContext(Dispatchers.IO) {
downloadArticle(articleId, applicationContext)
withContext(Dispatchers.Main) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ class CompaniesListController {
rating = it.statistics.rating,
investment = it.statistics.invest,
subscribersCount = it.statistics.subscribersCount
)
),
relatedData = it.relatedData?.let { CompanySnippet.RelatedData(it.isSubscribed) }
)
)
}
Expand Down Expand Up @@ -80,10 +81,15 @@ data class CompanyRef (
var titleHtml: String,
var descriptionHtml: String? = null,
var imageUrl: String?,
// val relatedData: Any? = null,
val relatedData: RelatedData? = null,
var statistics: CompaniesStatistics,
var commonHubs: List<CommonHub>
)
) {
@Serializable
data class RelatedData(
val isSubscribed: Boolean
)
}

@Serializable
data class CommonHub (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ data class CompanySnippet(

val description: String?,

val statistics: Statistics
val statistics: Statistics,

val relatedData: RelatedData?

) : HabrSnippet {
data class Statistics(
Expand All @@ -24,4 +26,8 @@ data class CompanySnippet(

val subscribersCount: Int
)

data class RelatedData(
val isSubscribed: Boolean
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.garnegsoft.hubs.R
import com.garnegsoft.hubs.api.company.list.CompanySnippet
import com.garnegsoft.hubs.api.utils.placeholderColorLegacy
import com.garnegsoft.hubs.ui.theme.DefaultRatingIndicatorColor
import com.garnegsoft.hubs.ui.theme.HubSubscribedColor


@Composable
Expand All @@ -53,7 +54,7 @@ fun CompanyCard(
modifier = Modifier
.clip(style.shape)
.background(style.backgroundColor)
.clickable { onClick() }
.clickable(onClick = onClick)
.padding(style.innerPadding),
verticalAlignment = remember {
if (style.showDescription && company.description != null)
Expand Down Expand Up @@ -92,7 +93,9 @@ fun CompanyCard(
Column(
modifier = Modifier.weight(1f),
) {
Text(text = company.title, style = style.titleTextStyle)
Text(text = company.title, style = if (company.relatedData?.isSubscribed == true) {
style.titleTextStyle.copy(color = HubSubscribedColor)
} else { style.titleTextStyle })
if (style.showDescription)
company.description?.let {
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import androidx.compose.ui.unit.sp
import coil.compose.AsyncImage
import com.garnegsoft.hubs.api.hub.list.HubSnippet
import com.garnegsoft.hubs.ui.theme.DefaultRatingIndicatorColor
import com.garnegsoft.hubs.ui.theme.HubSubscribedColor


@Composable
Expand Down Expand Up @@ -78,6 +79,7 @@ fun HubCard(
Text(
text =
remember { buildAnnotatedString {

append(hub.title)
if (hub.isProfiled) {
withStyle(
Expand All @@ -87,7 +89,9 @@ fun HubCard(
}
}
}},
style = style.titleTextStyle,
style = if (hub.relatedData?.isSubscribed == true) {
style.titleTextStyle.copy(color = HubSubscribedColor)
} else { style.titleTextStyle },
modifier = Modifier.wrapContentHeight(
Alignment.Top
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fun MainNavigationGraph(
builder = {

composable(
"articles",
route = "articles",
exitTransition = Transitions.GenericTransitions.exitTransition,
popEnterTransition = Transitions.EmptyTransitions.enterTransition
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ fun ArticleContent(
if (companyTitle != null) {
AsyncImage(
modifier = Modifier
.size(34.dp)
.size(38.dp)
.clip(RoundedCornerShape(8.dp))
.background(Color.White),
model = companyAvatarUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ fun MainScreen(
}) {
Icon(
modifier = Modifier
.size(20.dp)
.clip(RoundedCornerShape(20)),
.size(20.dp),
painter = painterResource(id = R.drawable.search_icon),
contentDescription = "search",
tint = Color.White
Expand Down Expand Up @@ -241,14 +240,19 @@ fun MainScreen(
showNoInternetConnectionElement = true
} else {
launch(Dispatchers.IO) {
try {
Socket().use { socket ->
socket.connect(InetSocketAddress("habr.com", 80), 2000)
for (i in 1..3) {
try {
Socket().use { socket ->
socket.connect(InetSocketAddress("habr.com", 80), 2000)
}
showNoInternetConnectionElement = false
break
} catch (e: IOException) {
if(i == 3) {
showNoInternetConnectionElement = true
}

}
showNoInternetConnectionElement = false
} catch (e: IOException) {
showNoInternetConnectionElement = true

}
}

Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ buildscript {
plugins {
id 'com.android.application' version '8.1.0' apply false
id 'com.android.library' version '8.1.0' apply false
id 'org.jetbrains.kotlin.android' version '1.9.10' apply false
id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.10'
id "org.jetbrains.kotlin.kapt" version "1.9.10"
id 'org.jetbrains.kotlin.android' version '1.9.22' apply false
id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.22'
id "org.jetbrains.kotlin.kapt" version "1.9.22"
id 'com.android.test' version '8.1.0' apply false
}

0 comments on commit 3645be6

Please sign in to comment.