@momo-kits/native-kits 0.169.6 → 0.169.7
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/ios/Application/ApplicationEnvironment.swift +2 -3
- package/ios/Application/DesignSystemKits.swift +4 -20
- package/ios/Application/DesignSystemKitsPayload.swift +0 -8
- package/ios/Application/LanguageSource.swift +0 -8
- package/ios/Application/Localize.swift +7 -31
- package/ios/Application/LocalizeModifier.swift +0 -8
- package/ios/Application/MaxApi.swift +3 -11
- package/ios/Avatar/Avatar.swift +0 -1
- package/ios/Badge/Badge.swift +0 -1
- package/ios/Badge/BadgeRibbon.swift +2 -5
- package/ios/Button/Button.swift +2 -5
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +2 -2
- package/ios/Carousel/Carousel.swift +5 -17
- package/ios/Checkbox/Checkbox.swift +0 -2
- 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/SkeletonUICompat.swift +0 -8
- package/ios/Icon/Icon.swift +1 -3
- package/ios/IconButton/IconButton.swift +0 -2
- package/ios/Input/ErrorView.swift +0 -7
- package/ios/Input/Input.swift +6 -19
- package/ios/Input/InputPhoneNumber.swift +0 -11
- package/ios/Input/InputSearch.swift +0 -6
- package/ios/Input/InputTextArea.swift +1 -12
- package/ios/InputDropDown/InputDropDown.swift +1 -11
- package/ios/InputMoney/InputMoney.swift +9 -28
- package/ios/InputOTP/InputOTP.swift +2 -9
- package/ios/Layout/Item.swift +1 -2
- package/ios/Layout/ModalLayout.swift +7 -14
- package/ios/Layout/ScreenLayout.swift +2 -7
- package/ios/Loader/Loader.swift +3 -12
- package/ios/Lottie/LottieView.swift +0 -11
- package/ios/Navigation/BottomSheet.swift +14 -35
- package/ios/Navigation/BottomTab/BottomTab.swift +10 -19
- package/ios/Navigation/BottomTab/BottomTabBar.swift +4 -10
- package/ios/Navigation/BottomTab/CurvedContainer.swift +5 -11
- package/ios/Navigation/BottomTab/DuoBarCompression.swift +6 -12
- package/ios/Navigation/BottomTab/DuoTabBar.swift +2 -7
- package/ios/Navigation/BottomTab/TabBarMetrics.swift +3 -9
- package/ios/Navigation/Component/FloatingButton.swift +4 -11
- package/ios/Navigation/Component/Header.swift +4 -8
- package/ios/Navigation/Component/HeaderBackground.swift +2 -8
- package/ios/Navigation/Component/HeaderJourney.swift +2 -7
- package/ios/Navigation/Component/HeaderLocation.swift +2 -7
- package/ios/Navigation/Component/HeaderRight.swift +2 -7
- package/ios/Navigation/Component/HeaderTitle.swift +1 -6
- package/ios/Navigation/Component/HeaderUser.swift +2 -9
- package/ios/Navigation/Component/SideBar.swift +3 -8
- package/ios/Navigation/Component/SnackBar.swift +5 -13
- package/ios/Navigation/HostBackGestureBridge.swift +3 -9
- package/ios/Navigation/ModalScreen.swift +2 -8
- package/ios/Navigation/Navigation.swift +2 -15
- package/ios/Navigation/NavigationContainer.swift +3 -12
- package/ios/Navigation/Navigator.swift +15 -27
- package/ios/Navigation/StackScreen.swift +8 -28
- package/ios/Navigation/StackTransition.swift +3 -11
- 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 +3 -3
- package/ios/Popup/PopupInput.swift +1 -1
- package/ios/Popup/PopupLayout.swift +3 -3
- 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 +2 -10
- 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 +9 -11
- package/ios/Swipeable/SwipeCell.swift +2 -2
- package/ios/Swipeable/SwipeCellModel.swift +3 -6
- package/ios/TabView/TabView.swift +12 -25
- package/ios/Template/TrustBanner/TrustBanner.swift +2 -9
- package/ios/Tooltip/Tooltip.swift +2 -7
- package/ios/Typography/FontScale.swift +3 -15
- package/ios/Typography/Text.swift +2 -7
- package/ios/Typography/Typography.swift +8 -10
- package/ios/Uploader/Uploader.swift +2 -17
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +0 -8
- package/package.json +1 -1
|
@@ -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
|
}
|
|
@@ -108,7 +108,7 @@ public struct PopupDisplay: View {
|
|
|
108
108
|
}
|
|
109
109
|
.fixedSize(horizontal: false, vertical: true)
|
|
110
110
|
.background(theme.colors.background.surface)
|
|
111
|
-
.clipShape(RoundedRectangle(cornerRadius: layout.popupRadius
|
|
111
|
+
.clipShape(RoundedRectangle(cornerRadius: layout.popupRadius))
|
|
112
112
|
|
|
113
113
|
if isShowCloseIcon {
|
|
114
114
|
ModalIconButton(icon: "navigation_close", accessibilityId: "ic_popup_close", action: onClose)
|
|
@@ -116,8 +116,8 @@ public struct PopupDisplay: View {
|
|
|
116
116
|
.padding(.trailing, Spacing.M)
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
|
|
120
|
-
.
|
|
119
|
+
// window minus 24 a side on phones too, host padding included (PopupNotify parity)
|
|
120
|
+
.frame(maxWidth: layout.modalLayout.popup.maxWidth)
|
|
121
121
|
.accessibilityElement(children: .contain)
|
|
122
122
|
.accessibilityIdentifier("popup_notify")
|
|
123
123
|
}
|
|
@@ -61,7 +61,7 @@ public struct PopupInput: View {
|
|
|
61
61
|
.padding(.trailing, Spacing.M)
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
.background(theme.colors.background.surface.cornerRadius(layout.popupRadius
|
|
64
|
+
.background(theme.colors.background.surface.cornerRadius(layout.popupRadius))
|
|
65
65
|
.shadow(color: .black.opacity(0.08), radius: 2, x: 0, y: 0)
|
|
66
66
|
.shadow(color: .black.opacity(0.16), radius: 24, x: 0, y: 0)
|
|
67
67
|
.frame(maxWidth: layout.popupMaxWidth)
|
|
@@ -19,9 +19,9 @@ extension ScreenLayout {
|
|
|
19
19
|
modalLayout.popup.maxHeight
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
/// Popup corner radius on every device (`modalLayout`, Compose `popupRadius`).
|
|
23
|
+
var popupRadius: CGFloat {
|
|
24
|
+
modalLayout.popup.radius
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -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,7 +25,6 @@ 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
|
}
|
|
@@ -47,7 +40,6 @@ private struct ShimmerLoading: View {
|
|
|
47
40
|
// Matches Compose `SHADOW_BRUSH_PERCENTAGE = 0.6f`.
|
|
48
41
|
private static let shadowBrushPercentage: CGFloat = 0.6
|
|
49
42
|
|
|
50
|
-
// Pre-computed shimmer colors (Colors.black_05, black_03, black_05).
|
|
51
43
|
private static let shimmerColors: [Color] = [
|
|
52
44
|
Colors.black05,
|
|
53
45
|
Colors.black03,
|
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
|
|
@@ -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
|
|
@@ -297,7 +297,7 @@ private struct StepsHorizontal: View {
|
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
-
//
|
|
300
|
+
// MARK: - Vertical layout
|
|
301
301
|
|
|
302
302
|
private struct StepsVertical: View {
|
|
303
303
|
@Environment(\.appTheme) private var theme
|
|
@@ -404,11 +404,9 @@ private struct StepsVertical: View {
|
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
406
|
|
|
407
|
-
//
|
|
407
|
+
// MARK: - Public API
|
|
408
408
|
|
|
409
|
-
///
|
|
410
|
-
///
|
|
411
|
-
/// Mirrors the Compose `Steps` component.
|
|
409
|
+
/// Guided progress through a sequence of steps; mirrors Compose `Steps`.
|
|
412
410
|
public struct Steps: View {
|
|
413
411
|
private let steps: [StepItem]
|
|
414
412
|
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
|
|