@momo-kits/native-kits 0.156.6-beta.1-debug → 0.156.6-beta.10-debug

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,7 +40,7 @@ kotlin {
40
40
  }
41
41
 
42
42
  cocoapods {
43
- version = "0.156.6-beta.1-debug"
43
+ version = "0.156.6-beta.10-debug"
44
44
  summary = "IOS Shared module"
45
45
  homepage = "https://momo.vn"
46
46
  ios.deploymentTarget = "15.0"
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |spec|
2
2
  spec.name = 'compose'
3
- spec.version = '0.156.1-beta.2'
3
+ spec.version = '0.156.1-test.6'
4
4
  spec.homepage = 'https://momo.vn'
5
5
  spec.source = { :http=> ''}
6
6
  spec.authors = ''
@@ -78,6 +78,14 @@ data class MiniAppContext(
78
78
  }
79
79
  }
80
80
 
81
+ @Immutable
82
+ data class ComponentInformation(
83
+ val componentName: String? = null,
84
+ val componentId: String? = null,
85
+ val params: Map<String,Any?>? = null,
86
+ val action: String? = null
87
+ )
88
+
81
89
  var IsShowBaseLineDebug = false
82
90
 
83
91
  val ApplicationContext = staticCompositionLocalOf<MiniAppContext?> {
@@ -92,4 +100,8 @@ val AppLanguage = staticCompositionLocalOf<String?> {
92
100
  null
93
101
  }
94
102
 
103
+ val LocalComponentInformation = staticCompositionLocalOf<ComponentInformation?> {
104
+ null
105
+ }
106
+
95
107
  internal val ScaleSizeMaxRate = staticCompositionLocalOf<Float?> { null }
@@ -370,9 +370,14 @@ private class LiteScreenHeaderPolicy(
370
370
  maxWidth = (realConstraints.maxWidth * (1 - scrollPercent)).toInt()
371
371
  .coerceAtLeast(minWidth)
372
372
  )
373
- } else realConstraints.copy(
374
- maxWidth = realConstraints.maxWidth - backIconPlaceable.safeWidth - headerRightPlaceable.safeWidth - spacing12 * 2
375
- )
373
+ } else {
374
+ var spaceConsumed = 0
375
+ if (backIconPlaceable.safeWidth != 0) spaceConsumed += backIconPlaceable.safeWidth + spacing12
376
+ if (headerRightPlaceable.safeWidth != 0) spaceConsumed += headerRightPlaceable.safeWidth + spacing12
377
+ realConstraints.copy(
378
+ maxWidth = realConstraints.maxWidth - spaceConsumed
379
+ )
380
+ }
376
381
  val inputSearchPlaceable = measurables.find { it.layoutId == HeaderId.INPUT_SEARCH_ID }
377
382
  ?.measure(inputSearchConstraints)
