Skip to content

Commit

Permalink
Removed composables from unstable composables baseline (Ivy-Apps#2967)
Browse files Browse the repository at this point in the history
* Removed composables from unstable composables baseline

* Made the composable function IconsRow() paramaters stable

* Revert "Made the composable function IconsRow() paramaters stable"

This reverts commit 2a93c72.

* Marked ComposeViewModel as Stable

* Marked All Implementations of ComposeViewModel as Stable

* Made IconsRow() paramaters stable

* Made SortModel()'s parameters stable

* Made PieChart()'s parameters stable

* Added composables to unstable composables baseline
  • Loading branch information
AMHaroun authored Feb 17, 2024
1 parent 9f48069 commit aadfa52
Show file tree
Hide file tree
Showing 25 changed files with 55 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.content.Context
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
import com.ivy.data.db.dao.write.WriteAccountDao
Expand All @@ -30,6 +31,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import javax.inject.Inject

@Stable
@SuppressLint("StaticFieldLeak")
@HiltViewModel
class AccountsViewModel @Inject constructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.ivy.attributions

import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import com.ivy.domain.ComposeViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@Stable
@HiltViewModel
class AttributionsViewModel @Inject constructor(
private val attributionsProvider: AttributionsProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ivy.balance

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableDoubleStateOf
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
Expand All @@ -16,6 +17,7 @@ import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject

@Stable
@HiltViewModel
class BalanceViewModel @Inject constructor(
private val plannedPaymentsLogic: PlannedPaymentsLogic,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ivy.budgets

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableDoubleStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
Expand Down Expand Up @@ -35,6 +36,7 @@ import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.launch
import javax.inject.Inject

@Stable
@HiltViewModel
class BudgetViewModel @Inject constructor(
private val sharedPrefs: SharedPrefs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ import com.ivy.wallet.ui.theme.modal.edit.CategoryModal
import com.ivy.wallet.ui.theme.modal.edit.CategoryModalData
import com.ivy.wallet.ui.theme.toComposeColor
import com.ivy.wallet.ui.theme.wallet.AmountCurrencyB1
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import java.util.UUID

Expand Down Expand Up @@ -415,7 +416,7 @@ private fun CategoryHeader(
@Suppress("UnusedParameter")
@Composable
fun BoxWithConstraintsScope.SortModal(
items: List<SortOrder>,
items: ImmutableList<SortOrder>,
visible: Boolean,
initialType: SortOrder,
dismiss: () -> Unit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ivy.categories

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
import com.ivy.base.legacy.Transaction
Expand Down Expand Up @@ -31,6 +32,7 @@ import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.launch
import javax.inject.Inject

@Stable
@HiltViewModel
class CategoriesViewModel @Inject constructor(
private val categoryCreator: CategoryCreator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ivy.contributors

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
import com.ivy.domain.ComposeViewModel
Expand All @@ -10,6 +11,7 @@ import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.launch
import javax.inject.Inject

@Stable
@HiltViewModel
class ContributorsViewModel @Inject constructor(
private val ivyWalletRepositoryDataSource: IvyWalletRepositoryDataSource
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ivy.transaction

import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableDoubleStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
Expand Down Expand Up @@ -58,6 +59,7 @@ import java.time.LocalTime
import java.util.UUID
import javax.inject.Inject

@Stable
@HiltViewModel
class EditTransactionViewModel @Inject constructor(
private val loanDao: LoanDao,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ivy.exchangerates

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
import com.ivy.data.db.dao.read.ExchangeRatesDao
Expand All @@ -22,6 +23,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import javax.inject.Inject

@Stable
@HiltViewModel
class ExchangeRatesViewModel @Inject constructor(
private val exchangeRatesDao: ExchangeRatesDao,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.ivy.features
import android.annotation.SuppressLint
import android.content.Context
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.lifecycle.viewModelScope
import com.ivy.domain.ComposeViewModel
import com.ivy.domain.features.Features
Expand All @@ -14,6 +15,7 @@ import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import javax.inject.Inject

@Stable
@SuppressLint("StaticFieldLeak")
@HiltViewModel
class FeaturesViewModel @Inject constructor(
Expand Down
2 changes: 2 additions & 0 deletions screen/home/src/main/java/com/ivy/home/HomeViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ivy.home

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
import com.ivy.base.legacy.Theme
Expand Down Expand Up @@ -56,6 +57,7 @@ import kotlinx.coroutines.launch
import java.math.BigDecimal
import javax.inject.Inject

@Stable
@HiltViewModel
class HomeViewModel @Inject constructor(
private val ivyContext: IvyWalletCtx,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ivy.loans.loan

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
import com.ivy.base.legacy.SharedPrefs
Expand Down Expand Up @@ -37,6 +38,7 @@ import kotlinx.coroutines.launch
import java.util.UUID
import javax.inject.Inject

@Stable
@HiltViewModel
class LoanViewModel @Inject constructor(
private val loanRecordDao: LoanRecordDao,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ivy.loans.loandetails

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableDoubleStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
Expand Down Expand Up @@ -49,6 +50,7 @@ import kotlinx.coroutines.launch
import java.util.UUID
import javax.inject.Inject

@Stable
@HiltViewModel
class LoanDetailsViewModel @Inject constructor(
private val loanDao: LoanDao,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ivy.onboarding.viewmodel

import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.runtime.State
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
Expand Down Expand Up @@ -43,6 +44,7 @@ import kotlinx.coroutines.launch
import timber.log.Timber
import javax.inject.Inject

@Stable
@HiltViewModel
class OnboardingViewModel @Inject constructor(
private val ivyContext: IvyWalletCtx,
Expand Down
6 changes: 4 additions & 2 deletions screen/piechart/src/main/java/com/ivy/piechart/PieChart.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import com.ivy.legacy.utils.timeNowUTC
import com.ivy.resources.R
import com.ivy.wallet.ui.theme.*
import com.ivy.wallet.ui.theme.components.IvyIcon
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import timber.log.Timber
import kotlin.math.acos
import kotlin.math.sqrt
Expand All @@ -38,7 +40,7 @@ const val RADIUS_DP = 112f
@Composable
fun PieChart(
type: TransactionType,
categoryAmounts: List<CategoryAmount>,
categoryAmounts: ImmutableList<CategoryAmount>,
selectedCategory: SelectedCategory?,
modifier: Modifier = Modifier,
onCategoryClicked: (Category?) -> Unit = {}
Expand Down Expand Up @@ -270,7 +272,7 @@ private fun Preview() {

PieChart(
type = TransactionType.EXPENSE,
categoryAmounts = listOf(
categoryAmounts = persistentListOf(
CategoryAmount(
category = Category("Bills", Green.toArgb()),
amount = 791.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ivy.piechart

import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableDoubleStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
Expand All @@ -25,6 +26,7 @@ import kotlinx.coroutines.launch
import java.util.UUID
import javax.inject.Inject

@Stable
@HiltViewModel
class PieChartStatisticViewModel @Inject constructor(
private val settingsDao: SettingsDao,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ivy.planned.edit

import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableDoubleStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
Expand Down Expand Up @@ -39,6 +40,7 @@ import kotlinx.coroutines.launch
import java.time.LocalDateTime
import javax.inject.Inject

@Stable
@HiltViewModel
class EditPlannedViewModel @Inject constructor(
private val accountDao: AccountDao,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ivy.planned.list

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableDoubleStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
Expand All @@ -21,6 +22,7 @@ import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.launch
import javax.inject.Inject

@Stable
@HiltViewModel
class PlannedPaymentsViewModel @Inject constructor(
private val settingsDao: SettingsDao,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ivy.releases

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
import com.ivy.domain.ComposeViewModel
Expand All @@ -10,6 +11,7 @@ import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.launch
import javax.inject.Inject

@Stable
@HiltViewModel
class ReleasesViewModel @Inject constructor(
private val releasesDataSource: ReleasesDataSource,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.ivy.reports
import android.content.Context
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableDoubleStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.graphics.toArgb
Expand Down Expand Up @@ -49,6 +50,7 @@ import java.math.BigDecimal
import java.util.UUID
import javax.inject.Inject

@Stable
@HiltViewModel
class ReportViewModel @Inject constructor(
private val plannedPaymentsLogic: PlannedPaymentsLogic,
Expand Down
2 changes: 2 additions & 0 deletions screen/search/src/main/java/com/ivy/search/SearchViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ivy.search

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
import com.ivy.base.legacy.TransactionHistoryItem
Expand All @@ -22,6 +23,7 @@ import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.launch
import javax.inject.Inject

@Stable
@HiltViewModel
class SearchViewModel @Inject constructor(
private val trnsWithDateDivsAct: TrnsWithDateDivsAct,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.content.Context
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.viewModelScope
Expand Down Expand Up @@ -35,6 +36,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import javax.inject.Inject

@Stable
@SuppressLint("StaticFieldLeak")
@HiltViewModel
class SettingsViewModel @Inject constructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ivy.transactions

import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableDoubleStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.graphics.toArgb
Expand Down Expand Up @@ -59,6 +60,7 @@ import kotlinx.coroutines.launch
import java.util.UUID
import javax.inject.Inject

@Stable
@HiltViewModel
class TransactionsViewModel @Inject constructor(
private val accountDao: AccountDao,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.ivy.domain

import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.lifecycle.ViewModel

/**
* A simple base ViewModel utilizing Compose' reactivity.
*/
@Stable
abstract class ComposeViewModel<UiState, UiEvent> : ViewModel() {
/**
* Optimized for Compose ui state.
Expand Down
Loading

0 comments on commit aadfa52

Please sign in to comment.