generated from me/template-mit
qwen3.6:35b's first attempt, does not compile (yet).
This commit is contained in:
1 parent
eeda4a18c5
commit
337403721b
17 files changed
+1486
-40
No files matched your search
+47
-37
@@ -1,51 +1,61 @@
|
||||
package com.hyperling.weather
|
||||
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.safeContentPadding
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import org.jetbrains.compose.reload.DevelopmentEntryPoint
|
||||
import org.jetbrains.compose.resources.painterResource
|
||||
|
||||
import com.hyperling.weather.resources.Res
|
||||
import com.hyperling.weather.resources.compose_multiplatform
|
||||
|
||||
@Composable
|
||||
@Preview
|
||||
@DevelopmentEntryPoint
|
||||
fun App() {
|
||||
// Initialize platform-specific storage and environment (JVM/Desktop vs Android)
|
||||
val platformInit = remember { getPlatformInit() }
|
||||
LaunchedEffect(platformInit) {
|
||||
platformInit.initialize()
|
||||
}
|
||||
|
||||
MaterialTheme {
|
||||
var showContent by remember { mutableStateOf(false) }
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.background(MaterialTheme.colorScheme.primaryContainer)
|
||||
.safeContentPadding()
|
||||
.fillMaxSize(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
Button(onClick = { showContent = !showContent }) {
|
||||
Text("Click me!")
|
||||
}
|
||||
AnimatedVisibility(showContent) {
|
||||
val greeting = remember { Greeting().greet() }
|
||||
Column(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
Image(painterResource(Res.drawable.compose_multiplatform), null)
|
||||
Text("Compose: $greeting")
|
||||
MainScreen(modifier = Modifier.fillMaxSize())
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun MainScreen(modifier: Modifier = Modifier) {
|
||||
val viewModel = remember { MainViewModel() }
|
||||
|
||||
// Initialize ViewModel by loading existing locations
|
||||
LaunchedEffect(Unit) {
|
||||
viewModel.init()
|
||||
}
|
||||
|
||||
Box(modifier = modifier) {
|
||||
CelticWheel(
|
||||
viewModel = viewModel,
|
||||
onLocationClick = { loc ->
|
||||
viewModel.startEditing(loc)
|
||||
},
|
||||
sizeInDp = 360
|
||||
)
|
||||
|
||||
// If editing a location, show the Editor overlay
|
||||
if (viewModel.editingLocation != null) {
|
||||
LocationEditor(
|
||||
entry = viewModel.editingLocation,
|
||||
onDismiss = { viewModel.cancelEditing() },
|
||||
onSave = { loc ->
|
||||
viewModel.saveLocation(loc)
|
||||
viewModel.cancelEditing()
|
||||
viewModel.fetchAllWeather() // Refresh data after saving
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// Loading indicator (optional visual cue)
|
||||
if (viewModel.loading) {
|
||||
androidx.compose.material3.CircularProgressIndicator(
|
||||
modifier = Modifier.align(androidx.compose.ui.Alignment.Center),
|
||||
color = SeasonColors.Accent
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user