-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: avs and cc versions in new section about this app (WPB-5935) (#3181
- Loading branch information
1 parent
3a803c8
commit 68d134b
Showing
10 changed files
with
228 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
...rc/main/kotlin/com/wire/android/ui/home/settings/about/dependencies/DependenciesScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2024 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.android.ui.home.settings.about.dependencies | ||
|
||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.wrapContentWidth | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.foundation.lazy.rememberLazyListState | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.unit.dp | ||
import androidx.hilt.navigation.compose.hiltViewModel | ||
import com.ramcosta.composedestinations.annotation.Destination | ||
import com.ramcosta.composedestinations.annotation.RootNavGraph | ||
import com.wire.android.R | ||
import com.wire.android.navigation.Navigator | ||
import com.wire.android.ui.common.RowItemTemplate | ||
import com.wire.android.ui.common.dimensions | ||
import com.wire.android.ui.common.scaffold.WireScaffold | ||
import com.wire.android.ui.common.topappbar.WireCenterAlignedTopAppBar | ||
import com.wire.android.ui.theme.wireColorScheme | ||
import com.wire.android.ui.theme.wireTypography | ||
import com.wire.android.util.ui.PreviewMultipleThemes | ||
import kotlinx.collections.immutable.ImmutableMap | ||
import kotlinx.collections.immutable.immutableMapOf | ||
|
||
@Composable | ||
@Destination | ||
@RootNavGraph | ||
fun DependenciesScreen( | ||
navigator: Navigator, | ||
viewModel: DependenciesViewModel = hiltViewModel() | ||
) { | ||
WireScaffold(topBar = { | ||
WireCenterAlignedTopAppBar( | ||
onNavigationPressed = navigator::navigateBack, | ||
elevation = 0.dp, | ||
title = stringResource(id = R.string.settings_dependencies_label) | ||
) | ||
}) { internalPadding -> | ||
DependenciesContent( | ||
internalPadding = internalPadding, | ||
dependencies = viewModel.state.dependencies | ||
) | ||
} | ||
} | ||
|
||
@Composable | ||
private fun DependenciesContent( | ||
internalPadding: PaddingValues, | ||
dependencies: ImmutableMap<String, String?>, | ||
) { | ||
val lazyListState = rememberLazyListState() | ||
LazyColumn( | ||
Modifier.fillMaxSize(), | ||
state = lazyListState, | ||
contentPadding = internalPadding | ||
) { | ||
dependencies.entries.forEach { | ||
item { | ||
DependenciesItem(dependencyName = it.key, dependencyVersion = it.value.orEmpty()) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
private fun DependenciesItem( | ||
dependencyName: String, | ||
dependencyVersion: String | ||
) { | ||
RowItemTemplate( | ||
modifier = Modifier.wrapContentWidth(), | ||
title = { | ||
Text( | ||
style = MaterialTheme.wireTypography.body01, | ||
color = MaterialTheme.wireColorScheme.onBackground, | ||
text = "${dependencyName.uppercase()}: $dependencyVersion", | ||
) | ||
} | ||
) | ||
} | ||
|
||
@Composable | ||
@PreviewMultipleThemes | ||
fun DependenciesContentPreview() { | ||
DependenciesContent( | ||
internalPadding = PaddingValues(dimensions().spacing8x), | ||
dependencies = immutableMapOf("avs" to "4.10.1", "cc" to "0.0.1") | ||
) | ||
} |
25 changes: 25 additions & 0 deletions
25
...src/main/kotlin/com/wire/android/ui/home/settings/about/dependencies/DependenciesState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2024 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.android.ui.home.settings.about.dependencies | ||
|
||
import kotlinx.collections.immutable.ImmutableMap | ||
import kotlinx.collections.immutable.persistentMapOf | ||
|
||
data class DependenciesState( | ||
val dependencies: ImmutableMap<String, String?> = persistentMapOf() | ||
) |
51 changes: 51 additions & 0 deletions
51
...main/kotlin/com/wire/android/ui/home/settings/about/dependencies/DependenciesViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2024 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.android.ui.home.settings.about.dependencies | ||
|
||
import android.content.Context | ||
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.wire.android.util.getDependenciesVersion | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import kotlinx.collections.immutable.toImmutableMap | ||
import kotlinx.coroutines.launch | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class DependenciesViewModel @Inject constructor( | ||
@ApplicationContext val context: Context | ||
) : ViewModel() { | ||
|
||
var state: DependenciesState by mutableStateOf(DependenciesState()) | ||
private set | ||
|
||
init { | ||
checkDependenciesVersion() | ||
} | ||
|
||
private fun checkDependenciesVersion() { | ||
viewModelScope.launch { | ||
val dependencies = context.getDependenciesVersion().toImmutableMap() | ||
state = state.copy(dependencies = dependencies) | ||
} | ||
} | ||
} |
Oops, something went wrong.