@momo-kits/native-kits 0.163.1-beta.3-debug → 0.163.1-beta.5-debug
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +1 -1
- package/compose/build.gradle.kts +2 -1
- package/compose/build.gradle.kts.backup +1 -0
- package/compose/compose.podspec +1 -1
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +7 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +8 -10
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +3 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +56 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +11 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +40 -55
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +69 -26
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +3 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +21 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +3 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +22 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +28 -21
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +4 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +112 -115
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +11 -6
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +3 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +3 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +2 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +9 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +66 -0
- package/gradle/libs.versions.toml +2 -0
- package/gradle.properties +1 -1
- package/ios/Application/ApplicationEnvironment.swift +11 -1
- package/ios/Application/Components.swift +34 -44
- package/ios/Application/FloatingButton.swift +10 -9
- package/ios/Application/HeaderRight.swift +79 -45
- package/ios/Application/Navigation/BottomTab/BottomTab.swift +103 -0
- package/ios/Application/Navigation/BottomTab/BottomTabBar.swift +215 -0
- package/ios/Application/Navigation/BottomTab/CurvedContainer.swift +65 -0
- package/ios/Application/Navigation/HeaderBackProps.swift +66 -0
- package/ios/Application/Navigation/HeaderTitle.swift +57 -0
- package/ios/Application/Navigation/HeaderUser.swift +209 -0
- package/ios/Application/Navigation/NavigationContainer.swift +176 -0
- package/ios/Application/Navigation/NavigationOptions.swift +109 -0
- package/ios/Application/Navigation/Navigator.swift +364 -0
- package/ios/Application/Navigation/Overplay/BottomSheet.swift +188 -0
- package/ios/Application/Navigation/Overplay/ModalScreen.swift +68 -0
- package/ios/Application/Navigation/Overplay/SnackBar.swift +144 -0
- package/ios/Application/Navigation/component/Header.swift +178 -0
- package/ios/Application/Navigation/component/HeaderBackground.swift +83 -0
- package/ios/Application/Navigation/component/HeaderColor.swift +65 -0
- package/ios/Application/Screen.swift +2 -1
- package/ios/Application/StackScreen.swift +453 -0
- package/ios/Avatar/Avatar.swift +193 -0
- package/ios/Badge/Badge.swift +11 -14
- package/ios/Badge/BadgeRibbon.swift +12 -21
- package/ios/BaselineView/BaselineView.swift +163 -0
- package/ios/Button/Button.swift +61 -22
- package/ios/Carousel/Carousel.swift +181 -0
- package/ios/Checkbox/Checkbox.swift +14 -13
- package/ios/Chip/Chip.swift +23 -9
- package/ios/Collapse/Collapse.swift +182 -0
- package/ios/Colors+Radius+Spacing/Colors.swift +12 -12
- package/ios/Colors+Radius+Spacing/Theme.swift +295 -0
- package/ios/DateTimePicker/DateTimePicker.swift +210 -0
- package/ios/DateTimePicker/DateTimePickerTypes.swift +55 -0
- package/ios/DateTimePicker/DateTimePickerUtils.swift +167 -0
- package/ios/DateTimePicker/WheelPicker.swift +161 -0
- package/ios/Divider/Divider.swift +16 -0
- package/ios/Extensions/Color++.swift +32 -0
- package/ios/Icon/Icon.swift +6 -1
- package/ios/IconButton/IconButton.swift +112 -0
- package/ios/Input/Input.swift +41 -25
- package/ios/Input/InputPhoneNumber.swift +20 -19
- package/ios/Input/InputSearch.swift +100 -47
- package/ios/Input/InputTextArea.swift +66 -40
- package/ios/InputDropDown/InputDropDown.swift +198 -0
- package/ios/InputMoney/InputMoney.swift +335 -0
- package/ios/InputOTP/InputOTP.swift +210 -0
- package/ios/Loader/Loader.swift +113 -0
- package/ios/MoMoUIKits.podspec +5 -0
- package/ios/Pagination/PaginationDot.swift +61 -0
- package/ios/Pagination/PaginationNumber.swift +35 -0
- package/ios/Pagination/PaginationScroll.swift +101 -0
- package/ios/Pagination/PaginationWhiteDot.swift +37 -0
- package/ios/Popup/PopupDisplay.swift +8 -16
- package/ios/Popup/PopupInput.swift +2 -8
- package/ios/Popup/PopupNotify.swift +219 -0
- package/ios/ProgressInfo/ProgressInfo.swift +294 -0
- package/ios/Radio/Radio.swift +70 -0
- package/ios/Rating/Rating.swift +82 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/AccentColor.colorset/Contents.json +11 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Background.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Border.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Card.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Contents.json +6 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Error.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Primary.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/PrimaryDark.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/PrimaryLight.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Secondary.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Success.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Text.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/TextSecondary.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/Contents.json +9 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-default.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-disable.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-pressed.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-selected.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-surface.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/background-tonal.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/border-default.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/border-disable.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/gradient.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/primary.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/secondary.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-container.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-primary.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/success-secondary.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-default.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-disable.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-hint.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/ThemeColors/text-secondary.colorset/Contents.json +38 -0
- package/ios/Resources/MoMoUIKitsColors.xcassets/Warning.colorset/Contents.json +38 -0
- package/ios/Skeleton/Skeleton.swift +99 -0
- package/ios/Slider/Slider.swift +237 -0
- package/ios/Stepper/Stepper.swift +220 -0
- package/ios/Steps/Steps.swift +451 -0
- package/ios/SuggestAction/SuggestAction.swift +97 -0
- package/ios/Swipeable/SwipeCell.swift +185 -0
- package/ios/Swipeable/SwipeCellModel.swift +21 -0
- package/ios/TabView/TabView.swift +530 -0
- package/ios/Tag/Tag.swift +98 -0
- package/ios/Title/Title.swift +269 -0
- package/ios/Tooltip/Tooltip.swift +482 -0
- package/ios/Typography/FontScaleStore.swift +19 -0
- package/ios/Typography/Text.swift +86 -17
- package/ios/Typography/Typography.swift +12 -14
- package/ios/Uploader/Uploader.swift +183 -0
- package/ios/native-kits.podspec +61 -8
- package/ios-demo/MoMoUIKitsDemo.podspec +20 -0
- package/ios-demo/README.md +120 -0
- package/ios-demo/Resources/dot_loading.json +558 -0
- package/ios-demo/Resources/icon.json +4052 -0
- package/ios-demo/Resources/lottie_circle_loader.json +1 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/DemoScaffold.swift +48 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsBadgeDemoView.swift +25 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsButtonDemoView.swift +26 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsCheckboxDemoView.swift +19 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsChipDemoView.swift +33 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsInputDemoView.swift +48 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsPopupDemoView.swift +21 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsRadioDemoView.swift +17 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/Demos/UIKitsTypographyDemoView.swift +28 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/MoMoUIKitsDemoContext.swift +31 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/MoMoUIKitsDemoFactory.swift +24 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AnimatedHeaderDemo.swift +110 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/AvatarDemo.swift +93 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BadgeDemo.swift +269 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BaselineView.swift +117 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +89 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ButtonDemo.swift +100 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CarouselDemo.swift +126 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CheckboxDemo.swift +63 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ChipDemo.swift +20 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CollapseDemo.swift +93 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ContentView.swift +107 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DateTimePickerDemo.swift +124 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/DividerDemo.swift +14 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/HeaderUserDemo.swift +49 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/Home.swift +278 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/IconButtonDemo.swift +58 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ImageDemo.swift +78 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InformationDemo.swift +138 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputDemo.swift +111 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputDropDownDemo.swift +136 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputMoneyDemo.swift +107 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputOTPDemo.swift +73 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputPhoneNumberDemo.swift +100 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputSearchDemo.swift +32 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputTextAreaDemo.swift +57 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LoaderDemo.swift +70 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +227 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PaginationDemo.swift +72 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupDisplayDemo.swift +175 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +121 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupPromotionDemo.swift +76 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ProgressInfoDemo.swift +89 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/RadioDemo.swift +32 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/RatingDemo.swift +56 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SkeletonDemo.swift +32 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SliderDemo.swift +150 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SnackBarDemo.swift +138 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/StepperDemo.swift +103 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/StepsDemo.swift +94 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SuggestActionDemo.swift +79 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SwipeDemo.swift +152 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SwitchDemo.swift +33 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TabViewDemo.swift +190 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TagDemo.swift +34 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ThemeDemo.swift +182 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TitleDemo.swift +109 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TooltipDemo.swift +187 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TypographyDemo.swift +87 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/UploaderDemo.swift +131 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SwiftUIDemoBrowserView.swift +51 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/UIKitsDemoModels.swift +15 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/UIKitsDemoRegistry.swift +73 -0
- package/package.json +1 -1
- package/publish.sh +50 -0
- package/scripts/gen-ios-color.mjs +136 -0
- package/example/ios/Example.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/example/ios/Example.xcworkspace/xcuserdata/huynhdung.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/example/ios/Example.xcworkspace/xcuserdata/huynhdung.xcuserdatad/xcschemes/xcschememanagement.plist +0 -5
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/MoMoUIKits.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/Pods-Example.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/SDWebImage.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/SDWebImageSwiftUI.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/SkeletonUI.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/xcschememanagement.plist +0 -46
- package/ios/Application/FontScaleStore.swift +0 -59
package/ios/Input/Input.swift
CHANGED
|
@@ -3,12 +3,14 @@ import SwiftUI
|
|
|
3
3
|
import Combine
|
|
4
4
|
|
|
5
5
|
public struct Input: View {
|
|
6
|
+
@Environment(\.appTheme) private var theme
|
|
6
7
|
@Binding public var text: String
|
|
7
8
|
|
|
8
9
|
public var placeholder: String
|
|
9
10
|
public var floatingValue: String
|
|
11
|
+
public var floatingValueColor: Color?
|
|
10
12
|
public var floatingIcon: String
|
|
11
|
-
public var floatingIconColor: Color
|
|
13
|
+
public var floatingIconColor: Color?
|
|
12
14
|
public var size: InputSize
|
|
13
15
|
public var hintText: String
|
|
14
16
|
public var error: String
|
|
@@ -17,9 +19,9 @@ public struct Input: View {
|
|
|
17
19
|
public var readOnly: Bool
|
|
18
20
|
public var secureTextEntry: Bool
|
|
19
21
|
public var rightIcon: String
|
|
20
|
-
public var rightIconColor: Color
|
|
22
|
+
public var rightIconColor: Color?
|
|
21
23
|
public var leadingIcon: String
|
|
22
|
-
public var leadingIconColor: Color
|
|
24
|
+
public var leadingIconColor: Color?
|
|
23
25
|
public var loading: Bool
|
|
24
26
|
public var required: Bool
|
|
25
27
|
public var maxLength: Int?
|
|
@@ -38,8 +40,9 @@ public struct Input: View {
|
|
|
38
40
|
text: Binding<String>,
|
|
39
41
|
placeholder: String = "",
|
|
40
42
|
floatingValue: String = "",
|
|
43
|
+
floatingValueColor: Color? = nil,
|
|
41
44
|
floatingIcon: String = "",
|
|
42
|
-
floatingIconColor: Color =
|
|
45
|
+
floatingIconColor: Color? = nil,
|
|
43
46
|
size: InputSize = .small,
|
|
44
47
|
hintText: String = "",
|
|
45
48
|
error: String = "",
|
|
@@ -48,9 +51,9 @@ public struct Input: View {
|
|
|
48
51
|
readOnly: Bool = false,
|
|
49
52
|
secureTextEntry: Bool = false,
|
|
50
53
|
rightIcon: String = "",
|
|
51
|
-
rightIconColor: Color =
|
|
54
|
+
rightIconColor: Color? = nil,
|
|
52
55
|
leadingIcon: String = "",
|
|
53
|
-
leadingIconColor: Color =
|
|
56
|
+
leadingIconColor: Color? = nil,
|
|
54
57
|
loading: Bool = false,
|
|
55
58
|
required: Bool = false,
|
|
56
59
|
maxLength: Int? = nil,
|
|
@@ -65,6 +68,7 @@ public struct Input: View {
|
|
|
65
68
|
self._text = text
|
|
66
69
|
self.placeholder = placeholder
|
|
67
70
|
self.floatingValue = floatingValue
|
|
71
|
+
self.floatingValueColor = floatingValueColor
|
|
68
72
|
self.floatingIcon = floatingIcon
|
|
69
73
|
self.floatingIconColor = floatingIconColor
|
|
70
74
|
self.size = size
|
|
@@ -107,14 +111,14 @@ public struct Input: View {
|
|
|
107
111
|
HStack(spacing: Spacing.XS) {
|
|
108
112
|
MomoText(floatingValue, typography: .labelSMedium, color: getFloatingColor())
|
|
109
113
|
if required {
|
|
110
|
-
MomoText("*", typography: .labelSMedium, color:
|
|
114
|
+
MomoText("*", typography: .labelSMedium, color: theme.colors.error.primary)
|
|
111
115
|
}
|
|
112
116
|
if !floatingIcon.isEmpty {
|
|
113
117
|
Icon(source: floatingIcon, size: 16, color: getFloatingIconColor())
|
|
114
118
|
}
|
|
115
119
|
}
|
|
116
120
|
.padding(.horizontal, Spacing.S)
|
|
117
|
-
.background(
|
|
121
|
+
.background(theme.colors.background.surface)
|
|
118
122
|
.offset(x: Spacing.S, y: -8)
|
|
119
123
|
.zIndex(10)
|
|
120
124
|
}
|
|
@@ -123,7 +127,7 @@ public struct Input: View {
|
|
|
123
127
|
HStack(alignment: .center, spacing: 0) {
|
|
124
128
|
// Leading icon
|
|
125
129
|
if !leadingIcon.isEmpty {
|
|
126
|
-
Icon(source: leadingIcon, size: size == .small ? 24 : 32, color:
|
|
130
|
+
Icon(source: leadingIcon, size: size == .small ? 24 : 32, color: getLeadingIconColor())
|
|
127
131
|
.padding(.trailing, Spacing.M)
|
|
128
132
|
}
|
|
129
133
|
|
|
@@ -144,6 +148,7 @@ public struct Input: View {
|
|
|
144
148
|
fontSize: scaleSize(14),
|
|
145
149
|
fontWeight: fontWeight == .bold ? .bold : .regular,
|
|
146
150
|
textColor: UIColor(getTextColor()),
|
|
151
|
+
cursorColor: UIColor(theme.colors.primary),
|
|
147
152
|
isDisabled: disabled || readOnly,
|
|
148
153
|
maxLength: maxLength,
|
|
149
154
|
onFocusChange: { focused in
|
|
@@ -160,7 +165,7 @@ public struct Input: View {
|
|
|
160
165
|
.ignoreBoldTextSetting()
|
|
161
166
|
.foregroundColor(getTextColor())
|
|
162
167
|
.disabled(disabled || readOnly)
|
|
163
|
-
.
|
|
168
|
+
.applyCursorColor(theme.colors.primary)
|
|
164
169
|
.onChange(of: text) { newValue in
|
|
165
170
|
let limited = limitText(newValue)
|
|
166
171
|
if limited != newValue {
|
|
@@ -176,7 +181,7 @@ public struct Input: View {
|
|
|
176
181
|
text = ""
|
|
177
182
|
onChangeText?("")
|
|
178
183
|
}) {
|
|
179
|
-
Icon(source: "24_navigation_close_circle_full", size: 16, color:
|
|
184
|
+
Icon(source: "24_navigation_close_circle_full", size: 16, color: theme.colors.text.hint)
|
|
180
185
|
.padding(.leading, Spacing.S).accessibility(identifier: "ic_clear")
|
|
181
186
|
}
|
|
182
187
|
}
|
|
@@ -195,14 +200,14 @@ public struct Input: View {
|
|
|
195
200
|
Icon(
|
|
196
201
|
source: isPasswordHidden ? "24_security_eye_off" : "24_security_eye_open",
|
|
197
202
|
size: 24,
|
|
198
|
-
color:
|
|
203
|
+
color: getRightIconColor()
|
|
199
204
|
)
|
|
200
205
|
.padding(.leading, Spacing.S).accessibility(identifier: "ic_show_hide")
|
|
201
206
|
}
|
|
202
207
|
}
|
|
203
208
|
} else if !rightIcon.isEmpty {
|
|
204
209
|
SwiftUI.Button(action: { onRightIconPressed?() }) {
|
|
205
|
-
Icon(source: rightIcon, size: 24, color:
|
|
210
|
+
Icon(source: rightIcon, size: 24, color: getRightIconColor())
|
|
206
211
|
.padding(.leading, Spacing.S)
|
|
207
212
|
}
|
|
208
213
|
}
|
|
@@ -211,7 +216,7 @@ public struct Input: View {
|
|
|
211
216
|
.frame(height: scaleSize(size == .small ? 48 : 56, 1.1))
|
|
212
217
|
.background(
|
|
213
218
|
RoundedRectangle(cornerRadius: Radius.S)
|
|
214
|
-
.fill(
|
|
219
|
+
.fill(theme.colors.background.surface)
|
|
215
220
|
)
|
|
216
221
|
.overlay(
|
|
217
222
|
RoundedRectangle(cornerRadius: Radius.S)
|
|
@@ -260,31 +265,39 @@ public struct Input: View {
|
|
|
260
265
|
|
|
261
266
|
private func borderColor() -> Color {
|
|
262
267
|
if disabled {
|
|
263
|
-
return
|
|
268
|
+
return theme.colors.border.disable
|
|
264
269
|
}
|
|
265
270
|
if !error.isEmpty {
|
|
266
|
-
return
|
|
271
|
+
return theme.colors.error.primary
|
|
267
272
|
}
|
|
268
273
|
if isFocused {
|
|
269
|
-
return
|
|
274
|
+
return theme.colors.primary
|
|
270
275
|
}
|
|
271
|
-
return
|
|
276
|
+
return theme.colors.border.default
|
|
272
277
|
}
|
|
273
278
|
|
|
274
279
|
private func getTextColor() -> Color {
|
|
275
|
-
return disabled ?
|
|
280
|
+
return disabled ? theme.colors.text.disable : theme.colors.text.default
|
|
276
281
|
}
|
|
277
282
|
|
|
278
283
|
private func getPlaceholderColor() -> Color {
|
|
279
|
-
return disabled ?
|
|
284
|
+
return disabled ? theme.colors.text.disable : theme.colors.text.hint
|
|
280
285
|
}
|
|
281
286
|
|
|
282
287
|
private func getFloatingColor() -> Color {
|
|
283
|
-
return disabled ?
|
|
288
|
+
return disabled ? theme.colors.text.disable : (floatingValueColor ?? theme.colors.text.hint)
|
|
284
289
|
}
|
|
285
290
|
|
|
286
291
|
private func getFloatingIconColor() -> Color {
|
|
287
|
-
return disabled ?
|
|
292
|
+
return disabled ? theme.colors.text.disable : (floatingIconColor ?? theme.colors.text.default)
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
private func getLeadingIconColor() -> Color {
|
|
296
|
+
return disabled ? theme.colors.text.disable : (leadingIconColor ?? theme.colors.text.hint)
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
private func getRightIconColor() -> Color {
|
|
300
|
+
return disabled ? theme.colors.text.disable : (rightIconColor ?? theme.colors.text.default)
|
|
288
301
|
}
|
|
289
302
|
}
|
|
290
303
|
|
|
@@ -296,6 +309,7 @@ private struct SecureInputField: UIViewRepresentable {
|
|
|
296
309
|
var fontSize: CGFloat
|
|
297
310
|
var fontWeight: UIFont.Weight
|
|
298
311
|
var textColor: UIColor
|
|
312
|
+
var cursorColor: UIColor
|
|
299
313
|
var isDisabled: Bool
|
|
300
314
|
var maxLength: Int?
|
|
301
315
|
var onFocusChange: (Bool) -> Void
|
|
@@ -316,7 +330,7 @@ private struct SecureInputField: UIViewRepresentable {
|
|
|
316
330
|
textField.setContentHuggingPriority(.defaultLow, for: .horizontal)
|
|
317
331
|
textField.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
|
|
318
332
|
textField.text = text
|
|
319
|
-
textField.tintColor =
|
|
333
|
+
textField.tintColor = cursorColor
|
|
320
334
|
textField.addTarget(
|
|
321
335
|
context.coordinator,
|
|
322
336
|
action: #selector(Coordinator.textFieldDidChange(_:)),
|
|
@@ -331,6 +345,8 @@ private struct SecureInputField: UIViewRepresentable {
|
|
|
331
345
|
textField.text = text
|
|
332
346
|
}
|
|
333
347
|
textField.isEnabled = !isDisabled
|
|
348
|
+
textField.textColor = textColor
|
|
349
|
+
textField.tintColor = cursorColor
|
|
334
350
|
if textField.keyboardType != keyboardType {
|
|
335
351
|
textField.keyboardType = keyboardType
|
|
336
352
|
textField.reloadInputViews()
|
|
@@ -401,9 +417,9 @@ private struct SecureInputField: UIViewRepresentable {
|
|
|
401
417
|
|
|
402
418
|
// MARK: - Helper Extension
|
|
403
419
|
private extension View {
|
|
404
|
-
func
|
|
420
|
+
func applyCursorColor(_ color: Color) -> some View {
|
|
405
421
|
if #available(iOS 15.0, *) {
|
|
406
|
-
return self.tint(
|
|
422
|
+
return self.tint(color)
|
|
407
423
|
} else {
|
|
408
424
|
return self
|
|
409
425
|
}
|
|
@@ -7,15 +7,17 @@
|
|
|
7
7
|
|
|
8
8
|
import SwiftUI
|
|
9
9
|
public struct InputPhoneNumber: View {
|
|
10
|
+
@Environment(\.appTheme) private var theme
|
|
10
11
|
@Binding public var text: String
|
|
11
12
|
|
|
12
13
|
public var placeholder: String
|
|
13
14
|
public var size: InputSize
|
|
14
15
|
public var hintText: String
|
|
15
16
|
public var error: String
|
|
17
|
+
public var errorSpacing: Bool
|
|
16
18
|
public var loading: Bool
|
|
17
19
|
public var rightIcon: String
|
|
18
|
-
public var rightIconColor: Color
|
|
20
|
+
public var rightIconColor: Color?
|
|
19
21
|
public var autofocus: Bool
|
|
20
22
|
public var onChangeText: ((String) -> Void)?
|
|
21
23
|
public var onFocus: (() -> Void)?
|
|
@@ -31,10 +33,11 @@ public struct InputPhoneNumber: View {
|
|
|
31
33
|
size: InputSize = .small,
|
|
32
34
|
hintText: String = "",
|
|
33
35
|
error: String = "",
|
|
36
|
+
errorSpacing: Bool = false,
|
|
34
37
|
loading: Bool = false,
|
|
35
38
|
required: Bool = false,
|
|
36
39
|
rightIcon: String = "",
|
|
37
|
-
rightIconColor: Color =
|
|
40
|
+
rightIconColor: Color? = nil,
|
|
38
41
|
autofocus: Bool = false,
|
|
39
42
|
onChangeText: ((String) -> Void)? = nil,
|
|
40
43
|
onFocus: (() -> Void)? = nil,
|
|
@@ -47,6 +50,7 @@ public struct InputPhoneNumber: View {
|
|
|
47
50
|
self.size = size
|
|
48
51
|
self.hintText = hintText
|
|
49
52
|
self.error = error
|
|
53
|
+
self.errorSpacing = errorSpacing
|
|
50
54
|
self.loading = loading
|
|
51
55
|
self.rightIcon = rightIcon
|
|
52
56
|
self.rightIconColor = rightIconColor
|
|
@@ -76,17 +80,17 @@ public struct InputPhoneNumber: View {
|
|
|
76
80
|
.padding(.trailing, Spacing.XS)
|
|
77
81
|
|
|
78
82
|
MomoText("+84", typography: size == .small ? .headerSSemibold : .headerMBold)
|
|
79
|
-
.foregroundColor(
|
|
83
|
+
.foregroundColor(theme.colors.text.default)
|
|
80
84
|
|
|
81
85
|
Rectangle()
|
|
82
|
-
.fill(
|
|
86
|
+
.fill(theme.colors.border.default)
|
|
83
87
|
.frame(width: 1, height: size == .small ? 24 : 32)
|
|
84
88
|
.padding(.horizontal, Spacing.M)
|
|
85
89
|
|
|
86
90
|
// Text input
|
|
87
91
|
ZStack(alignment: .leading) {
|
|
88
92
|
if text.isEmpty {
|
|
89
|
-
MomoText(placeholder, typography: size == .small ? .headerSSemibold : .headerMBold, color:
|
|
93
|
+
MomoText(placeholder, typography: size == .small ? .headerSSemibold : .headerMBold, color: theme.colors.text.hint)
|
|
90
94
|
}
|
|
91
95
|
|
|
92
96
|
TextField("", text: textBinding, onEditingChanged: { focused in
|
|
@@ -95,8 +99,8 @@ public struct InputPhoneNumber: View {
|
|
|
95
99
|
.keyboardType(.numberPad)
|
|
96
100
|
.font(size == .small ? .header_s_semibold : .header_m_bold)
|
|
97
101
|
.ignoreBoldTextSetting()
|
|
98
|
-
.foregroundColor(
|
|
99
|
-
.
|
|
102
|
+
.foregroundColor(theme.colors.text.default)
|
|
103
|
+
.applyCursorColor(theme.colors.primary)
|
|
100
104
|
.lineLimit(1)
|
|
101
105
|
.accessibility(identifier: accessibilityLabel ?? "")
|
|
102
106
|
.accessibilityValue(textBinding.wrappedValue.isEmpty ? placeholder : textBinding.wrappedValue)
|
|
@@ -108,7 +112,7 @@ public struct InputPhoneNumber: View {
|
|
|
108
112
|
text = ""
|
|
109
113
|
onChangeText?("")
|
|
110
114
|
}) {
|
|
111
|
-
Icon(source: "24_navigation_close_circle_full", size: 16, color:
|
|
115
|
+
Icon(source: "24_navigation_close_circle_full", size: 16, color: theme.colors.text.hint)
|
|
112
116
|
.padding(.leading, Spacing.S).accessibility(identifier: "ic_clear")
|
|
113
117
|
}
|
|
114
118
|
}
|
|
@@ -122,7 +126,7 @@ public struct InputPhoneNumber: View {
|
|
|
122
126
|
// ✅ Right icon
|
|
123
127
|
if !rightIcon.isEmpty {
|
|
124
128
|
SwiftUI.Button(action: { onRightIconPressed?() }) {
|
|
125
|
-
Icon(source: rightIcon, size: 24, color: rightIconColor)
|
|
129
|
+
Icon(source: rightIcon, size: 24, color: rightIconColor ?? theme.colors.text.default)
|
|
126
130
|
.padding(.leading, Spacing.S)
|
|
127
131
|
}
|
|
128
132
|
}
|
|
@@ -131,7 +135,7 @@ public struct InputPhoneNumber: View {
|
|
|
131
135
|
.frame(height: scaleSize(size == .small ? 48 : 56, 1.1))
|
|
132
136
|
.background(
|
|
133
137
|
RoundedRectangle(cornerRadius: Radius.S)
|
|
134
|
-
.fill(
|
|
138
|
+
.fill(theme.colors.background.surface)
|
|
135
139
|
)
|
|
136
140
|
.overlay(
|
|
137
141
|
RoundedRectangle(cornerRadius: Radius.S)
|
|
@@ -141,7 +145,7 @@ public struct InputPhoneNumber: View {
|
|
|
141
145
|
// Error or hint
|
|
142
146
|
ErrorView(
|
|
143
147
|
errorMessage: error,
|
|
144
|
-
errorSpacing:
|
|
148
|
+
errorSpacing: errorSpacing,
|
|
145
149
|
hintText: hintText
|
|
146
150
|
)
|
|
147
151
|
}
|
|
@@ -159,21 +163,18 @@ public struct InputPhoneNumber: View {
|
|
|
159
163
|
}
|
|
160
164
|
|
|
161
165
|
private func borderColor() -> Color {
|
|
162
|
-
if !error.isEmpty { return
|
|
163
|
-
if isFocused { return
|
|
164
|
-
return
|
|
166
|
+
if !error.isEmpty { return theme.colors.error.primary }
|
|
167
|
+
if isFocused { return theme.colors.primary }
|
|
168
|
+
return theme.colors.border.default
|
|
165
169
|
}
|
|
166
170
|
}
|
|
167
171
|
|
|
168
172
|
private extension View {
|
|
169
|
-
func
|
|
173
|
+
func applyCursorColor(_ color: Color) -> some View {
|
|
170
174
|
if #available(iOS 15.0, *) {
|
|
171
|
-
|
|
172
|
-
return self.tint(Colors.primary)
|
|
175
|
+
return self.tint(color)
|
|
173
176
|
} else {
|
|
174
|
-
// iOS 13–14: return unchanged (no tint support)
|
|
175
177
|
return self
|
|
176
178
|
}
|
|
177
179
|
}
|
|
178
180
|
}
|
|
179
|
-
|
|
@@ -9,11 +9,12 @@ import SwiftUI
|
|
|
9
9
|
// MARK: - RenderRightIconSearch
|
|
10
10
|
|
|
11
11
|
struct RenderRightIconSearch: View {
|
|
12
|
+
@Environment(\.appTheme) private var theme
|
|
12
13
|
let loading: Bool
|
|
13
14
|
let icon: String
|
|
14
15
|
let color: Color
|
|
15
16
|
let onClick: () -> Void
|
|
16
|
-
|
|
17
|
+
|
|
17
18
|
var body: some View {
|
|
18
19
|
HStack(spacing: 0) {
|
|
19
20
|
if loading {
|
|
@@ -24,12 +25,10 @@ struct RenderRightIconSearch: View {
|
|
|
24
25
|
if !icon.isEmpty {
|
|
25
26
|
Divider()
|
|
26
27
|
.frame(width: 1)
|
|
27
|
-
.background(
|
|
28
|
+
.background(theme.colors.primary)
|
|
28
29
|
.padding(.leading, Spacing.S)
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
.foregroundColor(color)
|
|
32
|
-
.frame(width: 24, height: 24)
|
|
31
|
+
Icon(source: icon, size: 24, color: color)
|
|
33
32
|
.padding(.leading, Spacing.S)
|
|
34
33
|
.onTapGesture(perform: onClick)
|
|
35
34
|
}
|
|
@@ -48,14 +47,18 @@ public struct InputSearchProps {
|
|
|
48
47
|
var error: String = ""
|
|
49
48
|
var disabled: Bool = false
|
|
50
49
|
var icon: String = ""
|
|
51
|
-
var iconColor: Color =
|
|
50
|
+
var iconColor: Color? = nil
|
|
52
51
|
var onRightIconPressed: () -> Void = {}
|
|
53
52
|
var onFocus: () -> Void = {}
|
|
54
53
|
var onBlur: () -> Void = {}
|
|
55
54
|
var loading: Bool = false
|
|
56
55
|
var fontWeight: Font.Weight = .regular
|
|
57
56
|
var keyboardType: UIKeyboardType = .default
|
|
58
|
-
|
|
57
|
+
// Mirrors Compose's InputSearchProps.searchIcon — a custom leading icon view.
|
|
58
|
+
var searchIcon: (() -> AnyView)? = nil
|
|
59
|
+
// Mirrors Compose's InputSearchProps.placeholderCustomRender — a custom placeholder view.
|
|
60
|
+
var placeholderCustomRender: (() -> AnyView)? = nil
|
|
61
|
+
|
|
59
62
|
public init(text: Binding<String>,
|
|
60
63
|
buttonText: String = "",
|
|
61
64
|
showButtonText: Bool = false,
|
|
@@ -66,13 +69,15 @@ public struct InputSearchProps {
|
|
|
66
69
|
error: String = "",
|
|
67
70
|
disabled: Bool = false,
|
|
68
71
|
icon: String = "",
|
|
69
|
-
iconColor: Color =
|
|
72
|
+
iconColor: Color? = nil,
|
|
70
73
|
onRightIconPressed: @escaping () -> Void = {},
|
|
71
74
|
onFocus: @escaping () -> Void = {},
|
|
72
75
|
onBlur: @escaping () -> Void = {},
|
|
73
76
|
loading: Bool = false,
|
|
74
77
|
fontWeight: Font.Weight = .regular,
|
|
75
|
-
keyboardType: UIKeyboardType = .default
|
|
78
|
+
keyboardType: UIKeyboardType = .default,
|
|
79
|
+
searchIcon: (() -> AnyView)? = nil,
|
|
80
|
+
placeholderCustomRender: (() -> AnyView)? = nil) {
|
|
76
81
|
self._text = text
|
|
77
82
|
self.buttonText = buttonText
|
|
78
83
|
self.showButtonText = showButtonText
|
|
@@ -90,12 +95,15 @@ public struct InputSearchProps {
|
|
|
90
95
|
self.loading = loading
|
|
91
96
|
self.fontWeight = fontWeight
|
|
92
97
|
self.keyboardType = keyboardType
|
|
98
|
+
self.searchIcon = searchIcon
|
|
99
|
+
self.placeholderCustomRender = placeholderCustomRender
|
|
93
100
|
}
|
|
94
101
|
}
|
|
95
102
|
|
|
96
103
|
// MARK: - InputSearch
|
|
97
104
|
|
|
98
105
|
public struct InputSearch: View {
|
|
106
|
+
@Environment(\.appTheme) private var theme
|
|
99
107
|
@Binding var text: String
|
|
100
108
|
var buttonText: String = ""
|
|
101
109
|
var showButtonText: Bool = false
|
|
@@ -106,17 +114,19 @@ public struct InputSearch: View {
|
|
|
106
114
|
var error: String = ""
|
|
107
115
|
var disabled: Bool = false
|
|
108
116
|
var icon: String = ""
|
|
109
|
-
var iconColor: Color =
|
|
117
|
+
var iconColor: Color? = nil
|
|
110
118
|
var onRightIconPressed: () -> Void = {}
|
|
111
119
|
var onFocus: () -> Void = {}
|
|
112
120
|
var onBlur: () -> Void = {}
|
|
113
121
|
var loading: Bool = false
|
|
114
122
|
var fontWeight: Font.Weight = .regular
|
|
115
123
|
var keyboardType: UIKeyboardType = .default
|
|
116
|
-
|
|
124
|
+
var searchIcon: (() -> AnyView)? = nil
|
|
125
|
+
var placeholderCustomRender: (() -> AnyView)? = nil
|
|
126
|
+
|
|
117
127
|
@State private var isFocused = false
|
|
118
128
|
@State private var isBlurred = false
|
|
119
|
-
|
|
129
|
+
|
|
120
130
|
public init(text: Binding<String>,
|
|
121
131
|
buttonText: String = "",
|
|
122
132
|
showButtonText: Bool = false,
|
|
@@ -127,13 +137,15 @@ public struct InputSearch: View {
|
|
|
127
137
|
error: String = "",
|
|
128
138
|
disabled: Bool = false,
|
|
129
139
|
icon: String = "",
|
|
130
|
-
iconColor: Color =
|
|
140
|
+
iconColor: Color? = nil,
|
|
131
141
|
onRightIconPressed: @escaping () -> Void = {},
|
|
132
142
|
onFocus: @escaping () -> Void = {},
|
|
133
143
|
onBlur: @escaping () -> Void = {},
|
|
134
144
|
loading: Bool = false,
|
|
135
145
|
fontWeight: Font.Weight = .regular,
|
|
136
|
-
keyboardType: UIKeyboardType = .default
|
|
146
|
+
keyboardType: UIKeyboardType = .default,
|
|
147
|
+
searchIcon: (() -> AnyView)? = nil,
|
|
148
|
+
placeholderCustomRender: (() -> AnyView)? = nil) {
|
|
137
149
|
self._text = text
|
|
138
150
|
self.buttonText = buttonText
|
|
139
151
|
self.showButtonText = showButtonText
|
|
@@ -151,24 +163,60 @@ public struct InputSearch: View {
|
|
|
151
163
|
self.loading = loading
|
|
152
164
|
self.fontWeight = fontWeight
|
|
153
165
|
self.keyboardType = keyboardType
|
|
166
|
+
self.searchIcon = searchIcon
|
|
167
|
+
self.placeholderCustomRender = placeholderCustomRender
|
|
154
168
|
}
|
|
155
169
|
|
|
156
|
-
|
|
170
|
+
/// Convenience initializer mirroring Compose's `InputSearch(inputSearchProps)`.
|
|
171
|
+
public init(props: InputSearchProps) {
|
|
172
|
+
self.init(
|
|
173
|
+
text: props.$text,
|
|
174
|
+
buttonText: props.buttonText,
|
|
175
|
+
showButtonText: props.showButtonText,
|
|
176
|
+
showBorder: props.showBorder,
|
|
177
|
+
placeholder: props.placeholder,
|
|
178
|
+
onChangeText: props.onChangeText,
|
|
179
|
+
onPressButtonText: props.onPressButtonText,
|
|
180
|
+
error: props.error,
|
|
181
|
+
disabled: props.disabled,
|
|
182
|
+
icon: props.icon,
|
|
183
|
+
iconColor: props.iconColor,
|
|
184
|
+
onRightIconPressed: props.onRightIconPressed,
|
|
185
|
+
onFocus: props.onFocus,
|
|
186
|
+
onBlur: props.onBlur,
|
|
187
|
+
loading: props.loading,
|
|
188
|
+
fontWeight: props.fontWeight,
|
|
189
|
+
keyboardType: props.keyboardType,
|
|
190
|
+
searchIcon: props.searchIcon,
|
|
191
|
+
placeholderCustomRender: props.placeholderCustomRender
|
|
192
|
+
)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
|
|
157
196
|
public var body: some View {
|
|
197
|
+
let iconColor: Color = disabled ? theme.colors.text.disable : (self.iconColor ?? theme.colors.text.default)
|
|
158
198
|
VStack(alignment: .leading, spacing: 0) {
|
|
159
199
|
HStack(spacing: 0) {
|
|
160
200
|
HStack {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
201
|
+
if let searchIcon = searchIcon {
|
|
202
|
+
searchIcon()
|
|
203
|
+
} else {
|
|
204
|
+
Image(systemName: "magnifyingglass")
|
|
205
|
+
.foregroundColor(theme.colors.text.hint)
|
|
206
|
+
.frame(width: 24, height: 24)
|
|
207
|
+
.padding(.trailing, Spacing.XS)
|
|
208
|
+
}
|
|
209
|
+
|
|
166
210
|
ZStack(alignment: .leading) {
|
|
167
211
|
if text.isEmpty {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
212
|
+
if let placeholderCustomRender = placeholderCustomRender {
|
|
213
|
+
placeholderCustomRender()
|
|
214
|
+
} else {
|
|
215
|
+
Text(placeholder)
|
|
216
|
+
.foregroundColor(disabled ? theme.colors.text.disable : theme.colors.text.hint)
|
|
217
|
+
.font(.system(size: scaleSize(14), weight: fontWeight))
|
|
218
|
+
.ignoreBoldTextSetting()
|
|
219
|
+
}
|
|
172
220
|
}
|
|
173
221
|
TextField("", text: $text, onEditingChanged: { editing in
|
|
174
222
|
isFocused = editing
|
|
@@ -182,26 +230,27 @@ public struct InputSearch: View {
|
|
|
182
230
|
}
|
|
183
231
|
}, onCommit: {})
|
|
184
232
|
.disabled(disabled)
|
|
185
|
-
.foregroundColor(disabled ?
|
|
186
|
-
.font(.system(size:
|
|
233
|
+
.foregroundColor(disabled ? theme.colors.text.disable : theme.colors.text.default)
|
|
234
|
+
.font(.system(size: scaleSize(14), weight: fontWeight))
|
|
187
235
|
.ignoreBoldTextSetting()
|
|
188
236
|
.keyboardType(keyboardType)
|
|
237
|
+
.applyCursorColor(theme.colors.primary)
|
|
189
238
|
}
|
|
190
239
|
|
|
191
240
|
if isFocused && !text.isEmpty {
|
|
192
241
|
SwiftButton(action: { text = "" }) {
|
|
193
242
|
Image(systemName: "xmark.circle.fill")
|
|
194
|
-
.foregroundColor(
|
|
243
|
+
.foregroundColor(theme.colors.text.hint)
|
|
195
244
|
.frame(width: 16, height: 16)
|
|
196
245
|
}
|
|
197
246
|
.padding(.leading, Spacing.S)
|
|
198
247
|
}
|
|
199
248
|
|
|
200
|
-
RenderRightIconSearch(loading: loading, icon: icon, color:
|
|
249
|
+
RenderRightIconSearch(loading: loading, icon: icon, color: iconColor, onClick: onRightIconPressed)
|
|
201
250
|
}
|
|
202
251
|
.padding(.horizontal, Spacing.M)
|
|
203
252
|
.padding(.vertical, Spacing.S)
|
|
204
|
-
.background(
|
|
253
|
+
.background(theme.colors.background.surface)
|
|
205
254
|
.cornerRadius(Radius.XL)
|
|
206
255
|
.overlay(
|
|
207
256
|
RoundedRectangle(cornerRadius: Radius.XL)
|
|
@@ -211,31 +260,35 @@ public struct InputSearch: View {
|
|
|
211
260
|
|
|
212
261
|
if showButtonText {
|
|
213
262
|
SwiftButton(action: onPressButtonText) {
|
|
214
|
-
|
|
215
|
-
.foregroundColor(Colors.black17)
|
|
216
|
-
.font(.system(size: 14, weight: .medium))
|
|
217
|
-
.ignoreBoldTextSetting()
|
|
263
|
+
MomoText(buttonText, typography: .actionDefaultBold, color: theme.colors.text.default)
|
|
218
264
|
}
|
|
219
265
|
.padding(.leading, Spacing.L)
|
|
220
266
|
}
|
|
221
267
|
}
|
|
222
268
|
}
|
|
223
269
|
}
|
|
224
|
-
}
|
|
225
270
|
|
|
226
|
-
// MARK: - Helper Functions
|
|
227
|
-
|
|
228
|
-
func getBorderColor(isFocused: Bool, error: String, disabled: Bool) -> Color {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
271
|
+
// MARK: - Helper Functions
|
|
272
|
+
|
|
273
|
+
func getBorderColor(isFocused: Bool, error: String, disabled: Bool) -> Color {
|
|
274
|
+
if disabled {
|
|
275
|
+
return theme.colors.border.disable
|
|
276
|
+
} else if !error.isEmpty {
|
|
277
|
+
return theme.colors.error.primary
|
|
278
|
+
} else if isFocused {
|
|
279
|
+
return theme.colors.primary
|
|
280
|
+
} else {
|
|
281
|
+
return theme.colors.border.default
|
|
282
|
+
}
|
|
237
283
|
}
|
|
238
284
|
}
|
|
239
285
|
|
|
240
|
-
|
|
241
|
-
|
|
286
|
+
private extension View {
|
|
287
|
+
func applyCursorColor(_ color: Color) -> some View {
|
|
288
|
+
if #available(iOS 15.0, *) {
|
|
289
|
+
return self.tint(color)
|
|
290
|
+
} else {
|
|
291
|
+
return self
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|