Skip to content

Commit

Permalink
Wrapping Up The Project
Browse files Browse the repository at this point in the history
  • Loading branch information
radusalagean committed Jun 25, 2021
1 parent 735543a commit 846e64c
Show file tree
Hide file tree
Showing 36 changed files with 58 additions and 236 deletions.
Binary file added app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityComponent
import dagger.hilt.android.scopes.ActivityScoped
import javax.inject.Named

@Module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@ import androidx.compose.foundation.layout.*
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.getValue
import androidx.compose.runtime.*
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.example.waterfiltercompanion.ui.components.detailscard

import android.util.Log
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.animation.slideInHorizontally
Expand All @@ -14,7 +13,6 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.example.waterfiltercompanion.R
import com.example.waterfiltercompanion.ui.components.detailscard.content.DetailsContent
import com.example.waterfiltercompanion.ui.components.detailscard.content.item.DetailsContentItem

@ExperimentalAnimationApi
@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.tween
import androidx.compose.animation.core.updateTransition
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ package com.example.waterfiltercompanion.ui.components.ringindicator
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
package com.example.waterfiltercompanion.ui.screen.main

import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import androidx.lifecycle.lifecycleScope
import com.example.waterfiltercompanion.common.dialog.MaterialDialogHelper
import com.example.waterfiltercompanion.ui.theme.WaterFilterCompanionTheme
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.launchIn
Expand Down Expand Up @@ -57,4 +50,12 @@ class MainActivity : ComponentActivity() {
eventsJob?.cancel()
eventsJob = null
}

override fun onBackPressed() {
if (viewModel.editMode) {
viewModel.leaveEditMode()
} else {
super.onBackPressed()
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.example.waterfiltercompanion.ui.screen.main

import android.content.res.Configuration
import android.util.Log
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.layout.*
import androidx.compose.material.MaterialTheme
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
package com.example.waterfiltercompanion.ui.screen.main

import androidx.compose.runtime.*
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.waterfiltercompanion.common.date.DateHelper
import com.example.waterfiltercompanion.ui.components.capacityinputdialog.CapacityInputDialogConfig
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import com.example.waterfiltercompanion.R
import com.example.waterfiltercompanion.common.date.DateHelper
import com.example.waterfiltercompanion.datapersistence.DataModel
import com.example.waterfiltercompanion.datapersistence.LocalRepository
import com.example.waterfiltercompanion.ui.components.capacityinputdialog.CapacityInputDialogConfig
import com.example.waterfiltercompanion.ui.components.confirmationdialog.ConfirmationDialogConfig
import com.example.waterfiltercompanion.ui.components.infobar.InfoBarMessage
import com.example.waterfiltercompanion.ui.components.infobar.InfoBarType
import com.example.waterfiltercompanion.watercontrol.ConsumeWaterUseCase
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.receiveAsFlow
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class MainViewModel @Inject constructor(
Expand All @@ -27,21 +30,31 @@ class MainViewModel @Inject constructor(

// Global state
var editMode by mutableStateOf(false)
private set
var totalCapacity: Int? by mutableStateOf(null)
private set
var remainingCapacity: Int? by mutableStateOf(null)
private set
var installedOn: Long? by mutableStateOf(null)
private set

// Candidate values
var totalCapacityCandidate: String? by mutableStateOf(null)
private set
var remainingCapacityCandidate: String? by mutableStateOf(null)
private set
var installedOnCandidate: Long? by mutableStateOf(null)
private set

// Dialogs
var capacityInputDialogConfig: CapacityInputDialogConfig? by mutableStateOf(null)
private set
var confirmationDialogConfig: ConfirmationDialogConfig? by mutableStateOf(null)
private set

// Info Bar
var infoBarMessage: InfoBarMessage? by mutableStateOf(null)
private set

// Derived states
val installedOnFormatted: String? by derivedStateOf {
Expand Down Expand Up @@ -95,7 +108,7 @@ class MainViewModel @Inject constructor(
leaveEditMode()
}

private fun leaveEditMode() {
fun leaveEditMode() {
editMode = false
clearCandidateValues()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.example.waterfiltercompanion.ui.theme

import androidx.compose.material.Typography
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
Expand Down
30 changes: 0 additions & 30 deletions app/src/main/res/drawable-v24/ic_launcher_foreground.xml

This file was deleted.

170 changes: 0 additions & 170 deletions app/src/main/res/drawable/ic_launcher_background.xml

This file was deleted.

Loading

0 comments on commit 846e64c

Please sign in to comment.