Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit 497d4c6

Browse files
committed
Refactor: Replace app name retrieval with string resource
1 parent d86b798 commit 497d4c6

2 files changed

Lines changed: 2 additions & 11 deletions

File tree

app/src/main/java/com/yangdai/opennote/presentation/component/main/DrawerContent.kt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,12 @@ import androidx.compose.runtime.LaunchedEffect
2929
import androidx.compose.runtime.getValue
3030
import androidx.compose.runtime.key
3131
import androidx.compose.runtime.mutableStateOf
32-
import androidx.compose.runtime.remember
3332
import androidx.compose.runtime.saveable.rememberSaveable
3433
import androidx.compose.runtime.setValue
3534
import androidx.compose.ui.Alignment
3635
import androidx.compose.ui.Modifier
3736
import androidx.compose.ui.graphics.Color
3837
import androidx.compose.ui.graphics.vector.ImageVector
39-
import androidx.compose.ui.platform.LocalContext
4038
import androidx.compose.ui.res.stringResource
4139
import androidx.compose.ui.text.font.FontWeight
4240
import androidx.compose.ui.text.style.TextAlign
@@ -47,7 +45,6 @@ import com.yangdai.opennote.data.local.entity.FolderEntity
4745
import com.yangdai.opennote.presentation.navigation.Screen
4846
import com.yangdai.opennote.presentation.navigation.Screen.Folders
4947
import com.yangdai.opennote.presentation.navigation.Screen.Settings
50-
import com.yangdai.opennote.presentation.util.getAppName
5148

5249
@Composable
5350
fun DrawerContent(
@@ -62,10 +59,6 @@ fun DrawerContent(
6259
.fillMaxWidth()
6360
.verticalScroll(rememberScrollState())
6461
) {
65-
val context = LocalContext.current
66-
val appName = remember { context.getAppName() }
67-
68-
6962
Row(
7063
modifier = Modifier
7164
.fillMaxWidth()
@@ -74,7 +67,7 @@ fun DrawerContent(
7467
verticalAlignment = Alignment.CenterVertically
7568
) {
7669
Text(
77-
text = appName,
70+
text = stringResource(R.string.app_name),
7871
style = MaterialTheme.typography.titleLarge,
7972
color = MaterialTheme.colorScheme.onSurface,
8073
fontWeight = FontWeight.SemiBold,

app/src/main/java/com/yangdai/opennote/presentation/util/Utils.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,4 @@ fun Int.toHexColor(): String {
132132

133133
fun IntRange.overlaps(other: IntRange): Boolean {
134134
return this.first <= other.last && other.first <= this.last
135-
}
136-
137-
fun Context.getAppName(): String = applicationInfo.loadLabel(packageManager).toString()
135+
}

0 commit comments

Comments
 (0)