@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,10 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's `navigation/SwipeBackHaptic.kt`: one light tick when the host back
|
|
6
|
-
// gesture has dragged the screen 50pt, re-armed once it goes back under.
|
|
7
|
-
//
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/SwipeBackHaptic.kt`: one light tick when the host back
|
|
2
|
+
// gesture has dragged the screen 50pt, re-armed once it goes back under.
|
|
8
3
|
|
|
9
4
|
import UIKit
|
|
10
5
|
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's `navigation/tracking/ScreenTracker.kt`. Pure
|
|
6
|
-
// logic, no platform dependency beyond the `MaxApi` bridge.
|
|
7
|
-
//
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/tracking/ScreenTracker.kt`. Pure
|
|
2
|
+
// logic, no platform dependency beyond the `MaxApi` bridge.
|
|
8
3
|
|
|
9
4
|
import Foundation
|
|
10
5
|
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
//
|
|
2
|
-
// PaginationDot.swift
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// Native SwiftUI port of Compose's PaginationDot.
|
|
6
|
-
// An active dot is a 12x4 pill in `activeColor`; inactive dots are 4x4
|
|
7
|
-
// rounded squares in the pressed-background token.
|
|
8
|
-
//
|
|
9
|
-
|
|
10
1
|
import SwiftUI
|
|
11
2
|
|
|
12
3
|
// MARK: - Dot
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
//
|
|
2
|
-
// PaginationNumber.swift
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// Native SwiftUI port of Compose's PaginationNumber.
|
|
6
|
-
// Renders "current/total" text on a translucent black rounded chip.
|
|
7
|
-
//
|
|
8
|
-
|
|
9
1
|
import SwiftUI
|
|
10
2
|
|
|
11
3
|
// MARK: - PaginationNumber
|
|
@@ -29,7 +21,7 @@ public struct PaginationNumber: View {
|
|
|
29
21
|
.padding(.horizontal, Spacing.S)
|
|
30
22
|
.background(
|
|
31
23
|
RoundedRectangle(cornerRadius: Radius.L)
|
|
32
|
-
.fill(
|
|
24
|
+
.fill(Colors.opacityBlack20)
|
|
33
25
|
)
|
|
34
26
|
}
|
|
35
27
|
}
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
//
|
|
2
|
-
// PaginationScroll.swift
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// Native SwiftUI port of Compose's PaginationScroll.
|
|
6
|
-
// Wraps arbitrary horizontally-scrollable content and renders a
|
|
7
|
-
// progress-bar style indicator whose position tracks the scroll offset.
|
|
8
|
-
//
|
|
9
|
-
|
|
10
1
|
import SwiftUI
|
|
11
2
|
|
|
12
3
|
// MARK: - Constants
|
|
@@ -22,10 +13,8 @@ private func calculateOffset(currentPosition: CGFloat, maxBound: CGFloat) -> CGF
|
|
|
22
13
|
|
|
23
14
|
// MARK: - PaginationScroll
|
|
24
15
|
|
|
25
|
-
/// Mirrors Compose's `PaginationScroll(modifier, content)
|
|
26
|
-
///
|
|
27
|
-
/// The trailing-closure `content` is laid out in a horizontal scroll view and
|
|
28
|
-
/// the indicator below reflects the current scroll progress.
|
|
16
|
+
/// Mirrors Compose's `PaginationScroll(modifier, content)`: horizontal scroll content with a
|
|
17
|
+
/// progress indicator below that tracks the scroll offset.
|
|
29
18
|
public struct PaginationScroll<Content: View>: View {
|
|
30
19
|
@Environment(\.appTheme) private var theme
|
|
31
20
|
|
|
@@ -76,7 +65,6 @@ public struct PaginationScroll<Content: View>: View {
|
|
|
76
65
|
.onPreferenceChange(ScrollOffsetKey.self) { scrollOffset = max($0, 0) }
|
|
77
66
|
.padding(.bottom, Spacing.L)
|
|
78
67
|
|
|
79
|
-
// Progress indicator
|
|
80
68
|
ZStack(alignment: .leading) {
|
|
81
69
|
RoundedRectangle(cornerRadius: Spacing.XS)
|
|
82
70
|
.fill(theme.colors.background.pressed)
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
//
|
|
2
|
-
// PaginationWhiteDot.swift
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// Native SwiftUI port of Compose's PaginationWhiteDot.
|
|
6
|
-
// Same dot layout as PaginationDot, but the active color is white
|
|
7
|
-
// (black_01) and the row sits on a translucent black rounded surface.
|
|
8
|
-
//
|
|
9
|
-
|
|
10
1
|
import SwiftUI
|
|
11
2
|
|
|
12
3
|
// MARK: - PaginationWhiteDot
|
|
@@ -31,7 +22,7 @@ public struct PaginationWhiteDot: View {
|
|
|
31
22
|
.padding(Spacing.XS)
|
|
32
23
|
.background(
|
|
33
24
|
RoundedRectangle(cornerRadius: Radius.S)
|
|
34
|
-
.fill(
|
|
25
|
+
.fill(Colors.opacityBlack20)
|
|
35
26
|
)
|
|
36
27
|
}
|
|
37
28
|
}
|
|
@@ -70,6 +70,7 @@ public struct PopupDisplay: View {
|
|
|
70
70
|
}
|
|
71
71
|
VStack(alignment: .leading, spacing: 0) {
|
|
72
72
|
MomoText(title, typography: .headerDefaultBold, maxLines: 2, accessibilityId: "title_popup_permission")
|
|
73
|
+
.padding(.trailing, isShowCloseIcon && url.isEmpty ? ModalMetrics.iconButtonSize + Spacing.M - Spacing.XL : 0)
|
|
73
74
|
.padding(.top, 24)
|
|
74
75
|
.padding(.bottom, 8)
|
|
75
76
|
|
|
@@ -107,15 +108,16 @@ public struct PopupDisplay: View {
|
|
|
107
108
|
}
|
|
108
109
|
.fixedSize(horizontal: false, vertical: true)
|
|
109
110
|
.background(theme.colors.background.surface)
|
|
110
|
-
.clipShape(RoundedRectangle(cornerRadius:
|
|
111
|
+
.clipShape(RoundedRectangle(cornerRadius: layout.popupRadius))
|
|
111
112
|
|
|
112
113
|
if isShowCloseIcon {
|
|
113
|
-
|
|
114
|
-
.
|
|
114
|
+
ModalIconButton(icon: "navigation_close", accessibilityId: "ic_popup_close", action: onClose)
|
|
115
|
+
.padding(.top, Spacing.M)
|
|
116
|
+
.padding(.trailing, Spacing.M)
|
|
115
117
|
}
|
|
116
118
|
}
|
|
117
|
-
|
|
118
|
-
.
|
|
119
|
+
// window minus 24 a side on phones too, host padding included (PopupNotify parity)
|
|
120
|
+
.frame(maxWidth: layout.modalLayout.popup.maxWidth)
|
|
119
121
|
.accessibilityElement(children: .contain)
|
|
120
122
|
.accessibilityIdentifier("popup_notify")
|
|
121
123
|
}
|
|
@@ -29,6 +29,7 @@ public struct PopupInput: View {
|
|
|
29
29
|
VStack {
|
|
30
30
|
VStack(alignment: .leading) {
|
|
31
31
|
MomoText(title, typography: .headerDefaultBold)
|
|
32
|
+
.padding(.trailing, ModalMetrics.iconButtonSize + Spacing.M - Spacing.XL)
|
|
32
33
|
.padding(.top, 12)
|
|
33
34
|
.padding(.bottom, 24)
|
|
34
35
|
|
|
@@ -55,15 +56,16 @@ public struct PopupInput: View {
|
|
|
55
56
|
|
|
56
57
|
}.clipped()
|
|
57
58
|
|
|
58
|
-
|
|
59
|
-
.
|
|
59
|
+
ModalIconButton(icon: "navigation_close", accessibilityId: "ic_popup_close", action: onPressClose)
|
|
60
|
+
.padding(.top, Spacing.M)
|
|
61
|
+
.padding(.trailing, Spacing.M)
|
|
60
62
|
}
|
|
61
63
|
}
|
|
62
|
-
.background(theme.colors.background.surface.cornerRadius(
|
|
64
|
+
.background(theme.colors.background.surface.cornerRadius(layout.popupRadius))
|
|
63
65
|
.shadow(color: .black.opacity(0.08), radius: 2, x: 0, y: 0)
|
|
64
66
|
.shadow(color: .black.opacity(0.16), radius: 24, x: 0, y: 0)
|
|
65
67
|
.frame(maxWidth: layout.popupMaxWidth)
|
|
66
|
-
.padding(.horizontal, 40)
|
|
68
|
+
.padding(.horizontal, layout.popupHorizontalPadding(40))
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
// MARK: Internal
|
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import SDWebImageSwiftUI
|
|
2
2
|
import SwiftUI
|
|
3
3
|
|
|
4
|
-
// Width of a system alert on the iPhone Duo inner display, in both orientations (RN Popup/utils.ts).
|
|
5
|
-
private let duoPopupMaxWidth: CGFloat = 440
|
|
6
|
-
|
|
7
4
|
extension ScreenLayout {
|
|
8
|
-
/// Card width
|
|
5
|
+
/// Card width on foldables (`modalLayout`, Compose `popupMaxWidth`); unbounded on phones,
|
|
6
|
+
/// where the popup's own padding sets the width.
|
|
9
7
|
var popupMaxWidth: CGFloat {
|
|
10
|
-
|
|
8
|
+
let modal = modalLayout
|
|
9
|
+
return modal.isFoldable ? modal.popup.maxWidth : .infinity
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/// The placement already keeps foldable popups off the edges, so their own side padding goes.
|
|
13
|
+
func popupHorizontalPadding(_ padding: CGFloat) -> CGFloat {
|
|
14
|
+
modalLayout.isFoldable ? 0 : padding
|
|
11
15
|
}
|
|
12
16
|
|
|
13
|
-
///
|
|
17
|
+
/// Tallest a popup gets on foldables; nil on phones.
|
|
14
18
|
var popupMaxHeight: CGFloat? {
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
modalLayout.popup.maxHeight
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/// Popup corner radius on every device (`modalLayout`, Compose `popupRadius`).
|
|
23
|
+
var popupRadius: CGFloat {
|
|
24
|
+
modalLayout.popup.radius
|
|
17
25
|
}
|
|
18
26
|
}
|
|
19
27
|
|
|
@@ -80,7 +88,7 @@ extension View {
|
|
|
80
88
|
}
|
|
81
89
|
}
|
|
82
90
|
|
|
83
|
-
/// 22pt round close button
|
|
91
|
+
/// 22pt round close button under `PopupPromotion`'s image (Compose `PopupPromotion`).
|
|
84
92
|
struct PopupCloseButton: View {
|
|
85
93
|
@Environment(\.appTheme) private var theme
|
|
86
94
|
var tapSize: CGFloat = 22
|
|
@@ -22,6 +22,7 @@ public struct PopupNotifyProps {
|
|
|
22
22
|
public var buttonDirection: PopupActionDirection
|
|
23
23
|
public var onIconClose: () -> Void
|
|
24
24
|
public var isShowCloseIcon: Bool
|
|
25
|
+
public var highlightText: [String]
|
|
25
26
|
|
|
26
27
|
public init(
|
|
27
28
|
image: String = "",
|
|
@@ -32,7 +33,8 @@ public struct PopupNotifyProps {
|
|
|
32
33
|
secondary: PopupAction? = nil,
|
|
33
34
|
buttonDirection: PopupActionDirection = .row,
|
|
34
35
|
onIconClose: @escaping () -> Void,
|
|
35
|
-
isShowCloseIcon: Bool = true
|
|
36
|
+
isShowCloseIcon: Bool = true,
|
|
37
|
+
highlightText: [String] = []
|
|
36
38
|
) {
|
|
37
39
|
self.image = image
|
|
38
40
|
self.title = title
|
|
@@ -43,6 +45,7 @@ public struct PopupNotifyProps {
|
|
|
43
45
|
self.buttonDirection = buttonDirection
|
|
44
46
|
self.onIconClose = onIconClose
|
|
45
47
|
self.isShowCloseIcon = isShowCloseIcon
|
|
48
|
+
self.highlightText = highlightText
|
|
46
49
|
}
|
|
47
50
|
}
|
|
48
51
|
|
|
@@ -55,7 +58,8 @@ public struct PopupNotify: View {
|
|
|
55
58
|
public let props: PopupNotifyProps
|
|
56
59
|
|
|
57
60
|
@State private var descriptionHeight: CGFloat = 0
|
|
58
|
-
@State private var
|
|
61
|
+
@State private var descriptionFrameHeight: CGFloat = 0
|
|
62
|
+
@State private var cardHeight: CGFloat = 0
|
|
59
63
|
@State private var oneLineHeight: CGFloat = 0
|
|
60
64
|
@State private var twoLinesHeight: CGFloat = 0
|
|
61
65
|
|
|
@@ -63,10 +67,13 @@ public struct PopupNotify: View {
|
|
|
63
67
|
localize.translate("errorCode")
|
|
64
68
|
}
|
|
65
69
|
|
|
66
|
-
// ~8.5 lines as laid out (Compose measures the real lines); nominal line height until measured
|
|
70
|
+
// ~8.5 lines as laid out (Compose measures the real lines); nominal line height until measured.
|
|
71
|
+
// With a max height (foldables) only the description gives way: image, title and actions stay.
|
|
67
72
|
private var maxDescriptionHeight: CGFloat {
|
|
68
|
-
popupLinesHeight(8.5, oneLine: oneLineHeight, twoLines: twoLinesHeight)
|
|
73
|
+
let lines = popupLinesHeight(8.5, oneLine: oneLineHeight, twoLines: twoLinesHeight)
|
|
69
74
|
?? fontScale(TypographyStyle.bodyDefaultRegular.lineHeight) * 8.5
|
|
75
|
+
guard let maxHeight = layout.modalLayout.popup.maxHeight else { return lines }
|
|
76
|
+
return max(min(lines, maxHeight - (cardHeight - descriptionFrameHeight)), 0)
|
|
70
77
|
}
|
|
71
78
|
|
|
72
79
|
private var shouldUseColumnButtons: Bool {
|
|
@@ -87,33 +94,29 @@ public struct PopupNotify: View {
|
|
|
87
94
|
}
|
|
88
95
|
|
|
89
96
|
public var body: some View {
|
|
97
|
+
let modal = layout.modalLayout
|
|
90
98
|
ZStack(alignment: .topTrailing) {
|
|
91
99
|
VStack(spacing: 0) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
VStack(spacing: 0) {
|
|
95
|
-
if !props.image.isEmpty {
|
|
96
|
-
PopupHeaderImage(url: props.image)
|
|
97
|
-
}
|
|
98
|
-
textContent
|
|
99
|
-
}
|
|
100
|
+
if !props.image.isEmpty {
|
|
101
|
+
PopupHeaderImage(url: props.image)
|
|
100
102
|
}
|
|
103
|
+
textContent
|
|
101
104
|
|
|
102
105
|
actionButtons
|
|
103
106
|
.padding(.horizontal, Spacing.XL)
|
|
104
107
|
.padding(.bottom, Spacing.XL)
|
|
105
|
-
.popupReadHeight($actionsHeight)
|
|
106
108
|
}
|
|
107
109
|
.background(theme.colors.background.surface)
|
|
108
|
-
.clipShape(RoundedRectangle(cornerRadius:
|
|
110
|
+
.clipShape(RoundedRectangle(cornerRadius: modal.popup.radius))
|
|
111
|
+
.popupReadHeight($cardHeight)
|
|
109
112
|
|
|
110
113
|
if props.isShowCloseIcon {
|
|
111
|
-
|
|
112
|
-
.
|
|
114
|
+
ModalIconButton(icon: "navigation_close", accessibilityId: "ic_popup_close", action: props.onIconClose)
|
|
115
|
+
.padding(.top, Spacing.M)
|
|
116
|
+
.padding(.trailing, Spacing.M)
|
|
113
117
|
}
|
|
114
118
|
}
|
|
115
|
-
.frame(maxWidth:
|
|
116
|
-
.padding(.horizontal, Spacing.M)
|
|
119
|
+
.frame(minWidth: modal.popup.minWidth, maxWidth: modal.popup.maxWidth)
|
|
117
120
|
.accessibilityElement(children: .contain)
|
|
118
121
|
.accessibilityIdentifier("popup_notify")
|
|
119
122
|
}
|
|
@@ -126,6 +129,7 @@ public struct PopupNotify: View {
|
|
|
126
129
|
maxLines: 2,
|
|
127
130
|
accessibilityId: "title_popup_permission"
|
|
128
131
|
)
|
|
132
|
+
.padding(.trailing, props.isShowCloseIcon && props.image.isEmpty ? ModalMetrics.iconButtonSize + Spacing.M - Spacing.XL : 0)
|
|
129
133
|
.padding(.bottom, Spacing.S)
|
|
130
134
|
|
|
131
135
|
descriptionContent
|
|
@@ -145,23 +149,26 @@ public struct PopupNotify: View {
|
|
|
145
149
|
.measureLineHeights(typography: .bodyDefaultRegular, oneLine: $oneLineHeight, twoLines: $twoLinesHeight)
|
|
146
150
|
}
|
|
147
151
|
|
|
148
|
-
@ViewBuilder
|
|
149
152
|
private var descriptionContent: some View {
|
|
150
|
-
|
|
151
|
-
|
|
153
|
+
Group {
|
|
154
|
+
if descriptionHeight > maxDescriptionHeight {
|
|
155
|
+
ScrollView(.vertical, showsIndicators: false) {
|
|
156
|
+
descriptionText
|
|
157
|
+
}
|
|
158
|
+
.frame(height: maxDescriptionHeight)
|
|
159
|
+
} else {
|
|
152
160
|
descriptionText
|
|
153
161
|
}
|
|
154
|
-
.frame(height: maxDescriptionHeight)
|
|
155
|
-
} else {
|
|
156
|
-
descriptionText
|
|
157
162
|
}
|
|
163
|
+
.popupReadHeight($descriptionFrameHeight)
|
|
158
164
|
}
|
|
159
165
|
|
|
160
166
|
private var descriptionText: some View {
|
|
161
167
|
MomoText(
|
|
162
168
|
props.description,
|
|
163
169
|
typography: .bodyDefaultRegular,
|
|
164
|
-
accessibilityId: "description_popup_permission"
|
|
170
|
+
accessibilityId: "description_popup_permission",
|
|
171
|
+
highlightText: props.highlightText
|
|
165
172
|
)
|
|
166
173
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
167
174
|
.popupReadHeight($descriptionHeight)
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
1
|
import Foundation
|
|
3
2
|
import SwiftUI
|
|
4
3
|
|
|
5
4
|
public struct FullscreenPopup<Item: Equatable, PopupContent: View>: ViewModifier {
|
|
6
5
|
|
|
7
|
-
// MARK: -
|
|
6
|
+
// MARK: - Presentation
|
|
8
7
|
@Binding var isPresented: Bool
|
|
9
8
|
@Binding var item: Item?
|
|
10
9
|
|
|
@@ -56,7 +55,7 @@ public struct FullscreenPopup<Item: Equatable, PopupContent: View>: ViewModifier
|
|
|
56
55
|
@State private var dispatchWorkHolder = DispatchWorkHolder()
|
|
57
56
|
|
|
58
57
|
// MARK: - Internal
|
|
59
|
-
/// Set dismiss
|
|
58
|
+
/// Set dismiss source to pass to dismiss callback
|
|
60
59
|
@State private var dismissSource: DismissSource?
|
|
61
60
|
|
|
62
61
|
init(isPresented: Binding<Bool>,
|
|
@@ -190,7 +189,7 @@ public struct FullscreenPopup<Item: Equatable, PopupContent: View>: ViewModifier
|
|
|
190
189
|
showContent = true // immediately load popup body
|
|
191
190
|
performWithDelay(0.01) {
|
|
192
191
|
shouldShowContent = true // this will cause currentOffset change thus triggering the sliding showing animation
|
|
193
|
-
opacity = 1 // this will cause cross
|
|
192
|
+
opacity = 1 // this will cause cross dissolving animation for background color
|
|
194
193
|
setupAutohide()
|
|
195
194
|
}
|
|
196
195
|
} else {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import SwiftUI
|
|
2
2
|
|
|
3
3
|
public enum DismissSource {
|
|
4
|
-
case binding // set isPresented to false
|
|
4
|
+
case binding // set isPresented to false or item to nil
|
|
5
5
|
case tapInside
|
|
6
6
|
case tapOutside
|
|
7
7
|
case drag
|
|
@@ -140,7 +140,7 @@ public struct Popup<Item: Equatable, PopupContent: View>: ViewModifier {
|
|
|
140
140
|
/// is called on any close action
|
|
141
141
|
var dismissCallback: (DismissSource) -> ()
|
|
142
142
|
|
|
143
|
-
/// Set dismiss
|
|
143
|
+
/// Set dismiss source to pass to dismiss callback
|
|
144
144
|
@Binding private var dismissSource: DismissSource?
|
|
145
145
|
|
|
146
146
|
/// called on showing/hiding sliding animation completed
|
|
@@ -128,7 +128,7 @@ struct AnimatableModifierDouble: AnimatableModifier {
|
|
|
128
128
|
// Set animatableData to the new value. But SwiftUI again directly
|
|
129
129
|
// and gradually varies the value while the body
|
|
130
130
|
// is being called to animate. Following line serves the purpose of
|
|
131
|
-
// associating the
|
|
131
|
+
// associating the external argument with the animatableData.
|
|
132
132
|
self.animatableData = bindedValue
|
|
133
133
|
targetValue = bindedValue
|
|
134
134
|
AnimatableModifierDouble.done = false
|
|
@@ -139,7 +139,6 @@ struct AnimatableModifierDouble: AnimatableModifier {
|
|
|
139
139
|
let delta = 0.1
|
|
140
140
|
if animatableData > targetValue - delta &&
|
|
141
141
|
animatableData < targetValue + delta {
|
|
142
|
-
//print("check", animatableData, targetValue)
|
|
143
142
|
AnimatableModifierDouble.done = true
|
|
144
143
|
DispatchQueue.main.async {
|
|
145
144
|
self.completion()
|
|
@@ -27,19 +27,8 @@ public enum ProgressInfoAlign {
|
|
|
27
27
|
|
|
28
28
|
// MARK: - Public entry-point
|
|
29
29
|
|
|
30
|
-
/// Display-only step progress
|
|
31
|
-
///
|
|
32
|
-
/// - Parameters:
|
|
33
|
-
/// - steps: Ordered list of steps; each has a title and an optional description.
|
|
34
|
-
/// - horizontal: When `true` renders steps in a horizontal row with connector lines;
|
|
35
|
-
/// when `false` (default) renders a vertical column.
|
|
36
|
-
/// - size: Icon diameter: `.small` = 16, `.large` = 24 (default).
|
|
37
|
-
/// - useNumber: Show the 1-based step index inside the icon instead of the default dot.
|
|
38
|
-
/// - align: Alignment of icon + text for the horizontal variant.
|
|
39
|
-
/// - showTitle: Whether step titles are rendered (default `true`).
|
|
40
|
-
/// - showDescription: Whether step descriptions are rendered (default `true`).
|
|
41
|
-
/// - customIcon: Icon source key rendered inside each step circle (overrides the dot;
|
|
42
|
-
/// itself overridden by `useNumber`).
|
|
30
|
+
/// Display-only step progress. Each step icon shows the 1-based index with `useNumber`, else
|
|
31
|
+
/// `customIcon`, else a dot; `align` applies to the horizontal variant only.
|
|
43
32
|
public struct ProgressInfo: View {
|
|
44
33
|
private let steps: [ProgressInfoItem]
|
|
45
34
|
private let horizontal: Bool
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
import SwiftUI
|
|
3
3
|
|
|
4
|
-
///
|
|
5
|
-
///
|
|
6
|
-
/// Fills the available space with a base placeholder color and overlays a
|
|
7
|
-
/// horizontal shimmer gradient that animates left-to-right on an infinite loop.
|
|
8
|
-
///
|
|
9
|
-
/// Mirrors the Compose surface: `Skeleton()` takes no required arguments and
|
|
10
|
-
/// fills its container. The shimmer animation parameters match the Compose
|
|
11
|
-
/// defaults (`durationMillis = 1000`, shimmer band = 60% of container width).
|
|
4
|
+
/// Compose `Skeleton`: fills its container with a placeholder color under a shimmer band
|
|
5
|
+
/// that loops left to right, with Compose's defaults (1000ms, band 60% of the width).
|
|
12
6
|
public struct Skeleton: View {
|
|
13
7
|
// Matches Compose `DEFAULT_DURATION_MILLIS = 1000`.
|
|
14
8
|
private let durationMillis: Int
|
|
@@ -31,14 +25,11 @@ public struct Skeleton: View {
|
|
|
31
25
|
angleOfAxisY: angleOfAxisY
|
|
32
26
|
)
|
|
33
27
|
}
|
|
34
|
-
// Compose base background (`Colors.black_05`).
|
|
35
28
|
.background(Colors.black05)
|
|
36
29
|
}
|
|
37
30
|
}
|
|
38
31
|
|
|
39
|
-
///
|
|
40
|
-
/// a linear gradient band (60% of the container width) translated across the
|
|
41
|
-
/// surface on an infinite, restarting, linearly-eased loop.
|
|
32
|
+
/// Compose's `Modifier.shimmerLoadingAnimation`: a gradient band 60% of the width sweeps across on a linear loop.
|
|
42
33
|
private struct ShimmerLoading: View {
|
|
43
34
|
let size: CGSize
|
|
44
35
|
let durationMillis: Int
|
|
@@ -47,7 +38,6 @@ private struct ShimmerLoading: View {
|
|
|
47
38
|
// Matches Compose `SHADOW_BRUSH_PERCENTAGE = 0.6f`.
|
|
48
39
|
private static let shadowBrushPercentage: CGFloat = 0.6
|
|
49
40
|
|
|
50
|
-
// Pre-computed shimmer colors (Colors.black_05, black_03, black_05).
|
|
51
41
|
private static let shimmerColors: [Color] = [
|
|
52
42
|
Colors.black05,
|
|
53
43
|
Colors.black03,
|
|
@@ -58,9 +48,8 @@ private struct ShimmerLoading: View {
|
|
|
58
48
|
(size.width * Self.shadowBrushPercentage).rounded(.towardZero)
|
|
59
49
|
}
|
|
60
50
|
|
|
61
|
-
// Compose animates
|
|
62
|
-
//
|
|
63
|
-
// from off-screen-left to off-screen-right: -widthOfShadowBrush ... maxWidth.
|
|
51
|
+
// Compose animates to `durationMillis + widthOfShadowBrush`; the band is anchored at the value, so the travel
|
|
52
|
+
// that shows runs from fully off-screen left to fully off-screen right: -widthOfShadowBrush ... maxWidth.
|
|
64
53
|
private var animationTarget: CGFloat {
|
|
65
54
|
size.width + widthOfShadowBrush
|
|
66
55
|
}
|
package/ios/Slider/Slider.swift
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import SwiftUI
|
|
2
2
|
|
|
3
|
-
//
|
|
3
|
+
// MARK: - Constants
|
|
4
4
|
|
|
5
5
|
private let THUMB_SIZE: CGFloat = 20
|
|
6
6
|
private let THUMB_BORDER: CGFloat = 3
|
|
7
7
|
private let TRACK_HEIGHT: CGFloat = 4
|
|
8
8
|
private let LABEL_GAP: CGFloat = 4 // space between label and thumb top (Spacing.XS)
|
|
9
9
|
|
|
10
|
-
//
|
|
10
|
+
// MARK: - Helpers (Compose / RN parity)
|
|
11
11
|
|
|
12
12
|
private func clampF(_ value: CGFloat, _ minV: CGFloat, _ maxV: CGFloat) -> CGFloat {
|
|
13
13
|
Swift.min(Swift.max(value, minV), maxV)
|
|
@@ -55,12 +55,10 @@ private func formatLabel(_ value: CGFloat) -> String {
|
|
|
55
55
|
return String(Double((value * 10).rounded(.towardZero)) / 10)
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
//
|
|
58
|
+
// MARK: - MomoSlider
|
|
59
59
|
|
|
60
|
-
///
|
|
61
|
-
///
|
|
62
|
-
/// SwiftUI ships a built-in `Slider`; this custom type is named `MomoSlider`
|
|
63
|
-
/// (convention, like `MomoText`) to avoid module-wide shadowing.
|
|
60
|
+
/// Compose range slider (one thumb with `disableRange`), named `MomoSlider` like `MomoText`
|
|
61
|
+
/// to avoid shadowing SwiftUI's `Slider`.
|
|
64
62
|
public struct MomoSlider: View {
|
|
65
63
|
@Environment(\.appTheme) private var theme
|
|
66
64
|
|
|
@@ -130,7 +128,6 @@ public struct MomoSlider: View {
|
|
|
130
128
|
let activeWidth = availableWidth * (activeEndFraction - activeStartFraction)
|
|
131
129
|
|
|
132
130
|
ZStack(alignment: .topLeading) {
|
|
133
|
-
// ── Floating label ────────────────────────────────────────────
|
|
134
131
|
if floatingLabel && isDragging {
|
|
135
132
|
let activeFraction = draggingLow ? lowFraction : highFraction
|
|
136
133
|
let activeValue = draggingLow ? lowValue : highValue
|
|
@@ -142,13 +139,11 @@ public struct MomoSlider: View {
|
|
|
142
139
|
.offset(x: availableWidth * activeFraction, y: 0)
|
|
143
140
|
}
|
|
144
141
|
|
|
145
|
-
// ── Inactive track (full width) ───────────────────────────────
|
|
146
142
|
Capsule()
|
|
147
143
|
.fill(trackInactiveColor)
|
|
148
144
|
.frame(width: max(trackWidth - THUMB_SIZE, 0), height: TRACK_HEIGHT)
|
|
149
145
|
.offset(x: THUMB_SIZE / 2, y: topPad + (THUMB_SIZE - TRACK_HEIGHT) / 2)
|
|
150
146
|
|
|
151
|
-
// ── Active track (selected range / single value) ──────────────
|
|
152
147
|
if activeWidth > 0 {
|
|
153
148
|
Capsule()
|
|
154
149
|
.fill(trackActiveColor)
|
|
@@ -156,11 +151,9 @@ public struct MomoSlider: View {
|
|
|
156
151
|
.offset(x: activeStartX, y: topPad + (THUMB_SIZE - TRACK_HEIGHT) / 2)
|
|
157
152
|
}
|
|
158
153
|
|
|
159
|
-
// ── Low thumb ─────────────────────────────────────────────────
|
|
160
154
|
thumb
|
|
161
155
|
.offset(x: availableWidth * lowFraction, y: topPad)
|
|
162
156
|
|
|
163
|
-
// ── High thumb (range mode only) ──────────────────────────────
|
|
164
157
|
if !disableRange {
|
|
165
158
|
thumb
|
|
166
159
|
.offset(x: availableWidth * highFraction, y: topPad)
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
NS_ASSUME_NONNULL_BEGIN
|
|
4
4
|
|
|
5
|
-
/// Posts `MoMoStatusBarTap.notificationName` on every status-bar tap.
|
|
6
|
-
///
|
|
7
|
-
/// `install` is a no-op kept for explicit/manual triggering.
|
|
5
|
+
/// Posts `MoMoStatusBarTap.notificationName` on every status-bar tap once `install` has run.
|
|
6
|
+
/// Opt-in: there is no `+load` auto-install; `install` is idempotent.
|
|
8
7
|
@interface MoMoStatusBarTap : NSObject
|
|
9
8
|
@property (class, nonatomic, readonly) NSNotificationName notificationName;
|
|
10
9
|
+ (void)install;
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
#import <objc/runtime.h>
|
|
4
4
|
#import "StatusBarTap.h"
|
|
5
5
|
|
|
6
|
-
// Performs the actual swizzle once per process. Safe to call multiple times.
|
|
7
6
|
static void mm_installStatusBarTapSwizzleOnce(void) {
|
|
8
7
|
static dispatch_once_t onceToken;
|
|
9
8
|
dispatch_once(&onceToken, ^{
|
|
@@ -15,9 +14,7 @@ static void mm_installStatusBarTapSwizzleOnce(void) {
|
|
|
15
14
|
Method swizzledMethod = class_getInstanceMethod(cls, swizzledSelector);
|
|
16
15
|
if (!originalMethod || !swizzledMethod) return;
|
|
17
16
|
|
|
18
|
-
//
|
|
19
|
-
// Encoding may include byte offsets (e.g. "v32@0:8@16") so we filter
|
|
20
|
-
// digits out before comparing.
|
|
17
|
+
// Bail unless the original is (id) -> void; the encoding carries byte offsets ("v32@0:8@16").
|
|
21
18
|
const char *encPtr = method_getTypeEncoding(originalMethod);
|
|
22
19
|
if (encPtr) {
|
|
23
20
|
NSMutableString *enc = [NSMutableString string];
|
|
@@ -48,24 +45,14 @@ static void mm_installStatusBarTapSwizzleOnce(void) {
|
|
|
48
45
|
@end
|
|
49
46
|
|
|
50
47
|
// MARK: - Swizzle target on UIStatusBarManager
|
|
51
|
-
// `mm_handleTapAction:`
|
|
52
|
-
//
|
|
53
|
-
// the body invokes UIKit's real handler so UIScrollView.scrollsToTop
|
|
54
|
-
// and any other side effects continue to work.
|
|
48
|
+
// After the swizzle `mm_handleTapAction:` points at UIKit's original IMP, so calling it runs the
|
|
49
|
+
// real handler (UIScrollView.scrollsToTop and other side effects) before posting.
|
|
55
50
|
|
|
56
51
|
@interface UIStatusBarManager (MoMoStatusBarTap)
|
|
57
52
|
@end
|
|
58
53
|
|
|
59
54
|
@implementation UIStatusBarManager (MoMoStatusBarTap)
|
|
60
55
|
|
|
61
|
-
// Auto-install at framework load. Commented out so the swizzle stays
|
|
62
|
-
// opt-in via `[MoMoStatusBarTap install]`. Uncomment to revert to
|
|
63
|
-
// auto-installation before main().
|
|
64
|
-
//
|
|
65
|
-
// + (void)load {
|
|
66
|
-
// mm_installStatusBarTapSwizzleOnce();
|
|
67
|
-
// }
|
|
68
|
-
|
|
69
56
|
- (void)mm_handleTapAction:(id)action {
|
|
70
57
|
[self mm_handleTapAction:action];
|
|
71
58
|
[[NSNotificationCenter defaultCenter] postNotificationName:MoMoStatusBarTap.notificationName
|