@momo-kits/native-kits 0.162.6 → 0.163.1-beta.1-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 (166) hide show
  1. package/CLAUDE.md +78 -0
  2. package/build.gradle.kts +11 -0
  3. package/compose/build.gradle.kts +186 -0
  4. package/compose/build.gradle.kts.backup +186 -0
  5. package/compose/compose.podspec +47 -0
  6. package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +6 -0
  7. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +123 -0
  8. package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
  9. package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
  10. package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
  11. package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
  12. package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
  13. package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
  14. package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
  15. package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
  16. package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
  17. package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
  18. package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
  19. package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
  20. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
  21. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
  22. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +57 -0
  23. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +109 -0
  24. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +201 -0
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +222 -0
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +48 -0
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +86 -0
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +76 -0
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +76 -0
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +305 -0
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +33 -0
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +921 -0
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +269 -0
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +120 -0
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +403 -0
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +69 -0
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +85 -0
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +340 -0
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +198 -0
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +357 -0
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +123 -0
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +94 -0
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +136 -0
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +224 -0
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +543 -0
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +23 -0
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +76 -0
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +148 -0
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +188 -0
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +116 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +452 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +172 -0
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +255 -0
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +235 -0
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +233 -0
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +259 -0
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +241 -0
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +364 -0
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +41 -0
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +92 -0
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +40 -0
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +352 -0
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +103 -0
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +338 -0
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +70 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +17 -0
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +96 -0
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +348 -0
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +256 -0
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +494 -0
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +131 -0
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +215 -0
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +96 -0
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +531 -0
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +92 -0
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +135 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +214 -0
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +590 -0
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +177 -0
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +192 -0
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +205 -0
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +239 -0
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +191 -0
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +306 -0
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +16 -0
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +188 -0
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +285 -0
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +2 -0
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +35 -0
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +2 -0
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +57 -0
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +68 -0
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +14 -0
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +50 -0
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +253 -0
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +133 -0
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +104 -0
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +135 -0
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +345 -0
  109. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +8 -0
  110. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +556 -0
  111. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +161 -0
  112. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +243 -0
  113. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +86 -0
  114. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +187 -0
  115. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +315 -0
  116. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +80 -0
  117. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +306 -0
  118. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +34 -0
  119. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +370 -0
  120. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +131 -0
  121. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +167 -0
  122. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +72 -0
  123. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +66 -0
  124. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
  125. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +70 -0
  126. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +15 -0
  127. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +105 -0
  128. package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +33 -0
  129. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +186 -0
  130. package/example/ios/Example.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  131. package/example/ios/Example.xcworkspace/xcuserdata/huynhdung.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  132. package/example/ios/Example.xcworkspace/xcuserdata/huynhdung.xcuserdatad/xcschemes/xcschememanagement.plist +5 -0
  133. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/MoMoUIKits.xcscheme +58 -0
  134. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/Pods-Example.xcscheme +58 -0
  135. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/SDWebImage.xcscheme +58 -0
  136. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/SDWebImageSwiftUI.xcscheme +58 -0
  137. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/SkeletonUI.xcscheme +58 -0
  138. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/xcschememanagement.plist +46 -0
  139. package/gradle/libs.versions.toml +67 -0
  140. package/gradle/wrapper/gradle-wrapper.jar +0 -0
  141. package/gradle/wrapper/gradle-wrapper.properties +8 -0
  142. package/gradle.properties +26 -0
  143. package/gradlew +252 -0
  144. package/gradlew.bat +94 -0
  145. package/ios/Application/ApplicationEnvironment.swift +0 -1
  146. package/ios/Application/Components.swift +0 -1
  147. package/ios/Application/FloatingButton.swift +0 -1
  148. package/ios/Badge/Badge.swift +0 -1
  149. package/ios/Badge/BadgeRibbon.swift +0 -2
  150. package/ios/Button/Button.swift +1 -1
  151. package/ios/Checkbox/Checkbox.swift +0 -1
  152. package/ios/Input/Input.swift +0 -1
  153. package/ios/Input/InputPhoneNumber.swift +0 -1
  154. package/ios/Input/InputSearch.swift +0 -3
  155. package/ios/Input/InputTextArea.swift +0 -1
  156. package/ios/OTPKeyboard/KeyboardButton.swift +1 -1
  157. package/ios/Popup/PopupDisplay.swift +0 -6
  158. package/ios/Popup/PopupInput.swift +0 -2
  159. package/ios/Template/TrustBanner/TrustBanner.swift +0 -2
  160. package/ios/Typography/Text.swift +7 -13
  161. package/ios/Typography/Typography.swift +8 -22
  162. package/local.properties +8 -0
  163. package/package.json +1 -1
  164. package/settings.gradle.kts +64 -0
  165. package/ios/Application/FontScaleStore.swift +0 -59
  166. package/ios/Information/Information.swift +0 -151
