simplify NavigationDrawer, update MetNorway User-Agent, refactor pressure unit conversion in PressureBlock

This commit is contained in:
PranshulGG committed 2026-05-28 20:41:58 +05:30
1 parent 0b58aa84be
commit efff11d670
4 files changed
+9 -16

No files matched your search

@@ -35,7 +35,7 @@ interface MetNorwayApi {
val request = chain.request().newBuilder()
.header(
"User-Agent",
"WeatherMaster/3.0.0 (com.pranshulgg.weathermaster; pranshul.devmain@gmail.com)"
"WeatherMaster (com.pranshulgg.weathermaster; pranshul.devmain@gmail.com)"
)
.build()
@@ -10,18 +10,11 @@ fun NavigationDrawer(
drawerContent: @Composable () -> Unit,
content: @Composable () -> Unit,
drawerState: DrawerState,
isTabletLike: Boolean
) {
if (isTabletLike) {
PermanentNavigationDrawer(
drawerContent = drawerContent
) { content() }
} else {
DismissibleNavigationDrawer(
drawerState = drawerState,
drawerContent = drawerContent
) { content() }
}
DismissibleNavigationDrawer(
drawerState = drawerState,
drawerContent = drawerContent
) { content() }
}
@@ -10,11 +10,13 @@ import com.pranshulgg.weather_master_app.R
import com.pranshulgg.weather_master_app.core.model.domain.location.Location
import com.pranshulgg.weather_master_app.core.model.domain.toAppException
import com.pranshulgg.weather_master_app.core.model.domain.toMessageRes
import com.pranshulgg.weather_master_app.core.model.domain.weather.Weather
import com.pranshulgg.weather_master_app.core.model.domain.weather.WeatherBlock
import com.pranshulgg.weather_master_app.core.model.sources.WeatherSource
import com.pranshulgg.weather_master_app.core.model.weather.WeatherResult
import com.pranshulgg.weather_master_app.core.model.weather.airquality.AirQualityResult
import com.pranshulgg.weather_master_app.core.network.github.GithubRepository
import com.pranshulgg.weather_master_app.core.network.sources.address.nominatim.json.NominatimRepository
import com.pranshulgg.weather_master_app.core.network.sources.airquality.openmeteo.OpenMeteoAqiRepository
import com.pranshulgg.weather_master_app.core.ui.snackbar.SnackbarManager
import com.pranshulgg.weather_master_app.data.provider.WeatherRepositoryProvider
@@ -120,8 +122,6 @@ class WeatherViewModel @Inject constructor(
weatherJob = viewModelScope.launch {
if (location.isDeviceLocation && isManualRefresh) {
// UPDATE POSITION (adds loading time)
// TODO: THIS IS TEMPORARY, HAS TO CHANGE LATER
handleDeviceLocation()
}
@@ -35,7 +35,7 @@ import com.pranshulgg.weather_master_app.core.ui.theme.ShapeRadius
fun PressureBlock(weather: Weather, units: WeatherUnits, context: Context) {
val pressure = weather.current.pressureMsl
val pressureInhg = PressureUnit.HPA.convert(pressure!!, PressureUnit.INHG)
val pressureConverted = PressureUnit.HPA.convert(pressure!!, units.pressureUnit)
val pressureHpa = weather.current.pressureMsl.toInt()
val progressDrawable = when {
@@ -74,7 +74,7 @@ fun PressureBlock(weather: Weather, units: WeatherUnits, context: Context) {
}
Text(
if (units.pressureUnit == PressureUnit.INHG) "%.2f".format(pressureInhg) else "$pressureHpa",
if (units.pressureUnit != PressureUnit.HPA) "%.2f".format(pressureConverted) else "$pressureHpa",
style = MaterialTheme.typography.displaySmall,
modifier = Modifier
.align(Alignment.Center)