From cb5669eb28dd5da57dceb987662f440b6546e5a8 Mon Sep 17 00:00:00 2001 From: "DHNGL-ABHISHEKP\\Abhishek P" Date: Thu, 11 Apr 2024 01:24:44 +0530 Subject: [PATCH] Updated Alarm feature --- .../features/alarm/AlarmUI.kt | 6 ++--- .../features/alarm/database/AppDatabase.kt | 9 +++++--- .../features/chatmodule/ChatViewModel.kt | 1 - .../random_fox/model/RandomFoxImpl.kt | 22 +++++++++++++------ .../ui/components/ExplandDataVIewModel.kt | 8 +++++++ .../ui/components/List.kt | 6 ++++- 6 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 app/src/main/java/com/example/jetpack_compose_all_in_one/ui/components/ExplandDataVIewModel.kt diff --git a/app/src/main/java/com/example/jetpack_compose_all_in_one/features/alarm/AlarmUI.kt b/app/src/main/java/com/example/jetpack_compose_all_in_one/features/alarm/AlarmUI.kt index 1cd782fd..8e6ceec2 100644 --- a/app/src/main/java/com/example/jetpack_compose_all_in_one/features/alarm/AlarmUI.kt +++ b/app/src/main/java/com/example/jetpack_compose_all_in_one/features/alarm/AlarmUI.kt @@ -44,7 +44,7 @@ import kotlin.reflect.KFunction2 @Composable fun AlarmMainUI( viewModel: AlarmViewModel = hiltViewModel(), - snackbarFunc: (String, Boolean) -> Unit + snackBarFunc: (String, Boolean) -> Unit ) { val localContext = LocalContext.current @@ -80,8 +80,8 @@ fun AlarmMainUI( localContext, data, on, - { info, delta -> snackbarFunc("Alarm ${info.id} rings after ${delta.formatTime()}", false) }, - { info -> snackbarFunc("Alarm ${info.id} disabled.", false) }, + { info, delta -> snackBarFunc("Alarm ${info.id} rings after ${delta.formatTime()}", false) }, + { info -> snackBarFunc("Alarm ${info.id} disabled.", false) }, viewModel::toggleAlarm ) }, { viewModel.removeAlarm(data) } diff --git a/app/src/main/java/com/example/jetpack_compose_all_in_one/features/alarm/database/AppDatabase.kt b/app/src/main/java/com/example/jetpack_compose_all_in_one/features/alarm/database/AppDatabase.kt index cf9e666c..de80087d 100644 --- a/app/src/main/java/com/example/jetpack_compose_all_in_one/features/alarm/database/AppDatabase.kt +++ b/app/src/main/java/com/example/jetpack_compose_all_in_one/features/alarm/database/AppDatabase.kt @@ -7,10 +7,13 @@ import com.example.jetpack_compose_all_in_one.features.profile_update.Converter import com.example.jetpack_compose_all_in_one.features.profile_update.Profile import com.example.jetpack_compose_all_in_one.features.profile_update.ProfileDao -@Database(entities = [AlarmInfo::class, Profile::class], version = 2, exportSchema = false) +@Database( + entities = [AlarmInfo::class, Profile::class], + version = 2, + exportSchema = false +) @TypeConverters(Converter::class) -abstract class AppDatabase: RoomDatabase() { +abstract class AppDatabase : RoomDatabase() { abstract fun getAlarmDao(): AlarmDao - abstract fun getProfileDao(): ProfileDao } \ No newline at end of file diff --git a/app/src/main/java/com/example/jetpack_compose_all_in_one/features/chatmodule/ChatViewModel.kt b/app/src/main/java/com/example/jetpack_compose_all_in_one/features/chatmodule/ChatViewModel.kt index ba5edce4..a6f42daa 100644 --- a/app/src/main/java/com/example/jetpack_compose_all_in_one/features/chatmodule/ChatViewModel.kt +++ b/app/src/main/java/com/example/jetpack_compose_all_in_one/features/chatmodule/ChatViewModel.kt @@ -47,7 +47,6 @@ class ChatViewModel @Inject constructor( override fun onCancelled(error: DatabaseError) { } - }) } diff --git a/app/src/main/java/com/example/jetpack_compose_all_in_one/features/random_fox/model/RandomFoxImpl.kt b/app/src/main/java/com/example/jetpack_compose_all_in_one/features/random_fox/model/RandomFoxImpl.kt index 07d19191..9fe3e12a 100644 --- a/app/src/main/java/com/example/jetpack_compose_all_in_one/features/random_fox/model/RandomFoxImpl.kt +++ b/app/src/main/java/com/example/jetpack_compose_all_in_one/features/random_fox/model/RandomFoxImpl.kt @@ -27,17 +27,25 @@ class RandomFoxImpl @Inject constructor(@RandomFoxAPI val service: RandomFoxServ override suspend fun getRandomFoxFlow() = flow { service.getRandomFoxUsingCoroutines().apply { - this.body()?.let { + if (!this.isSuccessful){ emit( - ResultState.Success( - it + ResultState.Error( + this.message().toString() ) - ).runCatching { + ) + }else{ + this.body()?.let { emit( - ResultState.Error( - it.toString() + ResultState.Success( + it ) - ) + ).runCatching { + emit( + ResultState.Error( + it.toString() + ) + ) + } } } } diff --git a/app/src/main/java/com/example/jetpack_compose_all_in_one/ui/components/ExplandDataVIewModel.kt b/app/src/main/java/com/example/jetpack_compose_all_in_one/ui/components/ExplandDataVIewModel.kt new file mode 100644 index 00000000..44123bce --- /dev/null +++ b/app/src/main/java/com/example/jetpack_compose_all_in_one/ui/components/ExplandDataVIewModel.kt @@ -0,0 +1,8 @@ +package com.example.jetpack_compose_all_in_one.ui.components + +import androidx.lifecycle.ViewModel + +class ExplandDataVIewModel :ViewModel(){ + + val +} \ No newline at end of file diff --git a/app/src/main/java/com/example/jetpack_compose_all_in_one/ui/components/List.kt b/app/src/main/java/com/example/jetpack_compose_all_in_one/ui/components/List.kt index 639c3744..3006be00 100644 --- a/app/src/main/java/com/example/jetpack_compose_all_in_one/ui/components/List.kt +++ b/app/src/main/java/com/example/jetpack_compose_all_in_one/ui/components/List.kt @@ -232,7 +232,11 @@ fun AnimatedExpandableCard(item: Country) { stiffness = Spring.StiffnessMedium ) ) - .clickable { expanded.value = !expanded.value }, + .clickable { + expanded.value = !expanded.value + + + }, ) { Column( modifier = Modifier