@momo-kits/native-kits 0.162.2-beta.26 → 0.162.2-beta.27
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 +1 -1
- package/ios/Application/ApplicationEnvironment.swift +0 -11
- package/ios/Application/Components.swift +44 -34
- package/ios/Application/FloatingButton.swift +9 -10
- package/ios/Application/HeaderRight.swift +45 -79
- package/ios/Application/Screen.swift +1 -2
- package/ios/Badge/Badge.swift +14 -11
- package/ios/Badge/BadgeRibbon.swift +21 -12
- package/ios/Button/Button.swift +22 -61
- package/ios/Checkbox/Checkbox.swift +13 -14
- package/ios/Chip/Chip.swift +9 -23
- package/ios/Colors+Radius+Spacing/Colors.swift +12 -12
- package/ios/Extensions/Color++.swift +0 -32
- package/ios/Icon/Icon.swift +1 -6
- package/ios/Input/Input.swift +25 -41
- package/ios/Input/InputPhoneNumber.swift +19 -20
- package/ios/Input/InputSearch.swift +47 -100
- package/ios/Input/InputTextArea.swift +40 -66
- package/ios/Popup/PopupDisplay.swift +16 -8
- package/ios/Popup/PopupInput.swift +8 -2
- package/ios/Swipeable/SwipeCell.swift +0 -185
- package/ios/Swipeable/SwipeCellModel.swift +0 -21
- package/ios/Typography/Text.swift +5 -79
- package/ios/Typography/Typography.swift +0 -3
- package/ios/native-kits.podspec +8 -61
- package/package.json +1 -1
- package/publish.sh +0 -50
- package/.claude/settings.local.json +0 -39
- package/ios/Application/Navigation/BottomTab/BottomTab.swift +0 -103
- package/ios/Application/Navigation/BottomTab/BottomTabBar.swift +0 -215
- package/ios/Application/Navigation/BottomTab/CurvedContainer.swift +0 -65
- package/ios/Application/Navigation/HeaderBackProps.swift +0 -66
- package/ios/Application/Navigation/HeaderTitle.swift +0 -57
- package/ios/Application/Navigation/HeaderUser.swift +0 -209
- package/ios/Application/Navigation/NavigationContainer.swift +0 -176
- package/ios/Application/Navigation/NavigationOptions.swift +0 -109
- package/ios/Application/Navigation/Navigator.swift +0 -364
- package/ios/Application/Navigation/Overplay/BottomSheet.swift +0 -188
- package/ios/Application/Navigation/Overplay/ModalScreen.swift +0 -68
- package/ios/Application/Navigation/Overplay/SnackBar.swift +0 -144
- package/ios/Application/Navigation/component/Header.swift +0 -178
- package/ios/Application/Navigation/component/HeaderBackground.swift +0 -83
- package/ios/Application/Navigation/component/HeaderColor.swift +0 -65
- package/ios/Application/StackScreen.swift +0 -453
- package/ios/Avatar/Avatar.swift +0 -193
- package/ios/BaselineView/BaselineView.swift +0 -163
- package/ios/Carousel/Carousel.swift +0 -181
- package/ios/Collapse/Collapse.swift +0 -182
- package/ios/Colors+Radius+Spacing/Theme.swift +0 -295
- package/ios/DateTimePicker/DateTimePicker.swift +0 -210
- package/ios/DateTimePicker/DateTimePickerTypes.swift +0 -55
- package/ios/DateTimePicker/DateTimePickerUtils.swift +0 -167
- package/ios/DateTimePicker/WheelPicker.swift +0 -161
- package/ios/Divider/Divider.swift +0 -16
- package/ios/IconButton/IconButton.swift +0 -112
- package/ios/InputDropDown/InputDropDown.swift +0 -198
- package/ios/InputMoney/InputMoney.swift +0 -335
- package/ios/InputOTP/InputOTP.swift +0 -210
- package/ios/Loader/Loader.swift +0 -113
- package/ios/MoMoUIKits.podspec +0 -5
- package/ios/Pagination/PaginationDot.swift +0 -61
- package/ios/Pagination/PaginationNumber.swift +0 -35
- package/ios/Pagination/PaginationScroll.swift +0 -101
- package/ios/Pagination/PaginationWhiteDot.swift +0 -37
- package/ios/Popup/PopupNotify.swift +0 -219
- package/ios/ProgressInfo/ProgressInfo.swift +0 -294
- package/ios/Radio/Radio.swift +0 -70
- package/ios/Rating/Rating.swift +0 -82
- package/ios/Resources/MoMoUIKitsColors.xcassets/AccentColor.colorset/Contents.json +0 -11
- package/ios/Resources/MoMoUIKitsColors.xcassets/Background.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/Border.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/Card.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/Contents.json +0 -6
- package/ios/Resources/MoMoUIKitsColors.xcassets/Error.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/Primary.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/PrimaryDark.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/PrimaryLight.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/Secondary.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/Success.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/Text.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/TextSecondary.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/Contents.json +0 -9
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-default.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-disable.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-pressed.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-selected.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-surface.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-tonal.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/border-default.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/border-disable.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/gradient.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/primary.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/secondary.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-container.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-primary.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-secondary.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-default.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-disable.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-hint.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-secondary.colorset/Contents.json +0 -38
- package/ios/Resources/MoMoUIKitsColors.xcassets/Warning.colorset/Contents.json +0 -38
- package/ios/Skeleton/Skeleton.swift +0 -99
- package/ios/Slider/Slider.swift +0 -237
- package/ios/Stepper/Stepper.swift +0 -220
- package/ios/Steps/Steps.swift +0 -451
- package/ios/SuggestAction/SuggestAction.swift +0 -97
- package/ios/TabView/TabView.swift +0 -530
- package/ios/Tag/Tag.swift +0 -98
- package/ios/Title/Title.swift +0 -269
- package/ios/Tooltip/Tooltip.swift +0 -482
- package/ios/Typography/FontScaleStore.swift +0 -19
- package/ios/Uploader/Uploader.swift +0 -183
- package/ios-demo/MoMoUIKitsDemo.podspec +0 -20
- package/ios-demo/Resources/dot_loading.json +0 -558
- package/ios-demo/Resources/icon.json +0 -4052
- package/ios-demo/Resources/lottie_circle_loader.json +0 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/DemoScaffold.swift +0 -48
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsBadgeDemoView.swift +0 -25
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsButtonDemoView.swift +0 -26
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsCheckboxDemoView.swift +0 -19
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsChipDemoView.swift +0 -33
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsInputDemoView.swift +0 -48
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsPopupDemoView.swift +0 -21
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsRadioDemoView.swift +0 -17
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsTypographyDemoView.swift +0 -28
- package/ios-demo/Sources/MoMoUIKitsDemo/MoMoUIKitsDemoContext.swift +0 -31
- package/ios-demo/Sources/MoMoUIKitsDemo/MoMoUIKitsDemoFactory.swift +0 -24
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +0 -110
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AvatarDemo.swift +0 -93
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BadgeDemo.swift +0 -269
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BaselineView.swift +0 -117
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +0 -89
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ButtonDemo.swift +0 -100
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CarouselDemo.swift +0 -126
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CheckboxDemo.swift +0 -63
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ChipDemo.swift +0 -20
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CollapseDemo.swift +0 -93
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ContentView.swift +0 -107
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DateTimePickerDemo.swift +0 -124
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DividerDemo.swift +0 -14
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/HeaderUserDemo.swift +0 -49
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/Home.swift +0 -278
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/IconButtonDemo.swift +0 -58
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ImageDemo.swift +0 -78
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InformationDemo.swift +0 -138
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputDemo.swift +0 -111
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputDropDownDemo.swift +0 -136
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputMoneyDemo.swift +0 -107
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputOTPDemo.swift +0 -73
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputPhoneNumberDemo.swift +0 -100
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputSearchDemo.swift +0 -32
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputTextAreaDemo.swift +0 -57
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LoaderDemo.swift +0 -70
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +0 -227
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PaginationDemo.swift +0 -72
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupDisplayDemo.swift +0 -175
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +0 -121
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupPromotionDemo.swift +0 -76
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ProgressInfoDemo.swift +0 -89
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/RadioDemo.swift +0 -32
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/RatingDemo.swift +0 -56
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SkeletonDemo.swift +0 -32
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SliderDemo.swift +0 -150
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SnackBarDemo.swift +0 -138
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/StepperDemo.swift +0 -103
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/StepsDemo.swift +0 -94
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SuggestActionDemo.swift +0 -79
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SwipeDemo.swift +0 -152
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SwitchDemo.swift +0 -33
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TabViewDemo.swift +0 -190
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TagDemo.swift +0 -34
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ThemeDemo.swift +0 -182
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TitleDemo.swift +0 -109
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TooltipDemo.swift +0 -187
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TypographyDemo.swift +0 -87
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/UploaderDemo.swift +0 -131
- package/ios-demo/Sources/MoMoUIKitsDemo/SwiftUIDemoBrowserView.swift +0 -51
- package/ios-demo/Sources/MoMoUIKitsDemo/UIKitsDemoModels.swift +0 -15
- package/ios-demo/Sources/MoMoUIKitsDemo/UIKitsDemoRegistry.swift +0 -73
- package/scripts/gen-ios-color.mjs +0 -136
package/CLAUDE.md
CHANGED
|
@@ -40,7 +40,7 @@ Publishing is automated (`publish.sh` + GitLab CI on `[ci build]` / `main`). Do
|
|
|
40
40
|
## Architecture essentials
|
|
41
41
|
|
|
42
42
|
- **Entry point:** wrap content in `NavigationContainer(...)` from `navigation/`. It builds the `Navigator`, takes a host-supplied `Localize` (falls back to an empty one), and provides the CompositionLocals below. **Do not use** `ApplicationContainer` (`application/NavigationContainer.kt`) — deprecated and does **not** wire `LocalLocalize` / `LocalNavigator` / `LocalMaxApi`.
|
|
43
|
-
- **Configuration flows via CompositionLocals**, not params. Public ones: `AppTheme`, `AppStatusBar`, `AppNavigationBar` (`const/Theme.kt`); `ApplicationContext`, `AppConfig`, `AppLanguage`, `LocalLocalize` (`application/`); `LocalNavigator`, `LocalMaxApi` (`navigation/`). Read with `X.current`.
|
|
43
|
+
- **Configuration flows via CompositionLocals**, not params. Public ones: `AppTheme`, `AppStatusBar`, `AppNavigationBar` (`const/Theme.kt`); `ApplicationContext`, `AppConfig`, `AppLanguage`, `LocalLocalize`, `ScaleSizeMaxRate` (`application/`); `LocalNavigator`, `LocalMaxApi` (`navigation/`). Read with `X.current`.
|
|
44
44
|
- **Platform code** goes through `expect`/`actual` in `platform/` — never reference Android/iOS APIs from `commonMain` directly.
|
|
45
45
|
- **Native bridge:** `IMaxApi` (`vn.momo.maxapi`, exposed as `LocalMaxApi`) is the host-app bridge (dismiss, tracking, device info, language).
|
|
46
46
|
- Navigation uses a runtime `DynamicScreenRegistry`; overlays (modal/bottom-sheet/snackbar) go through `Navigator` + `OverplayComponentRegistry`.
|
|
@@ -48,14 +48,3 @@ public class ApplicationEnvironment: ObservableObject {
|
|
|
48
48
|
self.config = config
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
private struct ApplicationEnvironmentKey: EnvironmentKey {
|
|
53
|
-
static let defaultValue = ApplicationEnvironment()
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
public extension EnvironmentValues {
|
|
57
|
-
var applicationEnvironment: ApplicationEnvironment {
|
|
58
|
-
get { self[ApplicationEnvironmentKey.self] }
|
|
59
|
-
set { self[ApplicationEnvironmentKey.self] = newValue }
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -83,8 +83,9 @@ public struct HeaderBackground: View {
|
|
|
83
83
|
self.headerTransparent = headerTransparent
|
|
84
84
|
self.fullScreenContent = fullScreenContent
|
|
85
85
|
}
|
|
86
|
-
|
|
86
|
+
|
|
87
87
|
public var body: some View {
|
|
88
|
+
|
|
88
89
|
let statusBarHeight = safeAreaTopInset()
|
|
89
90
|
let opacity = max(0, 1 - scrollState / 200)
|
|
90
91
|
let height = fullScreenContent ? 0 : statusBarHeight + 52
|
|
@@ -100,6 +101,21 @@ public struct HeaderBackground: View {
|
|
|
100
101
|
.frame(height: height)
|
|
101
102
|
.shadow(color: Colors.black20.opacity(0.2), radius: 10, x: 0, y: -2)
|
|
102
103
|
.background(backgroundColor)
|
|
104
|
+
.overlay(
|
|
105
|
+
headerTransparent ? AnyView(EmptyView()) :
|
|
106
|
+
AnyView(
|
|
107
|
+
Rectangle()
|
|
108
|
+
.fill(LinearGradient(
|
|
109
|
+
gradient: Gradient(colors: [
|
|
110
|
+
Color(red: 1, green: 0.8, blue: 0.87),
|
|
111
|
+
Color(red: 1, green: 0.8, blue: 0.87).opacity(0.5)
|
|
112
|
+
]),
|
|
113
|
+
startPoint: .top,
|
|
114
|
+
endPoint: .bottom))
|
|
115
|
+
.opacity(opacity)
|
|
116
|
+
.frame(height: height))
|
|
117
|
+
)
|
|
118
|
+
|
|
103
119
|
if !headerTransparent {
|
|
104
120
|
Rectangle()
|
|
105
121
|
.fill(Color.black.opacity(0.1))
|
|
@@ -132,26 +148,12 @@ public struct HeaderBackground: View {
|
|
|
132
148
|
}
|
|
133
149
|
}
|
|
134
150
|
|
|
135
|
-
// MARK: - Header right width preference
|
|
136
|
-
|
|
137
|
-
/// Reports the measured width of the header-right area so the animated search
|
|
138
|
-
/// header can compute its trailing inset (mirrors Compose's headerRightWidthPx).
|
|
139
|
-
public struct HeaderRightWidthKey: PreferenceKey {
|
|
140
|
-
public static var defaultValue: CGFloat = 0
|
|
141
|
-
public static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
|
|
142
|
-
value = max(value, nextValue())
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
151
|
// MARK: - Header View
|
|
147
152
|
|
|
148
153
|
public struct Header: View {
|
|
149
154
|
var headerType: HeaderType = .default
|
|
150
155
|
var titlePosition: TitlePosition
|
|
151
156
|
var title: String
|
|
152
|
-
/// Optional rich title (mirrors Compose's `HeaderTitle`); `.user` renders an
|
|
153
|
-
/// avatar group instead of `title`. Defaults to nil → plain `title` text.
|
|
154
|
-
var headerTitle: HeaderTitle?
|
|
155
157
|
var headerRight: (()->any View)? = {HeaderRight()}
|
|
156
158
|
var goBack: (() -> Void)?
|
|
157
159
|
var opacity: CGFloat = 1
|
|
@@ -159,27 +161,22 @@ public struct Header: View {
|
|
|
159
161
|
var scrollState: CGFloat = 0
|
|
160
162
|
var inputSearchProps: InputSearchProps?
|
|
161
163
|
var tintColor: Color?
|
|
162
|
-
/// Title opacity; used by the animated search header to fade the title out on scroll.
|
|
163
|
-
var titleOpacity: CGFloat = 1
|
|
164
164
|
|
|
165
165
|
public init(
|
|
166
166
|
headerType: HeaderType = .default,
|
|
167
167
|
titlePosition: TitlePosition,
|
|
168
168
|
title: String,
|
|
169
|
-
headerTitle: HeaderTitle? = nil,
|
|
170
169
|
headerRight: (()->any View)? = {HeaderRight()},
|
|
171
170
|
goBack: (() -> Void)? = nil,
|
|
172
171
|
opacity: CGFloat = 1,
|
|
173
172
|
animatedHeader: AnimatedHeader? = nil,
|
|
174
173
|
scrollState: CGFloat = 0,
|
|
175
174
|
inputSearchProps: InputSearchProps? = nil,
|
|
176
|
-
tintColor: Color? = nil
|
|
177
|
-
titleOpacity: CGFloat = 1
|
|
175
|
+
tintColor: Color? = nil
|
|
178
176
|
) {
|
|
179
177
|
self.headerType = headerType
|
|
180
178
|
self.titlePosition = titlePosition
|
|
181
179
|
self.title = title
|
|
182
|
-
self.headerTitle = headerTitle
|
|
183
180
|
self.headerRight = headerRight
|
|
184
181
|
self.goBack = goBack
|
|
185
182
|
self.opacity = opacity
|
|
@@ -187,11 +184,10 @@ public struct Header: View {
|
|
|
187
184
|
self.scrollState = scrollState
|
|
188
185
|
self.inputSearchProps = inputSearchProps
|
|
189
186
|
self.tintColor = tintColor
|
|
190
|
-
self.titleOpacity = titleOpacity
|
|
191
187
|
}
|
|
192
|
-
|
|
188
|
+
|
|
193
189
|
public var body: some View {
|
|
194
|
-
|
|
190
|
+
|
|
195
191
|
let backgroundButtonColor: Color = tintColor == Colors.black01 ? Colors.black20.opacity(0.6) : Colors.black01.opacity(0.6)
|
|
196
192
|
let borderColor: Color = tintColor == Colors.black01 ? Colors.black01.opacity(0.2) : Colors.black20.opacity(0.2)
|
|
197
193
|
|
|
@@ -216,9 +212,6 @@ public struct Header: View {
|
|
|
216
212
|
|
|
217
213
|
if let headerRight = headerRight {
|
|
218
214
|
AnyView(headerRight())
|
|
219
|
-
.background(GeometryReader { geo in
|
|
220
|
-
Color.clear.preference(key: HeaderRightWidthKey.self, value: geo.size.width)
|
|
221
|
-
})
|
|
222
215
|
}
|
|
223
216
|
}
|
|
224
217
|
.padding(.horizontal, 12)
|
|
@@ -230,16 +223,33 @@ public struct Header: View {
|
|
|
230
223
|
}
|
|
231
224
|
|
|
232
225
|
if let inputProps = inputSearchProps {
|
|
233
|
-
InputSearch(
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
226
|
+
InputSearch(
|
|
227
|
+
text: inputProps.$text,
|
|
228
|
+
buttonText: inputProps.buttonText,
|
|
229
|
+
showButtonText: inputProps.showButtonText,
|
|
230
|
+
showBorder: inputProps.showBorder,
|
|
231
|
+
placeholder: inputProps.placeholder,
|
|
232
|
+
onChangeText: inputProps.onChangeText,
|
|
233
|
+
onPressButtonText: inputProps.onPressButtonText,
|
|
234
|
+
error: inputProps.error,
|
|
235
|
+
disabled: inputProps.disabled,
|
|
236
|
+
icon: inputProps.icon,
|
|
237
|
+
iconColor: inputProps.iconColor,
|
|
238
|
+
onRightIconPressed: inputProps.onRightIconPressed,
|
|
239
|
+
onFocus: inputProps.onFocus,
|
|
240
|
+
onBlur: inputProps.onBlur,
|
|
241
|
+
loading: inputProps.loading,
|
|
242
|
+
fontWeight: inputProps.fontWeight,
|
|
243
|
+
keyboardType: inputProps.keyboardType
|
|
244
|
+
)
|
|
238
245
|
} else {
|
|
239
|
-
|
|
240
|
-
.
|
|
246
|
+
Text(title)
|
|
247
|
+
.font(.system(size: 17, weight: .bold))
|
|
248
|
+
.ignoreBoldTextSetting()
|
|
249
|
+
.foregroundColor(tintColor ?? Colors.black17)
|
|
241
250
|
.frame(maxWidth: titlePosition == .center ? UIScreen.main.bounds.width - 252 : nil)
|
|
242
251
|
.frame(maxWidth: titlePosition == .center ? .infinity : UIScreen.main.bounds.width - 172, alignment: titlePosition == .center ? .center : .leading)
|
|
252
|
+
.lineLimit(1)
|
|
243
253
|
}
|
|
244
254
|
|
|
245
255
|
Spacer()
|
|
@@ -3,16 +3,11 @@ import Combine
|
|
|
3
3
|
|
|
4
4
|
public enum FABSize {
|
|
5
5
|
case small
|
|
6
|
-
case `default`
|
|
7
|
-
/// Backward-compatible alias for older iOS call sites. Compose names this
|
|
8
|
-
/// size `DEFAULT`.
|
|
9
6
|
case large
|
|
7
|
+
|
|
10
8
|
}
|
|
11
9
|
|
|
12
10
|
public enum FABPosition {
|
|
13
|
-
case end
|
|
14
|
-
/// Backward-compatible alias for older iOS call sites. Compose names this
|
|
15
|
-
/// position `END`.
|
|
16
11
|
case right
|
|
17
12
|
case center
|
|
18
13
|
}
|
|
@@ -36,10 +31,10 @@ public struct FabProps {
|
|
|
36
31
|
label: String? = nil,
|
|
37
32
|
onClick: (() -> Void)? = nil,
|
|
38
33
|
containerColor: Color? = Colors.primary,
|
|
39
|
-
size: FABSize? = .
|
|
34
|
+
size: FABSize? = .small,
|
|
40
35
|
iconSize: CGFloat? = nil,
|
|
41
36
|
scrollOffset: CGFloat? = nil,
|
|
42
|
-
position: FABPosition? = .
|
|
37
|
+
position: FABPosition? = .right,
|
|
43
38
|
bottomPadding: CGFloat? = nil,
|
|
44
39
|
renderComponent: (() -> AnyView)? = nil
|
|
45
40
|
) {
|
|
@@ -70,7 +65,7 @@ public struct FloatingButton: View {
|
|
|
70
65
|
private var keyboardOffset: CGFloat
|
|
71
66
|
private var scrollOffset: CGFloat
|
|
72
67
|
private var bottomPadding: CGFloat { props.bottomPadding ?? 12 + keyboardOffset}
|
|
73
|
-
private var position: FABPosition? { props.position ?? .
|
|
68
|
+
private var position: FABPosition? { props.position ?? .right }
|
|
74
69
|
private var containerColor: Color? { props.containerColor ?? Colors.primary }
|
|
75
70
|
private var iconColor: Color? { props.iconColor ?? .white }
|
|
76
71
|
private var label: String? { props.label }
|
|
@@ -157,7 +152,11 @@ public struct FloatingButton: View {
|
|
|
157
152
|
if let label = label {
|
|
158
153
|
if showText {
|
|
159
154
|
Spacer().frame(width: 8)
|
|
160
|
-
|
|
155
|
+
Text(label)
|
|
156
|
+
.foregroundColor(.white)
|
|
157
|
+
.font(.system(size: scaleSize(16), weight: .bold))
|
|
158
|
+
.ignoreBoldTextSetting()
|
|
159
|
+
.lineLimit(1)
|
|
161
160
|
.background(
|
|
162
161
|
GeometryReader { geo in
|
|
163
162
|
Color.clear.onAppear {
|
|
@@ -101,98 +101,69 @@ struct ToolkitHeaderRight: View {
|
|
|
101
101
|
var tintColor: Color?
|
|
102
102
|
@State private var isFavorite: Bool = false
|
|
103
103
|
@State private var isLoading: Bool = false
|
|
104
|
-
@
|
|
105
|
-
|
|
106
|
-
private func apiValue(_ value: Any?) -> Any {
|
|
107
|
-
value ?? NSNull()
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
private var contextMap: [String: Any] {
|
|
111
|
-
let context = environment.applicationContext
|
|
112
|
-
return [
|
|
113
|
-
"appId": apiValue(context?.appId),
|
|
114
|
-
"code": apiValue(context?.appCode),
|
|
115
|
-
"name": apiValue(context?.appName),
|
|
116
|
-
"icon": apiValue(context?.appIcon),
|
|
117
|
-
"description": apiValue(context?.description),
|
|
118
|
-
"support": apiValue(context?.support),
|
|
119
|
-
"toolkitConfig": apiValue(context?.toolkitConfig),
|
|
120
|
-
"providerId": apiValue(context?.providerId),
|
|
121
|
-
"permissions": apiValue(context?.permissions)
|
|
122
|
-
]
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
private var shouldShowShortcut: Bool {
|
|
126
|
-
headerRight?.useShortcut == true && !(headerRight?.useMore == true && environment.applicationContext == nil)
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
private func parseResponse(_ response: String) -> Any? {
|
|
130
|
-
guard let jsonData = response.data(using: .utf8),
|
|
131
|
-
let json = try? JSONSerialization.jsonObject(with: jsonData) as? [String: Any] else {
|
|
132
|
-
return nil
|
|
133
|
-
}
|
|
134
|
-
return json["response"]
|
|
135
|
-
}
|
|
104
|
+
@EnvironmentObject private var environment: ApplicationEnvironment
|
|
136
105
|
|
|
137
106
|
// MARK: - Actions
|
|
138
|
-
private func loadFavoriteState() {
|
|
139
|
-
environment.composeApi?.request(
|
|
140
|
-
funcName: "isFavoriteApp",
|
|
141
|
-
params: ["code": apiValue(environment.applicationContext?.appCode)]
|
|
142
|
-
) { response in
|
|
143
|
-
if let isFavorite = parseResponse(response) as? Bool {
|
|
144
|
-
self.isFavorite = isFavorite
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
107
|
private func onPressShortcut() {
|
|
150
108
|
environment.composeApi?.request(
|
|
151
109
|
funcName: "onToolAction",
|
|
152
|
-
params: [
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
]
|
|
156
|
-
) { response in
|
|
157
|
-
if let result = parseResponse(response) as? [String: Any],
|
|
158
|
-
result["success"] as? Bool == true {
|
|
159
|
-
isFavorite.toggle()
|
|
160
|
-
}
|
|
110
|
+
params: ["item": ["key": "onFavorite"]]
|
|
111
|
+
) { _ in
|
|
112
|
+
isFavorite.toggle()
|
|
161
113
|
}
|
|
162
114
|
}
|
|
163
115
|
|
|
164
116
|
private func onPressHelpCenter() {
|
|
117
|
+
let context = environment.applicationContext
|
|
118
|
+
let paramMap: [String: Any] = [
|
|
119
|
+
"appId": context?.appId,
|
|
120
|
+
"code": context?.appCode,
|
|
121
|
+
"name": context?.appName,
|
|
122
|
+
"icon": context?.appIcon,
|
|
123
|
+
"description": context?.description
|
|
124
|
+
]
|
|
165
125
|
environment.composeApi?.request(
|
|
166
126
|
funcName: "showHelpCenter",
|
|
167
|
-
params:
|
|
168
|
-
"appId": apiValue(environment.applicationContext?.appId),
|
|
169
|
-
"code": apiValue(environment.applicationContext?.appCode),
|
|
170
|
-
"name": apiValue(environment.applicationContext?.appName),
|
|
171
|
-
"icon": apiValue(environment.applicationContext?.appIcon),
|
|
172
|
-
"description": apiValue(environment.applicationContext?.description)
|
|
173
|
-
]
|
|
127
|
+
params: paramMap
|
|
174
128
|
) { _ in }
|
|
175
129
|
}
|
|
176
130
|
|
|
177
131
|
private func onPressClose() {
|
|
178
132
|
environment.composeApi?.request(
|
|
179
133
|
funcName: "dismissAll",
|
|
180
|
-
params:
|
|
134
|
+
params: ""
|
|
181
135
|
) { _ in }
|
|
182
136
|
}
|
|
183
137
|
|
|
184
138
|
private func onPressMore() {
|
|
139
|
+
let context = environment.applicationContext
|
|
185
140
|
let params: [String: Any] = [
|
|
186
|
-
"useSystemTools": headerRight?.useSystemTools
|
|
141
|
+
"useSystemTools": headerRight?.useSystemTools,
|
|
187
142
|
"tools": headerRight?.tools.map { $0.toMap() } ?? [],
|
|
188
|
-
"context":
|
|
143
|
+
"context": [
|
|
144
|
+
"appId": context?.appId,
|
|
145
|
+
"code": context?.appCode,
|
|
146
|
+
"name": context?.appName,
|
|
147
|
+
"icon": context?.appIcon,
|
|
148
|
+
"description": context?.description,
|
|
149
|
+
"support": context?.support,
|
|
150
|
+
"toolkitConfig": context?.toolkitConfig,
|
|
151
|
+
"providerId": context?.providerId,
|
|
152
|
+
"permissions": context?.permissions
|
|
153
|
+
]
|
|
189
154
|
]
|
|
190
155
|
environment.composeApi?.request(
|
|
191
156
|
funcName: "showTools",
|
|
192
157
|
params: params
|
|
193
158
|
) { response in
|
|
194
|
-
|
|
195
|
-
|
|
159
|
+
do {
|
|
160
|
+
if let jsonData = response.data(using: .utf8),
|
|
161
|
+
let json = try JSONSerialization.jsonObject(with: jsonData) as? [String: Any],
|
|
162
|
+
let toolResponse = json["response"] as? String {
|
|
163
|
+
headerRight?.toolCallback?(toolResponse)
|
|
164
|
+
}
|
|
165
|
+
} catch {
|
|
166
|
+
print("Error parsing response:", error)
|
|
196
167
|
}
|
|
197
168
|
}
|
|
198
169
|
}
|
|
@@ -224,7 +195,7 @@ struct ToolkitHeaderRight: View {
|
|
|
224
195
|
} ?? false
|
|
225
196
|
|
|
226
197
|
HStack(alignment: .center, spacing: 0) {
|
|
227
|
-
if
|
|
198
|
+
if headerRight?.useShortcut == true {
|
|
228
199
|
NavigationButton(
|
|
229
200
|
disabled: isLoading,
|
|
230
201
|
icon: navButtonConfig.icon,
|
|
@@ -235,17 +206,15 @@ struct ToolkitHeaderRight: View {
|
|
|
235
206
|
}
|
|
236
207
|
|
|
237
208
|
HStack(alignment: .center, spacing: 0) {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
.frame(width: 0.5, height: 12)
|
|
248
|
-
}
|
|
209
|
+
Icon(source: "help_center", size: 20, color: tintColor ?? Colors.black17)
|
|
210
|
+
.padding(4)
|
|
211
|
+
.onTapGesture {
|
|
212
|
+
onPressHelpCenter()
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
Rectangle()
|
|
216
|
+
.fill(tintColor ?? Colors.black20)
|
|
217
|
+
.frame(width: 0.5, height: 12)
|
|
249
218
|
|
|
250
219
|
Icon(source: "16_basic_home", size: 20, color: tintColor ?? Colors.black17)
|
|
251
220
|
.padding(4)
|
|
@@ -262,9 +231,6 @@ struct ToolkitHeaderRight: View {
|
|
|
262
231
|
)
|
|
263
232
|
.padding(.leading, Spacing.S)
|
|
264
233
|
}
|
|
265
|
-
.onAppear {
|
|
266
|
-
loadFavoriteState()
|
|
267
|
-
}
|
|
268
234
|
}
|
|
269
235
|
}
|
|
270
236
|
|
|
@@ -229,7 +229,6 @@ public struct Screen<Content: View>: View {
|
|
|
229
229
|
struct Footer: View {
|
|
230
230
|
var footerView: AnyView
|
|
231
231
|
var keyboardSize: CGFloat
|
|
232
|
-
var bottomInset: CGFloat = 0
|
|
233
232
|
|
|
234
233
|
var body: some View {
|
|
235
234
|
VStack {
|
|
@@ -237,7 +236,7 @@ struct Footer: View {
|
|
|
237
236
|
}
|
|
238
237
|
.padding(.vertical, Spacing.S)
|
|
239
238
|
.padding(.horizontal, Spacing.M)
|
|
240
|
-
.padding(.bottom, keyboardSize
|
|
239
|
+
.padding(.bottom, keyboardSize)
|
|
241
240
|
.background(Colors.black01)
|
|
242
241
|
.overlay(
|
|
243
242
|
Rectangle()
|
package/ios/Badge/Badge.swift
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import SwiftUI
|
|
2
2
|
|
|
3
3
|
public struct Badge: View {
|
|
4
|
-
@Environment(\.appTheme) private var theme
|
|
5
4
|
let label: String
|
|
6
5
|
let backgroundColor: Color?
|
|
7
6
|
|
|
@@ -39,21 +38,24 @@ public struct Badge: View {
|
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
private var badgeColor: Color {
|
|
42
|
-
//
|
|
43
|
-
let
|
|
44
|
-
? theme.colors.error.primary
|
|
45
|
-
: theme.colors.warning.primary
|
|
46
|
-
|
|
47
|
-
// Mirror Compose: only apply backgroundColor when it is one of the
|
|
48
|
-
// allowed primaryColors; otherwise fall back to the label-based default.
|
|
49
|
-
if let bgColor = backgroundColor, primaryColors.contains(bgColor) {
|
|
41
|
+
// If a custom background color is provided, use it
|
|
42
|
+
if let bgColor = backgroundColor {
|
|
50
43
|
return bgColor
|
|
51
44
|
}
|
|
52
|
-
|
|
45
|
+
|
|
46
|
+
// Otherwise, use default colors based on label type
|
|
47
|
+
if isNumber(label) {
|
|
48
|
+
return Colors.red03 // error.primary
|
|
49
|
+
} else {
|
|
50
|
+
return Colors.orange03 // warning.primary
|
|
51
|
+
}
|
|
53
52
|
}
|
|
54
53
|
|
|
55
54
|
public var body: some View {
|
|
56
|
-
|
|
55
|
+
Text(formatTitle(label))
|
|
56
|
+
.font(.system(size: scaleSize(10), weight: .bold))
|
|
57
|
+
.ignoreBoldTextSetting()
|
|
58
|
+
.foregroundColor(Colors.black01)
|
|
57
59
|
.padding(.horizontal, Spacing.XS)
|
|
58
60
|
.frame(minWidth: scaleSize(16), minHeight: scaleSize(16))
|
|
59
61
|
.background(badgeColor)
|
|
@@ -81,3 +83,4 @@ struct Badge_Previews: PreviewProvider {
|
|
|
81
83
|
}
|
|
82
84
|
}
|
|
83
85
|
#endif
|
|
86
|
+
|
|
@@ -77,11 +77,10 @@ public enum RibbonPosition {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
public struct BadgeRibbon: View {
|
|
80
|
-
@Environment(\.appTheme) private var theme
|
|
81
80
|
let position: RibbonPosition
|
|
82
81
|
let label: String
|
|
83
82
|
let isRound: Bool
|
|
84
|
-
let backgroundColor: Color
|
|
83
|
+
let backgroundColor: Color
|
|
85
84
|
|
|
86
85
|
public init(
|
|
87
86
|
position: RibbonPosition = .topRight,
|
|
@@ -92,7 +91,7 @@ public struct BadgeRibbon: View {
|
|
|
92
91
|
self.position = position
|
|
93
92
|
self.label = label
|
|
94
93
|
self.isRound = isRound
|
|
95
|
-
self.backgroundColor = backgroundColor
|
|
94
|
+
self.backgroundColor = backgroundColor ?? Colors.orange03
|
|
96
95
|
}
|
|
97
96
|
|
|
98
97
|
private var rotation: Angle {
|
|
@@ -118,8 +117,6 @@ public struct BadgeRibbon: View {
|
|
|
118
117
|
}
|
|
119
118
|
|
|
120
119
|
public var body: some View {
|
|
121
|
-
let bgColor = backgroundColor ?? theme.colors.warning.primary
|
|
122
|
-
|
|
123
120
|
HStack(alignment: verticalAlignment, spacing: 0) {
|
|
124
121
|
if useUpTail {
|
|
125
122
|
upTail
|
|
@@ -128,18 +125,22 @@ public struct BadgeRibbon: View {
|
|
|
128
125
|
}
|
|
129
126
|
|
|
130
127
|
if isRound {
|
|
131
|
-
roundContent
|
|
128
|
+
roundContent
|
|
132
129
|
} else {
|
|
133
|
-
skewContent
|
|
130
|
+
skewContent
|
|
134
131
|
}
|
|
135
132
|
}
|
|
136
133
|
.frame(height: RibbonConstants.ribbonHeight)
|
|
137
134
|
.rotationEffect(rotation)
|
|
138
135
|
}
|
|
139
136
|
|
|
140
|
-
private
|
|
137
|
+
private var roundContent: some View {
|
|
141
138
|
HStack(spacing: 0) {
|
|
142
|
-
|
|
139
|
+
Text(label)
|
|
140
|
+
.font(.system(size: scaleSize(12), weight: .medium))
|
|
141
|
+
.ignoreBoldTextSetting()
|
|
142
|
+
.foregroundColor(Colors.black01)
|
|
143
|
+
.lineLimit(1)
|
|
143
144
|
.rotationEffect(rotation)
|
|
144
145
|
}
|
|
145
146
|
.frame(height: RibbonConstants.roundHeight)
|
|
@@ -155,9 +156,13 @@ public struct BadgeRibbon: View {
|
|
|
155
156
|
)
|
|
156
157
|
}
|
|
157
158
|
|
|
158
|
-
private
|
|
159
|
+
private var skewContent: some View {
|
|
159
160
|
HStack(spacing: 0) {
|
|
160
|
-
|
|
161
|
+
Text(label)
|
|
162
|
+
.font(.system(size: scaleSize(12), weight: .medium))
|
|
163
|
+
.ignoreBoldTextSetting()
|
|
164
|
+
.foregroundColor(Colors.black01)
|
|
165
|
+
.lineLimit(1)
|
|
161
166
|
.rotationEffect(rotation)
|
|
162
167
|
.frame(height: RibbonConstants.skewBodyHeight)
|
|
163
168
|
.padding(.horizontal, 8)
|
|
@@ -174,6 +179,7 @@ public struct BadgeRibbon: View {
|
|
|
174
179
|
)
|
|
175
180
|
.frame(width: RibbonConstants.headTailWidth, height: RibbonConstants.headTailHeight)
|
|
176
181
|
.rotationEffect(.degrees(180))
|
|
182
|
+
.offset(x: 1)
|
|
177
183
|
.clipped()
|
|
178
184
|
}
|
|
179
185
|
|
|
@@ -183,6 +189,7 @@ public struct BadgeRibbon: View {
|
|
|
183
189
|
placeholder: AnyView(Color.clear)
|
|
184
190
|
)
|
|
185
191
|
.frame(width: RibbonConstants.headTailWidth, height: RibbonConstants.headTailHeight)
|
|
192
|
+
.offset(x: 1)
|
|
186
193
|
.clipped()
|
|
187
194
|
}
|
|
188
195
|
|
|
@@ -192,6 +199,7 @@ public struct BadgeRibbon: View {
|
|
|
192
199
|
placeholder: AnyView(Color.clear)
|
|
193
200
|
)
|
|
194
201
|
.frame(width: RibbonConstants.skewTailWidth, height: RibbonConstants.skewTailHeight)
|
|
202
|
+
.offset(x: -2)
|
|
195
203
|
.clipped()
|
|
196
204
|
}
|
|
197
205
|
}
|
|
@@ -201,7 +209,7 @@ private struct RibbonConstants {
|
|
|
201
209
|
static let ribbonHeight: CGFloat = 20
|
|
202
210
|
static let roundHeight: CGFloat = 16
|
|
203
211
|
static let skewBodyHeight: CGFloat = 16
|
|
204
|
-
static let roundRightRadius: CGFloat =
|
|
212
|
+
static let roundRightRadius: CGFloat = 8
|
|
205
213
|
static let roundPaddingEnd: CGFloat = 6
|
|
206
214
|
static let skewTailWidth: CGFloat = 8
|
|
207
215
|
static let skewTailHeight: CGFloat = 16
|
|
@@ -233,3 +241,4 @@ struct BadgeRibbon_Previews: PreviewProvider {
|
|
|
233
241
|
}
|
|
234
242
|
}
|
|
235
243
|
#endif
|
|
244
|
+
|