Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,568 changes: 3,568 additions & 0 deletions core/common/src/main/assets/region_data.tsv

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@ import java.nio.charset.Charset

data class LocationRow(
val code: String,
val name: String,
)
val province: String,
val district: String,
val neighborhood: String,
) {
/** 리스트/검색용 전체 이름 */
val fullName: String
get() = listOf(province, district, neighborhood)
.filter { it.isNotBlank() }
.joinToString(" ")
}

object LocationStore {
@Volatile private var cache: List<LocationRow>? = null
Expand All @@ -20,31 +28,42 @@ object LocationStore {
return@withContext it
}

Log.d("LocationStore", "📂 Loading Location_info.txt from assets...")
Log.d("LocationStore", "📂 Loading region_data.tsv from assets...")

val lines = try {
context.assets.open("Location_info.txt")
.bufferedReader(Charset.forName("EUC-KR"))
.use {
it.readLines()
}
context.assets.open("region_data.tsv")
.bufferedReader(Charset.forName("UTF-8")) // 파일 인코딩이 다르면 여기만 변경
.use { it.readLines() }
} catch (e: Exception) {
Log.e("LocationStore", "❌ Failed to load asset: ${e.message}", e)
emptyList()
}

Log.d("LocationStore", "📄 Read ${lines.size} lines")

val parsed = lines.mapNotNull { line ->
val parts = line.split('\t')
if (parts.size < 3) return@mapNotNull null
val code = parts[0].trim()
val name = parts[1].trim()
val status = parts[2].trim()
if (status != "존재") null else LocationRow(code, name)
}
// 첫 줄이 헤더(code province district neighborhood)라고 가정
val parsed = lines
.drop(1) // 헤더 제거
.mapNotNull { line ->
val parts = line.split('\t')
if (parts.size < 4) return@mapNotNull null

val code = parts[0].trim()
val province = parts[1].trim()
val district = parts[2].trim()
val neighborhood = parts[3].trim()

if (code.isBlank() || neighborhood.isBlank()) return@mapNotNull null

Log.d("LocationStore", "✅ Parsed ${parsed.size} valid rows")
LocationRow(
code = code,
province = province,
district = district,
neighborhood = neighborhood
)
}

Log.d("LocationStore", "✅ Parsed ${parsed.size} rows")

cache = parsed
parsed
Expand All @@ -55,9 +74,11 @@ fun searchLocations(query: String, list: List<LocationRow>, limit: Int = 20): Li
if (query.isBlank()) return emptyList()

val normalized = query.trim().replace(" ", "").lowercase()
val results = list.filter {
it.name.replace(" ", "").lowercase().contains(normalized)
}.take(limit)

return results
return list
.filter {
it.fullName.replace(" ", "").lowercase().contains(normalized)
}
.take(limit)
}

Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ import com.umcspot.spot.designsystem.theme.G300
import com.umcspot.spot.designsystem.theme.G400
import com.umcspot.spot.designsystem.theme.SpotTheme
import com.umcspot.spot.designsystem.theme.White
import com.umcspot.spot.ui.extension.screenHeightDp
import com.umcspot.spot.ui.extension.screenWidthDp


@Composable
fun AppBarHome (
hasAlert: Boolean = false,
Expand All @@ -51,35 +51,40 @@ fun AppBarHome (
Row(
modifier = modifier
.fillMaxWidth()
.height(screenHeightDp(53.dp))
.background(SpotTheme.colors.white)
.padding(horizontal = 16.dp, vertical = 8.dp),
.padding(horizontal = screenWidthDp(17.dp)),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
) {

Image(
painter = painterResource(id = R.drawable.spot_logo),
contentDescription = "App Logo",
modifier = Modifier.size(32.dp)
modifier = Modifier.size(screenWidthDp(33.dp))
)

Row(verticalAlignment = Alignment.CenterVertically) {
IconButton(onClick = onSearchClick) {
IconButton(
modifier = Modifier.size(screenWidthDp(32.dp)),
onClick = onSearchClick) {
Icon(
painter = painterResource(id = R.drawable.search),
contentDescription = "Search",
modifier = Modifier.size(32.dp)
modifier = Modifier.size(screenWidthDp(24.dp))
)
}
Spacer(modifier = Modifier.width(8.dp))
IconButton(onClick = onAlertClick) {
Spacer(modifier = Modifier.width(screenWidthDp(8.dp)))
IconButton(
modifier = Modifier.size(screenWidthDp(32.dp)),
onClick = onAlertClick
) {
Icon(
painter = painterResource(
id = if (hasAlert) R.drawable.alert_noti else R.drawable.alert
),
contentDescription = if (hasAlert) "New Notifications" else "Notifications",
tint = Color.Unspecified,
modifier = Modifier.size(32.dp)
modifier = Modifier.size(screenWidthDp(24.dp))
)
}
}
Expand Down Expand Up @@ -119,21 +124,24 @@ fun BackTopBar(
Row(
modifier = modifier
.fillMaxWidth()
.height(screenHeightDp(53.dp))
.background(SpotTheme.colors.white)
.padding(start = 5.dp, top = 16.dp, bottom = 16.dp),
.padding(start = screenWidthDp(17.dp)),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Start
) {
IconButton(
onClick = onBackClick,
modifier = Modifier.size(screenWidthDp(20.dp)),
onClick = onBackClick
) {
Icon(
modifier = Modifier.size(screenWidthDp(20.dp)),
painter = painterResource(id = R.drawable.arrow_left),
contentDescription = "Back"
contentDescription = "Back"
)
}

Spacer(modifier = Modifier.width((-2).dp))
Spacer(modifier = Modifier.width(screenWidthDp(10.dp)))

Text(
text = title,
Expand Down Expand Up @@ -238,7 +246,6 @@ fun SearchTopBar(
@Composable
fun PreviewSearchTopBarWithText() {
var text by remember { mutableStateOf("안녕하세요") }

SpotTheme{
SearchTopBar(
value = text,
Expand Down
Loading