Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![CI-MASTER](https://github.com/jarroyoesp/ComposeMultiplatformApp/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/jarroyoesp/ComposeMultiplatformApp/actions/workflows/ci.yml)
[![Latest release](https://img.shields.io/github/v/release/JetBrains/compose-multiplatform?color=blue&label=Compose%20multiplatform)](https://github.com/JetBrains/compose-multiplatform/releases/tag/v1.7.3)
[![Latest release](https://img.shields.io/github/v/release/JetBrains/compose-multiplatform?color=blue&label=Compose%20multiplatform)](https://github.com/JetBrains/compose-multiplatform/releases/tag/v1.8.2)
![Kotlin Version](https://img.shields.io/badge/Kotlin-2.1.20-blue?logo=kotlin&logoColor=white)
<div align="center">
<img alt="Compose multiplatform charts" src="./screenshots/compose_multiplatform_logo.png"/>
Expand Down

Large diffs are not rendered by default.

1,505 changes: 753 additions & 752 deletions app/versions/dependencies/debugRuntimeClasspathDependencies.txt

Large diffs are not rendered by default.

1,509 changes: 755 additions & 754 deletions app/versions/dependencies/debugUnitTestRuntimeClasspathDependencies.txt

Large diffs are not rendered by default.

1,467 changes: 734 additions & 733 deletions app/versions/dependencies/releaseRuntimeClasspathDependencies.txt

Large diffs are not rendered by default.

1,471 changes: 736 additions & 735 deletions app/versions/dependencies/releaseUnitTestRuntimeClasspathDependencies.txt

Large diffs are not rendered by default.

Binary file modified build-conventions/build/libs/build-conventions.jar
Binary file not shown.
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
aboutlibraries = "11.4.0"
agp = "8.1.4"
androidCompileSdk = "34"
androidx-compose = "1.8.2"
androidx-compose = "1.8.3"
apollo = "4.3.0"
coil3 = "3.0.4"
coroutines = "1.10.1"
detekt = "1.23.7"
diktat = "1.2.5"
gitlive = "2.1.0"
gradle = "8.1.1"
jetbrains-lifecycle = "2.9.0-beta01"
jetbrains-navigation = "2.9.0-beta01"
jetbrains-lifecycle = "2.9.1"
jetbrains-navigation = "2.9.0-beta03"
koin = "4.0.0"
koin-ksp = "1.4.0"
kotlin = "2.1.21"
kotlinpoet = "2.0.0"
kotlin-multiplatform = "1.8.0"
kotlin-multiplatform = "1.8.2"
kotlin-result = "2.0.1"
kotlinx-datetime="0.6.0"
ksp = "2.1.21-2.0.1"
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ import com.jarroyo.library.network.di.ElectricityData
import com.jarroyo.library.ui.shared.ViewEffect
import com.jarroyo.library.ui.shared.ViewEvent
import com.jarroyo.library.ui.shared.ViewState
import com.kizitonwose.calendar.core.now
import kotlinx.datetime.LocalDate

object ElectricityContract {
data class State(
val dateSelected: LocalDate = LocalDate.now(),
val electricityData: ElectricityData? = null,
val loading: Boolean = false,
) : ViewState

sealed class Event : ViewEvent {
data class OnDateInputChipSelected(val localDate: LocalDate): Event()
data object OnUpButtonClicked: Event()
data object OnSwipeToRefresh: Event()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package com.jarroyo.feature.electricity.ui

import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
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.rememberScrollState
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
Expand All @@ -22,6 +25,7 @@ import androidx.compose.material.pullrefresh.PullRefreshIndicator
import androidx.compose.material.pullrefresh.pullRefresh
import androidx.compose.material.pullrefresh.rememberPullRefreshState
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.InputChip
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
Expand All @@ -30,13 +34,17 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.PathEffect
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import co.touchlab.kermit.Logger
import com.jarroyo.feature.electricity.ui.ElectricityContract.Effect
import com.jarroyo.feature.electricity.ui.ElectricityContract.Event
import com.jarroyo.feature.electricity.ui.ElectricityContract.State
import com.jarroyo.library.ui.shared.component.EmptyStateWithImage
import com.jarroyo.library.ui.shared.component.LocalMainScaffoldPadding
import com.jarroyo.library.ui.shared.component.placeholder
import com.jarroyo.library.ui.shared.theme.Spacing
import com.kizitonwose.calendar.core.minusDays
import com.kizitonwose.calendar.core.now
import io.github.koalaplot.core.ChartLayout
import io.github.koalaplot.core.line.LinePlot
Expand Down Expand Up @@ -108,8 +116,13 @@ private fun ElectricityScreen(
modifier = Modifier.padding(Spacing.x02),
verticalArrangement = Arrangement.spacedBy(Spacing.x02),
) {
Text(LocalDate.now().toString())
XYSamplePlot(state)
if (state.loading || state.electricityData != null) {
SelectorDateRow(sendEvent, state)
Text(state.dateSelected.toString())
XYSamplePlot(state)
} else {
EmptyStateWithImage("Something was wrong getting Electricity data.")
}
}
}
}
Expand Down Expand Up @@ -197,3 +210,34 @@ private fun TopAppBar(
},
)
}

@Composable
private fun SelectorDateRow(
sendEvent: (event: Event) -> Unit,
state: State,
placeholder: Boolean = false,
) {
val scrollState = rememberScrollState()
Row(
modifier = Modifier
.horizontalScroll(scrollState)
.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(Spacing.x01),
) {
for (dayPos in 0..5) {
val localDate = LocalDate.now().minusDays(dayPos)
InputChip(
selected = state.dateSelected == localDate,
onClick = { sendEvent(Event.OnDateInputChipSelected(localDate = localDate)) },
label = {
Text(
text = localDate.toString(),
overflow = TextOverflow.Ellipsis,
maxLines = 1,
)
},
modifier = Modifier.placeholder(placeholder),
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.jarroyo.feature.electricity.ui.ElectricityContract.Event
import com.jarroyo.feature.electricity.ui.ElectricityContract.State
import com.jarroyo.library.navigation.api.navigator.AppNavigator
import com.jarroyo.library.ui.shared.BaseViewModel
import com.kizitonwose.calendar.core.now
import kotlinx.coroutines.launch
import kotlinx.datetime.LocalDate

Expand All @@ -16,21 +15,27 @@ class ElectricityViewModel(
private val getElectricityDataInteractor: GetElectricityDataInteractor,
) : BaseViewModel<Event, State, Effect>() {
init {
refreshData()
refreshData(viewState.value.dateSelected)
}
override fun provideInitialState() = State()

override fun handleEvent(event: Event) {
when(event) {
is Event.OnSwipeToRefresh -> refreshData()
is Event.OnDateInputChipSelected -> handleOnDateInputChipSelected(event.localDate)
is Event.OnSwipeToRefresh -> refreshData(viewState.value.dateSelected)
is Event.OnUpButtonClicked -> appNavigator.navigateUp()
}
}

private fun refreshData() {
private fun handleOnDateInputChipSelected(localDate: LocalDate) {
updateState { copy(dateSelected = localDate) }
refreshData(localDate)
}

private fun refreshData(localDate: LocalDate) {
viewModelScope.launch {
updateState { copy(loading = true) }
val result = getElectricityDataInteractor(startDate = LocalDate.now(), endDate = LocalDate.now())
val result = getElectricityDataInteractor(startDate = localDate, endDate = localDate)
if (result.isOk) {
updateState { copy(electricityData = result.value) }
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import coil3.compose.AsyncImage
import com.jarroyo.composeapp.library.network.api.graphql.fragment.LaunchFragment
import com.jarroyo.composeapp.library.network.api.graphql.fragment.RocketFragment
import com.jarroyo.feature.launches.api.destination.LaunchDestination
import com.jarroyo.feature.launches.ui.launchdetail.LaunchDetailContract.Effect
import com.jarroyo.feature.launches.ui.launchdetail.LaunchDetailContract.Event
import com.jarroyo.feature.launches.ui.launchdetail.LaunchDetailContract.State
import com.jarroyo.library.ui.shared.component.EmptyStateWithImage
import com.jarroyo.library.ui.shared.component.LocalNavHostController
import com.jarroyo.library.ui.shared.component.placeholder
import com.jarroyo.library.ui.shared.component.setResult
Expand Down Expand Up @@ -96,11 +96,7 @@ private fun LaunchDetailScreen(
if (state.launch != null) {
DetailItem(state.launch, sendEvent)
} else {
Text(
text = "NO data available",
modifier = Modifier.fillMaxWidth(),
textAlign = TextAlign.Center,
)
EmptyStateWithImage("NO data available")
}
}
}
Expand Down Expand Up @@ -186,7 +182,7 @@ private fun BottomBar(
onClick = { sendEvent(Event.OnAddFavoritesButtonClicked) },
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = Spacing.x01)
.padding(Spacing.x02)
.navigationBarsPadding(),
enabled = !state.loading,
) {
Expand Down
1 change: 1 addition & 0 deletions modules/feature-schedules/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ kotlin {
androidMain.dependencies {
}
commonMain.dependencies {
implementation(compose.components.resources)
implementation(compose.ui)
implementation(compose.foundation)
implementation(compose.material)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
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.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.rememberLazyListState
Expand All @@ -32,12 +32,12 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.text.style.TextAlign
import com.jarroyo.feature.schedules.api.destination.ScheduleDetailDestination
import com.jarroyo.feature.schedules.api.model.Schedule
import com.jarroyo.feature.schedules.ui.list.ScheduleListContract.Effect
import com.jarroyo.feature.schedules.ui.list.ScheduleListContract.Event
import com.jarroyo.feature.schedules.ui.list.ScheduleListContract.State
import com.jarroyo.library.ui.shared.component.EmptyStateWithImage
import com.jarroyo.library.ui.shared.component.LocalMainScaffoldPadding
import com.jarroyo.library.ui.shared.component.LocalNavHostController
import com.jarroyo.library.ui.shared.component.observeResult
Expand Down Expand Up @@ -119,20 +119,16 @@ private fun ScheduleListScreen(
verticalArrangement = Arrangement.spacedBy(Spacing.x01),
) {
if (state.scheduleList.isNullOrEmpty() && state.loading) {
rocketList(getScheduleListPlaceholderData(), sendEvent, placeholder = true)
scheduleList(getScheduleListPlaceholderData(), sendEvent, placeholder = true)
} else {
if (!state.scheduleList.isNullOrEmpty()) {
rocketList(
scheduleList(
data = state.scheduleList,
sendEvent = sendEvent,
)
} else {
item {
Text(
text = "NO data available",
modifier = Modifier.fillMaxWidth(),
textAlign = TextAlign.Center,
)
EmptyStateWithImage("No data available")
}
}
}
Expand All @@ -141,7 +137,7 @@ private fun ScheduleListScreen(
}
}

private fun LazyListScope.rocketList(
private fun LazyListScope.scheduleList(
data: List<Schedule>,
sendEvent: (event: Event) -> Unit,
placeholder: Boolean = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.Delete
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.InputChip
Expand All @@ -44,11 +43,13 @@ import com.jarroyo.library.ui.shared.component.LocalNavHostController
import com.jarroyo.library.ui.shared.component.observeResult
import com.jarroyo.library.ui.shared.component.placeholder
import com.jarroyo.library.ui.shared.component.setResult
import com.jarroyo.library.ui.shared.resources.SharedResources
import com.jarroyo.library.ui.shared.theme.Spacing
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import org.jetbrains.compose.resources.painterResource
import org.koin.compose.viewmodel.koinViewModel

@Composable
Expand Down Expand Up @@ -173,7 +174,7 @@ private fun TopAppBar(
onClick = { sendEvent(Event.OnRemoveButtonClicked) },
) {
Icon(
imageVector = Icons.Filled.Delete,
painter = painterResource(SharedResources.ui_ic_delete),
contentDescription = null,
)
}
Expand All @@ -199,13 +200,13 @@ fun UserListItem(
horizontalArrangement = Arrangement.spacedBy(Spacing.quarter),
) {
for (user in userList) {
OptionPrimitiveItem(
UserInputChipItem(
text = user.getFullName(),
onclick = { sendEvent(Event.OnUserItemClicked) },
placeholder = placeholder,
)
}
OptionPrimitiveItem(
UserInputChipItem(
text = "Add more",
onclick = { sendEvent(Event.OnUserItemClicked) },
placeholder = placeholder,
Expand All @@ -215,7 +216,7 @@ fun UserListItem(
}

@Composable
fun OptionPrimitiveItem(
fun UserInputChipItem(
text: String,
onclick: () -> Unit,
modifier: Modifier = Modifier,
Expand All @@ -237,6 +238,12 @@ fun OptionPrimitiveItem(
)
},
modifier = Modifier.placeholder(placeholder),
leadingIcon = {
Icon(
painter = painterResource(SharedResources.ui_ic_user),
contentDescription = null,
)
},
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFF"
android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FFFFFFF"
android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z" />
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#000000"
android:viewportWidth="24"
android:viewportHeight="24">

<path
android:fillColor="#FFFFFFFF"
android:pathData="M19,5v14L5,19L5,5h14m0,-2L5,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2zM14.14,11.86l-3,3.87L9,13.14 6,17h12l-3.86,-5.14z" />

</vector>
Loading
Loading