ruby_native 0.10.8 → 0.10.9
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.
- checksums.yaml +4 -4
- data/lib/ruby_native/helper.rb +29 -0
- data/lib/ruby_native/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1020516eb9b684247d40d16d00153a75691082fbe9a3e769d552826d7a217135
|
|
4
|
+
data.tar.gz: cf8a1600e15ae4a7b26767b14543c763d13421aa96187e75a0608734e9780cab
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7dceda118ad0c65f7508a1d77ce5f9a77b0fbbd59d1137673d4076b987ccadc7311135dc0003cbe873747ecfea8b1a4838c69828364b3b56d724b71e3d236dee
|
|
7
|
+
data.tar.gz: '0528af6b54e2bc22abc87c6f24d5b1d470872c5abb3d0bb3f0ad8ce93fe0d4657514938e322a5cec578b7982fb827ac0c500fedbac0037fb32bfc047899597d1'
|
data/lib/ruby_native/helper.rb
CHANGED
|
@@ -126,6 +126,22 @@ module RubyNative
|
|
|
126
126
|
end
|
|
127
127
|
end
|
|
128
128
|
|
|
129
|
+
# Adds a native share button to the nav bar. Tapping it opens the
|
|
130
|
+
# platform share sheet for `url:` (defaults to the current page on the
|
|
131
|
+
# web side) so it works even where embedded web views don't support
|
|
132
|
+
# `navigator.share`. Icons follow the same rules as the other navbar
|
|
133
|
+
# buttons: `icon:` applies to every platform and `icons:` ({ ios:,
|
|
134
|
+
# android: }) overrides per platform.
|
|
135
|
+
def share_button(url: nil, title: "Share", icon: "square.and.arrow.up", icons: nil, position: :trailing)
|
|
136
|
+
resolved = RubyNative::Helper.resolve_icon(icon: icon, icons: icons, platform: @context.try(:native_platform))
|
|
137
|
+
data = { native_button: "", native_share: "" }
|
|
138
|
+
data[:native_title] = title if title
|
|
139
|
+
data[:native_icon] = resolved if resolved
|
|
140
|
+
data[:native_position] = position.to_s
|
|
141
|
+
data[:native_share_url] = url if url
|
|
142
|
+
@items << @context.tag.div(data: data)
|
|
143
|
+
end
|
|
144
|
+
|
|
129
145
|
def submit_button(title: "Save", click: "[type='submit']")
|
|
130
146
|
@items << @context.tag.div(data: {
|
|
131
147
|
native_submit_button: "",
|
|
@@ -155,6 +171,19 @@ module RubyNative
|
|
|
155
171
|
@items << @context.tag.div(data: data)
|
|
156
172
|
end
|
|
157
173
|
|
|
174
|
+
# Adds a share entry to a navbar button's dropdown menu. Selecting it
|
|
175
|
+
# opens the platform share sheet for `url:` (defaults to the current
|
|
176
|
+
# page on the web side). Icons follow the same `icon:`/`icons:` rules
|
|
177
|
+
# as the other menu items.
|
|
178
|
+
def share_item(title = "Share", url: nil, icon: "square.and.arrow.up", icons: nil, selected: false)
|
|
179
|
+
resolved = RubyNative::Helper.resolve_icon(icon: icon, icons: icons, platform: @context.try(:native_platform))
|
|
180
|
+
data = { native_menu_item: "", native_title: title, native_share: "" }
|
|
181
|
+
data[:native_share_url] = url if url
|
|
182
|
+
data[:native_icon] = resolved if resolved
|
|
183
|
+
data[:native_selected] = "" if selected
|
|
184
|
+
@items << @context.tag.div(data: data)
|
|
185
|
+
end
|
|
186
|
+
|
|
158
187
|
def to_html
|
|
159
188
|
@context.safe_join(@items)
|
|
160
189
|
end
|
data/lib/ruby_native/version.rb
CHANGED