@momo-kits/native-kits 0.152.4-beta.6 → 0.152.4-beta.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.
Files changed (156) hide show
  1. package/CODE_OF_CONDUCT.md +133 -0
  2. package/CONTRIBUTING.md +114 -0
  3. package/LICENSE +20 -0
  4. package/README.md +7 -0
  5. package/build.gradle.kts +32 -0
  6. package/compose/MoMoComposeKits.podspec +54 -0
  7. package/compose/build.gradle.kts +149 -0
  8. package/compose/src/androidMain/AndroidManifest.xml +2 -0
  9. package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +105 -0
  10. package/compose/src/commonMain/composeResources/files/lottie_circle_loader.json +1 -0
  11. package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
  12. package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
  13. package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
  14. package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
  15. package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
  16. package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
  17. package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
  18. package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
  19. package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
  20. package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
  21. package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
  22. package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
  23. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
  24. package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
  25. package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +57 -0
  26. package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +201 -0
  27. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +222 -0
  28. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +48 -0
  29. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +86 -0
  30. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +76 -0
  31. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +76 -0
  32. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +306 -0
  33. package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +33 -0
  34. package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +715 -0
  35. package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +214 -0
  36. package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +392 -0
  37. package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +69 -0
  38. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +77 -0
  39. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +27 -0
  40. package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +334 -0
  41. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +345 -0
  42. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +90 -0
  43. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +131 -0
  44. package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +543 -0
  45. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +23 -0
  46. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +58 -0
  47. package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +143 -0
  48. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +179 -0
  49. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +111 -0
  50. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +384 -0
  51. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +160 -0
  52. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +234 -0
  53. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +223 -0
  54. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +232 -0
  55. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +236 -0
  56. package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +228 -0
  57. package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +364 -0
  58. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +50 -0
  59. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +34 -0
  60. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +85 -0
  61. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +33 -0
  62. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +338 -0
  63. package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +95 -0
  64. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +64 -0
  65. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +89 -0
  66. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +91 -0
  67. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +86 -0
  68. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +84 -0
  69. package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +208 -0
  70. package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +172 -0
  71. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +199 -0
  72. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
  73. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +237 -0
  74. package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +191 -0
  75. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +306 -0
  76. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
  77. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +13 -0
  78. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +191 -0
  79. package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +258 -0
  80. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +2 -0
  81. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +35 -0
  82. package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +2 -0
  83. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +59 -0
  84. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +68 -0
  85. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
  86. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +49 -0
  87. package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
  88. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +232 -0
  89. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +111 -0
  90. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +94 -0
  91. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +159 -0
  92. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +302 -0
  93. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScaleSizeScope.kt +17 -0
  94. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +484 -0
  95. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +169 -0
  96. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +216 -0
  97. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +86 -0
  98. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +180 -0
  99. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +251 -0
  100. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +80 -0
  101. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +306 -0
  102. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +31 -0
  103. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +385 -0
  104. package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +123 -0
  105. package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +38 -0
  106. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
  107. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +62 -0
  108. package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +88 -0
  109. package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +144 -0
  110. package/gradle.properties +19 -0
  111. package/gradlew +240 -0
  112. package/gradlew.bat +91 -0
  113. package/ios/Application/ApplicationEnvironment.swift +50 -0
  114. package/ios/Application/Components.swift +263 -0
  115. package/ios/Application/ComposeApi.swift +22 -0
  116. package/ios/Application/FloatingButton.swift +172 -0
  117. package/ios/Application/HeaderRight.swift +271 -0
  118. package/ios/Application/Screen.swift +249 -0
  119. package/ios/Badge/BadgeDot.swift +31 -0
  120. package/ios/Button/Button.swift +211 -0
  121. package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +126 -0
  122. package/ios/Checkbox/Checkbox.swift +81 -0
  123. package/ios/Chip/Chip.swift +96 -0
  124. package/ios/Colors+Radius+Spacing/Colors.swift +172 -0
  125. package/ios/Colors+Radius+Spacing/Radius.swift +22 -0
  126. package/ios/Colors+Radius+Spacing/Spacing.swift +12 -0
  127. package/ios/Extensions/Color++.swift +25 -0
  128. package/ios/Icon/Icon.swift +51 -0
  129. package/ios/Image/Image.swift +70 -0
  130. package/ios/Input/Input.swift +207 -0
  131. package/ios/Input/InputPhoneNumber.swift +176 -0
  132. package/ios/Input/InputSearch.swift +238 -0
  133. package/ios/Input/InputTextArea.swift +242 -0
  134. package/ios/Lottie/LottieView.swift +86 -0
  135. package/ios/OTPKeyboard/KeyboardButton.swift +41 -0
  136. package/ios/OTPKeyboard/OTPKeyboard.swift +145 -0
  137. package/ios/Popup/PopupDisplay.swift +284 -0
  138. package/ios/Popup/PopupInput.swift +96 -0
  139. package/ios/Popup/PopupPromotion.swift +73 -0
  140. package/ios/PopupView/FullscreenPopup.swift +251 -0
  141. package/ios/PopupView/Modifiers.swift +158 -0
  142. package/ios/PopupView/PopupView.swift +289 -0
  143. package/ios/PopupView/Utils++.swift +281 -0
  144. package/ios/ScrollIndicator/ScrollIndicator.swift +110 -0
  145. package/ios/Swipeable/SwipeCell.swift +278 -0
  146. package/ios/Swipeable/SwipeCellModel.swift +86 -0
  147. package/ios/Switch/Switch.swift +44 -0
  148. package/ios/Template/Logo/Logo.swift +75 -0
  149. package/ios/Template/TrustBanner/TrustBanner.swift +120 -0
  150. package/ios/Theme.md +18 -0
  151. package/ios/Typography/Text.swift +140 -0
  152. package/ios/Typography/Typography.swift +95 -0
  153. package/ios/native-kits.podspec +18 -0
  154. package/package.json +6 -7
  155. package/settings.gradle.kts +25 -0
  156. package/shared/build.gradle.kts +0 -74
