@momo-kits/native-kits 0.162.2-sp.1-debug → 0.162.2-sp.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.
Files changed (198) hide show
  1. package/.claude/settings.local.json +15 -1
  2. package/CLAUDE.md +78 -0
  3. package/compose/build.gradle.kts +12 -8
  4. package/compose/build.gradle.kts.backup +11 -7
  5. package/compose/compose.podspec +1 -1
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +7 -0
  7. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +2 -7
  8. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +8 -11
  9. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +6 -24
  10. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +4 -19
  11. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +1 -10
  12. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +2 -2
  13. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +1 -1
  14. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +1 -1
  15. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +5 -16
  16. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +1 -1
  17. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +6 -101
  18. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +269 -0
  19. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +8 -19
  20. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +8 -33
  21. package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +56 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +1 -1
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +22 -25
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +27 -29
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +3 -26
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +30 -31
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +3 -13
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -5
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +3 -11
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +3 -18
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +11 -11
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +42 -65
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +69 -26
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +1 -5
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +84 -59
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +13 -71
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +10 -51
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +6 -1
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +4 -21
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +1 -1
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +16 -75
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +5 -26
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +1 -1
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +3 -11
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +16 -40
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +3 -9
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -28
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +2 -13
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +4 -0
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +4 -10
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +3 -28
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +8 -47
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +4 -25
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +2 -11
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +1 -17
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +1 -6
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +50 -111
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +1 -5
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +1 -5
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +1 -12
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +4 -96
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +5 -7
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +2 -12
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +9 -21
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +2 -2
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +9 -14
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +8 -11
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +22 -0
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +1 -1
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +11 -20
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +1 -1
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -5
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -2
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +94 -4
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -2
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +2 -2
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +3 -7
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +12 -16
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +120 -93
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +48 -33
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +88 -63
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +9 -14
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +13 -31
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +1 -1
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +6 -24
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +11 -6
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +2 -1
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +9 -6
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +1 -1
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +3 -13
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +3 -2
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +1 -40
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -2
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +9 -0
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -8
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +2 -17
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +1 -1
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +3 -3
  99. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +2 -3
  100. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +66 -0
  101. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -2
  102. package/gradle/libs.versions.toml +2 -0
  103. package/gradle.properties +1 -1
  104. package/ios/Application/ApplicationEnvironment.swift +15 -2
  105. package/ios/Application/Components.swift +16 -0
  106. package/ios/Application/HeaderRight.swift +79 -45
  107. package/ios/Application/Localize.swift +277 -0
  108. package/ios/Application/MaxApi.swift +18 -0
  109. package/ios/Application/Navigation/BottomTab/BottomTab.swift +3 -1
  110. package/ios/Application/Navigation/NavigationContainer.swift +53 -4
  111. package/ios/Application/Navigation/Navigator.swift +54 -29
  112. package/ios/Application/Navigation/Overplay/BottomSheet.swift +98 -18
  113. package/ios/Application/Navigation/Overplay/ModalScreen.swift +6 -0
  114. package/ios/Application/Navigation/Tracking/ScreenTracker.swift +117 -0
  115. package/ios/Application/Screen.swift +2 -1
  116. package/ios/Application/StackScreen.swift +55 -3
  117. package/ios/Badge/BadgeRibbon.swift +80 -0
  118. package/ios/Button/Button.swift +67 -11
  119. package/ios/Carousel/Carousel.swift +16 -1
  120. package/ios/Checkbox/Checkbox.swift +14 -20
  121. package/ios/Chip/Chip.swift +35 -26
  122. package/ios/Collapse/Collapse.swift +11 -1
  123. package/ios/Colors+Radius+Spacing/Colors.swift +20 -17
  124. package/ios/Colors+Radius+Spacing/Spacing.swift +3 -1
  125. package/ios/Colors+Radius+Spacing/Theme.swift +15 -15
  126. package/ios/DateTimePicker/DateTimePicker.swift +4 -2
  127. package/ios/DateTimePicker/WheelPicker.swift +7 -3
  128. package/ios/Extensions/ActiveOpacityButtonStyle.swift +14 -0
  129. package/ios/Extensions/Color++.swift +32 -0
  130. package/ios/Icon/Icon.swift +5 -1
  131. package/ios/IconButton/IconButton.swift +35 -7
  132. package/ios/Image/Image.swift +16 -3
  133. package/ios/Information/Information.swift +3 -1
  134. package/ios/Input/ErrorView.swift +3 -1
  135. package/ios/Input/Input.swift +31 -8
  136. package/ios/Input/InputPhoneNumber.swift +14 -3
  137. package/ios/Input/InputSearch.swift +7 -1
  138. package/ios/Input/InputTextArea.swift +78 -34
  139. package/ios/InputDropDown/InputDropDown.swift +4 -1
  140. package/ios/InputMoney/InputMoney.swift +16 -4
  141. package/ios/Popup/PopupDisplay.swift +3 -4
  142. package/ios/Popup/PopupNotify.swift +3 -4
  143. package/ios/ProgressInfo/ProgressInfo.swift +4 -2
  144. package/ios/Radio/Radio.swift +12 -13
  145. package/ios/Rating/Rating.swift +1 -1
  146. package/ios/Resources/MoMoUIKitsColors.xcassets/AccentColor.colorset/Contents.json +11 -0
  147. package/ios/Resources/MoMoUIKitsColors.xcassets/Background.colorset/Contents.json +38 -0
  148. package/ios/Resources/MoMoUIKitsColors.xcassets/Border.colorset/Contents.json +38 -0
  149. package/ios/Resources/MoMoUIKitsColors.xcassets/Card.colorset/Contents.json +38 -0
  150. package/ios/Resources/MoMoUIKitsColors.xcassets/Contents.json +6 -0
  151. package/ios/Resources/MoMoUIKitsColors.xcassets/Error.colorset/Contents.json +38 -0
  152. package/ios/Resources/MoMoUIKitsColors.xcassets/Primary.colorset/Contents.json +38 -0
  153. package/ios/Resources/MoMoUIKitsColors.xcassets/PrimaryDark.colorset/Contents.json +38 -0
  154. package/ios/Resources/MoMoUIKitsColors.xcassets/PrimaryLight.colorset/Contents.json +38 -0
  155. package/ios/Resources/MoMoUIKitsColors.xcassets/Secondary.colorset/Contents.json +38 -0
  156. package/ios/Resources/MoMoUIKitsColors.xcassets/Success.colorset/Contents.json +38 -0
  157. package/ios/Resources/MoMoUIKitsColors.xcassets/Text.colorset/Contents.json +38 -0
  158. package/ios/Resources/MoMoUIKitsColors.xcassets/TextSecondary.colorset/Contents.json +38 -0
  159. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/Contents.json +9 -0
  160. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-default.colorset/Contents.json +38 -0
  161. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-disable.colorset/Contents.json +38 -0
  162. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-pressed.colorset/Contents.json +38 -0
  163. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-selected.colorset/Contents.json +38 -0
  164. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-surface.colorset/Contents.json +38 -0
  165. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-tonal.colorset/Contents.json +38 -0
  166. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/border-default.colorset/Contents.json +38 -0
  167. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/border-disable.colorset/Contents.json +38 -0
  168. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/gradient.colorset/Contents.json +38 -0
  169. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/primary.colorset/Contents.json +38 -0
  170. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/secondary.colorset/Contents.json +38 -0
  171. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-container.colorset/Contents.json +38 -0
  172. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-primary.colorset/Contents.json +38 -0
  173. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-secondary.colorset/Contents.json +38 -0
  174. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-default.colorset/Contents.json +38 -0
  175. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-disable.colorset/Contents.json +38 -0
  176. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-hint.colorset/Contents.json +38 -0
  177. package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-secondary.colorset/Contents.json +38 -0
  178. package/ios/Resources/MoMoUIKitsColors.xcassets/Warning.colorset/Contents.json +38 -0
  179. package/ios/Stepper/Stepper.swift +2 -2
  180. package/ios/Steps/Steps.swift +22 -6
  181. package/ios/SuggestAction/SuggestAction.swift +5 -3
  182. package/ios/Swipeable/SwipeCell.swift +5 -3
  183. package/ios/Switch/Switch.swift +53 -28
  184. package/ios/TabView/TabView.swift +18 -14
  185. package/ios/Template/TrustBanner/TrustBanner.swift +6 -7
  186. package/ios/Tooltip/Tooltip.swift +3 -0
  187. package/ios/Typography/FontScaleStore.swift +19 -0
  188. package/ios/Typography/Text.swift +3 -0
  189. package/ios/Typography/Typography.swift +8 -5
  190. package/ios/Uploader/Uploader.swift +0 -9
  191. package/ios/native-kits.podspec +6 -3
  192. package/ios-demo/MoMoUIKitsDemo.podspec +5 -3
  193. package/ios-demo/Sources/MoMoUIKitsDemo/MoMoUIKitsDemoFactory.swift +9 -57
  194. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/Home.swift +21 -3
  195. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +188 -0
  196. package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +2 -0
  197. package/ios-demo/Sources/MoMoUIKitsDemo/SwiftUIDemoBrowserView.swift +5 -4
  198. package/package.json +1 -1
