@momo-kits/native-kits 0.300.7 → 0.300.8-beta.1
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.
- package/CLAUDE.md +12 -8
- package/README.md +8 -7
- package/ios/Application/ApplicationEnvironment.swift +6 -4
- package/ios/Application/DesignSystemKits.swift +59 -13
- package/ios/Application/DesignSystemKitsPayload.swift +0 -8
- package/ios/Application/LanguageSource.swift +2 -11
- package/ios/Application/Localize.swift +8 -35
- package/ios/Application/LocalizeModifier.swift +2 -11
- package/ios/Application/MaxApi.swift +3 -11
- package/ios/Avatar/Avatar.swift +0 -1
- package/ios/Badge/Badge.swift +5 -8
- package/ios/Badge/BadgeRibbon.swift +2 -5
- package/ios/Button/Button.swift +4 -8
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +5 -7
- package/ios/Carousel/Carousel.swift +4 -17
- package/ios/Checkbox/Checkbox.swift +0 -2
- package/ios/Collapse/Collapse.swift +17 -11
- package/ios/Colors+Radius+Spacing/Theme.swift +0 -7
- package/ios/DateTimePicker/DateTimePicker.swift +4 -10
- package/ios/DateTimePicker/DateTimePickerTypes.swift +1 -3
- package/ios/DateTimePicker/DateTimePickerUtils.swift +0 -3
- package/ios/DateTimePicker/WheelPicker.swift +2 -4
- package/ios/Extensions/ActiveOpacityButtonStyle.swift +2 -3
- package/ios/Extensions/Color++.swift +2 -4
- package/ios/Extensions/SkeletonUICompat.swift +0 -8
- package/ios/Icon/Icon.swift +3 -6
- package/ios/IconButton/IconButton.swift +2 -5
- package/ios/Input/ErrorView.swift +0 -7
- package/ios/Input/Input.swift +9 -20
- package/ios/Input/InputPhoneNumber.swift +37 -20
- package/ios/Input/InputSearch.swift +23 -12
- package/ios/Input/InputTextArea.swift +4 -13
- package/ios/InputDropDown/InputDropDown.swift +1 -11
- package/ios/InputMoney/InputMoney.swift +9 -28
- package/ios/InputOTP/InputOTP.swift +2 -9
- package/ios/Layout/HeaderLayout.swift +72 -0
- package/ios/Layout/Item.swift +1 -2
- package/ios/Layout/ModalLayout.swift +144 -0
- package/ios/Layout/ScreenLayout.swift +48 -31
- package/ios/Layout/Section.swift +2 -3
- package/ios/Loader/Loader.swift +3 -12
- package/ios/Lottie/LottieView.swift +0 -11
- package/ios/Navigation/BottomSheet.swift +73 -94
- package/ios/Navigation/BottomTab/BottomTab.swift +58 -73
- package/ios/Navigation/BottomTab/BottomTabBar.swift +286 -121
- package/ios/Navigation/BottomTab/CurvedContainer.swift +52 -54
- package/ios/Navigation/BottomTab/DuoBarCompression.swift +5 -12
- package/ios/Navigation/BottomTab/DuoTabBar.swift +67 -202
- package/ios/Navigation/BottomTab/TabBarMetrics.swift +97 -0
- package/ios/Navigation/Component/FloatingButton.swift +4 -11
- package/ios/Navigation/Component/Header.swift +35 -54
- package/ios/Navigation/Component/HeaderBackground.swift +2 -8
- package/ios/Navigation/Component/HeaderJourney.swift +4 -8
- package/ios/Navigation/Component/HeaderLocation.swift +4 -8
- package/ios/Navigation/Component/HeaderRight.swift +20 -22
- package/ios/Navigation/Component/HeaderTitle.swift +1 -6
- package/ios/Navigation/Component/HeaderUser.swift +4 -10
- package/ios/Navigation/Component/SideBar.swift +6 -21
- package/ios/Navigation/Component/SnackBar.swift +9 -13
- package/ios/Navigation/HostBackGestureBridge.swift +2 -9
- package/ios/Navigation/ModalScreen.swift +24 -13
- package/ios/Navigation/Navigation.swift +35 -19
- package/ios/Navigation/NavigationContainer.swift +4 -15
- package/ios/Navigation/Navigator.swift +21 -39
- package/ios/Navigation/StackScreen.swift +64 -51
- package/ios/Navigation/StackTransition.swift +7 -14
- package/ios/Navigation/SwipeBackHaptic.swift +2 -7
- package/ios/Navigation/Tracking/ScreenTracker.swift +2 -7
- package/ios/Pagination/PaginationDot.swift +0 -9
- package/ios/Pagination/PaginationNumber.swift +1 -9
- package/ios/Pagination/PaginationScroll.swift +2 -14
- package/ios/Pagination/PaginationWhiteDot.swift +1 -10
- package/ios/Popup/PopupDisplay.swift +7 -5
- package/ios/Popup/PopupInput.swift +6 -4
- package/ios/Popup/PopupLayout.swift +17 -9
- package/ios/Popup/PopupNotify.swift +32 -25
- package/ios/PopupView/FullscreenPopup.swift +3 -4
- package/ios/PopupView/PopupView.swift +2 -2
- package/ios/PopupView/Utils++.swift +1 -2
- package/ios/ProgressInfo/ProgressInfo.swift +2 -13
- package/ios/Skeleton/Skeleton.swift +5 -16
- package/ios/Slider/Slider.swift +5 -12
- package/ios/StatusBarTap/StatusBarTap.h +2 -3
- package/ios/StatusBarTap/StatusBarTap.m +3 -16
- package/ios/Stepper/Stepper.swift +8 -27
- package/ios/Steps/Steps.swift +29 -26
- package/ios/Swipeable/SwipeCell.swift +2 -2
- package/ios/Swipeable/SwipeCellModel.swift +3 -6
- package/ios/TabView/TabView.swift +14 -28
- package/ios/Template/TrustBanner/TrustBanner.swift +2 -9
- package/ios/Title/Title.swift +1 -3
- package/ios/Tooltip/Tooltip.swift +4 -9
- package/ios/Typography/FontScale.swift +79 -24
- package/ios/Typography/Text.swift +6 -12
- package/ios/Typography/Typography.swift +8 -11
- package/ios/Uploader/Uploader.swift +2 -17
- package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
- package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +11 -2
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +296 -59
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputPhoneNumberDemo.swift +15 -4
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +0 -8
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +114 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +29 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TypographyDemo.swift +16 -0
- package/package.json +1 -1
- package/publish.sh +8 -2
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import SwiftUI
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
// Size variant
|
|
5
|
-
// ---------------------------------------------------------------------------
|
|
3
|
+
// MARK: - Size
|
|
6
4
|
|
|
7
5
|
public enum StepperSize {
|
|
8
6
|
case large
|
|
@@ -25,10 +23,9 @@ private func stepperSizeSpec(_ size: StepperSize) -> StepperSizeSpec {
|
|
|
25
23
|
}
|
|
26
24
|
}
|
|
27
25
|
|
|
28
|
-
//
|
|
29
|
-
// Disabled spec — mirrors Compose `disabled: Any` (Bool or per-part array)
|
|
30
|
-
// ---------------------------------------------------------------------------
|
|
26
|
+
// MARK: - Disabled
|
|
31
27
|
|
|
28
|
+
/// Compose's `disabled: Any`: one Bool for every part, or per part.
|
|
32
29
|
public struct StepperDisabled {
|
|
33
30
|
let minus: Bool
|
|
34
31
|
let plus: Bool
|
|
@@ -40,7 +37,6 @@ public struct StepperDisabled {
|
|
|
40
37
|
self.plus = plus
|
|
41
38
|
}
|
|
42
39
|
|
|
43
|
-
/// All parts share the same disabled state.
|
|
44
40
|
public init(_ all: Bool) {
|
|
45
41
|
self.minus = all
|
|
46
42
|
self.plus = all
|
|
@@ -53,9 +49,7 @@ extension StepperDisabled: ExpressibleByBooleanLiteral {
|
|
|
53
49
|
}
|
|
54
50
|
}
|
|
55
51
|
|
|
56
|
-
//
|
|
57
|
-
// Private sub-views
|
|
58
|
-
// ---------------------------------------------------------------------------
|
|
52
|
+
// MARK: - Sub-views
|
|
59
53
|
|
|
60
54
|
private struct StepperButton: View {
|
|
61
55
|
@Environment(\.appTheme) private var theme
|
|
@@ -119,23 +113,10 @@ private struct StepperNumberView: View {
|
|
|
119
113
|
}
|
|
120
114
|
}
|
|
121
115
|
|
|
122
|
-
//
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
/// MomoStepper — quantity +/- control. Layout: [- button] [value] [+ button].
|
|
127
|
-
///
|
|
128
|
-
/// Named `MomoStepper` to avoid shadowing SwiftUI's built-in `Stepper`.
|
|
129
|
-
///
|
|
130
|
-
/// - Parameters:
|
|
131
|
-
/// - value: Binding to the current value. Clamped to `min...max`.
|
|
132
|
-
/// - min: Minimum allowed value (default 0). Minus auto-disables at this bound.
|
|
133
|
-
/// - max: Maximum allowed value (default 100). Plus auto-disables at this bound.
|
|
134
|
-
/// - step: Amount added/subtracted per press (default 1).
|
|
135
|
-
/// - size: Visual size variant (default `.large`).
|
|
136
|
-
/// - disabled: Disable state — `true` for everything, or `StepperDisabled(minus:plus:)`.
|
|
137
|
-
/// - editable: When `true` the number display becomes a keyboard input (default false).
|
|
138
|
-
/// - onValueChange: Callback invoked with the new value on every change.
|
|
116
|
+
// MARK: - MomoStepper
|
|
117
|
+
|
|
118
|
+
/// Quantity +/- control, named `MomoStepper` to avoid shadowing SwiftUI's `Stepper`.
|
|
119
|
+
/// `value` is clamped to `min...max`; each button disables itself at its bound.
|
|
139
120
|
public struct MomoStepper: View {
|
|
140
121
|
@Binding private var value: Int
|
|
141
122
|
private let min: Int
|
package/ios/Steps/Steps.swift
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import SwiftUI
|
|
2
2
|
|
|
3
|
-
//
|
|
3
|
+
// MARK: - Data model
|
|
4
4
|
|
|
5
5
|
/// A single step rendered inside a ``Steps`` indicator.
|
|
6
6
|
public struct StepItem: Identifiable {
|
|
@@ -23,7 +23,7 @@ public struct StepItem: Identifiable {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
//
|
|
26
|
+
// MARK: - Enumerations
|
|
27
27
|
|
|
28
28
|
public enum StepsSize {
|
|
29
29
|
case small
|
|
@@ -37,7 +37,7 @@ public enum StepsAlign {
|
|
|
37
37
|
case stretch
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
//
|
|
40
|
+
// MARK: - Internal status
|
|
41
41
|
|
|
42
42
|
private enum StepStatus {
|
|
43
43
|
case incomplete
|
|
@@ -60,7 +60,7 @@ private func resolveStatus(
|
|
|
60
60
|
return .incomplete
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
//
|
|
63
|
+
// MARK: - Color helpers
|
|
64
64
|
|
|
65
65
|
private func resolveIconBgAndBorder(_ status: StepStatus, theme: Theme) -> (bg: Color, border: Color) {
|
|
66
66
|
switch status {
|
|
@@ -88,7 +88,7 @@ private func resolveTitleColor(_ status: StepStatus, theme: Theme) -> Color {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
//
|
|
91
|
+
// MARK: - Step bubble
|
|
92
92
|
|
|
93
93
|
private struct StepBubble: View {
|
|
94
94
|
@Environment(\.appTheme) private var theme
|
|
@@ -143,7 +143,7 @@ private struct StepBubble: View {
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
//
|
|
146
|
+
// MARK: - Horizontal layout
|
|
147
147
|
|
|
148
148
|
private struct StepsHorizontal: View {
|
|
149
149
|
@Environment(\.appTheme) private var theme
|
|
@@ -180,10 +180,8 @@ private struct StepsHorizontal: View {
|
|
|
180
180
|
disabled: disabled
|
|
181
181
|
)
|
|
182
182
|
let isActiveOrError = status == .current || status == .error
|
|
183
|
-
let titleStyle: TypographyStyle = isActiveOrError
|
|
184
|
-
|
|
185
|
-
let descStyle: TypographyStyle = size == .small
|
|
186
|
-
? .descriptionXsRegular : .descriptionDefaultRegular
|
|
183
|
+
let titleStyle: TypographyStyle = isActiveOrError ? .headerXsSemibold : .descriptionDefaultRegular
|
|
184
|
+
let descStyle: TypographyStyle = size == .small ? .descriptionXsRegular : .descriptionDefaultRegular
|
|
187
185
|
let titleColor = resolveTitleColor(status, theme: theme)
|
|
188
186
|
let subColor = disabled ? theme.colors.text.disable : theme.colors.text.hint
|
|
189
187
|
|
|
@@ -193,12 +191,8 @@ private struct StepsHorizontal: View {
|
|
|
193
191
|
let hideLineLeft = align == .left || (align == .stretch && index == 0)
|
|
194
192
|
let hideLineRight = align == .right || (align == .stretch && index == steps.count - 1)
|
|
195
193
|
|
|
196
|
-
let lineLeft
|
|
197
|
-
|
|
198
|
-
: (activeIndex >= index ? completedLine : defaultLine)
|
|
199
|
-
let lineRight: Color = index == steps.count - 1
|
|
200
|
-
? Color.clear
|
|
201
|
-
: (activeIndex > index ? completedLine : defaultLine)
|
|
194
|
+
let lineLeft = lineColor(isOuterEnd: index == 0, isCompleted: activeIndex >= index)
|
|
195
|
+
let lineRight = lineColor(isOuterEnd: index == steps.count - 1, isCompleted: activeIndex > index)
|
|
202
196
|
|
|
203
197
|
let clickable = status == .completed && onPress != nil && !disabled
|
|
204
198
|
|
|
@@ -264,6 +258,13 @@ private struct StepsHorizontal: View {
|
|
|
264
258
|
}
|
|
265
259
|
}
|
|
266
260
|
|
|
261
|
+
private func lineColor(isOuterEnd: Bool, isCompleted: Bool) -> Color {
|
|
262
|
+
if isOuterEnd {
|
|
263
|
+
return .clear
|
|
264
|
+
}
|
|
265
|
+
return isCompleted ? completedLine : defaultLine
|
|
266
|
+
}
|
|
267
|
+
|
|
267
268
|
private func horizontalAlignment(for index: Int) -> HorizontalAlignment {
|
|
268
269
|
switch align {
|
|
269
270
|
case .left: return .leading
|
|
@@ -297,7 +298,7 @@ private struct StepsHorizontal: View {
|
|
|
297
298
|
}
|
|
298
299
|
}
|
|
299
300
|
|
|
300
|
-
//
|
|
301
|
+
// MARK: - Vertical layout
|
|
301
302
|
|
|
302
303
|
private struct StepsVertical: View {
|
|
303
304
|
@Environment(\.appTheme) private var theme
|
|
@@ -335,11 +336,8 @@ private struct StepsVertical: View {
|
|
|
335
336
|
let isActiveOrError = status == .current || status == .error
|
|
336
337
|
let isLast = index == steps.count - 1
|
|
337
338
|
|
|
338
|
-
let titleStyle
|
|
339
|
-
|
|
340
|
-
: (useSmall ? .descriptionDefaultRegular : .bodyDefaultRegular)
|
|
341
|
-
let descStyle: TypographyStyle = useSmall
|
|
342
|
-
? .descriptionXsRegular : .descriptionDefaultRegular
|
|
339
|
+
let titleStyle = resolveTitleStyle(isActiveOrError: isActiveOrError)
|
|
340
|
+
let descStyle: TypographyStyle = useSmall ? .descriptionXsRegular : .descriptionDefaultRegular
|
|
343
341
|
|
|
344
342
|
let titleColor = resolveTitleColor(status, theme: theme)
|
|
345
343
|
let subColor = disabled ? theme.colors.text.disable : theme.colors.text.hint
|
|
@@ -402,13 +400,18 @@ private struct StepsVertical: View {
|
|
|
402
400
|
rowBody
|
|
403
401
|
}
|
|
404
402
|
}
|
|
403
|
+
|
|
404
|
+
private func resolveTitleStyle(isActiveOrError: Bool) -> TypographyStyle {
|
|
405
|
+
if isActiveOrError {
|
|
406
|
+
return useSmall ? .headerXsSemibold : .headerSSemibold
|
|
407
|
+
}
|
|
408
|
+
return useSmall ? .descriptionDefaultRegular : .bodyDefaultRegular
|
|
409
|
+
}
|
|
405
410
|
}
|
|
406
411
|
|
|
407
|
-
//
|
|
412
|
+
// MARK: - Public API
|
|
408
413
|
|
|
409
|
-
///
|
|
410
|
-
///
|
|
411
|
-
/// Mirrors the Compose `Steps` component.
|
|
414
|
+
/// Guided progress through a sequence of steps; mirrors Compose `Steps`.
|
|
412
415
|
public struct Steps: View {
|
|
413
416
|
private let steps: [StepItem]
|
|
414
417
|
private let activeIndex: Int
|
|
@@ -340,7 +340,7 @@ public struct SwipeCellModifier: ViewModifier {
|
|
|
340
340
|
}
|
|
341
341
|
|
|
342
342
|
} else {
|
|
343
|
-
// leading group
|
|
343
|
+
// leading group empty
|
|
344
344
|
self.setOffsetX(value: 0)
|
|
345
345
|
}
|
|
346
346
|
} else if self.offsetX < 0 {
|
|
@@ -354,7 +354,7 @@ public struct SwipeCellModifier: ViewModifier {
|
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
} else {
|
|
357
|
-
// trailing group
|
|
357
|
+
// trailing group empty
|
|
358
358
|
self.setOffsetX(value: 0)
|
|
359
359
|
}
|
|
360
360
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
import Foundation
|
|
4
2
|
import SwiftUI
|
|
5
3
|
|
|
@@ -49,11 +47,11 @@ public struct SwipeCellActionItem: Identifiable {
|
|
|
49
47
|
// MARK: Lifecycle
|
|
50
48
|
|
|
51
49
|
/// Initializer
|
|
52
|
-
/// - Parameter id: Required to identify each
|
|
50
|
+
/// - Parameter id: Required to identify each button in the side menu. Default is a random uuid string.
|
|
53
51
|
/// - Parameter buttonView: The view in the foreground of the menu button. Make sure to set a maximum frame height less than the cell height!
|
|
54
52
|
/// - Parameter swipeOutButtonView: Alternative button view that is displayed only when the offset during swipe is beyond the swipe out trigger value.
|
|
55
|
-
/// - Parameter buttonWidth: Width of the button. The
|
|
56
|
-
/// - Parameter backgroundColor: The background colour of the
|
|
53
|
+
/// - Parameter buttonWidth: Width of the button. The open side menu width is calculated from the sum of all button widths. Default is 75.
|
|
54
|
+
/// - Parameter backgroundColor: The background colour of the menu button.
|
|
57
55
|
/// - Parameter swipeOutAction: A Boolean that determines if a swipe out action is activated or not. Default is false.
|
|
58
56
|
/// - Parameter swipeOutHapticFeedbackType: If a swipeOutAction is activated, a haptic feedback will occur after the swipe out threshold is passed. Default is nil.
|
|
59
57
|
/// - Parameter swipeOutIsDestructive: A Boolean that determines if the swipe out is destructive. If true, the content cell view will be "move out of sight" once the swipe out is triggered.
|
|
@@ -79,7 +77,6 @@ public struct SwipeCellActionItem: Identifiable {
|
|
|
79
77
|
public var swipeOutAction: Bool
|
|
80
78
|
public var swipeOutHapticFeedbackType: UINotificationFeedbackGenerator.FeedbackType?
|
|
81
79
|
public var swipeOutIsDestructive: Bool
|
|
82
|
-
/// public var swipeOutButtonViewScaleFactor: CGFloat
|
|
83
80
|
public var actionCallback: ()->()
|
|
84
81
|
}
|
|
85
82
|
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import SwiftUI
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
// types
|
|
6
|
-
// ---------------------------------------------------------------------------
|
|
3
|
+
// MARK: - Style enums
|
|
4
|
+
|
|
5
|
+
// Prefixed to avoid colliding with other public kit types (ButtonSize, InputSize, TagColor).
|
|
7
6
|
|
|
8
7
|
public enum TabViewType {
|
|
9
8
|
case `default`
|
|
@@ -15,10 +14,9 @@ public enum TabViewDirection {
|
|
|
15
14
|
case column
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
//
|
|
19
|
-
// Data model — mirrors Compose `TabViewItem`
|
|
20
|
-
// ---------------------------------------------------------------------------
|
|
17
|
+
// MARK: - Data model
|
|
21
18
|
|
|
19
|
+
/// Mirrors Compose `TabViewItem`.
|
|
22
20
|
public struct TabViewItem {
|
|
23
21
|
public let title: String
|
|
24
22
|
public let icon: String?
|
|
@@ -72,10 +70,9 @@ public struct TabViewItem {
|
|
|
72
70
|
}
|
|
73
71
|
}
|
|
74
72
|
|
|
75
|
-
//
|
|
76
|
-
// Public component — named `MomoTabView` to avoid shadowing SwiftUI.TabView
|
|
77
|
-
// ---------------------------------------------------------------------------
|
|
73
|
+
// MARK: - MomoTabView
|
|
78
74
|
|
|
75
|
+
/// Named `MomoTabView` to avoid shadowing SwiftUI's `TabView`.
|
|
79
76
|
public struct MomoTabView: View {
|
|
80
77
|
@Environment(\.appTheme) private var theme
|
|
81
78
|
|
|
@@ -213,9 +210,7 @@ public struct MomoTabView: View {
|
|
|
213
210
|
}
|
|
214
211
|
}
|
|
215
212
|
|
|
216
|
-
//
|
|
217
|
-
// Default fixed-width tab bar (equal-width items + animated underline)
|
|
218
|
-
// ---------------------------------------------------------------------------
|
|
213
|
+
// MARK: - Default tab bar (equal-width items)
|
|
219
214
|
|
|
220
215
|
private struct DefaultTabBar: View {
|
|
221
216
|
@Environment(\.appTheme) private var theme
|
|
@@ -266,9 +261,7 @@ private struct DefaultTabBar: View {
|
|
|
266
261
|
}
|
|
267
262
|
}
|
|
268
263
|
|
|
269
|
-
//
|
|
270
|
-
// Scrollable tab bar (wrap-width items, horizontal scroll, animated underline)
|
|
271
|
-
// ---------------------------------------------------------------------------
|
|
264
|
+
// MARK: - Scrollable tab bar (wrap-width items)
|
|
272
265
|
|
|
273
266
|
private struct ScrollableTabBar: View {
|
|
274
267
|
@Environment(\.appTheme) private var theme
|
|
@@ -347,9 +340,7 @@ private struct TabFramePreferenceKey: PreferenceKey {
|
|
|
347
340
|
}
|
|
348
341
|
}
|
|
349
342
|
|
|
350
|
-
//
|
|
351
|
-
// Card tab bar
|
|
352
|
-
// ---------------------------------------------------------------------------
|
|
343
|
+
// MARK: - Card tab bar
|
|
353
344
|
|
|
354
345
|
private let cardTabHeight: CGFloat = 40
|
|
355
346
|
private let cardTabActiveHeight: CGFloat = 44
|
|
@@ -474,15 +465,12 @@ private struct CardTabEarShape: Shape {
|
|
|
474
465
|
)
|
|
475
466
|
path.addLine(to: CGPoint(x: 0, y: 44))
|
|
476
467
|
path.closeSubpath()
|
|
477
|
-
return
|
|
478
|
-
|
|
479
|
-
: path
|
|
468
|
+
guard mirrored else { return path }
|
|
469
|
+
return path.applying(CGAffineTransform(a: -1, b: 0, c: 0, d: 1, tx: rect.width, ty: 0))
|
|
480
470
|
}
|
|
481
471
|
}
|
|
482
472
|
|
|
483
|
-
//
|
|
484
|
-
// Shared tab item (Default + Scrollable bars)
|
|
485
|
-
// ---------------------------------------------------------------------------
|
|
473
|
+
// MARK: - Shared tab item (default + scrollable bars)
|
|
486
474
|
|
|
487
475
|
private struct TabItemView: View {
|
|
488
476
|
let tab: TabViewItem
|
|
@@ -563,9 +551,7 @@ private struct TabItemView: View {
|
|
|
563
551
|
}
|
|
564
552
|
}
|
|
565
553
|
|
|
566
|
-
//
|
|
567
|
-
// Shared helpers
|
|
568
|
-
// ---------------------------------------------------------------------------
|
|
554
|
+
// MARK: - Shared helpers
|
|
569
555
|
|
|
570
556
|
private func barHeight(_ direction: TabViewDirection) -> CGFloat {
|
|
571
557
|
direction == .column ? 68 : 48
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
//
|
|
2
|
-
// TrustBanner.swift
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// Created by Nguyễn Hoàng Sơn on 14/12/2023.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
1
|
import Foundation
|
|
9
2
|
import SwiftUI
|
|
10
3
|
import SDWebImageSwiftUI
|
|
@@ -131,7 +124,7 @@ public struct TrustBanner: View {
|
|
|
131
124
|
MomoText(
|
|
132
125
|
localize.translateData(banner.content),
|
|
133
126
|
typography: .descriptionDefaultRegular,
|
|
134
|
-
color:
|
|
127
|
+
color: Colors.black15,
|
|
135
128
|
maxLines: 2
|
|
136
129
|
)
|
|
137
130
|
.padding(.bottom, 8)
|
|
@@ -166,7 +159,7 @@ public struct TrustBanner: View {
|
|
|
166
159
|
}
|
|
167
160
|
}
|
|
168
161
|
.padding(.all, 12)
|
|
169
|
-
.background(
|
|
162
|
+
.background(Colors.blue10)
|
|
170
163
|
.cornerRadius(12)
|
|
171
164
|
.contentShape(Rectangle())
|
|
172
165
|
.onTapGesture {
|
package/ios/Title/Title.swift
CHANGED
|
@@ -129,9 +129,7 @@ public struct Title: View {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
private var trailingBackground: Color {
|
|
132
|
-
type == .section
|
|
133
|
-
? Colors.black06.opacity(0.6)
|
|
134
|
-
: Colors.black06.opacity(0.3)
|
|
132
|
+
Colors.black06.opacity(type == .section ? 0.6 : 0.3)
|
|
135
133
|
}
|
|
136
134
|
|
|
137
135
|
// MARK: - Body
|
|
@@ -41,17 +41,14 @@ public final class TooltipState: ObservableObject {
|
|
|
41
41
|
|
|
42
42
|
public init() {}
|
|
43
43
|
|
|
44
|
-
/// Shows the tooltip.
|
|
45
44
|
public func show() {
|
|
46
45
|
isVisible = true
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
/// Hides the tooltip.
|
|
50
48
|
public func hide() {
|
|
51
49
|
isVisible = false
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
/// Toggles the tooltip visibility.
|
|
55
52
|
public func toggle() {
|
|
56
53
|
isVisible.toggle()
|
|
57
54
|
}
|
|
@@ -126,10 +123,8 @@ private struct TooltipAnchorBoundsKey: PreferenceKey {
|
|
|
126
123
|
|
|
127
124
|
// MARK: - Tooltip
|
|
128
125
|
|
|
129
|
-
///
|
|
130
|
-
///
|
|
131
|
-
///
|
|
132
|
-
/// Port of the Compose / React Native `Tooltip` component.
|
|
126
|
+
/// Port of the Compose / RN `Tooltip`: wraps `content` (the anchor) and shows a positioned popup
|
|
127
|
+
/// with title, description, close button and action buttons.
|
|
133
128
|
public struct Tooltip<Content: View>: View {
|
|
134
129
|
@ObservedObject private var state: TooltipState
|
|
135
130
|
private let title: String?
|
|
@@ -314,7 +309,7 @@ private struct TooltipPopupContent: View {
|
|
|
314
309
|
}
|
|
315
310
|
.padding(Spacing.M)
|
|
316
311
|
.frame(maxWidth: TooltipConst.maxWidth, alignment: .leading)
|
|
317
|
-
.background(Colors.
|
|
312
|
+
.background(Colors.blue03)
|
|
318
313
|
.clipShape(RoundedRectangle(cornerRadius: TooltipConst.cornerRadius))
|
|
319
314
|
}
|
|
320
315
|
.overlay(arrow, alignment: arrowAlignment)
|
|
@@ -328,7 +323,7 @@ private struct TooltipPopupContent: View {
|
|
|
328
323
|
let arrowHeight = TooltipConst.arrowSize
|
|
329
324
|
let isVertical = placement == .top || placement == .bottom
|
|
330
325
|
TooltipArrowShape(placement: placement)
|
|
331
|
-
.fill(Colors.
|
|
326
|
+
.fill(Colors.blue03)
|
|
332
327
|
.frame(
|
|
333
328
|
width: isVertical ? arrowWidth : arrowHeight,
|
|
334
329
|
height: isVertical ? arrowHeight : arrowWidth
|
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
// File: ios/Typography/FontScale.swift
|
|
2
|
-
// Created At: 2026-08-06 10:00:00 +07:00
|
|
3
|
-
// Created By: AI
|
|
4
|
-
// AI Agent: Claude Code
|
|
5
|
-
// Model: claude-opus-5
|
|
6
|
-
|
|
7
|
-
// AI-GENERATED START: reactive font-scale snapshot injected through the environment
|
|
8
1
|
import SwiftUI
|
|
9
2
|
|
|
10
|
-
/// Immutable snapshot of the
|
|
11
|
-
///
|
|
12
|
-
/// computed independently and the larger one wins.
|
|
3
|
+
/// Immutable snapshot of the font-scale inputs; formula 1:1 with Compose's `scaleSize()` (`const/Typography.kt`):
|
|
4
|
+
/// the device-width and OS Dynamic Type scales are computed independently and the larger wins.
|
|
13
5
|
public struct FontScale: Equatable {
|
|
14
6
|
private static let defaultScreenSize: CGFloat = 375
|
|
15
7
|
private static let maxFontScale: CGFloat = 1.5
|
|
@@ -19,20 +11,36 @@ public struct FontScale: Equatable {
|
|
|
19
11
|
public let useOSScaleRate: Bool
|
|
20
12
|
/// OS Dynamic Type factor at the time the snapshot was taken.
|
|
21
13
|
public let osFontScale: CGFloat
|
|
14
|
+
/// From the app window, not UIScreen.main (which stays on one display on iPhone Duo).
|
|
15
|
+
public let windowShortSide: CGFloat
|
|
16
|
+
/// Caps the result at size × maxScaleRate on both the userScaleRate and OS paths, nil = no cap. Set it with
|
|
17
|
+
/// `ScaleSizeScope` or `MiniAppContext.scaleSizeMaxRate` (Compose parity).
|
|
18
|
+
public let maxScaleRate: CGFloat?
|
|
22
19
|
|
|
23
|
-
public init(
|
|
20
|
+
public init(
|
|
21
|
+
userScaleRate: CGFloat = 1,
|
|
22
|
+
useOSScaleRate: Bool = true,
|
|
23
|
+
osFontScale: CGFloat = 1,
|
|
24
|
+
windowShortSide: CGFloat? = nil,
|
|
25
|
+
maxScaleRate: CGFloat? = nil
|
|
26
|
+
) {
|
|
24
27
|
self.userScaleRate = userScaleRate
|
|
25
28
|
self.useOSScaleRate = useOSScaleRate
|
|
26
29
|
self.osFontScale = osFontScale
|
|
30
|
+
self.windowShortSide = windowShortSide ?? DesignSystemKits.currentWindowShortSide()
|
|
31
|
+
self.maxScaleRate = maxScaleRate
|
|
27
32
|
}
|
|
28
33
|
|
|
29
34
|
/// `callAsFunction` so call sites keep reading like Compose's `scaleSize(16)`.
|
|
30
35
|
public func callAsFunction(_ size: CGFloat) -> CGFloat {
|
|
31
|
-
|
|
36
|
+
func cap(_ scaled: CGFloat) -> CGFloat {
|
|
37
|
+
guard let maxScaleRate else { return scaled }
|
|
38
|
+
return min(scaled, size * maxScaleRate)
|
|
39
|
+
}
|
|
40
|
+
guard useOSScaleRate else { return cap(size * userScaleRate) }
|
|
32
41
|
|
|
33
42
|
// Short side, not width: landscape must not inflate every font (and so every popup's height).
|
|
34
|
-
let
|
|
35
|
-
let deviceScale = min(bounds.width, bounds.height) / Self.defaultScreenSize
|
|
43
|
+
let deviceScale = windowShortSide / Self.defaultScreenSize
|
|
36
44
|
|
|
37
45
|
var deviceScaled = size
|
|
38
46
|
var osScaled = size
|
|
@@ -40,9 +48,20 @@ public struct FontScale: Equatable {
|
|
|
40
48
|
deviceScaled = min(size * deviceScale, size + Self.maxDeviceScale)
|
|
41
49
|
}
|
|
42
50
|
if osFontScale > 1 {
|
|
43
|
-
osScaled = min(size * osFontScale, size * Self.maxFontScale)
|
|
51
|
+
osScaled = min(size * osFontScale, size * (maxScaleRate ?? Self.maxFontScale))
|
|
44
52
|
}
|
|
45
|
-
return max(deviceScaled, osScaled)
|
|
53
|
+
return cap(max(deviceScaled, osScaled))
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/// A copy that caps the scale at `rate` (nil lifts the cap) while keeping the host/OS inputs.
|
|
57
|
+
public func cappedAt(_ rate: CGFloat?) -> FontScale {
|
|
58
|
+
FontScale(
|
|
59
|
+
userScaleRate: userScaleRate,
|
|
60
|
+
useOSScaleRate: useOSScaleRate,
|
|
61
|
+
osFontScale: osFontScale,
|
|
62
|
+
windowShortSide: windowShortSide,
|
|
63
|
+
maxScaleRate: rate
|
|
64
|
+
)
|
|
46
65
|
}
|
|
47
66
|
|
|
48
67
|
/// `.system(size:)` is a fixed-size font — SwiftUI does not Dynamic-Type it — so the scale has to
|
|
@@ -53,12 +72,15 @@ public struct FontScale: Equatable {
|
|
|
53
72
|
|
|
54
73
|
/// A host-pushed mini-app context wins per field, matching Compose's
|
|
55
74
|
/// `context?.useOSScaleRate ?: DesignSystemKits.getConfigs().useOSScaleRate`.
|
|
56
|
-
public func overriding(userScaleRate: CGFloat?, useOSScaleRate: Bool?) -> FontScale {
|
|
57
|
-
|
|
75
|
+
public func overriding(userScaleRate: CGFloat?, useOSScaleRate: Bool?, maxScaleRate: CGFloat? = nil) -> FontScale {
|
|
76
|
+
let overridesAny = userScaleRate != nil || useOSScaleRate != nil || maxScaleRate != nil
|
|
77
|
+
guard overridesAny else { return self }
|
|
58
78
|
return FontScale(
|
|
59
79
|
userScaleRate: userScaleRate ?? self.userScaleRate,
|
|
60
80
|
useOSScaleRate: useOSScaleRate ?? self.useOSScaleRate,
|
|
61
|
-
osFontScale: osFontScale
|
|
81
|
+
osFontScale: osFontScale,
|
|
82
|
+
windowShortSide: windowShortSide,
|
|
83
|
+
maxScaleRate: maxScaleRate ?? self.maxScaleRate
|
|
62
84
|
)
|
|
63
85
|
}
|
|
64
86
|
}
|
|
@@ -77,9 +99,8 @@ public extension EnvironmentValues {
|
|
|
77
99
|
}
|
|
78
100
|
|
|
79
101
|
public extension View {
|
|
80
|
-
/// Injects a
|
|
81
|
-
///
|
|
82
|
-
/// Use at every `UIHostingController` root that is not inside a `NavigationContainer`.
|
|
102
|
+
/// Injects a live font scale plus `\.designSystemKitsConfigs` (whitelist, remote config). Needed at every
|
|
103
|
+
/// `UIHostingController` root outside a `NavigationContainer`.
|
|
83
104
|
func momoFontScale(_ store: DesignSystemKits = .shared, context: MiniAppContext? = nil) -> some View {
|
|
84
105
|
modifier(MomoFontScaleModifier(store: store, context: context))
|
|
85
106
|
}
|
|
@@ -97,10 +118,44 @@ private struct MomoFontScaleModifier: ViewModifier {
|
|
|
97
118
|
\.momoFontScale,
|
|
98
119
|
store.fontScale.overriding(
|
|
99
120
|
userScaleRate: context?.userScaleRate,
|
|
100
|
-
useOSScaleRate: context?.useOSScaleRate
|
|
121
|
+
useOSScaleRate: context?.useOSScaleRate,
|
|
122
|
+
maxScaleRate: context?.scaleSizeMaxRate
|
|
101
123
|
)
|
|
102
124
|
)
|
|
103
125
|
.environment(\.designSystemKitsConfigs, store.getConfigs())
|
|
104
126
|
}
|
|
105
127
|
}
|
|
106
|
-
|
|
128
|
+
|
|
129
|
+
/// Compose's `ScaleSizeScope` (RN `ScaleSizeProvider`): caps the font scale of `content` at
|
|
130
|
+
/// size × `scaleSizeMaxRate`; the nearest scope wins and nil lifts the cap.
|
|
131
|
+
public struct ScaleSizeScope<Content: View>: View {
|
|
132
|
+
private let scaleSizeMaxRate: CGFloat?
|
|
133
|
+
private let content: Content
|
|
134
|
+
|
|
135
|
+
public init(scaleSizeMaxRate: CGFloat? = nil, @ViewBuilder content: () -> Content) {
|
|
136
|
+
self.scaleSizeMaxRate = scaleSizeMaxRate
|
|
137
|
+
self.content = content()
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
public var body: some View {
|
|
141
|
+
content.scaleSizeMaxRate(scaleSizeMaxRate)
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
public extension View {
|
|
146
|
+
/// Modifier form of `ScaleSizeScope`.
|
|
147
|
+
func scaleSizeMaxRate(_ rate: CGFloat?) -> some View {
|
|
148
|
+
modifier(ScaleSizeMaxRateModifier(rate: rate))
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/// Derives from the injected snapshot, so it stays live under `.momoFontScale()`.
|
|
153
|
+
private struct ScaleSizeMaxRateModifier: ViewModifier {
|
|
154
|
+
let rate: CGFloat?
|
|
155
|
+
|
|
156
|
+
@Environment(\.momoFontScale) private var fontScale
|
|
157
|
+
|
|
158
|
+
func body(content: Content) -> some View {
|
|
159
|
+
content.environment(\.momoFontScale, fontScale.cappedAt(rate))
|
|
160
|
+
}
|
|
161
|
+
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import SwiftUI
|
|
2
2
|
|
|
3
|
-
/// Non-reactive
|
|
4
|
-
///
|
|
5
|
-
/// re-renders when Dynamic Type or the host preference changes.
|
|
3
|
+
/// Non-reactive, for call sites that can't read the environment (UIKit bridges, free functions). In a view use
|
|
4
|
+
/// `@Environment(\.momoFontScale)` so it re-renders when Dynamic Type or the host preference changes.
|
|
6
5
|
public func scaleSize(_ size: CGFloat) -> CGFloat {
|
|
7
6
|
DesignSystemKits.shared.fontScale(size)
|
|
8
7
|
}
|
|
@@ -107,7 +106,7 @@ private enum MomoFontFace {
|
|
|
107
106
|
/// Port of Compose `getFontFamily`; SF Pro Text is the iOS system font, so the legacy family is `.system`.
|
|
108
107
|
private func momoFontFace(family: String, weight: Font.Weight, isWhiteList: Bool) -> MomoFontFace? {
|
|
109
108
|
let isNewFamily = family == "MomoTrustSans" || family == headerFontFamily
|
|
110
|
-
// Outside the whitelist the
|
|
109
|
+
// Outside the whitelist the DS-791 families fall back to the legacy font.
|
|
111
110
|
if family == "SFProText" || (isNewFamily && !isWhiteList) { return .system }
|
|
112
111
|
// single-file families (Compose maps every weight to the same .otf)
|
|
113
112
|
if family == headerFontFamily || family == "MoMoSignature" { return .named(family) }
|
|
@@ -264,8 +263,6 @@ public struct MomoText: View {
|
|
|
264
263
|
self.textAlign = textAlign
|
|
265
264
|
self.maxLines = maxLines
|
|
266
265
|
self.minLines = minLines
|
|
267
|
-
// SwiftUI's range-based `lineLimit` is iOS 16+ only; keep the range for
|
|
268
|
-
// newer OS versions and fall back to the legacy single-value overload.
|
|
269
266
|
if maxLines == Int.max && minLines <= 1 {
|
|
270
267
|
self.lineLimitRange = nil
|
|
271
268
|
} else {
|
|
@@ -281,8 +278,8 @@ public struct MomoText: View {
|
|
|
281
278
|
self.fontFamily = fontFamily
|
|
282
279
|
}
|
|
283
280
|
|
|
284
|
-
init(_ content: String, typography: TypographyStyle, highlightText: [String]) {
|
|
285
|
-
self.init(content, typography: typography)
|
|
281
|
+
init(_ content: String, typography: TypographyStyle, accessibilityId: String? = nil, highlightText: [String]) {
|
|
282
|
+
self.init(content, typography: typography, accessibilityId: accessibilityId)
|
|
286
283
|
self.highlightText = highlightText
|
|
287
284
|
}
|
|
288
285
|
|
|
@@ -345,8 +342,6 @@ public struct MomoText: View {
|
|
|
345
342
|
|
|
346
343
|
public var body: some View {
|
|
347
344
|
let textColor = color ?? theme.colors.text.default
|
|
348
|
-
// Strikethrough is driven either by the typography variant (mirrors Compose
|
|
349
|
-
// *Strikethrough styles) or the explicit `strikethrough` flag.
|
|
350
345
|
let isStrikethrough = strikethrough || typography.isStrikethrough
|
|
351
346
|
|
|
352
347
|
// lineSpacing is added on top of the font's natural line height, not on top of fontSize.
|
|
@@ -379,8 +374,7 @@ public struct MomoText: View {
|
|
|
379
374
|
}
|
|
380
375
|
}
|
|
381
376
|
|
|
382
|
-
//
|
|
383
|
-
// single-value overload so the file still compiles for iOS 15.
|
|
377
|
+
// Range-based `lineLimit` is iOS 16+; iOS 15 gets the upper bound only.
|
|
384
378
|
private struct LineLimitModifier: ViewModifier {
|
|
385
379
|
let range: ClosedRange<Int>?
|
|
386
380
|
|