@momo-kits/native-kits 0.161.2-beta.7-debug → 0.161.2-beta.8-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.161.2-beta.7-debug"
43
+ version = "0.161.2-beta.8-debug"
44
44
  summary = "IOS Shared module"
45
45
  homepage = "https://momo.vn"
46
46
  ios.deploymentTarget = "15.0"
@@ -13,6 +13,7 @@ import vn.momo.kits.navigation.component.HeaderBackProps
13
13
  import vn.momo.kits.navigation.component.HeaderRight
14
14
  import vn.momo.kits.navigation.component.HeaderTitle
15
15
  import vn.momo.kits.navigation.component.HeaderType
16
+ import vn.momo.kits.navigation.component.TitlePosition
16
17
 
17
18
  class Navigation(
18
19
  val id: Int = -1,
@@ -28,6 +29,7 @@ class Navigation(
28
29
  hiddenBack: Boolean? = null,
29
30
  headerBackProps: HeaderBackProps? = null,
30
31
  headerTitle: HeaderTitle? = null,
32
+ titlePosition: TitlePosition? = null,
31
33
  headerRight: HeaderRight? = null,
32
34
  headerType: HeaderType? = null,
33
35
  scrollData: ScrollData? = null,
@@ -43,6 +45,7 @@ class Navigation(
43
45
  hiddenBack = hiddenBack ?: options.hiddenBack,
44
46
  headerBackProps = headerBackProps ?: options.headerBackProps,
45
47
  headerTitle = headerTitle ?: options.headerTitle,
48
+ titlePosition = titlePosition ?: options.titlePosition,
46
49
  headerRight = headerRight ?: options.headerRight,
47
50
  headerType = headerType ?: options.headerType,
48
51
  scrollData = scrollData ?: options.scrollData,
@@ -77,6 +80,7 @@ data class NavigationOptions(
77
80
  val hiddenBack: Boolean = false,
78
81
  val headerBackProps: HeaderBackProps = HeaderBackProps(),
79
82
  val headerTitle: HeaderTitle = HeaderTitle.Default("Stack"),
83
+ val titlePosition: TitlePosition = TitlePosition.LEFT,
80
84
  val headerRight: HeaderRight = HeaderRight.Toolkit(),
81
85
  val headerType: HeaderType = HeaderType.Default(),
82
86
  val scrollData: ScrollData = ScrollData(),
@@ -6,7 +6,6 @@ import androidx.compose.foundation.border
6
6
  import androidx.compose.foundation.layout.Arrangement
7
7
  import androidx.compose.foundation.layout.Box
8
8
  import androidx.compose.foundation.layout.Row
9
- import androidx.compose.foundation.layout.RowScope
10
9
  import androidx.compose.foundation.layout.Spacer
11
10
  import androidx.compose.foundation.layout.fillMaxWidth
12
11
  import androidx.compose.foundation.layout.height
@@ -23,6 +22,7 @@ import androidx.compose.ui.graphics.Brush
23
22
  import androidx.compose.ui.graphics.Color
24
23
  import androidx.compose.ui.layout.onGloballyPositioned
25
24
  import androidx.compose.ui.platform.LocalDensity
25
+ import androidx.compose.ui.text.style.TextAlign
26
26
  import androidx.compose.ui.unit.Dp
27
27
  import androidx.compose.ui.unit.dp
28
28
  import vn.momo.kits.components.Icon
@@ -44,6 +44,7 @@ import vn.momo.kits.navigation.getInputSearchType
44
44
 
45
45
  const val HEADER_HEIGHT = 52
46
46
  enum class InputSearchType { None, Header, Animated }
47
+ enum class TitlePosition { LEFT, CENTER }
47
48
 
48
49
  @Composable
49
50
  fun Header(onBackHandler: (() -> Unit)? = null) {
@@ -76,6 +77,13 @@ fun Header(onBackHandler: (() -> Unit)? = null) {
76
77
  AppTheme.current.colors.background.surface
77
78
 
78
79
  if (options.headerType == HeaderType.None) return
80
+
81
+ val titlePosition = options.titlePosition
82
+ val titleColor = headerColor.tintIconColor
83
+ .copy(alpha = if (inputSearchType == InputSearchType.Animated) 1f - animatedAlpha else 1f)
84
+ // Centered title needs a full-width overlay to stay screen-centered, not boxed between back button and header right.
85
+ val centerTitle = titlePosition == TitlePosition.CENTER && options.headerTitle is HeaderTitle.Default
86
+
79
87
  Box(
80
88
  Modifier.height(AppStatusBar.current + HEADER_HEIGHT.dp)
81
89
  .fillMaxWidth()
@@ -104,17 +112,37 @@ fun Header(onBackHandler: (() -> Unit)? = null) {
104
112
  Spacer(Modifier.width(Spacing.M))
105
113
  }
106
114
 
107
- HeaderContent(
108
- options.headerTitle,
109
- headerColor.tintIconColor
110
- .copy(alpha = if (inputSearchType == InputSearchType.Animated) 1f - animatedAlpha else 1f)
111
- )
115
+ if (centerTitle) {
116
+ Spacer(Modifier.weight(1f))
117
+ } else {
118
+ HeaderContent(
119
+ headerTitle = options.headerTitle,
120
+ tintIconColor = titleColor,
121
+ titlePosition = titlePosition,
122
+ modifier = Modifier.weight(1f)
123
+ )
124
+ }
112
125
  Box(Modifier.onGloballyPositioned {
113
126
  if(headerRightWidthPx.intValue != it.size.width) headerRightWidthPx.intValue = it.size.width
114
127
  }){
115
128
  HeaderRight(options.headerRight, options.tintColor, headerColor)
116
129
  }
117
130
  }
131
+ if (centerTitle) {
132
+ Box(
133
+ modifier = Modifier.height(HEADER_HEIGHT.dp)
134
+ .fillMaxWidth()
135
+ .padding(horizontal = Spacing.M),
136
+ contentAlignment = Alignment.Center
137
+ ) {
138
+ HeaderContent(
139
+ headerTitle = options.headerTitle,
140
+ tintIconColor = titleColor,
141
+ titlePosition = titlePosition,
142
+ modifier = Modifier.fillMaxWidth()
143
+ )
144
+ }
145
+ }
118
146
  VerticalShadow(opacity)
119
147
  }
120
148
  }
@@ -140,15 +168,23 @@ private fun BackButton(borderColor: Color, backgroundButton: Color, tintIconColo
140
168
  }
141
169
 
142
170
  @Composable
143
- fun RowScope.HeaderContent(headerTitle: HeaderTitle, tintIconColor: Color){
171
+ fun HeaderContent(
172
+ headerTitle: HeaderTitle,
173
+ tintIconColor: Color,
174
+ titlePosition: TitlePosition = TitlePosition.LEFT,
175
+ modifier: Modifier = Modifier,
176
+ ){
144
177
  Box(
145
- Modifier.weight(1f)
178
+ modifier = modifier,
179
+ contentAlignment = if (titlePosition == TitlePosition.CENTER) Alignment.Center else Alignment.CenterStart
146
180
  ) {
147
181
  when (headerTitle){
148
182
  is HeaderTitle.Default -> {
149
183
  HeaderTitle(
150
184
  title = headerTitle.title,
151
- color = tintIconColor
185
+ color = tintIconColor,
186
+ modifier = Modifier.fillMaxWidth(fraction = if (titlePosition == TitlePosition.CENTER) 0.5f else 1f),
187
+ textAlign = if (titlePosition == TitlePosition.CENTER) TextAlign.Center else TextAlign.Start
152
188
  )
153
189
  }
154
190
  is HeaderTitle.Journey -> {}
@@ -16,11 +16,13 @@ import vn.momo.kits.modifier.setAutomationId
16
16
  fun HeaderTitle(
17
17
  title: String = "",
18
18
  color: Color? = null,
19
+ modifier: Modifier = Modifier.fillMaxWidth(),
20
+ textAlign: TextAlign = TextAlign.Start,
19
21
  ) {
20
22
  Text(
21
- modifier = Modifier.fillMaxWidth().zIndex(1f).setAutomationId("title_navigation_header"),
23
+ modifier = modifier.zIndex(1f).setAutomationId("title_navigation_header"),
22
24
  text = title,
23
- textAlign = TextAlign.Start,
25
+ textAlign = textAlign,
24
26
  style = Typography.actionSBold.copy(
25
27
  fontSize = 15.sp,
26
28
  lineHeight = 22.sp,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.161.2-beta.7-debug",
3
+ "version": "0.161.2-beta.8-debug",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},