378
383
  val titlePlaceable = measurables.find { it.layoutId == HeaderId.TITLE_ID }?.measure(
@@ -516,7 +521,7 @@ private fun LiteInputSearch(
516
521
 
517
522
  val isShowBtnText by remember(inputSearchProps.isShowBtnText, inputSearchProps.btnText) {
518
523
  derivedStateOf {
519
- inputSearchProps.isShowBtnText && inputSearchProps.btnText.isNullOrEmpty()
524
+ inputSearchProps.isShowBtnText && !inputSearchProps.btnText.isNullOrEmpty()
520
525
  }
521
526
  }
522
527
  val inputFieldStyle = remember(theme) {
@@ -11,17 +11,14 @@ import androidx.compose.foundation.interaction.collectIsPressedAsState
11
11
  import androidx.compose.foundation.layout.Arrangement
12
12
  import androidx.compose.foundation.layout.Box
13
13
  import androidx.compose.foundation.layout.Row
14
- import androidx.compose.foundation.layout.defaultMinSize
15
14
  import androidx.compose.foundation.layout.fillMaxWidth
16
15
  import androidx.compose.foundation.layout.height
17
16
  import androidx.compose.foundation.layout.padding
18
17
  import androidx.compose.foundation.layout.size
19
18
  import androidx.compose.foundation.shape.RoundedCornerShape
20
19
  import androidx.compose.runtime.Composable
21
- import androidx.compose.runtime.CompositionLocalProvider
22
20
  import androidx.compose.runtime.getValue
23
21
  import androidx.compose.runtime.remember
24
- import androidx.compose.runtime.staticCompositionLocalOf
25
22
  import androidx.compose.ui.Alignment
26
23
  import androidx.compose.ui.Modifier
27
24
  import androidx.compose.ui.draw.alpha
@@ -127,13 +124,12 @@ fun getTextColor(loading: Boolean, type: ButtonType): Color {
127
124
  }
128
125
 
129
126
  @Composable
130
- fun RenderTitle(size: Size, title: String = "", type: ButtonType) {
127
+ fun RenderTitle(size: Size, title: String = "", textColor: Color) {
131
128
  val style = remember(size) { getStyle(size) }
132
- val color = TextColor.current
133
129
  Text(
134
130
  style = style,
135
131
  text = title,
136
- color = color,
132
+ color = textColor,
137
133
  overflow = TextOverflow.Ellipsis,
138
134
  maxLines = 1
139
135
  )
@@ -145,21 +141,20 @@ fun RenderIcon(
145
141
  isIconLeft: Boolean,
146
142
  useTintColor: Boolean = true,
147
143
  icon: String = "",
148
- forceLoading: Boolean = false
144
+ forceLoading: Boolean = false,
145
+ bgColor: Color,
146
+ textColor: Color,
149
147
  ) {
150
- val bgColor = BackgroundColor.current
151
148
  val iconSize = remember(size) { getIconSize(size) }
152
149
  val margin = remember(size) { getIconSpace(size) }
153
- val color = if (useTintColor) TextColor.current else Color.Unspecified
154
-
155
- val showLoading = forceLoading
150
+ val color = if (useTintColor) textColor else Color.Unspecified
156
151
 
157
152
  val modifier = Modifier.padding(
158
153
  start = if (isIconLeft) 0.dp else margin,
159
154
  end = if (isIconLeft) margin else 0.dp
160
155
  )
161
156
 
162
- if (showLoading) {
157
+ if (forceLoading) {
163
158
  Box(modifier) {
164
159
  LottieAnimation(
165
160
  modifier = Modifier.size(iconSize),
@@ -195,9 +190,9 @@ fun getTypeStyle(
195
190
  type: ButtonType,
196
191
  color: Color? = AppTheme.current.colors.primary,
197
192
  size: Size,
193
+ bgColor: Color,
198
194
  ): Modifier {
199
195
  val theme = AppTheme.current
200
- val bgColor = BackgroundColor.current
201
196
  val radius = remember(size) { size.value.radius }
202
197
  val modifier = Modifier.background(bgColor)
203
198
 
@@ -304,45 +299,41 @@ fun Button(
304
299
  .clip(RoundedCornerShape(radius))
305
300
  }
306
301
 
307
- CompositionLocalProvider(
308
- IsLoading provides loading,
309
- BackgroundColor provides getButtonBackgroundColor(loading, type),
310
- TextColor provides getTextColor(loading, type)
302
+ val bgColor = getButtonBackgroundColor(loading, type)
303
+ val textColor = getTextColor(loading, type)
304
+
305
+ Row(
306
+ modifier = clickableModifier
307
+ .padding(horizontal = animatedPadding)
308
+ .clip(RoundedCornerShape(radius))
309
+ .then(getTypeStyle(type, size = size, bgColor = bgColor))
310
+ .conditional(IsShowBaseLineDebug) {
311
+ border(1.dp, Colors.blue_03)
312
+ }
313
+ .padding(horizontal = sizeSpecs.padding)
314
+ .height(sizeSpecs.height),
315
+ horizontalArrangement = Arrangement.Center,
316
+ verticalAlignment = Alignment.CenterVertically,
311
317
  ) {
312
- Row(
313
- modifier = clickableModifier
314
- .padding(horizontal = animatedPadding)
315
- .clip(RoundedCornerShape(radius))
316
- .then(getTypeStyle(type, size = size))
317
- .conditional(IsShowBaseLineDebug) {
318
- border(1.dp, Colors.blue_03)
319
- }
320
- .padding(horizontal = sizeSpecs.padding)
321
- .height(sizeSpecs.height),
322
- horizontalArrangement = Arrangement.Center,
323
- verticalAlignment = Alignment.CenterVertically,
324
- ) {
325
- RenderIcon(
326
- size = size,
327
- isIconLeft = true,
328
- useTintColor = useTintColor,
329
- icon = iconLeft,
330
- forceLoading = loading && loadingOnLeft
331
- )
332
- RenderTitle(size, title, type = type)
333
- RenderIcon(
334
- size = size,
335
- isIconLeft = false,
336
- useTintColor = useTintColor,
337
- icon = iconRight,
338
- forceLoading = loading && !loadingOnLeft
339
- )
340
- }
318
+ RenderIcon(
319
+ size = size,
320
+ isIconLeft = true,
321
+ useTintColor = useTintColor,
322
+ icon = iconLeft,
323
+ forceLoading = loading && loadingOnLeft,
324
+ bgColor = bgColor,
325
+ textColor = textColor
326
+ )
327
+ RenderTitle(size, title, textColor = textColor)
328
+ RenderIcon(
329
+ size = size,
330
+ isIconLeft = false,
331
+ useTintColor = useTintColor,
332
+ icon = iconRight,
333
+ forceLoading = loading && !loadingOnLeft,
334
+ bgColor = bgColor,
335
+ textColor = textColor
336
+ )
341
337
  }
342
338
  }
343
339
 
344
-
345
- private val IsLoading = staticCompositionLocalOf<Boolean> { false }
346
- private val BackgroundColor = staticCompositionLocalOf<Color> { Color.Transparent }
347
- private val TextColor = staticCompositionLocalOf<Color> { Color.Transparent }
348
-
@@ -40,6 +40,7 @@ import vn.momo.kits.const.Typography
40
40
  import vn.momo.kits.const.scaleSize
41
41
  import vn.momo.kits.modifier.conditional
42
42
  import vn.momo.kits.modifier.setAutomationId
43
+ import vn.momo.kits.utils.getComponentId
43
44
 
44
45
  data class InputPhoneNumberSizeDetail(
45
46
  val borderWidth: Dp,
@@ -98,6 +99,7 @@ fun InputPhoneNumber(
98
99
  onBlur: () -> Unit = {},
99
100
  loading: Boolean = false,
100
101
  modifier: Modifier = Modifier,
102
+ accessibilityLabel: String?,
101
103
  ) {
102
104
  // Consolidated state management
103
105
  var inputState by remember { mutableStateOf(InputState()) }
@@ -113,16 +115,16 @@ fun InputPhoneNumber(
113
115
  }
114
116
 
115
117
  val (textColor, placeholderColor, iconTintColor) = colors
118
+ val textStyle = scaleSize(size.values.textStyle.copy(color = textColor))
116
119
 
117
- val testId = "input_phone_number"
118
120
 
119
- val textStyle = scaleSize(size.values.textStyle.copy(color = textColor))
121
+ val componentName = "InputPhoneNumber"
122
+ val componentId = getComponentId(componentName, accessibilityLabel)
120
123
 
121
124
  Column(modifier = modifier
122
125
  .conditional(IsShowBaseLineDebug) {
123
126
  border(1.dp, Colors.blue_03)
124
- }
125
- .setAutomationId(testId)) {
127
+ }) {
126
128
  BasicTextField(
127
129
  singleLine = true,
128
130
  value = text.value,
@@ -143,7 +145,8 @@ fun InputPhoneNumber(
143
145
  } else if (inputState.hasBeenBlurred) {
144
146
  onBlur()
145
147
  }
146
- },
148
+ }
149
+ .setAutomationId(componentId),
147
150
  onValueChange = onChangeText,
148
151
  decorationBox = { innerTextField ->
149
152
  // Input container
@@ -180,10 +180,6 @@ val darkTheme = Theme(
180
180
 
181
181
  val AppTheme = staticCompositionLocalOf { defaultTheme }
182
182
 
183
- val AppThemeController = staticCompositionLocalOf<(Theme) -> Unit> {
184
- error("No AppTheme controller provided")
185
- }
186
-
187
183
  val AppStatusBar = staticCompositionLocalOf { 0.dp }
188
184
 
189
185
  val AppNavigationBar = staticCompositionLocalOf { 0.dp }
@@ -30,7 +30,6 @@ import vn.momo.kits.application.MiniAppContext
30
30
  import vn.momo.kits.const.AppNavigationBar
31
31
  import vn.momo.kits.const.AppStatusBar
32
32
  import vn.momo.kits.const.AppTheme
33
- import vn.momo.kits.const.AppThemeController
34
33
  import vn.momo.kits.const.Theme
35
34
  import vn.momo.kits.const.ThemeAssets
36
35
  import vn.momo.kits.const.defaultTheme
@@ -80,7 +79,6 @@ fun NavigationContainer(
80
79
  LocalNavigator provides navigator,
81
80
  LocalMaxApi provides maxApi,
82
81
  AppTheme provides theme.value,
83
- AppThemeController provides { theme.value = it },
84
82
  AppStatusBar provides statusBarHeight,
85
83
  AppNavigationBar provides navigationBarHeight,
86
84
  ApplicationContext provides mergedContext,
@@ -0,0 +1,15 @@
1
+ package vn.momo.kits.utils
2
+
3
+ import androidx.compose.runtime.Composable
4
+ import vn.momo.kits.application.LocalComponentInformation
5
+
6
+ @Composable
7
+ fun getComponentId(
8
+ componentName: String? = null,
9
+ accessibilityLabel: String? = null,
10
+ ): String {
11
+ val componentInformation = LocalComponentInformation.current
12
+ if (accessibilityLabel != null) return accessibilityLabel
13
+ if (componentInformation?.componentId != null) return componentInformation.componentId
14
+ return ""
15
+ }
package/gradle.properties CHANGED
@@ -18,7 +18,7 @@ kotlin.apple.xcodeCompatibility.nowarn=true
18
18
  name="ComposeKits"
19
19
  group=vn.momo.kits
20
20
  artifact.id=kits
21
- version=0.156.1-test.6
21
+ version=0.156.6-beta.10
22
22
 
23
23
  repo=GitLab
24
24
  url=https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven
@@ -31,11 +31,7 @@ public struct ImageView: View {
31
31
  .placeholder {
32
32
  VStack(alignment: .center, content: {
33
33
  if error {
34
- Image("media_fail")
35
- .resizable()
36
- .renderingMode(.template)
37
- .foregroundColor(Colors.black17)
38
- .frame(width: 24, height: 24)
34
+ Image(systemName: "photo.badge.exclamationmark").frame(width: 24, height: 24)
39
35
  } else if placeholder != nil {
40
36
  placeholder
41
37
  }
@@ -21,6 +21,7 @@ public struct InputPhoneNumber: View {
21
21
  public var onFocus: (() -> Void)?
22
22
  public var onBlur: (() -> Void)?
23
23
  public var onRightIconPressed: (() -> Void)?
24
+ public var accessibilityLabel: String?
24
25
 
25
26
  @State private var isFocused: Bool = false
26
27
 
@@ -38,7 +39,8 @@ public struct InputPhoneNumber: View {
38
39
  onChangeText: ((String) -> Void)? = nil,
39
40
  onFocus: (() -> Void)? = nil,
40
41
  onBlur: (() -> Void)? = nil,
41
- onRightIconPressed: (() -> Void)? = nil
42
+ onRightIconPressed: (() -> Void)? = nil,
43
+ accessibilityLabel: String? = nil
42
44
  ) {
43
45
  self._text = text
44
46
  self.placeholder = placeholder
@@ -53,6 +55,7 @@ public struct InputPhoneNumber: View {
53
55
  self.onFocus = onFocus
54
56
  self.onBlur = onBlur
55
57
  self.onRightIconPressed = onRightIconPressed
58
+ self.accessibilityLabel = accessibilityLabel
56
59
  }
57
60
 
58
61
  // MARK: - Body
@@ -94,6 +97,7 @@ public struct InputPhoneNumber: View {
94
97
  .foregroundColor(Colors.black17)
95
98
  .applyPrimaryCursorColor()
96
99
  .lineLimit(1)
100
+ .accessibility(identifier: accessibilityLabel)
97
101
  }
98
102
 
99
103
  // Clear button
@@ -113,7 +113,11 @@ public struct PopupDisplay: View {
113
113
  }
114
114
 
115
115
  VStack(spacing: 0) {
116
- if(!url.isEmpty) {
116
+ if(url.isEmpty) {
117
+ Icon(source: "media_fail")
118
+ .frame(width: .infinity, height: 184)
119
+ }
120
+ else {
117
121
  WebImage(url: URL(string: url), isAnimating: .constant(true))
118
122
  .resizable()
119
123
  .placeholder {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.156.6-beta.1-debug",
3
+ "version": "0.156.6-beta.10-debug",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},