@momo-kits/native-kits 0.0.1-beta.2

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 (101) 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 +6 -0
  5. package/android/build.gradle +82 -0
  6. package/android/gradle.properties +5 -0
  7. package/android/src/main/AndroidManifest.xml +4 -0
  8. package/android/src/main/java/com/momoplatform/nativekits/NativeKitsPackage.kt +17 -0
  9. package/android/src/main/java/com/momoplatform/nativekits/NativeKitsViewManager.kt +20 -0
  10. package/example/ios/Example/Assets.xcassets/AppIcon.appiconset/Contents.json +63 -0
  11. package/example/ios/Example/Assets.xcassets/Background.colorset/Contents.json +38 -0
  12. package/example/ios/Example/Assets.xcassets/Border.colorset/Contents.json +38 -0
  13. package/example/ios/Example/Assets.xcassets/Card.colorset/Contents.json +38 -0
  14. package/example/ios/Example/Assets.xcassets/Contents.json +6 -0
  15. package/example/ios/Example/Assets.xcassets/Error.colorset/Contents.json +38 -0
  16. package/example/ios/Example/Assets.xcassets/Primary.colorset/Contents.json +38 -0
  17. package/example/ios/Example/Assets.xcassets/PrimaryDark.colorset/Contents.json +38 -0
  18. package/example/ios/Example/Assets.xcassets/PrimaryLight.colorset/Contents.json +38 -0
  19. package/example/ios/Example/Assets.xcassets/Secondary.colorset/Contents.json +38 -0
  20. package/example/ios/Example/Assets.xcassets/Success.colorset/Contents.json +38 -0
  21. package/example/ios/Example/Assets.xcassets/Text.colorset/Contents.json +38 -0
  22. package/example/ios/Example/Assets.xcassets/TextSecondary.colorset/Contents.json +38 -0
  23. package/example/ios/Example/Assets.xcassets/Warning.colorset/Contents.json +38 -0
  24. package/example/ios/Example/ComponentDetail.swift +35 -0
  25. package/example/ios/Example/ComponentItem.swift +24 -0
  26. package/example/ios/Example/ComponentModel.swift +31 -0
  27. package/example/ios/Example/ContentView.swift +53 -0
  28. package/example/ios/Example/Example.entitlements +10 -0
  29. package/example/ios/Example/Foundation/ButtonDemo.swift +80 -0
  30. package/example/ios/Example/Foundation/Popup/ActionSheets.swift +136 -0
  31. package/example/ios/Example/Foundation/Popup/Floats.swift +127 -0
  32. package/example/ios/Example/Foundation/Popup/Popups.swift +101 -0
  33. package/example/ios/Example/Foundation/PopupDemo.swift +366 -0
  34. package/example/ios/Example/Foundation/TypographyDemo.swift +53 -0
  35. package/example/ios/Example/Foundation.swift +26 -0
  36. package/example/ios/Example/Info.plist +18 -0
  37. package/example/ios/Example/Library/SwipeableDemo.swift +105 -0
  38. package/example/ios/Example/Library.swift +26 -0
  39. package/example/ios/Example/Main.swift +11 -0
  40. package/example/ios/Example/Overview.swift +20 -0
  41. package/example/ios/Example/Preview Content/Preview Assets.xcassets/Contents.json +6 -0
  42. package/example/ios/Example/Resource/SFProText-Black.ttf +0 -0
  43. package/example/ios/Example/Resource/SFProText-Bold.ttf +0 -0
  44. package/example/ios/Example/Resource/SFProText-Heavy.ttf +0 -0
  45. package/example/ios/Example/Resource/SFProText-Light.ttf +0 -0
  46. package/example/ios/Example/Resource/SFProText-Medium.ttf +0 -0
  47. package/example/ios/Example/Resource/SFProText-Regular.ttf +0 -0
  48. package/example/ios/Example/Resource/SFProText-Semibold.ttf +0 -0
  49. package/example/ios/Example/Resource/SFProText-Thin.ttf +0 -0
  50. package/example/ios/Example/Resource/SFProText-Ultralight.ttf +0 -0
  51. package/example/ios/Example/Resource/foundation.json +33 -0
  52. package/example/ios/Example/Resource/library.json +8 -0
  53. package/example/ios/Example/Utils.swift +30 -0
  54. package/example/ios/Example/ViewModifier/DarkViewModifier.swift +22 -0
  55. package/example/ios/Example.xcodeproj/project.pbxproj +565 -0
  56. package/example/ios/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  57. package/example/ios/Example.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  58. package/example/ios/Example.xcodeproj/project.xcworkspace/xcuserdata/wem.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  59. package/example/ios/Example.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  60. package/example/ios/Example.xcworkspace/contents.xcworkspacedata +10 -0
  61. package/example/ios/Example.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  62. package/example/ios/Example.xcworkspace/xcuserdata/wem.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  63. package/example/ios/Example.xcworkspace/xcuserdata/wem.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +6 -0
  64. package/example/ios/Podfile +6 -0
  65. package/example/ios/Podfile.lock +16 -0
  66. package/example/ios/Pods/Local Podspecs/MoMoUIKits.podspec.json +29 -0
  67. package/example/ios/Pods/Manifest.lock +16 -0
  68. package/example/ios/Pods/Pods.xcodeproj/project.pbxproj +661 -0
  69. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/MoMoUIKits.xcscheme +58 -0
  70. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/Pods-Example.xcscheme +58 -0
  71. package/example/ios/Pods/Pods.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/xcschememanagement.plist +25 -0
  72. package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits-dummy.m +5 -0
  73. package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits-prefix.pch +12 -0
  74. package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits-umbrella.h +16 -0
  75. package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits.debug.xcconfig +12 -0
  76. package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits.modulemap +6 -0
  77. package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits.release.xcconfig +12 -0
  78. package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example-acknowledgements.markdown +3 -0
  79. package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example-acknowledgements.plist +29 -0
  80. package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example-dummy.m +5 -0
  81. package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example-umbrella.h +16 -0
  82. package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example.debug.xcconfig +14 -0
  83. package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example.modulemap +6 -0
  84. package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example.release.xcconfig +14 -0
  85. package/ios/Button/Button.swift +131 -0
  86. package/ios/Colors+Spacing/Colors.swift +170 -0
  87. package/ios/Colors+Spacing/Radius.swift +11 -0
  88. package/ios/Colors+Spacing/Spacing.swift +12 -0
  89. package/ios/Extensions/Color++.swift +25 -0
  90. package/ios/OTPKeyboard/KeyboardButton.swift +33 -0
  91. package/ios/OTPKeyboard/OTPKeyboard.swift +145 -0
  92. package/ios/Popup/Modifiers.swift +172 -0
  93. package/ios/Popup/PopupView.swift +397 -0
  94. package/ios/Popup/Utils.swift +186 -0
  95. package/ios/Swipeable/SwipeCell.swift +270 -0
  96. package/ios/Swipeable/SwipeCellModel.swift +86 -0
  97. package/ios/Theme.md +18 -0
  98. package/ios/Typography/Typography.swift +30 -0
  99. package/ios/native-kits.podspec +15 -0
  100. package/package.json +8 -0
  101. package/publish.sh +28 -0