@@ -0,0 +1,211 @@
1
+ import Foundation
2
+ import SwiftUI
3
+ import Lottie
4
+
5
+ // MARK: - ButtonType
6
+
7
+ public enum ButtonType {
8
+ case primary
9
+ case secondary
10
+ case tonal
11
+ case outline
12
+ case danger
13
+ case text
14
+ case disabled
15
+ }
16
+
17
+ // MARK: - ButtonSize
18
+
19
+ public enum ButtonSize {
20
+ case large
21
+ case medium
22
+ case small
23
+ }
24
+
25
+ public struct ButtonStyleData {
26
+ let background: Color
27
+ let content: Color
28
+ let border: Color?
29
+ let borderWidth: CGFloat
30
+ }
31
+
32
+ public extension ButtonType {
33
+ func backgroundColor(loading: Bool) -> Color {
34
+ switch self {
35
+ case .disabled: return Colors.black05.opacity(loading ? 0.75 : 1)
36
+ case .primary: return Colors.primary.opacity(loading ? 0.75 : 1)
37
+ case .secondary: return Colors.card.opacity(loading ? 0.75 : 1)
38
+ case .outline: return Colors.card.opacity(loading ? 0.75 : 1)
39
+ case .tonal: return Colors.primaryLight.opacity(loading ? 0.75 : 1)
40
+ case .danger: return Colors.error.opacity(loading ? 0.75 : 1)
41
+ case .text: return .clear
42
+ }
43
+ }
44
+
45
+ func contentColor(loading: Bool) -> Color {
46
+ switch self {
47
+ case .disabled: return Colors.black06.opacity(loading ? 0.75 : 1)
48
+ case .primary: return Colors.black01
49
+ case .secondary: return Colors.black17
50
+ case .outline: return Colors.primary
51
+ case .tonal: return Colors.primary
52
+ case .danger: return Colors.black01
53
+ case .text: return Colors.primary
54
+ }
55
+ }
56
+
57
+ var borderColor: Color? {
58
+ switch self {
59
+ case .outline: return Colors.primary
60
+ case .secondary: return Colors.black04
61
+ default: return nil
62
+ }
63
+ }
64
+
65
+ var borderWidth: CGFloat {
66
+ switch self {
67
+ case .outline: return 1
68
+ case .secondary: return 1
69
+ default: return 0
70
+ }
71
+ }
72
+ }
73
+
74
+ extension ButtonSize {
75
+ var height: CGFloat {
76
+ switch self {
77
+ case .large: return 48
78
+ case .medium: return 36
79
+ case .small: return 28
80
+ }
81
+ }
82
+
83
+ var padding: CGFloat {
84
+ switch self {
85
+ case .large: return Spacing.L
86
+ case .medium: return Spacing.M
87
+ case .small: return Spacing.S
88
+ }
89
+ }
90
+
91
+ var radius: CGFloat {
92
+ Radius.S
93
+ }
94
+
95
+ var iconSize: CGFloat {
96
+ switch self {
97
+ case .large: return 24
98
+ case .medium, .small: return 16
99
+ }
100
+ }
101
+
102
+ var iconSpacing: CGFloat {
103
+ switch self {
104
+ case .small: return Spacing.XS
105
+ case .medium, .large: return Spacing.S
106
+ }
107
+ }
108
+
109
+ var font: Font {
110
+ switch self {
111
+ case .large: return .system(size: 16, weight: .bold)
112
+ case .medium: return .system(size: 14, weight: .bold)
113
+ case .small: return .system(size: 12, weight: .bold)
114
+ }
115
+ }
116
+ }
117
+
118
+ public struct Button: View {
119
+
120
+ var title: String
121
+ var action: () -> Void
122
+ var type: ButtonType
123
+ var size: ButtonSize
124
+ var iconLeft: AnyView?
125
+ var iconRight: AnyView?
126
+ var loading: Bool
127
+
128
+ public init(
129
+ title: String = "",
130
+ action: @escaping () -> Void,
131
+ type: ButtonType = .primary,
132
+ size: ButtonSize = .large,
133
+ iconLeft: AnyView? = nil,
134
+ iconRight: AnyView? = nil,
135
+ loading: Bool = false
136
+ ) {
137
+ self.title = title
138
+ self.action = action
139
+ self.type = type
140
+ self.size = size
141
+ self.iconLeft = iconLeft
142
+ self.iconRight = iconRight
143
+ self.loading = loading
144
+ }
145
+
146
+ private func shouldLoadingOnLeft(_ left: AnyView?, _ right: AnyView?) -> Bool {
147
+ let hasLeft = left != nil
148
+ let hasRight = right != nil
149
+
150
+ switch (hasLeft, hasRight) {
151
+ case (false, false): return true
152
+ case (true, false): return true
153
+ case (false, true): return false
154
+ case (true, true): return false
155
+ }
156
+ }
157
+
158
+ public var body: some View {
159
+
160
+ let loadingOnLeft = shouldLoadingOnLeft(iconLeft, iconRight)
161
+
162
+ let bg = type.backgroundColor(loading: loading)
163
+ let fg = type.contentColor(loading: loading)
164
+ let border = type.borderColor
165
+ let borderWidth = type.borderWidth
166
+
167
+ SwiftUI.Button(action: {
168
+ if !loading && type != .disabled {
169
+ action()
170
+ }
171
+ }) {
172
+ HStack(spacing: size.iconSpacing) {
173
+
174
+ if loading && loadingOnLeft {
175
+ LottieView(name: "lottie_circle_loader", loopMode: .loop)
176
+ .frame(width: size.iconSize, height: size.iconSize)
177
+ .colorMultiply(fg)
178
+
179
+ } else if let iconLeft = iconLeft {
180
+ iconLeft.frame(width: size.iconSize, height: size.iconSize)
181
+ }
182
+
183
+ Text(title)
184
+ .font(size.font)
185
+ .foregroundColor(fg)
186
+ .lineLimit(1)
187
+ .truncationMode(.tail)
188
+
189
+ if loading && !loadingOnLeft {
190
+ LottieView(name: "lottie_circle_loader", loopMode: .loop)
191
+ .frame(width: size.iconSize, height: size.iconSize)
192
+ .colorMultiply(fg)
193
+
194
+ } else if let iconRight = iconRight {
195
+ iconRight.frame(width: size.iconSize, height: size.iconSize)
196
+ }
197
+ }
198
+ .frame(maxWidth: .infinity)
199
+ .padding(.horizontal, size.padding)
200
+ .frame(height: size.height)
201
+ .background(bg)
202
+ .overlay(
203
+ RoundedRectangle(cornerRadius: size.radius)
204
+ .stroke(border ?? .clear, lineWidth: border != nil ? borderWidth : 0)
205
+ )
206
+ .clipShape(RoundedRectangle(cornerRadius: size.radius))
207
+ .opacity(loading ? 0.75 : 1)
208
+ }
209
+ .disabled(type == .disabled || loading)
210
+ }
211
+ }
@@ -0,0 +1,126 @@
1
+
2
+ import Foundation
3
+ import SwiftUI
4
+
5
+ // MARK: - CalculatorKeyboard
6
+
7
+
8
+ extension String {
9
+ var isNumber: Bool {
10
+ let digitsCharacters = CharacterSet(charactersIn: "0123456789")
11
+ return CharacterSet(charactersIn: self).isSubset(of: digitsCharacters)
12
+ }
13
+ }
14
+
15
+
16
+ public struct CalculatorKeyboard: View {
17
+ // MARK: Lifecycle
18
+ @Binding var value: String
19
+ @State var tempValue: String = ""
20
+
21
+ public init(_ value: Binding<String>) {
22
+ self._value = value
23
+ }
24
+
25
+ func onPressBack(){
26
+ if (value.count > 0 ){
27
+ value.removeLast()
28
+ }
29
+
30
+ }
31
+
32
+ func onPressClear(key: String){
33
+ value = ""
34
+ tempValue = ""
35
+ }
36
+
37
+ func onPressEqual(key: String){
38
+ if (tempValue == "") {
39
+ return
40
+ }
41
+ if (tempValue.last?.isNumber == false){
42
+ tempValue.removeLast()
43
+ }
44
+ let expression = NSExpression(format: tempValue)
45
+
46
+ value = String(expression.expressionValue(with: nil, context: nil) as! Int)
47
+ if (Int(value) ?? 0 < 0){
48
+ value = ""
49
+ }
50
+ }
51
+
52
+ func onPressKey(key:String){
53
+ if (tempValue.last?.isNumber == false){
54
+ if (key.isNumber == false){
55
+ return
56
+ }
57
+ }
58
+ var convertedKey = key
59
+ if (key == "x") {convertedKey = "*"}
60
+ if (key == "÷") {convertedKey = "/"}
61
+ if (value == "" && (key == "0" || key == "000" || key.isNumber == false)) {
62
+ return
63
+ }
64
+ else {
65
+ value.append(key)
66
+ tempValue.append(convertedKey)
67
+ }
68
+ }
69
+
70
+ // MARK: Public
71
+
72
+ public var body: some View {
73
+ return GeometryReader { geo in
74
+ VStack {
75
+ HStack {
76
+ KeyboardButton("AC", action: self.onPressClear, color: Colors.pink07, textColor: Colors.black01)
77
+ KeyboardButton("÷", action: self.onPressKey, color: Colors.pink07, textColor: Colors.black01)
78
+ KeyboardButton("x", action: self.onPressKey, color: Colors.pink07, textColor: Colors.black01)
79
+
80
+ SwiftUI.Button(action: onPressBack) {
81
+ HStack {
82
+ Image(
83
+ systemName: "delete.backward"
84
+ ).foregroundColor(Colors.black01)
85
+ }.frame(maxWidth: .infinity, minHeight: 48)
86
+ .background(Colors.pink07)
87
+ .foregroundColor(Colors.black01)
88
+ .clipShape(RoundedRectangle(cornerRadius: 8))
89
+ }
90
+ }
91
+
92
+ HStack {
93
+ KeyboardButton("7", action: self.onPressKey)
94
+ KeyboardButton("8", action: self.onPressKey)
95
+ KeyboardButton("9", action: self.onPressKey)
96
+ KeyboardButton("-", action: self.onPressKey, color: Colors.pink07, textColor: Colors.black01)
97
+ }
98
+
99
+ HStack {
100
+ KeyboardButton("4", action: self.onPressKey)
101
+ KeyboardButton("5", action: self.onPressKey)
102
+ KeyboardButton("6", action: self.onPressKey)
103
+ KeyboardButton("+", action: self.onPressKey, color: Colors.pink07, textColor: Colors.black01)
104
+ }
105
+
106
+ HStack{
107
+ VStack{
108
+ HStack {
109
+ KeyboardButton("1", action: self.onPressKey)
110
+ KeyboardButton("2", action: self.onPressKey)
111
+ KeyboardButton("3", action: self.onPressKey)
112
+ }
113
+
114
+ HStack{
115
+ KeyboardButton("000", action: self.onPressKey)
116
+ KeyboardButton("0", action: self.onPressKey, width: CGFloat(geo.size.width * 0.25 - 5))
117
+ }
118
+ }
119
+
120
+ KeyboardButton("=", action: self.onPressEqual, width: CGFloat(geo.size.width * 0.25 - 5), height: 102, color: Colors.primary, textColor: Colors.black01)
121
+
122
+ }
123
+ }.background(Colors.background)
124
+ }
125
+ }
126
+ }
@@ -0,0 +1,81 @@
1
+ import Foundation
2
+ import SwiftUI
3
+
4
+ public struct Checkbox: View{
5
+ @Binding var checked: Bool
6
+ var disabled: Bool
7
+ var onChange: ((Bool)->Void)?
8
+ var indeterminate: Bool
9
+ var title: String
10
+
11
+
12
+ public init(_ checked: Binding<Bool>,disabled: Bool = false, onChange: ( (Bool) -> Void)? = nil,
13
+ indeterminate: Bool = false,
14
+ title: String = ""){
15
+ self._checked = checked
16
+ self.disabled = disabled
17
+ self.onChange = onChange
18
+ self.indeterminate = indeterminate
19
+ self.title = title
20
+ }
21
+
22
+ func onCheck(){
23
+ checked.toggle()
24
+ onChange?(checked)
25
+ }
26
+
27
+ public var body: some View {
28
+ HStack(spacing: Spacing.S) {
29
+ // Checkbox
30
+ ZStack {
31
+ RoundedRectangle(cornerRadius: Radius.XS)
32
+ .fill(backgroundColor)
33
+ .frame(width: 20, height: 20)
34
+ .overlay(
35
+ RoundedRectangle(cornerRadius: Radius.XS)
36
+ .stroke(borderColor, lineWidth: Spacing.XXS)
37
+ )
38
+
39
+ if checked {
40
+ Image(systemName: indeterminate ? "minus.square.fill" : "checkmark.square.fill")
41
+ .resizable()
42
+ .foregroundColor(backgroundColor)
43
+ .background(Colors.black01)
44
+ .frame(width: 20, height: 20)
45
+ }
46
+ }
47
+
48
+ .onTapGesture {
49
+ if !disabled {
50
+ onCheck()
51
+ }
52
+ }
53
+
54
+ // Title
55
+ if !title.isEmpty {
56
+ Text(title)
57
+ .font(.description1)
58
+ }
59
+ }
60
+ }
61
+
62
+ private var borderColor: Color {
63
+ if disabled {
64
+ return Colors.black03
65
+ } else if checked {
66
+ return Colors.primary
67
+ } else {
68
+ return Colors.text
69
+ }
70
+ }
71
+
72
+ private var backgroundColor: Color {
73
+ if disabled && checked {
74
+ return Colors.pink08
75
+ } else if checked {
76
+ return Colors.primary
77
+ } else {
78
+ return Color.clear
79
+ }
80
+ }
81
+ }
@@ -0,0 +1,96 @@
1
+ import SwiftUI
2
+ import Foundation
3
+
4
+ public struct Chip: View {
5
+ public enum ChipSize { case small, large }
6
+
7
+ public struct Dimensions {
8
+ let horizontal: CGFloat
9
+ let vertical: CGFloat
10
+ let iconSize: CGFloat
11
+ let iconSpacing: CGFloat
12
+ }
13
+
14
+ public static let Large = Dimensions(horizontal: 12, vertical: 8, iconSize: 20, iconSpacing: 8)
15
+ public static let Small = Dimensions(horizontal: 10, vertical: 6, iconSize: 16, iconSpacing: 6)
16
+
17
+ private let label: String?
18
+ private let iconLeft: String?
19
+ private let iconRight: String?
20
+ private let selected: Bool
21
+ private let onClick: () -> Void
22
+ private let size: ChipSize
23
+ private let iconLeftTint: Color?
24
+ private let iconRightTint: Color?
25
+ private let backgroundColor: Color?
26
+ private let accessibilityLabel: String?
27
+
28
+ public init(
29
+ label: String? = "Label",
30
+ iconLeft: String? = nil,
31
+ iconRight: String? = nil,
32
+ selected: Bool = false,
33
+ onClick: @escaping () -> Void = {},
34
+ size: ChipSize = .large,
35
+ iconLeftTint: Color? = nil,
36
+ iconRightTint: Color? = nil,
37
+ backgroundColor: Color? = nil,
38
+ accessibilityLabel: String? = nil
39
+ ) {
40
+ self.label = label
41
+ self.iconLeft = iconLeft
42
+ self.iconRight = iconRight
43
+ self.selected = selected
44
+ self.onClick = onClick
45
+ self.size = size
46
+ self.iconLeftTint = iconLeftTint
47
+ self.iconRightTint = iconRightTint
48
+ self.backgroundColor = backgroundColor
49
+ self.accessibilityLabel = accessibilityLabel
50
+ }
51
+
52
+ public var body: some View {
53
+ let dims = (size == .small) ? Self.Small : Self.Large
54
+
55
+ let bg: Color = {
56
+ if selected { return Colors.pink10 }
57
+ if let explicit = backgroundColor { return explicit }
58
+ return Colors.black03
59
+ }()
60
+
61
+ let textColor: Color = selected ? Colors.primary : Colors.text
62
+ let leftTint: Color = selected ? Colors.primary : iconLeftTint ?? Colors.text
63
+ let rightTint: Color = selected ? Colors.primary : iconRightTint ?? Colors.text
64
+
65
+ HStack(spacing: dims.iconSpacing) {
66
+ if let iconLeft {
67
+ Icon(source: iconLeft, size: dims.iconSize, color: leftTint)
68
+ }
69
+
70
+ if let text = label, !text.isEmpty {
71
+ MomoText(text, typography: (size == .large) ? .labelDefaultMedium : .labelSMedium, color: textColor)
72
+ .lineLimit(1)
73
+ }
74
+
75
+ if let iconRight {
76
+ Icon(source: iconRight, size: dims.iconSize, color: rightTint)
77
+ }
78
+ }
79
+ .padding(.horizontal, dims.horizontal)
80
+ .padding(.vertical, dims.vertical)
81
+ .background(
82
+ RoundedRectangle(cornerRadius: Radius.L, style: .continuous)
83
+ .fill(bg)
84
+ )
85
+ .overlay(
86
+ Group {
87
+ if selected {
88
+ RoundedRectangle(cornerRadius: Radius.L, style: .continuous)
89
+ .stroke(Colors.primary, lineWidth: 2)
90
+ }
91
+ }
92
+ )
93
+ .contentShape(RoundedRectangle(cornerRadius: Radius.L, style: .continuous))
94
+ .onTapGesture(perform: onClick)
95
+ }
96
+ }
@@ -0,0 +1,172 @@
1
+
2
+ import Foundation
3
+ import SwiftUI
4
+
5
+ public enum Colors {
6
+ public static let primary = Color("Primary")
7
+ public static let primaryDark = Color("PrimaryDark")
8
+ public static let primaryLight = Color("PrimaryLight")
9
+ public static let secondary = Color("Secondary")
10
+ public static let background = Color("Background")
11
+ public static let border = Color("Border")
12
+ public static let text = Color("Text")
13
+ public static let textSecondary = Color("TextSecondary")
14
+ public static let card = Color("Card")
15
+ public static let error = Color("Error")
16
+ public static let info = Color("Info")
17
+ public static let success = Color("Success")
18
+
19
+ public static let black20 = Color(hex: "000000")
20
+ public static let black19 = Color(hex: "18191a")
21
+ public static let black18 = Color(hex: "242424")
22
+ public static let black17 = Color(hex: "303233")
23
+ public static let black16 = Color(hex: "404040")
24
+ public static let black15 = Color(hex: "484848")
25
+ public static let black14 = Color(hex: "565656")
26
+ public static let black13 = Color(hex: "646464")
27
+ public static let black12 = Color(hex: "727272")
28
+ public static let black11 = Color(hex: "878787")
29
+ public static let black10 = Color(hex: "a0a0a0")
30
+ public static let black09 = Color(hex: "b9b9b9")
31
+ public static let black08 = Color(hex: "c6c6c6")
32
+ public static let black07 = Color(hex: "cccccc")
33
+ public static let black06 = Color(hex: "d8d8d8")
34
+ public static let black05 = Color(hex: "e5e5e5")
35
+ public static let black04 = Color(hex: "e8e8e8")
36
+ public static let black03 = Color(hex: "f0f0f0")
37
+ public static let black02 = Color(hex: "f9f9f9")
38
+ public static let black01 = Color(hex: "ffffff")
39
+
40
+
41
+ public static let pink11 = Color(hex: "fef8fc")
42
+ public static let pink10 = Color(hex: "fef4fa")
43
+ public static let pink09 = Color(hex: "fdeaf4")
44
+ public static let pink08 = Color(hex: "fbd5ea")
45
+ public static let pink07 = Color(hex: "f7acd5")
46
+ public static let pink06 = Color(hex: "f382c0")
47
+ public static let pink05 = Color(hex: "ef59ab")
48
+ public static let pink04 = Color(hex: "ed43a0")
49
+ public static let pink03 = Color(hex: "eb2f96")
50
+ public static let pink02 = Color(hex: "d42a87")
51
+ public static let pink01 = Color(hex: "bc2678")
52
+
53
+
54
+ public static let violet10 = Color(hex: "fcf8fe")
55
+ public static let violet09 = Color(hex: "faf4fe")
56
+ public static let violet08 = Color(hex: "ead4fc")
57
+ public static let violet07 = Color(hex: "d5aaf9")
58
+ public static let violet06 = Color(hex: "f4e9fd")
59
+ public static let violet05 = Color(hex: "c07ff6")
60
+ public static let violet04 = Color(hex: "ab55f3")
61
+ public static let violet03 = Color(hex: "962af0")
62
+ public static let violet02 = Color(hex: "8726d8")
63
+ public static let violet01 = Color(hex: "7822c0")
64
+
65
+ public static let indigo11 = Color(hex: "f9f9ff")
66
+ public static let indigo10 = Color(hex: "f6f6ff")
67
+ public static let indigo09 = Color(hex: "ededff")
68
+ public static let indigo08 = Color(hex: "dcdbff")
69
+ public static let indigo07 = Color(hex: "b8b7ff")
70
+ public static let indigo06 = Color(hex: "9593ff")
71
+ public static let indigo05 = Color(hex: "716fff")
72
+ public static let indigo04 = Color(hex: "5f5dff")
73
+ public static let indigo03 = Color(hex: "4e4bff")
74
+ public static let indigo02 = Color(hex: "4644e6")
75
+ public static let indigo01 = Color(hex: "3e3ccc")
76
+
77
+ public static let blue11 = Color(hex: "f7fbff")
78
+ public static let blue10 = Color(hex: "f2f8ff")
79
+ public static let blue09 = Color(hex: "e5f1ff")
80
+ public static let blue08 = Color(hex: "cce4ff")
81
+ public static let blue07 = Color(hex: "99caff")
82
+ public static let blue06 = Color(hex: "66afff")
83
+ public static let blue05 = Color(hex: "3395ff")
84
+ public static let blue04 = Color(hex: "1987ff")
85
+ public static let blue03 = Color(hex: "007aff")
86
+ public static let blue02 = Color(hex: "006ee6")
87
+ public static let blue01 = Color(hex: "0062cc")
88
+
89
+ public static let mint11 = Color(hex: "f8fdfd")
90
+ public static let mint10 = Color(hex: "f3fcfc")
91
+ public static let mint09 = Color(hex: "e7f8f8")
92
+ public static let mint08 = Color(hex: "d0f3f3")
93
+ public static let mint07 = Color(hex: "a1e7e7")
94
+ public static let mint06 = Color(hex: "71dada")
95
+ public static let mint05 = Color(hex: "42cece")
96
+ public static let mint04 = Color(hex: "2ac8c8")
97
+ public static let mint03 = Color(hex: "13c2c2")
98
+ public static let mint02 = Color(hex: "11afaf")
99
+ public static let mint01 = Color(hex: "0f9b9b")
100
+
101
+ public static let green11 = Color(hex: "f9fdfa")
102
+ public static let green10 = Color(hex: "f5fcf6")
103
+ public static let green09 = Color(hex: "eaf9ee")
104
+ public static let green08 = Color(hex: "d6f4de")
105
+ public static let green07 = Color(hex: "aee9bd")
106
+ public static let green06 = Color(hex: "85dd9b")
107
+ public static let green05 = Color(hex: "5dd27a")
108
+ public static let green04 = Color(hex: "48cc69")
109
+ public static let green03 = Color(hex: "34c759")
110
+ public static let green02 = Color(hex: "2fb350")
111
+ public static let green01 = Color(hex: "2a9f47")
112
+
113
+ public static let lime11 = Color(hex: "fcfef8")
114
+ public static let lime10 = Color(hex: "fafdf3")
115
+ public static let lime09 = Color(hex: "f5fbe7")
116
+ public static let lime08 = Color(hex: "ecf7cf")
117
+ public static let lime07 = Color(hex: "d9f0a0")
118
+ public static let lime06 = Color(hex: "c6e870")
119
+ public static let lime05 = Color(hex: "b3e141")
120
+ public static let lime04 = Color(hex: "a9dc28")
121
+ public static let lime03 = Color(hex: "a0d911")
122
+ public static let lime02 = Color(hex: "90c30f")
123
+ public static let lime01 = Color(hex: "80ae0e")
124
+
125
+ public static let yellow11 = Color(hex: "fffdf7")
126
+ public static let yellow10 = Color(hex: "fffcf2")
127
+ public static let yellow09 = Color(hex: "fff9e5")
128
+ public static let yellow08 = Color(hex: "fff5cc")
129
+ public static let yellow07 = Color(hex: "ffeb99")
130
+ public static let yellow06 = Color(hex: "ffe066")
131
+ public static let yellow05 = Color(hex: "ffd633")
132
+ public static let yellow04 = Color(hex: "ffd119")
133
+ public static let yellow03 = Color(hex: "fc0")
134
+ public static let yellow02 = Color(hex: "e6b800")
135
+ public static let yellow01 = Color(hex: "cca300")
136
+
137
+ public static let gold11 = Color(hex: "fefbf8")
138
+ public static let gold10 = Color(hex: "fff9f3")
139
+ public static let gold09 = Color(hex: "fef3e7")
140
+ public static let gold08 = Color(hex: "fee8d0")
141
+ public static let gold07 = Color(hex: "fdd1a2")
142
+ public static let gold06 = Color(hex: "fcba73")
143
+ public static let gold05 = Color(hex: "fba345")
144
+ public static let gold04 = Color(hex: "fa972d")
145
+ public static let gold03 = Color(hex: "fa8c16")
146
+ public static let gold02 = Color(hex: "e17e14")
147
+ public static let gold01 = Color(hex: "c87012")
148
+
149
+ public static let orange11 = Color(hex: "fefaf8")
150
+ public static let orange10 = Color(hex: "fff6f3")
151
+ public static let orange09 = Color(hex: "feede8")
152
+ public static let orange08 = Color(hex: "feddd2")
153
+ public static let orange07 = Color(hex: "fdbba4")
154
+ public static let orange06 = Color(hex: "fc9877")
155
+ public static let orange05 = Color(hex: "fb7649")
156
+ public static let orange04 = Color(hex: "fa6532")
157
+ public static let orange03 = Color(hex: "fa541c")
158
+ public static let orange02 = Color(hex: "e14c19")
159
+ public static let orange01 = Color(hex: "c84316")
160
+
161
+ public static let red11 = Color(hex: "fef8f8")
162
+ public static let red10 = Color(hex: "fef4f4")
163
+ public static let red09 = Color(hex: "fee8ea")
164
+ public static let red08 = Color(hex: "fdd3d5")
165
+ public static let red07 = Color(hex: "fba7ab")
166
+ public static let red06 = Color(hex: "f97a81")
167
+ public static let red05 = Color(hex: "f74e57")
168
+ public static let red04 = Color(hex: "f63842")
169
+ public static let red03 = Color(hex: "f5222d")
170
+ public static let red02 = Color(hex: "dd1f29")
171
+ public static let red01 = Color(hex: "c41b24")
172
+ }