Skip to content

Commit

Permalink
Migrated fragment_profile.xml to ProfileScreen.kt in compose
Browse files Browse the repository at this point in the history
  • Loading branch information
narendraanjana09 committed Aug 25, 2023
1 parent bc7b6bf commit 813a133
Show file tree
Hide file tree
Showing 23 changed files with 942 additions and 944 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ dependencies {
debugImplementation 'androidx.compose.ui:ui-test-manifest'
implementation "androidx.activity:activity-compose:$rootProject.composeActivityVersion"
implementation "com.google.accompanist:accompanist-systemuicontroller:$rootProject.accompanist_version"
implementation "com.google.accompanist:accompanist-permissions:$rootProject.accompanist_version"

//Coil
implementation("io.coil-kt:coil-compose:$rootProject.coilVersion")
Expand Down
7 changes: 2 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-feature
android:name="android.hardware.camera"
android:required="true" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera.any"/>

<application
android:name=".AgoraApp"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.aossie.agoraandroid.ui.di.models

import android.content.Context

data class AppContext(
val context: Context
)
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import org.aossie.agoraandroid.domain.useCases.profile.GetUserDataUseCase
import org.aossie.agoraandroid.domain.useCases.profile.ProfileUseCases
import org.aossie.agoraandroid.domain.useCases.profile.ToggleTwoFactorAuthUseCase
import org.aossie.agoraandroid.domain.useCases.profile.UpdateUserUseCase
import org.aossie.agoraandroid.ui.di.models.AppContext
import org.aossie.agoraandroid.utilities.AppConstants
import org.aossie.agoraandroid.utilities.InternetManager
import org.aossie.agoraandroid.utilities.SecurityUtil
Expand Down Expand Up @@ -501,4 +502,10 @@ class AppModule {
): CastVoteActivityUseCases {
return CastVoteActivityUseCases(castVoteUseCase, verifyVotersUseCase)
}

@Singleton
@Provides
fun provideAppContext(context: Context): AppContext {
return AppContext(context)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ import androidx.lifecycle.viewModelScope
import com.yariksoffice.lingver.Lingver
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch
Expand All @@ -24,7 +21,6 @@ import org.aossie.agoraandroid.utilities.ApiException
import org.aossie.agoraandroid.utilities.AppConstants
import org.aossie.agoraandroid.utilities.LocaleUtil
import org.aossie.agoraandroid.utilities.NoInternetException
import org.aossie.agoraandroid.utilities.ResponseUI
import org.aossie.agoraandroid.utilities.SessionExpirationException
import java.text.SimpleDateFormat
import java.util.Calendar
Expand All @@ -42,8 +38,6 @@ constructor(
private val homeViewModelUseCases: HomeFragmentUseCases,
private val prefs: PreferenceProvider
) : ViewModel() {
private val _getLogoutStateFLow: MutableStateFlow<ResponseUI<Any>?> = MutableStateFlow(null)
val getLogoutStateFlow: StateFlow<ResponseUI<Any>?> = _getLogoutStateFLow
var sessionExpiredListener: SessionExpiredListener? = null
private val formatter = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.ENGLISH)
private val currentDate: Date = Calendar.getInstance()
Expand Down Expand Up @@ -125,25 +119,20 @@ constructor(

fun doLogout() {
showLoading("Logging you out...")
_getLogoutStateFLow.value = ResponseUI.loading()
viewModelScope.launch {
try {
homeViewModelUseCases.logOut()
hideSnackBar()
hideLoading()
_uiEvents.emit(UiEvents.UserLoggedOut)
_getLogoutStateFLow.value = ResponseUI.success()
} catch (e: ApiException) {
showMessage(e.message!!)
_getLogoutStateFLow.value = ResponseUI.error(e.message)
} catch (e: SessionExpirationException) {
sessionExpiredListener?.onSessionExpired()
} catch (e: NoInternetException) {
showMessage(e.message!!)
_getLogoutStateFLow.value = ResponseUI.error(e.message)
} catch (e: Exception) {
showMessage(e.message!!)
_getLogoutStateFLow.value = ResponseUI.error(e.message)
}
}
}
Expand Down
Loading

0 comments on commit 813a133

Please sign in to comment.