@@ -0,0 +1,270 @@
1
+ import Foundation
2
+ import SwiftUI
3
+
4
+ // MARK: - SwipeCellModifier
5
+
6
+ public struct SwipeCellModifier: ViewModifier {
7
+ var id: String
8
+ var cellWidth: CGFloat = .infinity
9
+ var leadingSideGroup: [SwipeCellActionItem] = []
10
+ var trailingSideGroup: [SwipeCellActionItem] = []
11
+ @Binding var currentUserInteractionCellID: String?
12
+ var settings: SwipeCellSettings = .init()
13
+
14
+ @State private var offsetX: CGFloat = 0
15
+
16
+ let generator = UINotificationFeedbackGenerator()
17
+ @State private var hapticFeedbackOccurred: Bool = false
18
+ @State private var openSideLock: SwipeGroupSide?
19
+
20
+ public func body(content: Content)->some View {
21
+ ZStack {
22
+ if self.leadingSideGroup.isEmpty == false && self.offsetX != 0 {
23
+ self.swipeToRevealArea(swipeItemGroup: self.leadingSideGroup, side: .leading)
24
+ }
25
+
26
+ if self.trailingSideGroup.isEmpty == false && self.offsetX != 0 {
27
+ self.swipeToRevealArea(swipeItemGroup: self.trailingSideGroup, side: .trailing)
28
+ }
29
+
30
+ content
31
+ .offset(x: self.offsetX)
32
+ .gesture(DragGesture(minimumDistance: 30, coordinateSpace: .local).onChanged(self.dragOnChanged(value:)).onEnded(dragOnEnded(value:)))
33
+
34
+ }.frame(width: cellWidth)
35
+ .edgesIgnoringSafeArea(.horizontal)
36
+ .clipped()
37
+ .onChange(of: self.currentUserInteractionCellID) { _ in
38
+ if let currentDragCellID = self.currentUserInteractionCellID, currentDragCellID != self.id && self.openSideLock != nil {
39
+ // if this cell has an open side area and is not the cell being dragged, close the cell
40
+ self.setOffsetX(value: 0)
41
+ // reset the drag cell id to nil
42
+ self.currentUserInteractionCellID = nil
43
+ }
44
+ }
45
+ }
46
+
47
+ internal func swipeToRevealArea(swipeItemGroup: [SwipeCellActionItem], side: SwipeGroupSide)->some View {
48
+ HStack {
49
+ if side == .trailing {
50
+ Spacer()
51
+ }
52
+ ZStack {
53
+ HStack(spacing: 0) {
54
+ ForEach(swipeItemGroup) { item in
55
+ SwiftUI.Button {
56
+ self.setOffsetX(value: 0)
57
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
58
+ item.actionCallback()
59
+ }
60
+ } label: {
61
+ self.buttonContentView(item: item, group: swipeItemGroup, side: side)
62
+ }.buttonStyle(BorderlessButtonStyle())
63
+ }
64
+ }
65
+ }.opacity(self.swipeRevealAreaOpacity(side: side))
66
+
67
+ if side == .leading {
68
+ Spacer()
69
+ }
70
+ }
71
+ }
72
+
73
+ internal func buttonContentView(item: SwipeCellActionItem, group: [SwipeCellActionItem], side: SwipeGroupSide)->some View {
74
+ ZStack {
75
+ item.backgroundColor
76
+
77
+ HStack {
78
+ if self.warnSwipeOutCondition(side: side, hasSwipeOut: item.swipeOutAction) && item.swipeOutButtonView != nil {
79
+ item.swipeOutButtonView!()
80
+ } else {
81
+ item.buttonView()
82
+ }
83
+ }
84
+
85
+ }.frame(width: self.itemButtonWidth(item: item, itemGroup: group, side: side))
86
+ }
87
+
88
+ internal func menuWidth(side: SwipeGroupSide)->CGFloat {
89
+ switch side {
90
+ case .leading:
91
+ return self.leadingSideGroup.map { $0.buttonWidth }.reduce(0, +)
92
+
93
+ case .trailing:
94
+ return self.trailingSideGroup.map { $0.buttonWidth }.reduce(0, +)
95
+ }
96
+ }
97
+
98
+ // MARK: drag gesture
99
+
100
+ internal func dragOnChanged(value: DragGesture.Value) {
101
+ let horizontalTranslation = value.translation.width
102
+ if self.nonDraggableCondition(horizontalTranslation: horizontalTranslation) {
103
+ return
104
+ }
105
+
106
+ if self.openSideLock != nil {
107
+ // if one side is open, we need to add the menu width!
108
+ let menuWidth = self.openSideLock == .leading ? self.menuWidth(side: .leading) : self.menuWidth(side: .trailing)
109
+ self.offsetX = menuWidth * openSideLock!.sideFactor + horizontalTranslation
110
+ self.triggerHapticFeedbackIfNeeded(horizontalTranslation: horizontalTranslation)
111
+ return
112
+ }
113
+
114
+ self.triggerHapticFeedbackIfNeeded(horizontalTranslation: horizontalTranslation)
115
+
116
+ if horizontalTranslation > 8 || horizontalTranslation < -8 { // makes sure the swipe cell doesn't open too easily
117
+ self.currentUserInteractionCellID = self.id
118
+ self.offsetX = horizontalTranslation
119
+ } else {
120
+ self.offsetX = 0
121
+ }
122
+ }
123
+
124
+ internal func nonDraggableCondition(horizontalTranslation: CGFloat)->Bool {
125
+ return self.offsetX == 0 && (self.leadingSideGroup.isEmpty && horizontalTranslation > 0 || self.trailingSideGroup.isEmpty && horizontalTranslation < 0)
126
+ }
127
+
128
+ internal func dragOnEnded(value: DragGesture.Value) {
129
+ let swipeOutTriggerValue = self.cellWidth * self.settings.swipeOutTriggerRatio
130
+
131
+ if self.offsetX == 0 {
132
+ self.openSideLock = nil
133
+ } else if self.offsetX > 0 {
134
+ if self.leadingSideGroup.isEmpty == false {
135
+ if self.offsetX < settings.openTriggerValue || (self.openSideLock == .leading && self.offsetX < self.menuWidth(side: .leading) * 0.8) {
136
+ self.setOffsetX(value: 0)
137
+ } else if let leftItem = self.leadingSideGroup.filter({ $0.swipeOutAction == true }).first, self.offsetX.magnitude > swipeOutTriggerValue {
138
+ self.swipeOutAction(item: leftItem, sideFactor: 1)
139
+ } else {
140
+ self.lockSideMenu(side: .leading)
141
+ }
142
+
143
+ } else {
144
+ // leading group emtpy
145
+ self.setOffsetX(value: 0)
146
+ }
147
+ } else if self.offsetX < 0 {
148
+ if self.trailingSideGroup.isEmpty == false {
149
+ if self.offsetX.magnitude < settings.openTriggerValue || (self.openSideLock == .trailing && self.offsetX > -self.menuWidth(side: .trailing) * 0.8) {
150
+ self.setOffsetX(value: 0)
151
+ } else if let rightItem = self.trailingSideGroup.filter({ $0.swipeOutAction == true }).first, self.offsetX.magnitude > swipeOutTriggerValue {
152
+ self.swipeOutAction(item: rightItem, sideFactor: -1)
153
+ } else {
154
+ self.lockSideMenu(side: .trailing)
155
+ }
156
+
157
+ } else {
158
+ // trailing group emtpy
159
+ self.setOffsetX(value: 0)
160
+ }
161
+ }
162
+ }
163
+
164
+ internal func triggerHapticFeedbackIfNeeded(horizontalTranslation: CGFloat) {
165
+ let side: SwipeGroupSide = horizontalTranslation > 0 ? .leading : .trailing
166
+ let group = side == .leading ? self.leadingSideGroup : self.trailingSideGroup
167
+ let swipeOutActionCondition = self.warnSwipeOutCondition(side: side, hasSwipeOut: true)
168
+ if let item = self.swipeOutItemWithHapticFeedback(group: group), self.hapticFeedbackOccurred == false, swipeOutActionCondition == true {
169
+ self.generator.notificationOccurred(item.swipeOutHapticFeedbackType!)
170
+ self.hapticFeedbackOccurred = true
171
+ }
172
+ }
173
+
174
+ internal func swipeOutItemWithHapticFeedback(group: [SwipeCellActionItem])->SwipeCellActionItem? {
175
+ if let item = group.filter({ $0.swipeOutAction == true }).first {
176
+ if item.swipeOutHapticFeedbackType != nil {
177
+ return item
178
+ }
179
+ }
180
+ return nil
181
+ }
182
+
183
+ internal func swipeOutAction(item: SwipeCellActionItem, sideFactor: CGFloat) {
184
+ if item.swipeOutIsDestructive {
185
+ let swipeOutWidth = cellWidth + 10
186
+ self.setOffsetX(value: swipeOutWidth * sideFactor)
187
+ self.openSideLock = nil
188
+ } else {
189
+ self.setOffsetX(value: 0) // open side lock set in function!
190
+ }
191
+
192
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
193
+ item.actionCallback()
194
+ }
195
+ }
196
+
197
+ internal func lockSideMenu(side: SwipeGroupSide) {
198
+ self.setOffsetX(value: side.sideFactor * self.menuWidth(side: side))
199
+ self.openSideLock = side
200
+ self.hapticFeedbackOccurred = false
201
+ }
202
+
203
+ internal func setOffsetX(value: CGFloat) {
204
+ withAnimation(.spring()) {
205
+ self.offsetX = value
206
+ }
207
+ if self.offsetX == 0 {
208
+ self.openSideLock = nil
209
+ self.hapticFeedbackOccurred = false
210
+ }
211
+ }
212
+
213
+ internal func itemButtonWidth(item: SwipeCellActionItem, itemGroup: [SwipeCellActionItem], side: SwipeGroupSide)->CGFloat {
214
+ let dynamicButtonWidth = self.dynamicButtonWidth(item: item, itemCount: itemGroup.count, side: side)
215
+ let triggerValue = self.cellWidth * settings.swipeOutTriggerRatio
216
+ let swipeOutActionCondition = side == .leading ? self.offsetX > triggerValue : self.offsetX < -triggerValue
217
+
218
+ if item.swipeOutAction && swipeOutActionCondition {
219
+ return self.offsetX.magnitude + settings.addWidthMargin
220
+ } else if swipeOutActionCondition && item.swipeOutAction == false && itemGroup.contains(where: { $0.swipeOutAction == true }) {
221
+ return 0
222
+ } else {
223
+ return dynamicButtonWidth
224
+ }
225
+ }
226
+
227
+ internal func dynamicButtonWidth(item: SwipeCellActionItem, itemCount: Int, side: SwipeGroupSide)->CGFloat {
228
+ let menuWidth = self.menuWidth(side: side)
229
+ return (self.offsetX.magnitude + settings.addWidthMargin) * (item.buttonWidth / menuWidth)
230
+ }
231
+
232
+ internal func warnSwipeOutCondition(side: SwipeGroupSide, hasSwipeOut: Bool)->Bool {
233
+ if hasSwipeOut == false {
234
+ return false
235
+ }
236
+ let triggerValue = self.cellWidth * settings.swipeOutTriggerRatio
237
+ return (side == .trailing && self.offsetX < -triggerValue) || (side == .leading && self.offsetX > triggerValue)
238
+ }
239
+
240
+ internal func swipeRevealAreaOpacity(side: SwipeGroupSide)->Double {
241
+ switch side {
242
+ case .leading:
243
+
244
+ return self.offsetX > 5 ? 1 : 0
245
+ case .trailing:
246
+ return self.offsetX < -5 ? 1 : 0
247
+ }
248
+ }
249
+ }
250
+
251
+ public extension View {
252
+ /// swipe cell modifier
253
+ /// - Parameters:
254
+ /// - id: the string id of this cell. The default value is a uuid string. If you want to set the currentUserInteractionCellID yourself, e.g. for tap to close functionality, you need to override this id value with your own cell id.
255
+ /// - cellWidth: the width of the content view - typically a cell or row in a list under which the swipe to reveal menu should appear.
256
+ /// - leadingSideGroup: the button group on the leading side that shall appear when the user swipes the cell to the right
257
+ /// - trailingSideGroup: the button group on the trailing side that shall appear when the user swipes the cell to the left
258
+ /// - currentUserInteractionCellID: a Binding of an optional UUID that should be set either in the view model of the parent view in which the cells appear or as a State variable into the parent view itself. Don't assign it a value!
259
+ /// - settings: settings. can be omitted in which case the settings struct default values apply.
260
+ /// - Returns: the modified view of the view that can be swiped.
261
+ func swipeCell(id: String = UUID().uuidString, cellWidth: CGFloat = .infinity, leadingSideGroup: [SwipeCellActionItem], trailingSideGroup: [SwipeCellActionItem], currentUserInteractionCellID: Binding<String?> = .constant(""), settings: SwipeCellSettings = SwipeCellSettings())->some View {
262
+ self.modifier(SwipeCellModifier(id: id, cellWidth: cellWidth, leadingSideGroup: leadingSideGroup, trailingSideGroup: trailingSideGroup, currentUserInteractionCellID: currentUserInteractionCellID, settings: settings))
263
+ }
264
+ }
265
+
266
+ public extension View {
267
+ func castToAnyView()->AnyView {
268
+ return AnyView(self)
269
+ }
270
+ }
@@ -0,0 +1,86 @@
1
+
2
+
3
+ import Foundation
4
+ import SwiftUI
5
+
6
+ // MARK: - SwipeGroupSide
7
+
8
+ public enum SwipeGroupSide {
9
+ case leading
10
+ case trailing
11
+
12
+ // MARK: Internal
13
+
14
+ var sideFactor: CGFloat {
15
+ switch self {
16
+ case .leading:
17
+ return 1
18
+
19
+ case .trailing:
20
+ return -1
21
+ }
22
+ }
23
+ }
24
+
25
+ // MARK: - SwipeCellActionItem
26
+
27
+ public struct SwipeCellActionItem: Identifiable {
28
+ // MARK: Lifecycle
29
+
30
+ /// Initializer
31
+ /// - Parameter id: Required to identify each buttin in the side menu. Default is a random uuid string.
32
+ /// - Parameter buttonView: The view in the foreground of the menu button. Make sure to set a maximum frame height less than the cell height!
33
+ /// - Parameter swipeOutButtonView: Alternative button view that is displayed only when the offset during swipe is beyond the swipe out trigger value.
34
+ /// - Parameter buttonWidth: Width of the button. The the open side menu width is calculated from the sum of all button widths. Default is 75.
35
+ /// - Parameter backgroundColor: The background colour of the the menu button.
36
+ /// - Parameter swipeOutAction: A Boolean that determines if a swipe out action is activated or not. Default is false.
37
+ /// - Parameter swipeOutHapticFeedbackType: If a swipeOutAction is activated, a haptic feedback will occur after the swipe out threshold is passed. Default is nil.
38
+ /// - Parameter swipeOutIsDestructive: A Boolean that determines if the swipe out is destructive. If true, the content cell view will be "move out of sight" once the swipe out is triggered.
39
+ public init(id: String = UUID().uuidString, buttonView: @escaping ()->AnyView, swipeOutButtonView: (()->AnyView)? = nil, buttonWidth: CGFloat = 75, backgroundColor: Color, swipeOutAction: Bool = false, swipeOutHapticFeedbackType: UINotificationFeedbackGenerator.FeedbackType? = nil, swipeOutIsDestructive: Bool = true, actionCallback: @escaping ()->()) {
40
+ self.id = id
41
+ self.buttonView = buttonView
42
+ self.swipeOutButtonView = swipeOutButtonView
43
+ self.buttonWidth = buttonWidth
44
+ self.backgroundColor = backgroundColor
45
+ self.swipeOutAction = swipeOutAction
46
+ self.swipeOutHapticFeedbackType = swipeOutHapticFeedbackType
47
+ self.swipeOutIsDestructive = swipeOutIsDestructive
48
+ self.actionCallback = actionCallback
49
+ }
50
+
51
+ // MARK: Public
52
+
53
+ public var id: String
54
+ public var buttonView: ()->AnyView
55
+ public var swipeOutButtonView: (()->AnyView)?
56
+ public var buttonWidth: CGFloat
57
+ public var backgroundColor: Color
58
+ public var swipeOutAction: Bool
59
+ public var swipeOutHapticFeedbackType: UINotificationFeedbackGenerator.FeedbackType?
60
+ public var swipeOutIsDestructive: Bool
61
+ /// public var swipeOutButtonViewScaleFactor: CGFloat
62
+ public var actionCallback: ()->()
63
+ }
64
+
65
+ // MARK: - SwipeCellSettings
66
+
67
+ /// Swipe Cell Settings
68
+ public struct SwipeCellSettings {
69
+ // MARK: Lifecycle
70
+
71
+ /// initializer
72
+ public init(openTriggerValue: CGFloat = 60, swipeOutTriggerRatio: CGFloat = 0.7, addWidthMargin: CGFloat = 5) {
73
+ self.openTriggerValue = openTriggerValue
74
+ self.swipeOutTriggerRatio = swipeOutTriggerRatio
75
+ self.addWidthMargin = addWidthMargin
76
+ }
77
+
78
+ // MARK: Public
79
+
80
+ /// minimum horizontal translation value necessary to open the side menu
81
+ public var openTriggerValue: CGFloat
82
+ /// the ratio of the total cell width that triggers a swipe out action (provided one action has swipe out activated)
83
+ public var swipeOutTriggerRatio: CGFloat = 0.7
84
+ /// An additional value to add to the open menu width. This is useful if the cell has rounded corners.
85
+ public var addWidthMargin: CGFloat = 5
86
+ }
package/ios/Theme.md ADDED
@@ -0,0 +1,18 @@
1
+ ## 🎯 Usage
2
+ ### Declaring themes with Asset
3
+ To get started, you need to define four different types of assets in xcode
4
+ ```swift
5
+ public static let primary = Color("Primary")
6
+ public static let primaryDark = Color("PrimaryDark")
7
+ public static let primaryLight = Color("PrimaryLight")
8
+ public static let secondary = Color("Secondary")
9
+ public static let background = Color("Background")
10
+ public static let border = Color("Border")
11
+ public static let text = Color("Text")
12
+ public static let textSecondary = Color("TextSecondary")
13
+ public static let card = Color("Card")
14
+ public static let error = Color("Error")
15
+ public static let info = Color("Info")
16
+ public static let success = Color("Success")
17
+ ```
18
+ > You can refer Colors class with static colors
@@ -0,0 +1,30 @@
1
+ import SwiftUI
2
+
3
+ public extension Font {
4
+ static func appFont(size: CGFloat) -> Font {
5
+ return Font.custom("SFProText", size: size)
6
+ }
7
+
8
+ static let h1 = appFont(size: 36).weight(.semibold)
9
+ static let h2 = appFont(size: 32).weight(.semibold)
10
+ static let h3 = appFont(size: 28).weight(.semibold)
11
+ static let h4 = appFont(size: 24).weight(.semibold)
12
+ static let title1 = appFont(size: 20).weight(.bold)
13
+ static let title2 = appFont(size: 18).weight(.bold)
14
+ static let title3 = appFont(size: 16).weight(.bold)
15
+ static let headerText1 = appFont(size: 15).weight(.semibold)
16
+ static let headerText2 = appFont(size: 14).weight(.semibold)
17
+ static let headerText3 = appFont(size: 12).weight(.semibold)
18
+ static let paragraph = appFont(size: 15).weight(.regular)
19
+ static let description1 = appFont(size: 14).weight(.regular)
20
+ static let description2 = appFont(size: 12).weight(.regular)
21
+ static let description3 = appFont(size: 10).weight(.regular)
22
+ static let label1 = appFont(size: 14).weight(.medium)
23
+ static let label2 = appFont(size: 12).weight(.medium)
24
+ static let label3 = appFont(size: 10).weight(.medium)
25
+ static let label4 = appFont(size: 8).weight(.medium)
26
+ static let action1 = appFont(size: 16).weight(.bold)
27
+ static let action2 = appFont(size: 15).weight(.bold)
28
+ static let action3 = appFont(size: 12).weight(.bold)
29
+ static let action4 = appFont(size: 10).weight(.bold)
30
+ }
@@ -0,0 +1,15 @@
1
+ Pod::Spec.new do |spec|
2
+ spec.name = 'MoMoUIKits'
3
+ spec.version = '1.0.0'
4
+ spec.license = { :type => 'MIT', :file => 'LICENSE' }
5
+ spec.homepage = 'https://gitlab.com'
6
+ spec.authors = { 'Developer' => 'momo@mservice.com.vn' }
7
+ spec.summary = 'Components for SwiftUI'
8
+ spec.source = { :git => 'https://gitlab.com', :tag => 'v1.0.0' }
9
+ spec.swift_versions = ['5.0']
10
+ spec.ios.deployment_target = '14.0'
11
+
12
+ spec.source_files = "**/*.swift"
13
+
14
+ spec.framework = 'SwiftUI', 'Combine'
15
+ end
package/package.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "@momo-kits/native-kits",
3
+ "version": "0.0.1-beta.2",
4
+ "private": false,
5
+ "dependencies": {},
6
+ "devDependencies": {},
7
+ "license": "MoMo"
8
+ }
package/publish.sh ADDED
@@ -0,0 +1,28 @@
1
+ #!/bin/bash
2
+ rm -rf dist
3
+ mkdir dist
4
+
5
+ cp . ./dist
6
+
7
+ # GET VERSION from mck_package.json
8
+ VERSIONSTRING=( v$(jq .version package.json) )
9
+ VERSION=(${VERSIONSTRING//[\"]/})
10
+ echo VERSION: $VERSION
11
+
12
+ rsync -r --verbose --exclude '*.mdx' --exclude '*Demo.js' --exclude 'props-type.js' --exclude 'prop-types.js' ./* dist
13
+
14
+ # #babel component to dist
15
+ #babel ./dist -d dist --copy-files
16
+
17
+ #copy option
18
+ #cp -r ./src/ dist
19
+
20
+
21
+ #npm login
22
+ #publish dist to npm
23
+ cd dist
24
+ npm publish --tag beta --access=public
25
+ cd ..
26
+ rm -rf dist
27
+
28
+ curl -X POST -H 'Content-Type: application/json' 'https://chat.googleapis.com/v1/spaces/AAAAbP8987c/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=UGSFRvk_oYb9uGsAgs31bVvMm6jDkmD8zihGm3eyaQA%3D&threadKey=JoaXTEYaNNkl' -d '{"text": "@momo-kits/native new version release: '*"$VERSION"*' https://www.npmjs.com/package/@momo-kits/native-kits"}'