@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,33 @@
1
+ import Foundation
2
+ import SwiftUI
3
+
4
+ typealias SwiftButton = SwiftUI.Button
5
+
6
+ // MARK: - KeyboardButton
7
+
8
+ public struct KeyboardButton: View {
9
+ // MARK: Lifecycle
10
+
11
+ public init(_ key: String, action: @escaping (_ key: String)->Void) {
12
+ self.key = key
13
+ self.action = action
14
+ }
15
+
16
+ // MARK: Public
17
+
18
+ public var body: some View {
19
+ SwiftUI.Button(action: { self.action(key) }) {
20
+ HStack {
21
+ Text(key).font(.system(size: 24, weight: .bold))
22
+ }.frame(maxWidth: .infinity, minHeight: 48)
23
+ .background(Colors.card)
24
+ .foregroundColor(Colors.text)
25
+ .clipShape(RoundedRectangle(cornerRadius: 8))
26
+ }
27
+ }
28
+
29
+ // MARK: Internal
30
+
31
+ var key: String = ""
32
+ var action: (_ key: String)->Void
33
+ }
@@ -0,0 +1,145 @@
1
+
2
+ import Foundation
3
+ import SwiftUI
4
+
5
+ // MARK: - OTPKeyboard
6
+
7
+ public struct OTPKeyboard: View {
8
+ // MARK: Lifecycle
9
+
10
+ public init(value: Binding<String>, length: Int, content: AnyView? = nil, onChange: ((String) -> Void)? = nil, onClose: @escaping () -> Void) {
11
+ self._value = value
12
+ self.length = length
13
+ self.content = content
14
+ self.onChange = onChange
15
+ self.onClose = onClose
16
+ }
17
+
18
+ // MARK: Public
19
+
20
+ public var body: some View {
21
+ return VStack {
22
+ VStack {
23
+ HStack(){
24
+ SwiftUI.Button(action: onClose) {
25
+ Image(systemName: "xmark")
26
+ .foregroundColor(Colors.text)
27
+ }
28
+ Spacer()
29
+ }
30
+
31
+ ZStack(alignment: .trailing) {
32
+ ValueView(value, valueLength: length).padding(.trailing, 12)
33
+ SwiftUI.Button(action: onClear) {
34
+ Image(systemName: "xmark.circle.fill")
35
+ .resizable()
36
+ .frame(width: 12, height: 12)
37
+ .foregroundColor(Colors.text)
38
+ }.offset(x: -12)
39
+ }.frame(minWidth: 148, maxWidth: 180, minHeight: 40)
40
+ .background(Colors.card)
41
+ .clipShape(Capsule())
42
+ .padding(.bottom, Spacing.M)
43
+ }
44
+
45
+ content
46
+
47
+ HStack {
48
+ KeyboardButton("7", action: self.onPressKey)
49
+ KeyboardButton("8", action: self.onPressKey)
50
+ KeyboardButton("9", action: self.onPressKey)
51
+ }
52
+
53
+ HStack {
54
+ KeyboardButton("4", action: self.onPressKey)
55
+ KeyboardButton("5", action: self.onPressKey)
56
+ KeyboardButton("6", action: self.onPressKey)
57
+ }
58
+
59
+ HStack {
60
+ KeyboardButton("1", action: self.onPressKey)
61
+ KeyboardButton("2", action: self.onPressKey)
62
+ KeyboardButton("3", action: self.onPressKey)
63
+ }
64
+
65
+ HStack {
66
+ KeyboardButton("", action: self.onPressKey).disabled(true).opacity(0)
67
+ KeyboardButton("0", action: self.onPressKey)
68
+ SwiftUI.Button(action: onPressBack) {
69
+ HStack {
70
+ Image(
71
+ systemName: "delete.backward"
72
+ ).foregroundColor(Colors.text)
73
+ }
74
+ }.frame(maxWidth: .infinity, minHeight: 48)
75
+ .clipShape(RoundedRectangle(cornerRadius: 8))
76
+ }
77
+ }
78
+ .background(Colors.background)
79
+ .onChange(of: value) { aa in
80
+ if onChange != nil {
81
+ self.onChange!(aa)
82
+ }
83
+ }
84
+ }
85
+
86
+ public func buildContent(_ content: @escaping () -> AnyView) -> OTPKeyboard {
87
+ var newSelf = self
88
+ newSelf.content = content()
89
+ return newSelf
90
+ }
91
+
92
+ // MARK: Internal
93
+
94
+ @Binding var value: String
95
+ var length: Int
96
+ var content: AnyView?
97
+ var onChange: ((String) -> Void)?
98
+ var onClose: () -> Void
99
+
100
+ func onPressKey(key: String) {
101
+ if value.count < length {
102
+ value.append(key)
103
+ }
104
+ }
105
+
106
+ func onPressBack() {
107
+ if !value.isEmpty {
108
+ value.removeLast()
109
+ }
110
+ }
111
+
112
+ func onClear() {
113
+ value.removeAll()
114
+ }
115
+ }
116
+
117
+ // MARK: - ValueView
118
+
119
+ private struct ValueView: View {
120
+ // MARK: Lifecycle
121
+
122
+ public init(_ value: String, valueLength: Int) {
123
+ self.value = value
124
+ self.valueLength = valueLength
125
+ }
126
+
127
+ // MARK: Public
128
+
129
+ public var body: some View {
130
+ return HStack {
131
+ ForEach(0 ..< valueLength, id: \.self) { i in
132
+ if i < value.count {
133
+ Circle().foregroundColor(Colors.text).frame(width: 8, height: 8)
134
+ } else {
135
+ Circle().foregroundColor(Colors.textSecondary).frame(width: 8, height: 8)
136
+ }
137
+ }
138
+ }.frame(maxWidth: .infinity, minHeight: 40)
139
+ }
140
+
141
+ // MARK: Internal
142
+
143
+ var value: String = ""
144
+ var valueLength: Int
145
+ }
@@ -0,0 +1,172 @@
1
+
2
+
3
+ import SwiftUI
4
+
5
+ extension View {
6
+
7
+ public func popup<Item: Equatable, PopupContent: View>(
8
+ item: Binding<Item?>,
9
+ type: Popup<Item, PopupContent>.PopupType = .`default`,
10
+ position: Popup<Item, PopupContent>.Position = .bottom,
11
+ animation: Animation = Animation.easeOut(duration: 0.3),
12
+ autohideIn: Double? = nil,
13
+ dragToDismiss: Bool = true,
14
+ closeOnTap: Bool = true,
15
+ closeOnTapOutside: Bool = false,
16
+ backgroundColor: Color = Color.clear,
17
+ @ViewBuilder view: @escaping () -> PopupContent) -> some View {
18
+ self.modifier(
19
+ Popup(
20
+ item: item,
21
+ type: type,
22
+ position: position,
23
+ animation: animation,
24
+ autohideIn: autohideIn,
25
+ dragToDismiss: dragToDismiss,
26
+ closeOnTap: closeOnTap,
27
+ closeOnTapOutside: closeOnTapOutside,
28
+ backgroundColor: backgroundColor,
29
+ dismissCallback: { _ in },
30
+ view: view)
31
+ )
32
+ }
33
+
34
+ public func popup<PopupContent: View>(
35
+ isPresented: Binding<Bool>,
36
+ type: Popup<Int, PopupContent>.PopupType = .`default`,
37
+ position: Popup<Int, PopupContent>.Position = .bottom,
38
+ animation: Animation = Animation.easeOut(duration: 0.3),
39
+ autohideIn: Double? = nil,
40
+ dragToDismiss: Bool = true,
41
+ closeOnTap: Bool = true,
42
+ closeOnTapOutside: Bool = false,
43
+ backgroundColor: Color = Color.clear,
44
+ @ViewBuilder view: @escaping () -> PopupContent) -> some View {
45
+ self.modifier(
46
+ Popup<Int, PopupContent>(
47
+ isPresented: isPresented,
48
+ type: type,
49
+ position: position,
50
+ animation: animation,
51
+ autohideIn: autohideIn,
52
+ dragToDismiss: dragToDismiss,
53
+ closeOnTap: closeOnTap,
54
+ closeOnTapOutside: closeOnTapOutside,
55
+ backgroundColor: backgroundColor,
56
+ dismissCallback: { _ in },
57
+ view: view)
58
+ )
59
+ }
60
+
61
+ public func popup<Item: Equatable, PopupContent: View>(
62
+ item: Binding<Item?>,
63
+ type: Popup<Item, PopupContent>.PopupType = .`default`,
64
+ position: Popup<Item, PopupContent>.Position = .bottom,
65
+ animation: Animation = Animation.easeOut(duration: 0.3),
66
+ autohideIn: Double? = nil,
67
+ dragToDismiss: Bool = true,
68
+ closeOnTap: Bool = true,
69
+ closeOnTapOutside: Bool = false,
70
+ backgroundColor: Color = Color.clear,
71
+ dismissCallback: @escaping () -> (),
72
+ @ViewBuilder view: @escaping () -> PopupContent) -> some View {
73
+ self.modifier(
74
+ Popup(
75
+ item: item,
76
+ type: type,
77
+ position: position,
78
+ animation: animation,
79
+ autohideIn: autohideIn,
80
+ dragToDismiss: dragToDismiss,
81
+ closeOnTap: closeOnTap,
82
+ closeOnTapOutside: closeOnTapOutside,
83
+ backgroundColor: backgroundColor,
84
+ dismissCallback: { _ in dismissCallback() },
85
+ view: view)
86
+ )
87
+ }
88
+
89
+ public func popup<PopupContent: View>(
90
+ isPresented: Binding<Bool>,
91
+ type: Popup<Int, PopupContent>.PopupType = .`default`,
92
+ position: Popup<Int, PopupContent>.Position = .bottom,
93
+ animation: Animation = Animation.easeOut(duration: 0.3),
94
+ autohideIn: Double? = nil,
95
+ dragToDismiss: Bool = true,
96
+ closeOnTap: Bool = true,
97
+ closeOnTapOutside: Bool = false,
98
+ backgroundColor: Color = Color.clear,
99
+ dismissCallback: @escaping () -> (),
100
+ @ViewBuilder view: @escaping () -> PopupContent) -> some View {
101
+ self.modifier(
102
+ Popup<Int, PopupContent>(
103
+ isPresented: isPresented,
104
+ type: type,
105
+ position: position,
106
+ animation: animation,
107
+ autohideIn: autohideIn,
108
+ dragToDismiss: dragToDismiss,
109
+ closeOnTap: closeOnTap,
110
+ closeOnTapOutside: closeOnTapOutside,
111
+ backgroundColor: backgroundColor,
112
+ dismissCallback: { _ in dismissCallback() },
113
+ view: view)
114
+ )
115
+ }
116
+
117
+ public func popup<Item: Equatable, PopupContent: View>(
118
+ item: Binding<Item?>,
119
+ type: Popup<Item, PopupContent>.PopupType = .`default`,
120
+ position: Popup<Item, PopupContent>.Position = .bottom,
121
+ animation: Animation = Animation.easeOut(duration: 0.3),
122
+ autohideIn: Double? = nil,
123
+ dragToDismiss: Bool = true,
124
+ closeOnTap: Bool = true,
125
+ closeOnTapOutside: Bool = false,
126
+ backgroundColor: Color = Color.clear,
127
+ dismissSourceCallback: @escaping (DismissSource) -> (),
128
+ @ViewBuilder view: @escaping () -> PopupContent) -> some View {
129
+ self.modifier(
130
+ Popup(
131
+ item: item,
132
+ type: type,
133
+ position: position,
134
+ animation: animation,
135
+ autohideIn: autohideIn,
136
+ dragToDismiss: dragToDismiss,
137
+ closeOnTap: closeOnTap,
138
+ closeOnTapOutside: closeOnTapOutside,
139
+ backgroundColor: backgroundColor,
140
+ dismissCallback: dismissSourceCallback,
141
+ view: view)
142
+ )
143
+ }
144
+
145
+ public func popup<PopupContent: View>(
146
+ isPresented: Binding<Bool>,
147
+ type: Popup<Int, PopupContent>.PopupType = .`default`,
148
+ position: Popup<Int, PopupContent>.Position = .bottom,
149
+ animation: Animation = Animation.easeOut(duration: 0.3),
150
+ autohideIn: Double? = nil,
151
+ dragToDismiss: Bool = true,
152
+ closeOnTap: Bool = true,
153
+ closeOnTapOutside: Bool = false,
154
+ backgroundColor: Color = Color.clear,
155
+ dismissSourceCallback: @escaping (DismissSource) -> (),
156
+ @ViewBuilder view: @escaping () -> PopupContent) -> some View {
157
+ self.modifier(
158
+ Popup<Int, PopupContent>(
159
+ isPresented: isPresented,
160
+ type: type,
161
+ position: position,
162
+ animation: animation,
163
+ autohideIn: autohideIn,
164
+ dragToDismiss: dragToDismiss,
165
+ closeOnTap: closeOnTap,
166
+ closeOnTapOutside: closeOnTapOutside,
167
+ backgroundColor: backgroundColor,
168
+ dismissCallback: dismissSourceCallback,
169
+ view: view)
170
+ )
171
+ }
172
+ }