@@ -10,9 +10,11 @@ import androidx.compose.animation.core.tween
1010import androidx.compose.foundation.background
1111import androidx.compose.foundation.layout.*
1212import androidx.compose.runtime.*
13+ import androidx.compose.ui.Alignment
1314import androidx.compose.ui.Modifier
1415import androidx.compose.ui.graphics.Brush
1516import androidx.compose.ui.graphics.Color
17+ import androidx.compose.ui.unit.dp
1618import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
1719import com.hackeros.app.data.model.AppScreen
1820import com.hackeros.app.ui.components.HackerOSNavBar
@@ -24,107 +26,104 @@ class MainActivity : ComponentActivity() {
2426
2527 private val viewModel: MainViewModel by viewModels()
2628
27- override fun onCreate (savedInstanceState : Bundle ? ) {
28- installSplashScreen()
29- super .onCreate(savedInstanceState)
30- enableEdgeToEdge()
29+ override fun onCreate (savedInstanceState : Bundle ? ) {
30+ installSplashScreen()
31+ super .onCreate(savedInstanceState)
32+ enableEdgeToEdge()
3133
32- setContent {
33- val currentThemeId by viewModel.currentTheme.collectAsState()
34- val currentLanguage by viewModel.currentLanguage.collectAsState()
35- val currentScreen by viewModel.currentScreen.collectAsState()
36- val releases by viewModel.releases.collectAsState()
37- val releasesLoading by viewModel.releasesLoading.collectAsState()
38- val releasesError by viewModel.releasesError.collectAsState()
39- val gallery by viewModel.gallery.collectAsState()
40- val galleryLoading by viewModel.galleryLoading.collectAsState()
41- val galleryError by viewModel.galleryError.collectAsState()
42- val notificationsEnabled by viewModel.notificationsEnabled.collectAsState()
43- val updateStatus by viewModel.updateStatus.collectAsState()
44- val remoteVersion by viewModel.remoteVersion.collectAsState()
34+ setContent {
35+ val currentThemeId by viewModel.currentTheme.collectAsState()
36+ val currentLanguage by viewModel.currentLanguage.collectAsState()
37+ val currentScreen by viewModel.currentScreen.collectAsState()
38+ val releases by viewModel.releases.collectAsState()
39+ val releasesLoading by viewModel.releasesLoading.collectAsState()
40+ val releasesError by viewModel.releasesError.collectAsState()
41+ val gallery by viewModel.gallery.collectAsState()
42+ val galleryLoading by viewModel.galleryLoading.collectAsState()
43+ val galleryError by viewModel.galleryError.collectAsState()
44+ val notificationsEnabled by viewModel.notificationsEnabled.collectAsState()
45+ val updateStatus by viewModel.updateStatus.collectAsState()
46+ val remoteVersion by viewModel.remoteVersion.collectAsState()
4547
46- val appTheme = THEMES [currentThemeId] ? : THEMES [com.hackeros.app.data.model.ThemeId .HACKER ]!!
47- val translations = getTranslations(currentLanguage)
48+ val appTheme = THEMES [currentThemeId] ? : THEMES [com.hackeros.app.data.model.ThemeId .HACKER ]!!
49+ val translations = getTranslations(currentLanguage)
4850
49- HackerOSTheme (appTheme = appTheme) {
50- Box (
51- modifier = Modifier
52- .fillMaxSize()
53- .background(appTheme.backgroundColor())
54- .windowInsetsPadding(WindowInsets .statusBars)
55- ) {
56- // Ambient background glow
51+ HackerOSTheme (appTheme = appTheme) {
5752 Box (
5853 modifier = Modifier
54+ .fillMaxSize()
55+ .background(Color (appTheme.background))
56+ .windowInsetsPadding(WindowInsets .statusBars)
57+ ) {
58+ Box (
59+ modifier = Modifier
5960 .fillMaxWidth()
6061 .height(300 .dp)
6162 .background(
6263 Brush .verticalGradient(
6364 colors = listOf (
64- appTheme.primaryColor( ).copy(alpha = 0.04f ),
65- Color .Transparent
65+ Color ( appTheme.primary ).copy(alpha = 0.04f ),
66+ Color .Transparent
6667 )
6768 )
6869 )
69- )
70+ )
7071
71- // Main content with cross-fade animation
72- AnimatedContent (
73- targetState = currentScreen,
74- transitionSpec = {
75- (fadeIn(tween(220 )) + slideInHorizontally(tween(220 )) { it / 12 })
72+ AnimatedContent (
73+ targetState = currentScreen,
74+ transitionSpec = {
75+ (fadeIn(tween(220 )) + slideInHorizontally(tween(220 )) { it / 12 })
7676 .togetherWith(fadeOut(tween(180 )) + slideOutHorizontally(tween(180 )) { - it / 12 })
77- },
78- modifier = Modifier .fillMaxSize(),
79- label = " screenTransition"
80- ) { screen ->
81- Box (modifier = Modifier .fillMaxSize()) {
82- when (screen) {
83- AppScreen .RELEASES -> ReleasesScreen (
84- releases = releases,
85- loading = releasesLoading,
86- error = releasesError,
87- translations = translations,
88- onRetry = { viewModel.fetchReleases() }
89- )
90- AppScreen .WALLPAPERS -> WallpapersScreen (
91- wallpapers = Constants .WALLPAPERS ,
92- translations = translations
93- )
94- AppScreen .GALLERY -> GalleryScreen (
95- images = gallery,
96- loading = galleryLoading,
97- error = galleryError,
98- translations = translations,
99- onRetry = { viewModel.fetchGallery() }
100- )
101- AppScreen .TEAM -> TeamScreen (translations = translations)
102- AppScreen .SETTINGS -> SettingsScreen (
103- currentTheme = currentThemeId,
104- onThemeChange = { viewModel.setTheme(it) },
105- currentLanguage = currentLanguage,
106- onLanguageChange = { viewModel.setLanguage(it) },
107- notificationsEnabled = notificationsEnabled,
108- onToggleNotifications = { viewModel.toggleNotifications() },
109- updateStatus = updateStatus,
110- remoteVersion = remoteVersion,
111- onCheckUpdate = { viewModel.checkForUpdates() },
112- translations = translations
113- )
77+ },
78+ modifier = Modifier .fillMaxSize(),
79+ label = " screenTransition"
80+ ) { screen ->
81+ Box (modifier = Modifier .fillMaxSize()) {
82+ when (screen) {
83+ AppScreen .RELEASES -> ReleasesScreen (
84+ releases = releases,
85+ loading = releasesLoading,
86+ error = releasesError,
87+ translations = translations,
88+ onRetry = { viewModel.fetchReleases() }
89+ )
90+ AppScreen .WALLPAPERS -> WallpapersScreen (
91+ wallpapers = Constants .WALLPAPERS ,
92+ translations = translations
93+ )
94+ AppScreen .GALLERY -> GalleryScreen (
95+ images = gallery,
96+ loading = galleryLoading,
97+ error = galleryError,
98+ translations = translations,
99+ onRetry = { viewModel.fetchGallery() }
100+ )
101+ AppScreen .TEAM -> TeamScreen (translations = translations)
102+ AppScreen .SETTINGS -> SettingsScreen (
103+ currentTheme = currentThemeId,
104+ onThemeChange = { viewModel.setTheme(it) },
105+ currentLanguage = currentLanguage,
106+ onLanguageChange = { viewModel.setLanguage(it) },
107+ notificationsEnabled = notificationsEnabled,
108+ onToggleNotifications = { viewModel.toggleNotifications() },
109+ updateStatus = updateStatus,
110+ remoteVersion = remoteVersion,
111+ onCheckUpdate = { viewModel.checkForUpdates() },
112+ translations = translations
113+ )
114+ }
114115 }
115116 }
116- }
117117
118- // Bottom navigation bar
119- Box (modifier = Modifier .align(androidx.compose.ui. Alignment . BottomCenter )) {
120- HackerOSNavBar (
121- currentScreen = currentScreen ,
122- onScreenChange = { viewModel.setScreen(it) },
123- translations = translations
124- )
118+ Box (modifier = Modifier .align( Alignment . BottomCenter )) {
119+ HackerOSNavBar (
120+ currentScreen = currentScreen,
121+ onScreenChange = { viewModel.setScreen(it) } ,
122+ translations = translations
123+ )
124+ }
125125 }
126126 }
127127 }
128128 }
129- }
130129}
0 commit comments