@@ -223,7 +223,6 @@ public struct InputTextArea: View {
223
223
  onBlur()
224
224
  }
225
225
  }
226
- .ignoreBoldTextSetting()
227
226
  }
228
227
 
229
228
  private var borderColor: Color {
@@ -22,7 +22,7 @@ public struct KeyboardButton: View {
22
22
  public var body: some View {
23
23
  SwiftUI.Button(action: { self.action(key) }) {
24
24
  HStack {
25
- Text(key).font(.system(size: 24, weight: .bold)).ignoreBoldTextSetting()
25
+ Text(key).font(.system(size: 24, weight: .bold))
26
26
  }.frame(maxWidth: CGFloat(width), minHeight: height)
27
27
  .background(color)
28
28
  .foregroundColor(textColor)
@@ -24,7 +24,6 @@ extension View {
24
24
  VStack(spacing: 0) {
25
25
  Text("A")
26
26
  .font(font)
27
- .ignoreBoldTextSetting()
28
27
  .lineLimit(1)
29
28
  .fixedSize()
30
29
  .background(
@@ -36,7 +35,6 @@ extension View {
36
35
 
37
36
  Text("A\nA")
38
37
  .font(font)
39
- .ignoreBoldTextSetting()
40
38
  .lineLimit(2)
41
39
  .fixedSize(horizontal: false, vertical: true)
42
40
  .background(
@@ -223,14 +221,12 @@ public struct PopupDisplay: View {
223
221
  SwiftUI.Button(action: onPressCloseButton) {
224
222
  Text(closeButtonTitle)
225
223
  .font(.action2)
226
- .ignoreBoldTextSetting()
227
224
  }.foregroundColor(Colors.black09)
228
225
  .padding(.trailing, 12)
229
226
 
230
227
  SwiftUI.Button(action: onPressAction) {
231
228
  Text(actionButtonTitle)
232
229
  .font(.action2)
233
- .ignoreBoldTextSetting()
234
230
  }.foregroundColor(Colors.primary)
235
231
  }
236
232
  .frame(maxWidth: .infinity, alignment: .trailing)
@@ -242,14 +238,12 @@ public struct PopupDisplay: View {
242
238
  SwiftUI.Button(action: onPressAction) {
243
239
  Text(actionButtonTitle)
244
240
  .font(.action2)
245
- .ignoreBoldTextSetting()
246
241
  }.foregroundColor(Colors.primary)
247
242
  .padding(.bottom, 6)
248
243
 
249
244
  SwiftUI.Button(action: onPressCloseButton) {
250
245
  Text(closeButtonTitle)
251
246
  .font(.action2)
252
- .ignoreBoldTextSetting()
253
247
  }.foregroundColor(Colors.black09)
254
248
  }
255
249
  .frame(maxWidth: .infinity, alignment: .trailing)
@@ -38,14 +38,12 @@ public struct PopupInput: View {
38
38
  Text(title)
39
39
  .foregroundColor(.black)
40
40
  .font(.headerText1)
41
- .ignoreBoldTextSetting()
42
41
  .padding(.top, 12)
43
42
  .padding(.bottom, 24)
44
43
 
45
44
  Text(description)
46
45
  .foregroundColor(.black)
47
46
  .font(.paragraph)
48
- .ignoreBoldTextSetting()
49
47
  .opacity(0.6)
50
48
  .multilineTextAlignment(.leading)
51
49
  .padding(.bottom, 20)
@@ -79,7 +79,6 @@ public struct TrustBanner: View {
79
79
  .foregroundColor(Color(hex: "484848"))
80
80
  .lineLimit(2)
81
81
  .font(.system(size: 13, weight: Font.Weight.regular))
82
- .ignoreBoldTextSetting()
83
82
  .lineSpacing(3)
84
83
  .padding(.bottom, 8)
85
84
  HStack {
@@ -87,7 +86,6 @@ public struct TrustBanner: View {
87
86
  Text(applicationEnvironment.config?.trustBanner?.subContent[language ?? "vi"] as? String ?? defaultBanner.subContent[language ?? "vi"])
88
87
  .foregroundColor(Colors.pink03)
89
88
  .font(.system(size: 13, weight: .bold))
90
- .ignoreBoldTextSetting()
91
89
  .padding(.trailing, 4)
92
90
 
93
91
  Icon(source: "arrow_chevron_right_small", color: Colors.pink03)
@@ -1,30 +1,27 @@
1
1
  import SwiftUI
2
2
 
3
3
  public func scaleSize(_ size: CGFloat, _ scaleRate: CGFloat? = nil) -> CGFloat {
4
- let config = FontScaleStore.shared.config
5
4
  let defaultScreenSize: CGFloat = 375
6
5
  let maxFontScale: CGFloat = scaleRate ?? 1.5
7
6
  let maxDeviceScale: CGFloat = 5
8
7
 
9
- if !config.useOSFontScale {
10
- let customRate = config.userScaleRate ?? 1
11
- return customRate > 1 ? size * customRate : size
12
- }
13
-
14
- let deviceScale = UIScreen.main.bounds.width / defaultScreenSize
8
+ let deviceWidth = UIScreen.main.bounds.width
9
+ let deviceScale = deviceWidth / defaultScreenSize
15
10
 
16
11
  let defaultFont = UIFont.systemFont(ofSize: UIFont.labelFontSize)
17
12
  let scaledFont = UIFontMetrics.default.scaledFont(for: defaultFont)
18
- let osFontScale = scaledFont.pointSize / defaultFont.pointSize
13
+ let fontScale = scaledFont.pointSize / defaultFont.pointSize
19
14
 
20
15
  var fontSizeDeviceScale = size
21
16
  var fontSizeOSScale = size
22
17
 
18
+
23
19
  if deviceScale > 1 {
24
20
  fontSizeDeviceScale = min(fontSizeDeviceScale * deviceScale, fontSizeDeviceScale + maxDeviceScale)
25
21
  }
26
- if osFontScale > 1 {
27
- fontSizeOSScale = min(fontSizeOSScale * osFontScale, fontSizeOSScale * maxFontScale)
22
+
23
+ if fontScale > 1 {
24
+ fontSizeOSScale = min(fontSizeOSScale * fontScale, fontSizeOSScale * maxFontScale)
28
25
  }
29
26
 
30
27
  return max(fontSizeDeviceScale, fontSizeOSScale)
@@ -121,7 +118,6 @@ public struct MomoText: View {
121
118
  private let content: String
122
119
  private let typography: TypographyStyle
123
120
  private let color: Color
124
- @ObservedObject private var fontScale = FontScaleStore.shared
125
121
 
126
122
  public init(
127
123
  _ content: String,
@@ -134,13 +130,11 @@ public struct MomoText: View {
134
130
  }
135
131
 
136
132
  public var body: some View {
137
- _ = fontScale.config
138
133
  let text = SwiftUI.Text(content)
139
134
  .font(.system(size: scaleSize(typography.fontSize), weight: typography.fontWeight))
140
135
  .foregroundColor(color)
141
136
  .lineSpacing(scaleSize(typography.lineHeight) - scaleSize(typography.fontSize))
142
137
 
143
138
  return text
144
- .ignoreBoldTextSetting()
145
139
  }
146
140
  }
@@ -1,40 +1,26 @@
1
1
  import SwiftUI
2
2
 
3
- public extension View {
4
- /// Forces SwiftUI to ignore the OS "Bold Text" accessibility setting so the
5
- /// kit's typography weight stays fixed and matches the Compose implementation
6
- /// (which does not honor that OS setting). Apply it wherever a `.font(...)` is set.
7
- func ignoreBoldTextSetting() -> some View {
8
- environment(\.legibilityWeight, .regular)
9
- }
10
- }
11
-
12
3
  public extension Font {
13
4
  static func appFont(size: CGFloat) -> Font {
14
- let config = FontScaleStore.shared.config
15
5
  let defaultScreenSize: CGFloat = 375
16
6
  let maxFontScale: CGFloat = 1.5
17
7
  let maxDeviceScale: CGFloat = 5
18
-
19
- if !config.useOSFontScale {
20
- let customRate = config.userScaleRate ?? 1
21
- let scaled = customRate > 1 ? size * customRate : size
22
- return Font.system(size: scaled)
23
- }
24
-
25
- let deviceScale = UIScreen.main.bounds.width / defaultScreenSize
26
-
8
+
9
+ let deviceWidth = UIScreen.main.bounds.width
10
+ let deviceScale = deviceWidth / defaultScreenSize
11
+
27
12
  let defaultFont = UIFont.systemFont(ofSize: UIFont.labelFontSize)
28
13
  let scaledFont = UIFontMetrics.default.scaledFont(for: defaultFont)
29
- let osFontScale = scaledFont.pointSize / defaultFont.pointSize
14
+ let fontScale = scaledFont.pointSize / defaultFont.pointSize
30
15
 
31
16
  var fontSize = size
32
17
 
33
18
  if deviceScale > 1 {
34
19
  fontSize = min(fontSize * deviceScale, fontSize + maxDeviceScale)
35
20
  }
36
- if osFontScale > 1 {
37
- fontSize = min(fontSize * osFontScale, fontSize * maxFontScale)
21
+
22
+ if fontScale > 1 {
23
+ fontSize = min(fontSize * fontScale, fontSize * maxFontScale)
38
24
  }
39
25
 
40
26
  return Font.system(size: fontSize)
@@ -0,0 +1,8 @@
1
+ ## This file must *NOT* be checked into Version Control Systems,
2
+ # as it contains information specific to your local configuration.
3
+ #
4
+ # Location of the SDK. This is only used by Gradle.
5
+ # For customization when using a Version Control System, please read the
6
+ # header note.
7
+ #Wed Aug 21 14:20:12 ICT 2024
8
+ sdk.dir=/Users/huynhdung/Library/Android/sdk
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.162.6",
3
+ "version": "0.163.1-beta.1-debug",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},
@@ -0,0 +1,64 @@
1
+ import org.gradle.kotlin.dsl.maven
2
+
3
+ rootProject.name = "momo-native-kits"
4
+ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
5
+
6
+ pluginManagement {
7
+ repositories {
8
+ google {
9
+ mavenContent {
10
+ includeGroupAndSubgroups("androidx")
11
+ includeGroupAndSubgroups("com.android")
12
+ includeGroupAndSubgroups("com.google")
13
+ }
14
+ }
15
+ mavenCentral()
16
+ gradlePluginPortal()
17
+ maven {
18
+ url = uri("https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven")
19
+ credentials {username = "download_packages"; password = "gldt-bjDqLpU_sPcHDuXau2ws" }
20
+ }
21
+ maven {
22
+ url = uri("https://artifacts.mservice.com.vn/repository/maven-momo-app/")
23
+ credentials {
24
+ username = "viewer"
25
+ password = "viewer"
26
+ }
27
+ isAllowInsecureProtocol = true
28
+ }
29
+ }
30
+ }
31
+
32
+ dependencyResolutionManagement {
33
+ repositories {
34
+ google {
35
+ mavenContent {
36
+ includeGroupAndSubgroups("androidx")
37
+ includeGroupAndSubgroups("com.android")
38
+ includeGroupAndSubgroups("com.google")
39
+ }
40
+ }
41
+ mavenCentral()
42
+ maven { url = uri("https://maven.pkg.jetbrains.space/public/p/compose/dev") }
43
+ maven {
44
+ url = uri("https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven")
45
+ credentials {
46
+ username = "download_packages";
47
+ password = "gldt-bjDqLpU_sPcHDuXau2ws"
48
+ }
49
+ }
50
+ maven {
51
+ url = uri("https://artifacts.mservice.com.vn/repository/maven-momo-app/")
52
+ credentials {
53
+ username = "viewer"
54
+ password = "viewer"
55
+ }
56
+ isAllowInsecureProtocol = true
57
+ }
58
+ }
59
+ }
60
+
61
+ include(":compose")
62
+
63
+ include(":sample:androidApp")
64
+ include(":sample:shared")
@@ -1,59 +0,0 @@
1
- import SwiftUI
2
-
3
- public struct FontScaleConfig {
4
- public var useOSFontScale: Bool
5
- public var userScaleRate: CGFloat?
6
-
7
- public init(useOSFontScale: Bool = true, userScaleRate: CGFloat? = nil) {
8
- self.useOSFontScale = useOSFontScale
9
- self.userScaleRate = userScaleRate
10
- }
11
- }
12
-
13
- public final class FontScaleStore: ObservableObject {
14
- public static let shared = FontScaleStore()
15
-
16
- @Published public private(set) var config = FontScaleConfig()
17
-
18
- private var didBind = false
19
- private var observerId: String?
20
-
21
- private init() {}
22
-
23
- public func update(_ newConfig: FontScaleConfig) {
24
- if Thread.isMainThread {
25
- config = newConfig
26
- } else {
27
- DispatchQueue.main.async { [weak self] in self?.config = newConfig }
28
- }
29
- }
30
-
31
- public func bind(_ api: KitComposeApi?) {
32
- guard let api = api, !didBind else { return }
33
- didBind = true
34
-
35
- apply(api.request(funcName: "getFontScaleConfig", params: nil))
36
- observerId = api.request(funcName: "observer", params: ["font_scale_config"]) { [weak self] response in
37
- self?.apply(response)
38
- }
39
- }
40
-
41
- private func apply(_ response: String) {
42
- guard let parsed = FontScaleStore.parse(response) else { return }
43
- update(parsed)
44
- }
45
-
46
- static func parse(_ response: String) -> FontScaleConfig? {
47
- guard
48
- let data = response.data(using: .utf8),
49
- let json = (try? JSONSerialization.jsonObject(with: data)) as? [String: Any]
50
- else { return nil }
51
-
52
- let obj = (json["response"] as? [String: Any]) ?? (json["data"] as? [String: Any]) ?? json
53
- guard obj["useOSFontScale"] != nil || obj["userScaleRate"] != nil else { return nil }
54
-
55
- let useOS = (obj["useOSFontScale"] as? Bool) ?? true
56
- let rate = (obj["userScaleRate"] as? NSNumber).map { CGFloat($0.doubleValue) }
57
- return FontScaleConfig(useOSFontScale: useOS, userScaleRate: rate)
58
- }
59
- }
@@ -1,151 +0,0 @@
1
- import SwiftUI
2
-
3
- public enum InformationState {
4
- case `default`
5
- case warning
6
- case error
7
- }
8
-
9
- public struct Information: View {
10
- private let title: String?
11
- private let description: String
12
- private let state: InformationState
13
- private let image: String?
14
- private let onPressAction: (() -> Void)?
15
- private let showIcon: Bool
16
- private let action: String?
17
- private let showIconClose: Bool
18
- private let onPressClose: (() -> Void)?
19
-
20
- public init(
21
- title: String? = nil,
22
- description: String = "Description",
23
- state: InformationState = .default,
24
- image: String? = nil,
25
- onPressAction: (() -> Void)? = nil,
26
- showIcon: Bool = true,
27
- action: String? = nil,
28
- showIconClose: Bool = true,
29
- onPressClose: (() -> Void)? = nil
30
- ) {
31
- self.title = title
32
- self.description = description
33
- self.state = state
34
- self.image = image
35
- self.onPressAction = onPressAction
36
- self.showIcon = showIcon
37
- self.action = action
38
- self.showIconClose = showIconClose
39
- self.onPressClose = onPressClose
40
- }
41
-
42
- private var borderColor: Color {
43
- switch state {
44
- case .default: return Colors.blue07
45
- case .warning: return Colors.yellow06
46
- case .error: return Colors.red07
47
- }
48
- }
49
-
50
- private var backgroundColor: Color {
51
- switch state {
52
- case .default: return Colors.blue10
53
- case .warning: return Colors.yellow09
54
- case .error: return Colors.red10
55
- }
56
- }
57
-
58
- private var accentColor: Color {
59
- switch state {
60
- case .default: return Colors.blue03
61
- case .warning: return Colors.orange03
62
- case .error: return Colors.red03
63
- }
64
- }
65
-
66
- private var iconSource: String {
67
- switch state {
68
- case .default: return "notifications_info"
69
- case .warning: return "24_notifications_alert_triangle"
70
- case .error: return "24_notifications_alert_octagon"
71
- }
72
- }
73
-
74
- public var body: some View {
75
- VStack(alignment: .leading, spacing: 0) {
76
- HStack(alignment: .top, spacing: 0) {
77
- if let image {
78
- ImageView(image)
79
- .frame(width: 40, height: 40)
80
- .clipShape(RoundedRectangle(cornerRadius: Radius.S))
81
- .padding(.trailing, Spacing.S)
82
- } else if showIcon {
83
- Icon(source: iconSource, size: 16, color: accentColor)
84
- .padding(.trailing, Spacing.S)
85
- }
86
-
87
- VStack(alignment: .leading, spacing: 0) {
88
- if let title {
89
- MomoText(title, typography: .labelDefaultMedium)
90
- }
91
- MomoText(description, typography: .descriptionDefaultRegular)
92
- }
93
- .frame(maxWidth: .infinity, alignment: .leading)
94
-
95
- if let onPressClose, showIconClose {
96
- Icon(source: "navigation_close", size: 16, color: Colors.black17)
97
- .contentShape(Rectangle())
98
- .onTapGesture(perform: onPressClose)
99
- }
100
- }
101
-
102
- if let action, let onPressAction {
103
- MomoText(action, typography: .actionXsBold, color: accentColor)
104
- .frame(maxWidth: .infinity, alignment: .trailing)
105
- .contentShape(Rectangle())
106
- .onTapGesture(perform: onPressAction)
107
- .padding(.top, Spacing.S)
108
- }
109
- }
110
- .padding(Spacing.M)
111
- .background(
112
- RoundedRectangle(cornerRadius: Radius.S)
113
- .fill(backgroundColor)
114
- )
115
- .overlay(
116
- RoundedRectangle(cornerRadius: Radius.S)
117
- .stroke(borderColor, lineWidth: 0.5)
118
- )
119
- }
120
- }
121
-
122
- // MARK: - Preview
123
- #if DEBUG
124
- struct Information_Previews: PreviewProvider {
125
- static var previews: some View {
126
- VStack(spacing: 16) {
127
- Information(
128
- title: "Information",
129
- description: "This is a default information message."
130
- )
131
- Information(
132
- title: "Warning",
133
- description: "This is a warning message.",
134
- state: .warning
135
- )
136
- Information(
137
- title: "Error",
138
- description: "This is an error message.",
139
- state: .error,
140
- onPressAction: {}, action: "Retry"
141
- )
142
- Information(
143
- description: "Dismissible information.",
144
- onPressClose: {}
145
- )
146
- }
147
- .padding()
148
- .previewLayout(.sizeThatFits)
149
- }
150
- }
151
- #endif