@@ -1,44 +1,69 @@
1
1
  import Foundation
2
2
  import SwiftUI
3
3
 
4
- public struct Switch: View{
4
+ public struct Switch: View {
5
5
  @Binding var value: Bool
6
6
  var disabled: Bool
7
- var onChange: ((Bool)->Void)?
8
-
9
- public init(_ value: Binding<Bool>,disabled: Bool = false, onChange: ((Bool)->Void)? = nil){
7
+ var onChange: ((Bool) -> Void)?
8
+ var title: String?
9
+ var accessibilityId: String?
10
+
11
+ public init(
12
+ _ value: Binding<Bool>,
13
+ disabled: Bool = false,
14
+ onChange: ((Bool) -> Void)? = nil,
15
+ title: String? = "",
16
+ accessibilityId: String? = ""
17
+ ) {
10
18
  self._value = value
11
19
  self.disabled = disabled
12
20
  self.onChange = onChange
21
+ self.title = title
22
+ self.accessibilityId = accessibilityId
23
+ }
24
+
25
+ // Mirrors Kotlin's `backgroundColor`: shared by the track AND the inner dot.
26
+ private var backgroundColor: Color {
27
+ switch (disabled, value) {
28
+ case (true, true): return Colors.green09
29
+ case (true, false): return Colors.black05
30
+ case (false, true): return Colors.green03
31
+ case (false, false): return Colors.black07
32
+ }
33
+ }
34
+
35
+ // Mirrors Kotlin's `circleBackgroundColor` (the outer 14pt thumb circle).
36
+ private var circleColor: Color {
37
+ value ? Colors.black01 : Colors.black03
13
38
  }
14
-
15
-
39
+
40
+ private var automationId: String {
41
+ accessibilityId?.isEmpty == false ? accessibilityId! : "toggle_\(title?.isEmpty == false ? title! : "unknown")_\(value)"
42
+ }
43
+
16
44
  public var body: some View {
17
45
  SwiftUI.Button(action: {
18
- withAnimation{
46
+ withAnimation {
19
47
  value.toggle()
20
48
  onChange?(value)
21
49
  }
22
- }){
23
- HStack{
24
- HStack {
25
- }
26
- .frame(width: 6, height: 6)
27
- .background(value ? Colors.pink03 : Colors.black07)
28
- .clipShape(Circle())
29
- .opacity(disabled ? 0.4 : 1)
30
- }
31
- .frame(width: 14, height: 14)
32
- .background(Colors.black01)
33
- .clipShape(Circle())
34
- .padding(.leading,5)
35
- .padding(.trailing,5)
36
-
37
- }
38
- .disabled(disabled)
39
- .frame(width: 40, height: 24, alignment: value == true ? .trailing : .leading)
40
- .background(value ? Colors.pink03 : Colors.black07)
41
- .clipShape(Capsule())
42
- .opacity(disabled ? 0.4 : 1)
50
+ }) {
51
+ HStack {
52
+ HStack {}
53
+ .frame(width: 6, height: 6)
54
+ .background(backgroundColor)
55
+ .clipShape(Circle())
56
+ }
57
+ .frame(width: 14, height: 14)
58
+ .background(circleColor)
59
+ .clipShape(Circle())
60
+ .padding(.leading, Spacing.XS)
61
+ .padding(.trailing, Spacing.XS)
62
+ }
63
+ .disabled(disabled)
64
+ .frame(width: 38, height: 20, alignment: value ? .trailing : .leading)
65
+ .background(backgroundColor)
66
+ .clipShape(Capsule())
67
+ .accessibilityIdentifier(automationId)
43
68
  }
44
69
  }
@@ -363,13 +363,15 @@ private struct CardTabBar: View {
363
363
  let isActive = selectedIndex == index
364
364
  let iconColor = isActive ? selectedColor : unselectedColor
365
365
 
366
- cardItem(tab: tab, isActive: isActive, iconColor: iconColor)
367
- .frame(maxWidth: .infinity)
368
- .frame(height: isActive ? 44 : 40)
369
- .background(isActive ? theme.colors.background.surface : theme.colors.background.tonal)
370
- .clipShape(UnstyledRoundedRectangle(topLeft: Radius.M, topRight: Radius.M))
371
- .contentShape(Rectangle())
372
- .onTapGesture { onPress(index) }
366
+ SwiftUI.Button(action: { onPress(index) }) {
367
+ cardItem(tab: tab, isActive: isActive, iconColor: iconColor)
368
+ .frame(maxWidth: .infinity)
369
+ .frame(height: isActive ? 44 : 40)
370
+ .background(isActive ? theme.colors.background.surface : theme.colors.background.tonal)
371
+ .clipShape(UnstyledRoundedRectangle(topLeft: Radius.M, topRight: Radius.M))
372
+ .contentShape(Rectangle())
373
+ }
374
+ .buttonStyle(ActiveOpacityButtonStyle())
373
375
  }
374
376
  }
