ruby_native 0.11.0 → 0.11.1
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 +30 -1
- 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: c596379ed0170d7784e8273e1ac3c10023ebc6115a7d8a7d1edb2633f7325449
|
|
4
|
+
data.tar.gz: b966e8aeb40899fa32ff8f34f85dffc031b073f0637cf1917083f43ce504e06a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fbddcd87a18dc14cd8eacdf1b4456c6cacc41c2f26c76e3dc0d6d2383b8c40a76de274901d3456d2ee40a79f56edd3b17d0a9510918e7a67adc9d6fa675f57d3
|
|
7
|
+
data.tar.gz: 1d9bbb26a648e42952fd11de6d63cb65286d8247e5c847fbd2007760de213ed371f5ff6a61372f582a9cfe75b26fb10f8b11f6c5187187f415af4c511021a748
|
data/lib/ruby_native/helper.rb
CHANGED
|
@@ -131,14 +131,43 @@ module RubyNative
|
|
|
131
131
|
# form (`{ ios: "...", android: "..." }`). When both are given, a matching
|
|
132
132
|
# `icons[platform]` wins; otherwise falls back to `icon`. Returns nil when
|
|
133
133
|
# nothing resolves.
|
|
134
|
+
#
|
|
135
|
+
# A non-Hash `icons:` raises rather than falling through. `icons: [ios:
|
|
136
|
+
# "...", android: "..."]` is an easy slip in ERB and yields an Array holding
|
|
137
|
+
# one Hash, which used to skip the lookup and fall back to `icon` — usually
|
|
138
|
+
# nil, so the button rendered with no icon on either platform and nothing
|
|
139
|
+
# said why. That reads as "per-platform icons are broken" rather than "wrong
|
|
140
|
+
# bracket," and it is invisible on whichever platform you aren't testing.
|
|
134
141
|
def self.resolve_icon(icon: nil, icons: nil, platform: nil)
|
|
142
|
+
if !icons.nil? && !icons.is_a?(Hash)
|
|
143
|
+
raise ArgumentError,
|
|
144
|
+
"icons: must be a Hash like { ios: \"square.and.arrow.up\", android: \"share\" }, " \
|
|
145
|
+
"got #{icons.class}. Check for square brackets instead of curly braces."
|
|
146
|
+
end
|
|
147
|
+
|
|
135
148
|
if icons.is_a?(Hash) && platform
|
|
136
149
|
key = platform.to_sym
|
|
137
150
|
per_platform = icons[key] || icons[key.to_s]
|
|
138
151
|
return per_platform if per_platform
|
|
139
152
|
end
|
|
140
|
-
|
|
153
|
+
|
|
154
|
+
# Nothing matched, which is every web render: `native_platform` is nil in
|
|
155
|
+
# a browser. Fall back to `icon:`, then to any name in `icons:`, the same
|
|
156
|
+
# order `RubyNative.backfill_tab_icons` uses for the YAML config.
|
|
157
|
+
#
|
|
158
|
+
# Returning nil here instead would make `icons:` alone unusable, because
|
|
159
|
+
# `native_fab_tag` raises on a nil icon and would 500 a page that renders
|
|
160
|
+
# fine inside the app. The signal element is hidden and only read by the
|
|
161
|
+
# native app, so which name survives on the web doesn't matter.
|
|
162
|
+
icon || fallback_icon(icons)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def self.fallback_icon(icons)
|
|
166
|
+
return nil unless icons.is_a?(Hash)
|
|
167
|
+
|
|
168
|
+
icons[:ios] || icons["ios"] || icons[:android] || icons["android"]
|
|
141
169
|
end
|
|
170
|
+
private_class_method :fallback_icon
|
|
142
171
|
|
|
143
172
|
class NavbarBuilder
|
|
144
173
|
def initialize(context)
|
data/lib/ruby_native/version.rb
CHANGED