192 lines
6.4 KiB
Kotlin
192 lines
6.4 KiB
Kotlin
package com.module.breeze
|
|
|
|
import android.content.Intent
|
|
import android.os.Bundle
|
|
import android.provider.CalendarContract
|
|
import androidx.activity.ComponentActivity
|
|
import androidx.activity.compose.setContent
|
|
import androidx.activity.enableEdgeToEdge
|
|
import androidx.compose.foundation.layout.Arrangement
|
|
import androidx.compose.foundation.layout.Column
|
|
import androidx.compose.foundation.layout.PaddingValues
|
|
import androidx.compose.foundation.layout.Row
|
|
import androidx.compose.foundation.layout.fillMaxSize
|
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
import androidx.compose.foundation.layout.padding
|
|
import androidx.compose.foundation.layout.size
|
|
import androidx.compose.foundation.layout.width
|
|
import androidx.compose.foundation.shape.CircleShape
|
|
import androidx.compose.material.icons.Icons
|
|
import androidx.compose.material.icons.outlined.AcUnit
|
|
import androidx.compose.material.icons.outlined.Air
|
|
import androidx.compose.material.icons.outlined.ArrowDownward
|
|
import androidx.compose.material.icons.outlined.ArrowUpward
|
|
import androidx.compose.material.icons.outlined.Map
|
|
import androidx.compose.material.icons.outlined.Settings
|
|
import androidx.compose.material.icons.outlined.WaterDrop
|
|
import androidx.compose.material.icons.rounded.AcUnit
|
|
import androidx.compose.material.icons.rounded.Air
|
|
import androidx.compose.material.icons.rounded.ArrowDownward
|
|
import androidx.compose.material.icons.rounded.ArrowDropDown
|
|
import androidx.compose.material.icons.rounded.ArrowUpward
|
|
import androidx.compose.material.icons.rounded.KeyboardArrowDown
|
|
import androidx.compose.material.icons.rounded.KeyboardArrowUp
|
|
import androidx.compose.material.icons.rounded.LocationOn
|
|
import androidx.compose.material.icons.rounded.Map
|
|
import androidx.compose.material.icons.rounded.Settings
|
|
import androidx.compose.material.icons.rounded.WaterDrop
|
|
import androidx.compose.material.icons.sharp.KeyboardArrowDown
|
|
import androidx.compose.material.icons.twotone.AccountCircle
|
|
import androidx.compose.material3.Button
|
|
import androidx.compose.material3.ButtonColors
|
|
import androidx.compose.material3.ButtonDefaults
|
|
import androidx.compose.material3.Icon
|
|
import androidx.compose.material3.Scaffold
|
|
import androidx.compose.material3.Text
|
|
import androidx.compose.runtime.Composable
|
|
import androidx.compose.ui.Alignment
|
|
import androidx.compose.ui.Modifier
|
|
import androidx.compose.ui.draw.alpha
|
|
import androidx.compose.ui.graphics.Color
|
|
import androidx.compose.ui.graphics.RectangleShape
|
|
import androidx.compose.ui.graphics.vector.ImageVector
|
|
import androidx.compose.ui.platform.LocalContext
|
|
import androidx.compose.ui.text.font.FontWeight
|
|
import androidx.compose.ui.tooling.preview.Preview
|
|
import androidx.compose.ui.unit.dp
|
|
import androidx.compose.ui.unit.sp
|
|
import com.module.breeze.ui.theme.BreezeTheme
|
|
|
|
|
|
val fontSizeCurrentTemp = 48.sp
|
|
val fontSizeUpper = 16.sp
|
|
val fontSizeTitle = 24.sp
|
|
val breezeFontWeight = FontWeight.Bold
|
|
val iconStyle = Icons.Outlined;
|
|
val textColor = Color(0, 0, 0)
|
|
|
|
class MainActivity : ComponentActivity() {
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
enableEdgeToEdge()
|
|
setContent {
|
|
BreezeTheme {
|
|
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
|
|
WeatherInfo(
|
|
modifier = Modifier.padding(innerPadding)
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@Composable
|
|
fun WeatherInfo(modifier: Modifier = Modifier) {
|
|
val ctx = LocalContext.current
|
|
|
|
|
|
var displayRain = false;
|
|
var displaySnow = false;
|
|
var displayWind = false;
|
|
|
|
Navigation(iconStyle.Settings, "Settings Icon", onClick = {
|
|
var intent = Intent(ctx, SettingsActivity::class.java)
|
|
ctx.startActivity(intent)
|
|
})
|
|
|
|
Column(
|
|
modifier = Modifier.fillMaxSize(),
|
|
verticalArrangement = Arrangement.Center,
|
|
horizontalAlignment = Alignment.CenterHorizontally,
|
|
) {
|
|
Row(verticalAlignment = Alignment.Bottom)
|
|
{
|
|
Icon(
|
|
imageVector = iconStyle.Map,
|
|
contentDescription = "Location Icon",
|
|
modifier = Modifier
|
|
.padding(end = 16.dp)
|
|
.size(32.dp)
|
|
)
|
|
Icon(
|
|
imageVector = iconStyle.WaterDrop,
|
|
contentDescription = "Rain Icon",
|
|
modifier = Modifier.alpha(if (displayRain) 1F else 0.2F)
|
|
)
|
|
Icon(
|
|
imageVector = iconStyle.AcUnit,
|
|
contentDescription = "Snow Icon",
|
|
modifier = Modifier.alpha(if (displaySnow) 1F else 0.2F)
|
|
)
|
|
|
|
Icon(
|
|
imageVector = iconStyle.Air,
|
|
contentDescription = "Wind Icon",
|
|
modifier = Modifier.alpha(if (displayWind) 1F else 0.2F)
|
|
)
|
|
}
|
|
Row {
|
|
Icon(
|
|
imageVector = iconStyle.ArrowDownward,
|
|
contentDescription = "Arrow down Icon"
|
|
)
|
|
Text(
|
|
text = "18°",
|
|
fontSize = fontSizeUpper,
|
|
fontWeight = breezeFontWeight
|
|
)
|
|
Icon(
|
|
imageVector = iconStyle.ArrowUpward,
|
|
contentDescription = "Arrow up Icon"
|
|
)
|
|
Text(
|
|
text = "23°",
|
|
fontSize = fontSizeUpper,
|
|
fontWeight = breezeFontWeight
|
|
)
|
|
}
|
|
Text(
|
|
text = "15°",
|
|
fontSize = fontSizeCurrentTemp,
|
|
fontWeight = breezeFontWeight,
|
|
)
|
|
}
|
|
}
|
|
|
|
@Preview(showBackground = true)
|
|
@Composable
|
|
fun GreetingPreview() {
|
|
BreezeTheme {
|
|
WeatherInfo()
|
|
}
|
|
}
|
|
|
|
@Composable
|
|
public fun Navigation(icon: ImageVector, iconDescription: String, onClick: () -> Unit = {}) {
|
|
Row(
|
|
horizontalArrangement = Arrangement.End,
|
|
modifier = Modifier.fillMaxWidth()
|
|
)
|
|
{
|
|
Button(
|
|
onClick = onClick,
|
|
colors = ButtonDefaults.buttonColors(
|
|
containerColor = Color(255, 0, 0, 0),
|
|
contentColor = textColor
|
|
),
|
|
shape = CircleShape,
|
|
contentPadding = PaddingValues(0.dp),
|
|
modifier = Modifier
|
|
.padding(0.dp, 40.dp, 28.dp, 0.dp)
|
|
) {
|
|
Icon(
|
|
imageVector = icon,
|
|
contentDescription = iconDescription,
|
|
modifier = Modifier
|
|
.size(40.dp)
|
|
)
|
|
}
|
|
}
|
|
}
|