375
377
  .frame(maxWidth: .infinity)
@@ -416,15 +418,17 @@ private struct TabItemView: View {
416
418
  private var textStyle: TypographyStyle { active ? .headerSSemibold : .bodyDefaultRegular }
417
419
 
418
420
  var body: some View {
419
- Group {
420
- if direction == .column {
421
- columnBody
422
- } else {
423
- rowBody
421
+ SwiftUI.Button(action: onPress) {
422
+ Group {
423
+ if direction == .column {
424
+ columnBody
425
+ } else {
426
+ rowBody
427
+ }
424
428
  }
429
+ .contentShape(Rectangle())
425
430
  }
426
- .contentShape(Rectangle())
427
- .onTapGesture { onPress() }
431
+ .buttonStyle(ActiveOpacityButtonStyle())
428
432
  }
429
433
 
430
434
  @ViewBuilder
@@ -52,15 +52,14 @@ let defaultBanner = TrustBannerData(
52
52
 
53
53
  public struct TrustBanner: View {
54
54
  @EnvironmentObject var applicationEnvironment: ApplicationEnvironment
55
-
55
+ @EnvironmentObject private var localize: Localize
56
+
56
57
  var onPress: ((String)->Void)?
57
-
58
+
58
59
  public init(onPress: ((String)->Void)?) {
59
60
  self.onPress = onPress
60
61
  }
61
-
62
- var language: String? = "vi"
63
-
62
+
64
63
  func onPressSecurity() {
65
64
  if (onPress != nil) {
66
65
  onPress!(applicationEnvironment.config?.trustBanner?.urlConfig ?? defaultBanner.urlConfig)
@@ -75,7 +74,7 @@ public struct TrustBanner: View {
75
74
  .scaledToFit()
76
75
  .frame(width: 64, height: 64)
77
76
  VStack(alignment: .leading){
78
- Text(applicationEnvironment.config?.trustBanner?.content[language ?? "vi"] as? String ?? defaultBanner.content[language ?? "vi"])
77
+ Text(applicationEnvironment.config?.trustBanner?.content[localize.currentLanguage] ?? defaultBanner.content[localize.currentLanguage])
79
78
  .foregroundColor(Color(hex: "484848"))
80
79
  .lineLimit(2)
81
80
  .font(.system(size: 13, weight: Font.Weight.regular))
@@ -84,7 +83,7 @@ public struct TrustBanner: View {
84
83
  .padding(.bottom, 8)
85
84
  HStack {
86
85
  HStack(spacing: 0) {
87
- Text(applicationEnvironment.config?.trustBanner?.subContent[language ?? "vi"] as? String ?? defaultBanner.subContent[language ?? "vi"])
86
+ Text(applicationEnvironment.config?.trustBanner?.subContent[localize.currentLanguage] ?? defaultBanner.subContent[localize.currentLanguage])
88
87
  .foregroundColor(Colors.pink03)
89
88
  .font(.system(size: 13, weight: .bold))
90
89
  .ignoreBoldTextSetting()
@@ -462,6 +462,9 @@ private struct TooltipSecondaryButton: View {
462
462
  .padding(.vertical, Spacing.S)
463
463
  }
464
464
  .buttonStyle(.plain)
465
+ // Mirrors Compose's `Modifier.weight(1f, fill = false)` on the secondary button:
466
+ // it yields space to the primary button first under width pressure.
467
+ .layoutPriority(-1)
465
468
  }
466
469
  }
467
470
 
@@ -0,0 +1,19 @@
1
+ import CoreGraphics
2
+
3
+ /// App-wide font-scale preference for the SwiftUI kit. An exported holder the host writes once at
4
+ /// app startup (from the cache-backed `FontScaleProvider`); `scaleSize`/`appFont` read the snapshot.
5
+ /// No realtime: the SwiftUI kit has no navigation container to scope reactive updates, so a startup
6
+ /// snapshot is enough. When `useOSScaleRate` is false the kit applies `userScaleRate` instead of the
7
+ /// OS Dynamic Type factor.
8
+ public final class FontScaleStore {
9
+ public static let shared = FontScaleStore()
10
+ private init() {}
11
+
12
+ public private(set) var userScaleRate: CGFloat = 1
13
+ public private(set) var useOSScaleRate: Bool = true
14
+
15
+ public func update(userScaleRate: CGFloat, useOSScaleRate: Bool) {
16
+ self.userScaleRate = userScaleRate
17
+ self.useOSScaleRate = useOSScaleRate
18
+ }
19
+ }
@@ -1,6 +1,9 @@
1
1
  import SwiftUI
2
2
 
3
3
  public func scaleSize(_ size: CGFloat, _ scaleRate: CGFloat? = nil) -> CGFloat {
4
+ if !FontScaleStore.shared.useOSScaleRate {
5
+ return size * FontScaleStore.shared.userScaleRate
6
+ }
4
7
  let defaultScreenSize: CGFloat = 375
5
8
  let maxFontScale: CGFloat = scaleRate ?? 1.5
6
9
  let maxDeviceScale: CGFloat = 5
@@ -11,13 +11,16 @@ public extension View {
11
11
 
12
12
  public extension Font {
13
13
  static func appFont(size: CGFloat) -> Font {
14
+ if !FontScaleStore.shared.useOSScaleRate {
15
+ return Font.system(size: size * FontScaleStore.shared.userScaleRate)
16
+ }
14
17
  let defaultScreenSize: CGFloat = 375
15
18
  let maxFontScale: CGFloat = 1.5
16
19
  let maxDeviceScale: CGFloat = 5
17
-
20
+
18
21
  let deviceWidth = UIScreen.main.bounds.width
19
22
  let deviceScale = deviceWidth / defaultScreenSize
20
-
23
+
21
24
  let defaultFont = UIFont.systemFont(ofSize: UIFont.labelFontSize)
22
25
  let scaledFont = UIFontMetrics.default.scaledFont(for: defaultFont)
23
26
  let fontScale = scaledFont.pointSize / defaultFont.pointSize
@@ -34,7 +37,7 @@ public extension Font {
34
37
 
35
38
  return Font.system(size: fontSize)
36
39
  }
37
-
40
+
38
41
  // New supported typography styles
39
42
  static let headline_default_bold = appFont(size: 24).weight(.bold)
40
43
  static let header_m_bold = appFont(size: 18).weight(.bold)
@@ -52,7 +55,7 @@ public extension Font {
52
55
  static let action_s_bold = appFont(size: 14).weight(.bold)
53
56
  static let action_xs_bold = appFont(size: 12).weight(.bold)
54
57
  static let action_xxs_bold = appFont(size: 10).weight(.bold)
55
-
58
+
56
59
  // Legacy styles
57
60
  static let headline_default = appFont(size: 28).weight(.semibold)
58
61
  static let headline_s = appFont(size: 24).weight(.semibold)
@@ -77,7 +80,7 @@ public extension Font {
77
80
  static let action_xxs = appFont(size: 10).weight(.bold)
78
81
  static let action_xs = appFont(size: 12).weight(.bold)
79
82
  static let action_s = appFont(size: 15).weight(.bold)
80
-
83
+
81
84
  // deprecated
82
85
  static let h1 = appFont(size: 36).weight(.semibold) //headline_xl
83
86
  static let h2 = appFont(size: 32).weight(.semibold)
@@ -172,12 +172,3 @@ private struct UploaderImageItem: View {
172
172
  .buttonStyle(ActiveOpacityButtonStyle())
173
173
  }
174
174
  }
175
-
176
- // MARK: - Active opacity button style
177
-
178
- private struct ActiveOpacityButtonStyle: ButtonStyle {
179
- func makeBody(configuration: Configuration) -> some View {
180
- configuration.label
181
- .opacity(configuration.isPressed ? 0.5 : 1)
182
- }
183
- }
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = 'MoMoUIKits'
3
- s.version = '0.162.2-sp.1'
3
+ s.version = '0.162.2-sp.10'
4
4
  s.summary = 'MoMoUIKits for iOS'
5
5
  s.homepage = 'https://momo.vn'
6
6
  s.license = { :type => 'MIT' }
@@ -60,12 +60,15 @@ Pod::Spec.new do |s|
60
60
  "Typography/**/*.{swift,m,h}",
61
61
  "Uploader/**/*.{swift,m,h}"
62
62
  ]
63
+ s.resource_bundles = {
64
+ 'MoMoUIKitsResources' => ['Resources/**/*']
65
+ }
63
66
  s.public_header_files = "StatusBarTap/*.h"
64
67
  s.frameworks = 'SwiftUI', 'Combine'
65
68
  s.pod_target_xcconfig = {
66
69
  'DEFINES_MODULE' => 'YES'
67
70
  }
68
- s.dependency 'SDWebImageSwiftUI', '2.2.3'
69
- s.dependency 'lottie-ios', '4.5.2'
71
+ s.dependency 'SDWebImageSwiftUI', '2.2.1'
72
+ s.dependency 'lottie-ios', '4.6.0'
70
73
  s.dependency 'SkeletonUI', '1.0.11'
71
74
  end
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = 'MoMoUIKitsDemo'
3
- s.version = '0.162.2-sp.1'
3
+ s.version = '0.162.2-sp.10'
4
4
  s.summary = 'Demo browser for MoMoUIKits SwiftUI components'
5
5
  s.homepage = 'https://momo.vn'
6
6
  s.license = { :type => 'MIT' }
@@ -11,8 +11,10 @@ Pod::Spec.new do |s|
11
11
  s.swift_version = '5.0'
12
12
 
13
13
  s.source_files = 'Sources/**/*.{swift}'
14
- s.resources = 'Resources/**/*'
14
+ s.resource_bundles = {
15
+ 'MoMoUIKitsDemoResources' => ['Resources/**/*']
16
+ }
15
17
  s.frameworks = 'SwiftUI', 'UIKit'
16
18
  s.dependency 'MoMoUIKits'
17
- s.dependency 'lottie-ios', '4.5.2'
19
+ s.dependency 'lottie-ios', '4.6.0'
18
20
  end
@@ -6,67 +6,19 @@ public enum MoMoUIKitsDemoViewControllerFactory {
6
6
  public static func make(
7
7
  context: MoMoUIKitsDemoContext = MoMoUIKitsDemoContext(),
8
8
  composeViewController: (() -> UIViewController)? = nil
9
+ ) -> UIViewController {
10
+ composeViewController?() ?? makeSwiftUI(context: context)
11
+ }
12
+
13
+ public static func makeSwiftUI(
14
+ context: MoMoUIKitsDemoContext = MoMoUIKitsDemoContext(),
15
+ onOpenCompose: @escaping () -> Void = {}
9
16
  ) -> UIViewController {
10
17
  UIHostingController(
11
- rootView: MoMoUIKitsDemoView(
18
+ rootView: SwiftUIDemoBrowserView(
12
19
  context: context,
13
- composeViewController: composeViewController
20
+ onOpenCompose: onOpenCompose
14
21
  )
15
22
  )
16
23
  }
17
24
  }
18
-
19
- public struct MoMoUIKitsDemoView: View {
20
- private let context: MoMoUIKitsDemoContext
21
- private let composeViewController: (() -> UIViewController)?
22
- @State private var mode: MoMoUIKitsDemoMode
23
-
24
- public init(
25
- context: MoMoUIKitsDemoContext = MoMoUIKitsDemoContext(),
26
- composeViewController: (() -> UIViewController)? = nil
27
- ) {
28
- self.context = context
29
- self.composeViewController = composeViewController
30
- _mode = State(initialValue: composeViewController == nil ? .swiftUI : .compose)
31
- }
32
-
33
- public var body: some View {
34
- VStack(spacing: 0) {
35
- Picker("", selection: $mode) {
36
- if composeViewController != nil {
37
- Text("Compose").tag(MoMoUIKitsDemoMode.compose)
38
- }
39
- Text("SwiftUI").tag(MoMoUIKitsDemoMode.swiftUI)
40
- }
41
- .pickerStyle(.segmented)
42
- .padding(.horizontal, 16)
43
- .padding(.vertical, 12)
44
- .background(Color(.systemBackground))
45
-
46
- Group {
47
- if mode == .compose, let composeViewController {
48
- ComposeDemoHostView(makeViewController: composeViewController)
49
- } else {
50
- SwiftUIDemoBrowserView(context: context)
51
- }
52
- }
53
- .frame(maxWidth: .infinity, maxHeight: .infinity)
54
- }
55
- }
56
- }
57
-
58
- private enum MoMoUIKitsDemoMode: String {
59
- case compose
60
- case swiftUI
61
- }
62
-
63
- private struct ComposeDemoHostView: UIViewControllerRepresentable {
64
- let makeViewController: () -> UIViewController
65
-
66
- func makeUIViewController(context: Context) -> UIViewController {
67
- makeViewController()
68
- }
69
-
70
- func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
71
- }
72
-
@@ -89,6 +89,7 @@ public let ScreenUsages: [ScreenUsage] = [
89
89
  ScreenUsage(title: "Bottom Tab", destination: AnyView(BottomTabDemo()), icon: getIcon(icon: "Layout")),
90
90
  ScreenUsage(title: "Animated Header", destination: AnyView(AnimatedHeaderDemo()), icon: getIcon(icon: "Layout")),
91
91
  ScreenUsage(title: "Theme", destination: AnyView(ThemeDemo()), icon: getIcon(icon: "Typography")),
92
+ ScreenUsage(title: "Localize", destination: AnyView(LocalizeDemo()), icon: getIcon(icon: "Typography")),
92
93
  ]
93
94
 
94
95
  @available(iOS 16.0, *)
@@ -96,8 +97,22 @@ public struct HomeView: View {
96
97
  // Mirrors Compose's `inputSearch` state: bound into the header search and
97
98
  // forwarded into the content for filtering.
98
99
  @State private var searchText = ""
100
+ private let onOpenCompose: () -> Void
101
+ private let applicationContext: MiniAppContext?
102
+ private let composeApi: KitComposeApi?
103
+ private let config: KitConfig?
99
104
 
100
- public init() {}
105
+ public init(
106
+ onOpenCompose: @escaping () -> Void = {},
107
+ applicationContext: MiniAppContext? = nil,
108
+ composeApi: KitComposeApi? = nil,
109
+ config: KitConfig? = nil
110
+ ) {
111
+ self.onOpenCompose = onOpenCompose
112
+ self.applicationContext = applicationContext
113
+ self.composeApi = composeApi
114
+ self.config = config
115
+ }
101
116
 
102
117
  public var body: some View {
103
118
  NavigationContainer(
@@ -124,7 +139,7 @@ public struct HomeView: View {
124
139
  AnyView(
125
140
  MoMoUIKits.Button(
126
141
  title: "Footer Button",
127
- action: { print("Footer Button") },
142
+ action: onOpenCompose,
128
143
  type: .primary,
129
144
  size: .large
130
145
  )
@@ -179,7 +194,10 @@ public struct HomeView: View {
179
194
  position: .right,
180
195
  bottomPadding: nil
181
196
  )
182
- )
197
+ ),
198
+ applicationContext: applicationContext,
199
+ composeApi: composeApi,
200
+ config: config
183
201
  )
184
202
  }
185
203
  }
@@ -0,0 +1,188 @@
1
+ //
2
+ // LocalizeDemo.swift
3
+ // MoMoUIKitsDemo
4
+ //
5
+ // SwiftUI port of the Compose demo `sample/shared/.../screens/LocalizeUsage.kt`,
6
+ // showcasing the `Localize` i18n port (ios/Application/Localize.swift).
7
+ // Synced from sample/iosApp/iosApp/Demo/LocalizeDemo.swift.
8
+ //
9
+
10
+ import MoMoUIKits
11
+ import SwiftUI
12
+
13
+ // App-specific dictionary. Keys here do NOT exist in the kit defaults, so addTranslations
14
+ // registers them cleanly (addTranslations keeps existing keys on clash, host-default wins).
15
+ private let AppTranslations = LocalizationObject(
16
+ vi: [
17
+ "demo_greeting": "Xin chào MoMo!",
18
+ "demo_cart_title": "Giỏ hàng của bạn",
19
+ ],
20
+ en: [
21
+ "demo_greeting": "Hello MoMo!",
22
+ "demo_cart_title": "Your cart",
23
+ ]
24
+ )
25
+
26
+ struct LocalizeDemo: View {
27
+ @EnvironmentObject private var localize: Localize
28
+
29
+ private var isEnglish: Bool { localize.currentLanguage == Localize.EN }
30
+
31
+ var body: some View {
32
+ ScrollView {
33
+ VStack(alignment: .leading, spacing: 0) {
34
+
35
+ LocalizeSectionBox(title: "Đổi ngôn ngữ (toàn app)") {
36
+ MomoText(
37
+ "localize.changeLanguage(...) đổi ngôn ngữ cho cả NavigationContainer — mọi màn hình đang đọc translate() sẽ cập nhật theo.",
38
+ typography: .descriptionDefaultRegular
39
+ )
40
+ Switch(
41
+ .constant(isEnglish),
42
+ onChange: { _ in localize.changeLanguage(isEnglish ? Localize.VI : Localize.EN) },
43
+ title: "English"
44
+ )
45
+ MomoText("currentLanguage = \(localize.currentLanguage)", typography: .labelDefaultMedium)
46
+ }
47
+
48
+ LocalizeSectionBox(title: "translate(key) — từ điển mặc định của kit") {
49
+ TranslationRow(key: "confirm", value: localize.translate("confirm"))
50
+ TranslationRow(key: "cancel", value: localize.translate("cancel"))
51
+ TranslationRow(key: "done", value: localize.translate("done"))
52
+ TranslationRow(key: "seeMore", value: localize.translate("seeMore"))
53
+ TranslationRow(key: "balance", value: localize.translate("balance"))
54
+ }
55
+
56
+ LocalizeSectionBox(title: "Key thiếu → trả về chính key") {
57
+ MomoText(
58
+ "translate() với key không có (hoặc giá trị rỗng) sẽ trả lại đúng key để dễ phát hiện thiếu bản dịch.",
59
+ typography: .descriptionDefaultRegular
60
+ )
61
+ TranslationRow(key: "not_a_real_key", value: localize.translate("not_a_real_key"))
62
+ }
63
+
64
+ LocalizeSectionBox(title: "Chèn tham số vào bản dịch") {
65
+ MomoText(
66
+ "Bản port không tự nội suy {placeholder} — tự replace ở nơi dùng.",
67
+ typography: .descriptionDefaultRegular
68
+ )
69
+ TranslationRow(
70
+ key: "voucherRemindHour",
71
+ value: localize.translate("voucherRemindHour").replacingOccurrences(of: "{hours}", with: "3")
72
+ )
73
+ }
74
+
75
+ LocalizeSectionBox(title: "translateData(vi:en:) — dịch nội tuyến") {
76
+ MomoText(
77
+ "Cho chuỗi dùng một lần, không cần khai báo key trong từ điển.",
78
+ typography: .descriptionDefaultRegular
79
+ )
80
+ MomoText(localize.translateData(vi: "Thanh toán ngay", en: "Pay now"), typography: .headerDefaultBold)
81
+ }
82
+
83
+ LocalizeSectionBox(title: "translateData(map) — chọn theo ngôn ngữ") {
84
+ MomoText(
85
+ localize.translateData([
86
+ Localize.VI: "Lịch sử giao dịch",
87
+ Localize.EN: "Transaction history",
88
+ ]),
89
+ typography: .headerDefaultBold
90
+ )
91
+ }
92
+
93
+ LocalizeSectionBox(title: "addTranslations — từ điển riêng của app") {
94
+ MomoText(
95
+ "Host đăng ký key riêng (đã add khi màn hình xuất hiện), rồi dùng translate() như key mặc định.",
96
+ typography: .descriptionDefaultRegular
97
+ )
98
+ TranslationRow(key: "demo_greeting", value: localize.translate("demo_greeting"))
99
+ TranslationRow(key: "demo_cart_title", value: localize.translate("demo_cart_title"))
100
+ }
101
+
102
+ LocalizeSectionBox(title: "Ví dụ thực tế") {
103
+ // errorCode already ends with a separator ("Mã lỗi: " / "Error code: ").
104
+ MomoText(localize.translate("errorCode") + "E-4097", typography: .bodyDefaultRegular)
105
+ HStack(spacing: Spacing.M) {
106
+ Button(
107
+ title: localize.translate("cancel"),
108
+ action: {},
109
+ type: .outline,
110
+ size: .medium,
111
+ isFull: false
112
+ )
113
+ Button(
114
+ title: localize.translate("confirm"),
115
+ action: {},
116
+ type: .primary,
117
+ size: .medium,
118
+ isFull: false
119
+ )
120
+ }
121
+ }
122
+
123
+ Spacer(minLength: 32)
124
+ }
125
+ }
126
+ // Registers the app-specific dictionary once per appearance; addTranslations'
127
+ // merge is idempotent, so re-entry (e.g. re-navigating back to this screen) is safe.
128
+ .onAppear {
129
+ localize.addTranslations(AppTranslations)
130
+ }
131
+ }
132
+ }
133
+
134
+ // MARK: - LocalizeSectionBox
135
+
136
+ /// Titled rounded-card section container, mirroring Compose's `BasicColumnBox`
137
+ /// (title label above a `theme.colors.background.surface` card with `Radius.M` corners).
138
+ private struct LocalizeSectionBox<Content: View>: View {
139
+ @Environment(\.appTheme) private var theme
140
+ let title: String
141
+ @ViewBuilder let content: () -> Content
142
+
143
+ var body: some View {
144
+ VStack(alignment: .leading, spacing: 8) {
145
+ if !title.isEmpty {
146
+ MomoText(title, typography: .headerMBold)
147
+ .padding(.top, 8)
148
+ }
149
+
150
+ VStack(alignment: .leading, spacing: 8) {
151
+ content()
152
+ }
153
+ .frame(maxWidth: .infinity, alignment: .leading)
154
+ .padding(12)
155
+ .background(theme.colors.background.surface)
156
+ .clipShape(RoundedRectangle(cornerRadius: Radius.M))
157
+ }
158
+ .padding(12)
159
+ }
160
+ }
161
+
162
+ // MARK: - TranslationRow
163
+
164
+ private struct TranslationRow: View {
165
+ @Environment(\.appTheme) private var theme
166
+ let key: String
167
+ let value: String
168
+
169
+ var body: some View {
170
+ VStack(alignment: .leading, spacing: 2) {
171
+ MomoText(key, typography: .labelDefaultMedium, color: theme.colors.text.secondary)
172
+ MomoText(value, typography: .bodyDefaultRegular)
173
+ }
174
+ }
175
+ }
176
+
177
+ // MARK: - Preview
178
+
179
+ #Preview {
180
+ if #available(iOS 16.0, *) {
181
+ NavigationStack {
182
+ LocalizeDemo()
183
+ .environmentObject(Localize())
184
+ }
185
+ } else {
186
+ // Fallback on earlier versions
187
+ }
188
+ }
@@ -23,6 +23,7 @@ struct NavigationDemo: View {
23
23
  @available(iOS 16.0, *)
24
24
  private struct NavigationDemoContent: View {
25
25
  @EnvironmentObject private var navigator: Navigator
26
+ @State private var textValue1 = ""
26
27
 
27
28
  var body: some View {
28
29
  ScrollView {
@@ -72,6 +73,7 @@ private struct NavigationDemoContent: View {
72
73
  row("Show Bottom Sheet") {
73
74
  navigator.showBottomSheet({
74
75
  VStack(spacing: 12) {
76
+ Input(text: $textValue1, placeholder: "Test Bottom Sheet")
75
77
  ForEach(0..<4, id: \.self) { i in
76
78
  MomoText("Bottom sheet row \(i + 1)")
77
79
  .frame(maxWidth: .infinity, alignment: .leading)