mirror of
https://github.com/atsunatsu/Look4Sat.git
synced 2026-10-04 03:37:21 +00:00
Added Compose dependencies and basic classes
This commit is contained in:
1 parent
0303c53a72
commit
8f411d4c5e
16 files changed
+472
-27
No files matched your search
@@ -24,6 +24,7 @@ import android.content.res.Configuration
|
||||
import android.os.Bundle
|
||||
import android.os.SystemClock
|
||||
import android.view.View
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.annotation.IdRes
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||
@@ -36,6 +37,8 @@ import androidx.navigation.ui.NavigationUI
|
||||
import androidx.navigation.ui.NavigationUiSaveStateControl
|
||||
import com.rtbishop.look4sat.R
|
||||
import com.rtbishop.look4sat.databinding.ActivityMainBinding
|
||||
import com.rtbishop.look4sat.presentation.bottomNav.MainScreenView
|
||||
import com.rtbishop.look4sat.presentation.theme.Look4SatTheme
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
||||
@AndroidEntryPoint
|
||||
@@ -51,6 +54,7 @@ class MainActivity : AppCompatActivity() {
|
||||
val host = supportFragmentManager.findFragmentById(R.id.nav_host) as NavHostFragment
|
||||
NavigationUI.setupWithNavController(binding.navBar, host.navController, false)
|
||||
setContentView(binding.root)
|
||||
// setContent { Look4SatTheme { MainScreenView() } }
|
||||
}
|
||||
|
||||
override fun attachBaseContext(newBase: Context?) {
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.rtbishop.look4sat.presentation.aboutScreen
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.material.Card
|
||||
import androidx.compose.material.Icon
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.ComposeView
|
||||
import androidx.compose.ui.platform.ViewCompositionStrategy
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.rtbishop.look4sat.R
|
||||
import com.rtbishop.look4sat.presentation.theme.Look4SatTheme
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
||||
@AndroidEntryPoint
|
||||
class AboutFragment : Fragment() {
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||
): View {
|
||||
return ComposeView(requireContext()).apply {
|
||||
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
|
||||
setContent { AboutScreen() }
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(showBackground = true, widthDp = 400, heightDp = 720, showSystemUi = true)
|
||||
@Composable
|
||||
private fun AboutScreen() {
|
||||
Look4SatTheme {
|
||||
LazyColumn(
|
||||
contentPadding = PaddingValues(8.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||
modifier = Modifier.fillMaxSize()
|
||||
) {
|
||||
item { CardAbout() }
|
||||
item { CardOutro() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun CardAbout(modifier: Modifier = Modifier, version: String = "3.2.0") {
|
||||
Card(modifier = modifier.fillMaxWidth()) {
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
Row(horizontalArrangement = Arrangement.Center) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.ic_satellite),
|
||||
tint = MaterialTheme.colors.secondary,
|
||||
contentDescription = null,
|
||||
modifier = Modifier
|
||||
.size(96.dp)
|
||||
.padding(top = 8.dp, end = 8.dp)
|
||||
)
|
||||
Column {
|
||||
Text(
|
||||
text = stringResource(id = R.string.app_name),
|
||||
fontSize = 48.sp,
|
||||
color = MaterialTheme.colors.secondary
|
||||
)
|
||||
Text(
|
||||
text = stringResource(id = R.string.app_version, version),
|
||||
fontSize = 21.sp
|
||||
)
|
||||
}
|
||||
}
|
||||
Text(
|
||||
text = stringResource(id = R.string.app_subtitle),
|
||||
fontSize = 21.sp,
|
||||
modifier = modifier.padding(top = 4.dp, bottom = 8.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun CardOutro(modifier: Modifier = Modifier) {
|
||||
Card(modifier = modifier.fillMaxWidth()) {
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
Text(
|
||||
text = stringResource(id = R.string.outro_title),
|
||||
fontSize = 19.sp,
|
||||
color = MaterialTheme.colors.secondary,
|
||||
modifier = modifier.padding(8.dp)
|
||||
)
|
||||
Text(
|
||||
text = stringResource(id = R.string.outro_thanks),
|
||||
fontSize = 17.sp,
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = modifier.padding(start = 8.dp, end = 8.dp)
|
||||
)
|
||||
Text(
|
||||
text = stringResource(id = R.string.outro_license),
|
||||
fontSize = 17.sp,
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = modifier.padding(8.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.rtbishop.look4sat.presentation.bottomNav
|
||||
|
||||
import com.rtbishop.look4sat.R
|
||||
|
||||
sealed class BottomNavItem(var title: String, var icon: Int, var screen_route: String) {
|
||||
object Satellites : BottomNavItem("Satellites", R.drawable.ic_satellite, "satellites")
|
||||
object Passes : BottomNavItem("Passes", R.drawable.ic_list, "passes")
|
||||
object WorldMap : BottomNavItem("World Map", R.drawable.ic_map, "world_map")
|
||||
object Settings : BottomNavItem("Settings", R.drawable.ic_settings, "settings")
|
||||
object About : BottomNavItem("About", R.drawable.ic_about, "about")
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.rtbishop.look4sat.presentation.bottomNav
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.wrapContentSize
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.rtbishop.look4sat.R
|
||||
|
||||
@Composable
|
||||
fun SatellitesScreen() {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.background(colorResource(id = R.color.background))
|
||||
.wrapContentSize(Alignment.Center)
|
||||
) {
|
||||
Text(
|
||||
text = "Satellites",
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = Color.White,
|
||||
modifier = Modifier.align(Alignment.CenterHorizontally),
|
||||
textAlign = TextAlign.Center,
|
||||
fontSize = 20.sp
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun PassesScreen() {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.background(colorResource(id = R.color.background))
|
||||
.wrapContentSize(Alignment.Center)
|
||||
) {
|
||||
Text(
|
||||
text = "Passes",
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = Color.White,
|
||||
modifier = Modifier.align(Alignment.CenterHorizontally),
|
||||
textAlign = TextAlign.Center,
|
||||
fontSize = 20.sp
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun WorldMapScreen() {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.background(colorResource(id = R.color.background))
|
||||
.wrapContentSize(Alignment.Center)
|
||||
) {
|
||||
Text(
|
||||
text = "World Map",
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = Color.White,
|
||||
modifier = Modifier.align(Alignment.CenterHorizontally),
|
||||
textAlign = TextAlign.Center,
|
||||
fontSize = 20.sp
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SettingsScreen() {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.background(colorResource(id = R.color.background))
|
||||
.wrapContentSize(Alignment.Center)
|
||||
) {
|
||||
Text(
|
||||
text = "Settings",
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = Color.White,
|
||||
modifier = Modifier.align(Alignment.CenterHorizontally),
|
||||
textAlign = TextAlign.Center,
|
||||
fontSize = 20.sp
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun AboutScreen() {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.background(colorResource(id = R.color.background))
|
||||
.wrapContentSize(Alignment.Center)
|
||||
) {
|
||||
Text(
|
||||
text = "About",
|
||||
fontWeight = FontWeight.Bold,
|
||||
color = Color.White,
|
||||
modifier = Modifier.align(Alignment.CenterHorizontally),
|
||||
textAlign = TextAlign.Center,
|
||||
fontSize = 20.sp
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.rtbishop.look4sat.presentation.bottomNav
|
||||
|
||||
import androidx.compose.material.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.NavHostController
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import com.rtbishop.look4sat.R
|
||||
import com.rtbishop.look4sat.presentation.theme.Yellow
|
||||
import com.rtbishop.look4sat.presentation.theme.Look4SatTheme
|
||||
import com.rtbishop.look4sat.presentation.theme.TextWhite
|
||||
|
||||
@Composable
|
||||
fun BottomNavView(navController: NavController) {
|
||||
val items = listOf(
|
||||
BottomNavItem.Satellites,
|
||||
BottomNavItem.Passes,
|
||||
BottomNavItem.WorldMap,
|
||||
BottomNavItem.Settings,
|
||||
BottomNavItem.About
|
||||
)
|
||||
BottomNavigation(backgroundColor = colorResource(id = R.color.bottomBar)) {
|
||||
val navBackStackEntry by navController.currentBackStackEntryAsState()
|
||||
val currentRoute = navBackStackEntry?.destination?.route
|
||||
items.forEach { item ->
|
||||
BottomNavigationItem(icon = {
|
||||
Icon(painterResource(id = item.icon), contentDescription = item.title)
|
||||
},
|
||||
label = { Text(text = item.title, fontSize = 9.sp) },
|
||||
selectedContentColor = Yellow,
|
||||
unselectedContentColor = TextWhite.copy(0.4f),
|
||||
alwaysShowLabel = true,
|
||||
selected = currentRoute == item.screen_route,
|
||||
onClick = {
|
||||
navController.navigate(item.screen_route) {
|
||||
navController.graph.startDestinationRoute?.let { screen_route ->
|
||||
popUpTo(screen_route) { saveState = true }
|
||||
}
|
||||
launchSingleTop = true
|
||||
restoreState = true
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun NavigationGraph(navController: NavHostController) {
|
||||
NavHost(navController, startDestination = BottomNavItem.Satellites.screen_route) {
|
||||
composable(BottomNavItem.Satellites.screen_route) { SatellitesScreen() }
|
||||
composable(BottomNavItem.Passes.screen_route) { PassesScreen() }
|
||||
composable(BottomNavItem.WorldMap.screen_route) { WorldMapScreen() }
|
||||
composable(BottomNavItem.Settings.screen_route) { SettingsScreen() }
|
||||
composable(BottomNavItem.About.screen_route) { AboutScreen() }
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun MainScreenView() {
|
||||
val navController = rememberNavController()
|
||||
Scaffold(bottomBar = { BottomNavView(navController = navController) }) {
|
||||
NavigationGraph(navController = navController)
|
||||
it.calculateBottomPadding()
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(showBackground = true)
|
||||
@Composable
|
||||
fun DefaultPreview() {
|
||||
Look4SatTheme { MainScreenView() }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.rtbishop.look4sat.presentation.theme
|
||||
|
||||
import androidx.compose.ui.graphics.Color
|
||||
|
||||
val Yellow = Color(0xFFFFE082)
|
||||
val TextWhite = Color(0xCCFFFFFF)
|
||||
val TextGrey = Color(0x66FFFFFF)
|
||||
val TextBlack = Color(0xFF000000)
|
||||
val ButtonGrey = Color(0xFF2A2A2A)
|
||||
val SurfaceGrey = Color(0xFF1C1C1C)
|
||||
val Background = Color(0xFF121212)
|
||||
val Transparent = Color(0x00000000)
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.rtbishop.look4sat.presentation.theme
|
||||
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.Shapes
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
val Shapes = Shapes(
|
||||
small = RoundedCornerShape(8.dp),
|
||||
medium = RoundedCornerShape(8.dp),
|
||||
large = RoundedCornerShape(8.dp)
|
||||
)
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.rtbishop.look4sat.presentation.theme
|
||||
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.darkColors
|
||||
import androidx.compose.material.lightColors
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
@Composable
|
||||
fun Look4SatTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
|
||||
val colors = if (darkTheme) DarkColors else LightColors
|
||||
MaterialTheme(colors = colors, typography = Typography, shapes = Shapes, content = content)
|
||||
}
|
||||
|
||||
private val LightColors = lightColors(
|
||||
primary = SurfaceGrey,
|
||||
primaryVariant = Background,
|
||||
secondary = Yellow,
|
||||
background = Background,
|
||||
surface = SurfaceGrey,
|
||||
onPrimary = TextWhite,
|
||||
onSecondary = TextBlack,
|
||||
onBackground = TextWhite,
|
||||
onSurface = TextWhite
|
||||
)
|
||||
|
||||
private val DarkColors = darkColors(
|
||||
primary = SurfaceGrey,
|
||||
primaryVariant = Background,
|
||||
secondary = Yellow,
|
||||
background = Background,
|
||||
surface = SurfaceGrey,
|
||||
onPrimary = TextWhite,
|
||||
onSecondary = TextBlack,
|
||||
onBackground = TextWhite,
|
||||
onSurface = TextWhite
|
||||
)
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.rtbishop.look4sat.presentation.theme
|
||||
|
||||
import androidx.compose.material.Typography
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.sp
|
||||
|
||||
val Typography = Typography(
|
||||
body1 = TextStyle(
|
||||
fontFamily = FontFamily.Default, fontWeight = FontWeight.Normal, fontSize = 16.sp
|
||||
)
|
||||
// button = TextStyle(
|
||||
// fontFamily = FontFamily.Default,
|
||||
// fontWeight = FontWeight.W500,
|
||||
// fontSize = 14.sp
|
||||
// ),
|
||||
// caption = TextStyle(
|
||||
// fontFamily = FontFamily.Default,
|
||||
// fontWeight = FontWeight.Normal,
|
||||
// fontSize = 12.sp
|
||||
// )
|
||||
)
|
||||
Reference in new issue
Block a user