Skip to content

Commit 7d7e881

Browse files
committed
fix: corrected lint errors
1 parent 28c6abf commit 7d7e881

7 files changed

Lines changed: 55 additions & 31 deletions

File tree

mobile/androidApp/src/main/kotlin/app/myfaq/android/screens/HomeScreen.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,10 @@ private fun NewsTabContent(
238238
}
239239

240240
@Composable
241-
private fun NewsCard(news: NewsItem, onClick: () -> Unit = {}) {
241+
private fun NewsCard(
242+
news: NewsItem,
243+
onClick: () -> Unit = {},
244+
) {
242245
Card(modifier = Modifier.fillMaxWidth().clickable(onClick = onClick)) {
243246
Column(modifier = Modifier.padding(16.dp)) {
244247
Text(

mobile/androidApp/src/main/kotlin/app/myfaq/android/screens/NewsDetailScreen.kt

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,17 @@ fun NewsDetailScreen(
6666
) { padding ->
6767
when (val s = state) {
6868
is UiState.Loading -> LoadingIndicator(modifier = Modifier.padding(padding))
69-
is UiState.Error -> ErrorRetry(
70-
message = s.message,
71-
onRetry = { vm.load() },
72-
modifier = Modifier.padding(padding),
73-
)
74-
is UiState.Success -> NewsDetailContent(
75-
news = s.data,
76-
modifier = Modifier.padding(padding),
77-
)
69+
is UiState.Error ->
70+
ErrorRetry(
71+
message = s.message,
72+
onRetry = { vm.load() },
73+
modifier = Modifier.padding(padding),
74+
)
75+
is UiState.Success ->
76+
NewsDetailContent(
77+
news = s.data,
78+
modifier = Modifier.padding(padding),
79+
)
7880
}
7981
}
8082
}
@@ -89,10 +91,11 @@ private fun NewsDetailContent(
8991
val textColor = MaterialTheme.colorScheme.onSurface.toArgb()
9092

9193
Column(
92-
modifier = modifier
93-
.fillMaxSize()
94-
.verticalScroll(rememberScrollState())
95-
.padding(16.dp),
94+
modifier =
95+
modifier
96+
.fillMaxSize()
97+
.verticalScroll(rememberScrollState())
98+
.padding(16.dp),
9699
) {
97100
Text(
98101
text = news.header,
@@ -131,28 +134,42 @@ private fun NewsDetailContent(
131134
@SuppressLint("SetJavaScriptEnabled")
132135
settings.javaScriptEnabled = true
133136
setBackgroundColor(bgColor)
134-
webViewClient = object : android.webkit.WebViewClient() {
135-
override fun onPageFinished(view: WebView?, url: String?) {
136-
view?.evaluateJavascript("document.body.scrollHeight") { heightStr ->
137-
val heightPx = heightStr.toFloatOrNull() ?: return@evaluateJavascript
138-
webViewHeight = (heightPx / density).dp + 16.dp
137+
webViewClient =
138+
object : android.webkit.WebViewClient() {
139+
override fun onPageFinished(
140+
view: WebView?,
141+
url: String?,
142+
) {
143+
view?.evaluateJavascript("document.body.scrollHeight") { heightStr ->
144+
val heightPx = heightStr.toFloatOrNull() ?: return@evaluateJavascript
145+
webViewHeight = (heightPx / density).dp + 16.dp
146+
}
139147
}
140148
}
141-
}
142149
loadDataWithBaseURL(null, htmlContent, "text/html", "UTF-8", null)
143150
}
144151
},
145152
update = { webView ->
146153
webView.setBackgroundColor(bgColor)
147-
webView.loadDataWithBaseURL(null, buildNewsHtml(news.content, bgHex, fgHex), "text/html", "UTF-8", null)
154+
webView.loadDataWithBaseURL(
155+
null,
156+
buildNewsHtml(news.content, bgHex, fgHex),
157+
"text/html",
158+
"UTF-8",
159+
null,
160+
)
148161
},
149162
modifier = Modifier.fillMaxWidth().height(webViewHeight),
150163
)
151164
}
152165
}
153166
}
154167

155-
private fun buildNewsHtml(body: String, bgColor: String, fgColor: String): String =
168+
private fun buildNewsHtml(
169+
body: String,
170+
bgColor: String,
171+
fgColor: String,
172+
): String =
156173
"""
157174
<!DOCTYPE html><html><head>
158175
<meta name="viewport" content="width=device-width, initial-scale=1.0">

mobile/androidApp/src/main/kotlin/app/myfaq/android/screens/WorkspacesScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import androidx.compose.material.icons.Icons
1717
import androidx.compose.material.icons.filled.Add
1818
import androidx.compose.material.icons.filled.Delete
1919
import androidx.compose.material.icons.filled.Edit
20-
import androidx.compose.material3.OutlinedTextField
2120
import androidx.compose.material3.AlertDialog
2221
import androidx.compose.material3.Button
2322
import androidx.compose.material3.Card
@@ -27,6 +26,7 @@ import androidx.compose.material3.FloatingActionButton
2726
import androidx.compose.material3.Icon
2827
import androidx.compose.material3.IconButton
2928
import androidx.compose.material3.MaterialTheme
29+
import androidx.compose.material3.OutlinedTextField
3030
import androidx.compose.material3.Scaffold
3131
import androidx.compose.material3.Text
3232
import androidx.compose.material3.TextButton

mobile/shared/src/commonMain/kotlin/app/myfaq/shared/api/MyFaqApi.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package app.myfaq.shared.api
22

3-
import app.myfaq.shared.api.dto.Category
43
import app.myfaq.shared.api.dto.Attachment
4+
import app.myfaq.shared.api.dto.Category
55
import app.myfaq.shared.api.dto.Comment
66
import app.myfaq.shared.api.dto.FaqDetail
77
import app.myfaq.shared.api.dto.FaqPopularItem

mobile/shared/src/commonMain/kotlin/app/myfaq/shared/ui/FaqDetailViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class FaqDetailViewModel(
4949
scope.launch {
5050
try {
5151
_attachments.value = UiState.Success(aim.repository.attachments(faqId))
52-
} catch (e: Exception) {
52+
} catch (_: Exception) {
5353
// Attachments are optional — treat failure as empty rather than error
5454
_attachments.value = UiState.Success(emptyList())
5555
}

mobile/shared/src/commonMain/kotlin/app/myfaq/shared/ui/NewsDetailViewModel.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ class NewsDetailViewModel(
2323
scope.launch {
2424
try {
2525
val item = aim.repository.news().find { it.id == newsId }
26-
_news.value = if (item != null) {
27-
UiState.Success(item)
28-
} else {
29-
UiState.Error("News item not found")
30-
}
26+
_news.value =
27+
if (item != null) {
28+
UiState.Success(item)
29+
} else {
30+
UiState.Error("News item not found")
31+
}
3132
} catch (e: Exception) {
3233
_news.value = UiState.Error(e.message ?: "Failed to load news")
3334
}

mobile/shared/src/commonMain/kotlin/app/myfaq/shared/ui/WorkspacesViewModel.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ class WorkspacesViewModel(
9292
activeInstanceManager.setActive(instance)
9393
}
9494

95-
fun renameInstance(instanceId: String, newName: String) {
95+
fun renameInstance(
96+
instanceId: String,
97+
newName: String,
98+
) {
9699
val now = Clock.System.now().epochSeconds
97100
db.instancesQueries.updateDisplayName(newName, now, instanceId)
98101
refreshList()

0 commit comments

Comments
 (0)