Skip to content

Commit 9e49a11

Browse files
committed
Various fixes
1 parent ffeceff commit 9e49a11

13 files changed

Lines changed: 167 additions & 83 deletions

File tree

app/src/main/java/com/orange/ouds/app/ui/MainScreen.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ import com.orange.ouds.core.theme.OudsTheme
5757
import com.orange.ouds.foundation.RestrictedOudsApi
5858
import com.orange.ouds.foundation.extensions.orElse
5959
import com.orange.ouds.theme.OudsThemeSettings
60-
import com.orange.ouds.theme.wireframe.WIREFRAME_THEME_NAME
61-
//import com.orange.ouds.theme.orange.ORANGE_THEME_NAME
60+
import com.orange.ouds.theme.orange.ORANGE_THEME_NAME
6261
import dev.chrisbanes.haze.HazeStyle
6362
import dev.chrisbanes.haze.hazeEffect
6463
import dev.chrisbanes.haze.hazeSource
@@ -68,8 +67,7 @@ import dev.chrisbanes.haze.rememberHazeState
6867
fun MainScreen(mainViewModel: MainViewModel = hiltViewModel()) {
6968
MainScreen(
7069
themeSettings = mainViewModel.getUserThemeSettings().orElse { OudsThemeSettings() },
71-
//currentThemeName = mainViewModel.getUserThemeName().orElse { ORANGE_THEME_NAME },
72-
currentThemeName = mainViewModel.getUserThemeName().orElse { WIREFRAME_THEME_NAME },
70+
currentThemeName = mainViewModel.getUserThemeName().orElse { ORANGE_THEME_NAME },
7371
onThemeChange = { themeName ->
7472
mainViewModel.storeUserThemeName(themeName)
7573
},
@@ -206,7 +204,7 @@ private fun PreviewMainScreen() = AppPreview {
206204
// See https://issuetracker.google.com/issues/240601093
207205
MainScreen(
208206
themeSettings = OudsThemeSettings(),
209-
currentThemeName = WIREFRAME_THEME_NAME,//ORANGE_THEME_NAME,
207+
currentThemeName = ORANGE_THEME_NAME,
210208
onThemeChange = {},
211209
onThemeSettingsChange = {}
212210
)

app/src/main/java/com/orange/ouds/app/ui/ThemeState.kt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,6 @@ import com.orange.ouds.theme.orangecompact.ORANGE_COMPACT_THEME_NAME
3030
import com.orange.ouds.theme.orangecompact.OrangeCompactTheme
3131
import com.orange.ouds.theme.sosh.SOSH_THEME_NAME
3232
import com.orange.ouds.theme.sosh.SoshTheme
33-
//import com.orange.ouds.theme.orange.ORANGE_THEME_NAME
34-
//import com.orange.ouds.theme.orange.OrangeFontFamily
35-
//import com.orange.ouds.theme.orange.OrangeHelveticaNeueArabic
36-
//import com.orange.ouds.theme.orange.OrangeHelveticaNeueLatin
37-
//import com.orange.ouds.theme.orange.OrangeTheme
38-
//import com.orange.ouds.theme.orangecompact.ORANGE_COMPACT_THEME_NAME
39-
//import com.orange.ouds.theme.orangecompact.OrangeCompactTheme
40-
//import com.orange.ouds.theme.sosh.SOSH_THEME_NAME
41-
//import com.orange.ouds.theme.sosh.SoshTheme
4233
import com.orange.ouds.theme.wireframe.WIREFRAME_THEME_NAME
4334
import com.orange.ouds.theme.wireframe.WireframeTheme
4435

@@ -51,7 +42,7 @@ fun rememberThemeState(
5142
SOSH_THEME_NAME,
5243
WIREFRAME_THEME_NAME
5344
),
54-
currentThemeName: String = WIREFRAME_THEME_NAME,//ORANGE_THEME_NAME,
45+
currentThemeName: String = ORANGE_THEME_NAME,
5546
areDownloadableOrangeFontFamiliesPreloaded: Boolean = false
5647
) = rememberSaveable(settings, themeNames, currentThemeName, areDownloadableOrangeFontFamiliesPreloaded, saver = ThemeState.Saver) {
5748
ThemeState(settings, themeNames, currentThemeName, areDownloadableOrangeFontFamiliesPreloaded)
@@ -117,7 +108,7 @@ class ThemeState(
117108

118109
private fun getCurrentTheme(name: String): OudsThemeContract {
119110
return themes.firstOrNull { it.name == name }
120-
.orElse { themes.firstOrNull { it.name == WIREFRAME_THEME_NAME } }
111+
.orElse { themes.firstOrNull { it.name == ORANGE_THEME_NAME } }
121112
.orElse { themes.first() }
122113
}
123114

app/src/main/java/com/orange/ouds/app/ui/utilities/ThemeDrawableResources.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ class ThemeDrawableResources(val theme: OudsThemeContract) {
4444
else -> error(ThemeDrawableResources::call)
4545
}
4646

47+
val close: Int
48+
@DrawableRes
49+
get() = when (theme) {
50+
is OrangeTheme, is OrangeCompactTheme -> R.drawable.ic_orange_close
51+
is SoshTheme -> R.drawable.ic_sosh_close
52+
is WireframeTheme -> R.drawable.ic_wireframe_close
53+
else -> error(ThemeDrawableResources::close)
54+
}
55+
4756
val filters: Int
4857
@DrawableRes
4958
get() = when (theme) {

app/src/main/java/com/orange/ouds/app/ui/utilities/composable/AppPreview.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ import com.orange.ouds.foundation.InternalOudsApi
2525
import com.orange.ouds.theme.orange.OrangeTheme
2626
import com.orange.ouds.theme.orange.getPreviewOrangeFontFamily
2727

28-
//import com.orange.ouds.theme.orange.OrangeTheme
29-
//import com.orange.ouds.theme.orange.getPreviewOrangeFontFamily
30-
3128
@OptIn(InternalOudsApi::class)
3229
@Composable
3330
fun AppPreview(

app/src/main/java/com/orange/ouds/app/ui/utilities/composable/CustomizationElements.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import androidx.compose.ui.text.TextStyle
4848
import androidx.compose.ui.text.input.TextFieldValue
4949
import androidx.compose.ui.unit.Dp
5050
import com.orange.ouds.app.R
51+
import com.orange.ouds.app.ui.utilities.LocalThemeDrawableResources
5152
import com.orange.ouds.core.component.OudsFilterChip
5253
import com.orange.ouds.core.component.OudsSwitchItem
5354
import com.orange.ouds.core.component.OudsTextInput
@@ -202,7 +203,7 @@ fun CustomizationTextInput(
202203
keyboardOptions = keyboardOptions,
203204
trailingIconButton = if (value.text.isNotEmpty()) {
204205
OudsTextInputTrailingIconButton(
205-
painter = painterResource(R.drawable.ic_copy),
206+
painter = painterResource(id = LocalThemeDrawableResources.current.close),
206207
contentDescription = stringResource(R.string.app_components_common_textInputClearIcon_a11y),
207208
onClick = {
208209
onValueChange(value.copy(text = resetValue))
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24">
6+
<path
7+
android:pathData="m18.75,7.178 l-1.928,-1.929L12,10.071 7.178,5.25 5.249,7.18 10.071,12 5.25,16.822l1.93,1.929L12,13.929l4.822,4.822 1.929,-1.929L13.929,12l4.822,-4.822Z"
8+
android:fillColor="#000000"/>
9+
</vector>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24">
6+
<path
7+
android:pathData="M18.397,5.603c0.47,0.47 0.47,1.235 0,1.706l-4.691,4.69 4.69,4.692a1.207,1.207 0,0 1,-1.705 1.706L12,13.705l-4.691,4.692a1.207,1.207 0,0 1,-1.706 -1.706l4.691,-4.692 -4.69,-4.69a1.207,1.207 0,0 1,1.705 -1.706L12,10.293l4.691,-4.69c0.47,-0.47 1.235,-0.47 1.706,0Z"
8+
android:fillColor="#000000"
9+
android:fillType="evenOdd"/>
10+
</vector>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24">
6+
<path
7+
android:pathData="M17.293,5.293a1,1 0,1 1,1.414 1.414L13.414,12l5.293,5.293 0.068,0.076a1,1 0,0 1,-1.406 1.406l-0.076,-0.068L12,13.414l-5.293,5.293a1,1 0,1 1,-1.414 -1.414L10.586,12 5.293,6.707l-0.068,-0.076A1,1 0,0 1,6.63 5.225l0.076,0.068L12,10.586l5.293,-5.293Z"
8+
android:fillColor="#000000"/>
9+
</vector>
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
* Software Name: OUDS Android
3+
* SPDX-FileCopyrightText: Copyright (c) Orange SA
4+
* SPDX-License-Identifier: MIT
5+
*
6+
* This software is distributed under the MIT license,
7+
* the text of which is available at https://opensource.org/license/MIT/
8+
* or see the "LICENSE" file for more details.
9+
*
10+
* Software description: Android library of reusable graphical components
11+
*/
12+
13+
package com.orange.ouds.core.component
14+
15+
import androidx.compose.foundation.text.input.TextFieldState
16+
import androidx.compose.foundation.text.input.insert
17+
import androidx.compose.material3.ExperimentalMaterial3Api
18+
import androidx.compose.material3.LocalRippleConfiguration
19+
import androidx.compose.material3.RichTooltip
20+
import androidx.compose.material3.Text
21+
import androidx.compose.material3.TextButton
22+
import androidx.compose.material3.TooltipAnchorPosition
23+
import androidx.compose.material3.TooltipBox
24+
import androidx.compose.material3.TooltipDefaults
25+
import androidx.compose.material3.rememberTooltipState
26+
import androidx.compose.runtime.Composable
27+
import androidx.compose.runtime.CompositionLocalProvider
28+
import androidx.compose.runtime.rememberCoroutineScope
29+
import androidx.compose.ui.platform.LocalClipboard
30+
import com.orange.ouds.core.theme.OudsTheme
31+
import kotlinx.coroutines.launch
32+
import org.jetbrains.compose.resources.stringResource
33+
import ouds_android.core.generated.resources.Res
34+
import ouds_android.core.generated.resources.core_pinCodeInput_paste_label
35+
36+
@OptIn(ExperimentalMaterial3Api::class)
37+
@Composable
38+
internal actual fun OudsPinCodeInputTooltipBox(
39+
textFieldState: TextFieldState,
40+
length: OudsPinCodeInputLength,
41+
content: @Composable () -> Unit
42+
) {
43+
val tooltipState = rememberTooltipState(isPersistent = true)
44+
// TODO: Replace with OUDS tooltip when available
45+
TooltipBox(
46+
positionProvider = TooltipDefaults.rememberTooltipPositionProvider(
47+
positioning = TooltipAnchorPosition.Above,
48+
spacingBetweenTooltipAndAnchor = OudsTheme.spaces.fixed.extraSmall
49+
),
50+
tooltip = {
51+
val clipboard = LocalClipboard.current
52+
val scope = rememberCoroutineScope()
53+
RichTooltip {
54+
CompositionLocalProvider(LocalRippleConfiguration provides null) {
55+
TextButton(
56+
onClick = {
57+
scope.launch {
58+
clipboard.getClipEntry()?.clipData?.let { clipData ->
59+
if (clipData.itemCount > 0) {
60+
val text = clipData.getItemAt(0).text.toString()
61+
textFieldState.edit {
62+
insert(selection.min, text)
63+
with(inputTransformation(length)) {
64+
transformInput()
65+
}
66+
}
67+
}
68+
}
69+
tooltipState.dismiss()
70+
}
71+
}
72+
) {
73+
Text(text = stringResource(Res.string.core_pinCodeInput_paste_label))
74+
}
75+
}
76+
}
77+
},
78+
state = tooltipState,
79+
content = content
80+
)
81+
}

core/src/commonMain/kotlin/com/orange/ouds/core/component/OudsPinCodeInput.kt

Lines changed: 7 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,16 @@ import androidx.compose.foundation.text.input.delete
2828
import androidx.compose.foundation.text.input.forEachChangeReversed
2929
import androidx.compose.foundation.text.input.insert
3030
import androidx.compose.foundation.text.input.rememberTextFieldState
31-
import androidx.compose.material3.ExperimentalMaterial3Api
32-
import androidx.compose.material3.LocalRippleConfiguration
33-
import androidx.compose.material3.RichTooltip
34-
import androidx.compose.material3.Text
35-
import androidx.compose.material3.TextButton
36-
import androidx.compose.material3.TooltipAnchorPosition
37-
import androidx.compose.material3.TooltipBox
38-
import androidx.compose.material3.TooltipDefaults
39-
import androidx.compose.material3.rememberTooltipState
31+
4032
import androidx.compose.runtime.Composable
41-
import androidx.compose.runtime.CompositionLocalProvider
4233
import androidx.compose.runtime.LaunchedEffect
4334
import androidx.compose.runtime.getValue
4435
import androidx.compose.runtime.remember
45-
import androidx.compose.runtime.rememberCoroutineScope
4636
import androidx.compose.runtime.snapshotFlow
4737
import androidx.compose.ui.Alignment
4838
import androidx.compose.ui.Modifier
4939
import androidx.compose.ui.focus.FocusRequester
5040
import androidx.compose.ui.focus.focusRequester
51-
import androidx.compose.ui.platform.LocalClipboard
5241
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
5342
import androidx.compose.ui.text.TextRange
5443
import androidx.compose.ui.text.input.KeyboardType
@@ -71,10 +60,6 @@ import com.orange.ouds.core.utilities.mapSettings
7160
import com.orange.ouds.foundation.utilities.BasicPreviewParameterProvider
7261
import com.orange.ouds.theme.OudsThemeContract
7362
import com.orange.ouds.theme.OudsThemeSettings
74-
import kotlinx.coroutines.launch
75-
import org.jetbrains.compose.resources.stringResource
76-
import ouds_android.core.generated.resources.Res
77-
import ouds_android.core.generated.resources.core_pinCodeInput_paste_label
7863

7964
/**
8065
* PIN code input is a UI element that allows to capture short, fixed-length numeric codes, typically for authentication or confirmation purposes, such as a
@@ -272,48 +257,12 @@ private fun OudsPinCodeInput(
272257
}
273258
}
274259

275-
@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class)
276260
@Composable
277-
private fun OudsPinCodeInputTooltipBox(textFieldState: TextFieldState, length: OudsPinCodeInputLength, content: @Composable () -> Unit) {
278-
val tooltipState = rememberTooltipState(isPersistent = true)
279-
// TODO: Replace with OUDS tooltip when available
280-
TooltipBox(
281-
positionProvider = TooltipDefaults.rememberTooltipPositionProvider(
282-
positioning = TooltipAnchorPosition.Above,
283-
spacingBetweenTooltipAndAnchor = OudsTheme.spaces.fixed.extraSmall
284-
),
285-
tooltip = {
286-
val clipboard = LocalClipboard.current
287-
val scope = rememberCoroutineScope()
288-
RichTooltip {
289-
CompositionLocalProvider(LocalRippleConfiguration provides null) {
290-
TextButton(
291-
onClick = {
292-
scope.launch {
293-
// clipboard.getClipEntry()?.clipData?.let { clipData ->
294-
// if (clipData.itemCount > 0) {
295-
// val text = clipData.getItemAt(0).text.toString()
296-
// textFieldState.edit {
297-
// insert(selection.min, text)
298-
// with(inputTransformation(length)) {
299-
// transformInput()
300-
// }
301-
// }
302-
// }
303-
// }
304-
tooltipState.dismiss()
305-
}
306-
}
307-
) {
308-
Text(text = stringResource(Res.string.core_pinCodeInput_paste_label))
309-
}
310-
}
311-
}
312-
},
313-
state = tooltipState,
314-
content = content
315-
)
316-
}
261+
internal expect fun OudsPinCodeInputTooltipBox(
262+
textFieldState: TextFieldState,
263+
length: OudsPinCodeInputLength,
264+
content: @Composable () -> Unit
265+
)
317266

318267
@Composable
319268
private fun OudsPinCodeInputDecorator(
@@ -392,7 +341,7 @@ private fun smallDeviceSpecificRules(length: OudsPinCodeInputLength): Boolean {
392341
}
393342

394343
@OptIn(ExperimentalFoundationApi::class)
395-
private fun inputTransformation(length: OudsPinCodeInputLength): InputTransformation {
344+
internal fun inputTransformation(length: OudsPinCodeInputLength): InputTransformation {
396345
return InputTransformation {
397346
changes.forEachChangeReversed { range, originalRange ->
398347
// Text is inserted with either keyboard inputs or pasting from the clipboard

0 commit comments

Comments
 (0)